Поиск в Поддержке

Избегайте мошенников, выдающих себя за службу поддержки. Мы никогда не попросим вас позвонить, отправить текстовое сообщение или поделиться личной информацией. Сообщайте о подозрительной активности, используя функцию «Пожаловаться».

Learn More

Need help in checking the dom node position for different screen resoultions

  • 1 ответ
  • 1 имеет эту проблему
  • 2 просмотра
  • Последний ответ от FredMcD

more options

Hi,

We are working on an Open Source Chrome extension: Digital Assistant Client

I am recording the domnode by converting into json by domJson and saving into server. We can find the same recordednode by comparing the json attributes and matching to the original node on the page. We have one problem here when we search for the nodes sometimes we get similar nodes via json which has same property names. In that case we are trying to match the node position that we have recorded. When we try to match the node position in different screen resolutions, it gives us the wrong node. How do we solve this. My code is as given below

// calculate distance between selected node and matching node getDistance: function (node1, node2) {

  const x = node1.x - node2.x;
  const y = node1.y - node2.y;
  const dist = Math.abs(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
  return dist;

},

Hi, We are working on an Open Source Chrome extension: [https://github.com/kcramakrishna/Digital_Assistant_Client Digital Assistant Client] I am recording the domnode by converting into json by domJson and saving into server. We can find the same recordednode by comparing the json attributes and matching to the original node on the page. We have one problem here when we search for the nodes sometimes we get similar nodes via json which has same property names. In that case we are trying to match the node position that we have recorded. When we try to match the node position in different screen resolutions, it gives us the wrong node. How do we solve this. My code is as given below // calculate distance between selected node and matching node getDistance: function (node1, node2) { const x = node1.x - node2.x; const y = node1.y - node2.y; const dist = Math.abs(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))); return dist; },

Все ответы (1)

more options

Add-on questions should be posted in the add-ons forum; https://discourse.mozilla-community.org/c/add-ons