同步多个设备上的网站(DOM) [英] Synchronizing Website (DOM) on multiple devices

查看:165
本文介绍了同步多个设备上的网站(DOM)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要发明一种方法来连接到一网站的多个设备进行同步。
可以说我有一个平板电脑和一台笔记本电脑,改变笔记本电脑上的DOM的一些元素。然后,
网站上的平板电脑应该随之改变。

起初我需要一种方法来监视DOM变化。我看了很多论坛和也试图与浏览器的同步工作( https://github.com/ shakyShane /浏览器的同步功能),但它不监视的所有事件。然而,可能发生的是网站不同步。

我也曾尝试使用新技术MutationServer。但我不知道究竟如何在其他设备更新网站:

在的情况下的新节点已被添加到DOM我首先要确定其在树内的位置;然后把所有的信息给其他客户端(通过我猜的NodeJS和socketio)。客户必须把新创建的节点在其树的正确位置。

在的情况下一个节点已被编辑或删除我必须在它的反应,以及...

所以我的问题是:你有什么想法或文学解决我的问题?
我只是需要一些很好的提示启动,因为我真的不知道哪种方法使我的最佳的解决方案。我想发明一种有效的解决方案,以及。
当然,我可以监视通过检查x次在第二个变化发生是否在DOM。但这种方法是不是真的有效尤其不适合移动设备

希望你们能帮助我,使我朝着正确的方向。

最好的问候。


解决方案

  

请注意:没有什么准备,这不是那么简单做



  1. 捕获所有DOM也许这将帮助您:酸DOM查看器

  2. 捕捉事件侦听器使用视觉事件2

避免捕获帧(或使用它们),因为可能会出现安全问题(跨域)。

在我看来,没有必要捕捉到整个文档,那只需要捕获插入身体和HEAD

和避免复杂的结构,也许是事件(eventslistiners)不需要捕获,只有你需要有,增加了现有的事件库。除非事件是由客户创建的,在这种情况下,你将不得不捕捉它们。

要发送它们,你必须使用Ajax和数据库(SQLSERVER,MySQL和MongoDB的,等等)。

共享

从我的角度来看:

如果您要创建只是数据共享的应用程序,例如有人张贴一个新的照片或新评论,效果会更好,使其中的传输插入在数据库的JSON和客户端阅读JSON主JavaScript库将动态生成的内容。

因此​​将传输更使事情更快,更容易实现的过程。

I need to invent a method to synchronize multiple devices that are connected to a Website. Lets say I have a Tablet and a Laptop and change some elements of the dom on the laptop. Then the website on the Tablet should change accordingly.

At first I need a way to monitor the dom changes. I read a lot in forums and have also tried to work with browser-synch (https://github.com/shakyShane/browser-sync) but it does not monitor all events. However it may happen that the websites are not in synch.

I have also tried to use the new MutationServer techniques. But I am not sure how exactly to update the websites on the other devices:

In case a new node has been added to the DOM I first have to determine its position inside the tree; then send all the informations to the other clients (i guess via nodejs and socketio). The clients have to put the newly created node in the right position of their tree.

In case a node has been edited or removed I have to react on it as well...

So my question is: Do you have any ideas or literature to solve my problem? I just need some good hints to start because I am not really sure which method leads me to the "best" solution. I want to invent an efficient solution as well. Sure, I could monitor the DOM by checking x times in a second whether changes occured. But this method is not really efficient especially not for mobile devices.

Hope you guys can help me and lead me to the right direction.

Best regards.

解决方案

note: There is nothing ready and this is not so simple to do.

  1. Capture all DOM maybe this will help you: AcID DOM Inspector
  2. Capture "event Listeners" use Visual Event 2

Avoid capture frames (or use them) because security issues (cross-origin) may occur.

In my view it is not necessary to capture the entire document, it would only be necessary to capture inserts the "BODY" and "HEAD"

And avoid complex structures, perhaps the events (eventslistiners) need not be captured, only you would need to have a library that adds already existing events. Unless the events are created by customers, in which case you will have to capture them.

To transmit them you have to use Ajax and shared with DataBase (SQLServer, Mysql, MongoDB, etc).

From my point of view:

If you want to create is an application just to share data, for example someone posted a "new photo" or a "new comment", would be better to make the transmission of which was inserted in the "database" for "JSON" and clients read the "JSON" your main "javascript library" would dynamically generate the contents.

Thus would transmit much less making things faster and easier to implement process.

这篇关于同步多个设备上的网站(DOM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆