Concurrent drawing with paper.js

I have an app that deals with drawing widget based upon paper.js. Several users can draw at the same time, and changes are broadcast to each other in real time. The problem is that I need to store the changes and show drawn image while document is loaded. The natural solution is to store commands sent by clients in DB. But drawn images can consist of thousands of commands, and I can have ten

与paper.js同时绘图

我有一个应用程序,基于paper.js处理绘图小部件。 几个用户可以同时进行绘制,并且实时更改相互之间的广播。 问题是我需要在文档加载时存储更改并显示绘制的图像。 自然的解决方案是存储客户端在数据库中发送的命令。 但绘制的图像可以包含数千个命令,并且我可以拥有数十个图像。 所以当我打开一个从服务器获取命令列表的文档时,绘图可能会花费太多时间。 有没有更好的方式来存储图像和客户端之间的交互? 请注意,

Accessing property of constructor without creating new instance

Is it possible to access properties of a constructor object/function without first creating an instance from it ? For example, let's say I have this constructor: function Cat() { this.legs = 4; }; And now – without creating a new cat instance – I want to know what value of legs is inside the constructor. Is this possible? (And I'm not looking for stuff like: var legs = new Cat().

在不创建新实例的情况下访问构造函数的属性

如果没有首先创建实例,是否可以访问构造函数对象/函数的属性? 例如,假设我有这个构造函数: function Cat() { this.legs = 4; }; 而现在 - 没有创建一个新的猫实例 - 我想知道构造函数中legs价值。 这可能吗? (而且我并不是在寻找像下面这样的东西: var legs = new Cat().legs 。(比方说,由于某种原因,新Cat的实例化是超级CPU。)) 有这样的事情吗? function Cat() { this.legs = 4; } var obj = {}; Cat

How to receive UDP broadcast packets in Chrome App running on Android

I can receive broadcast packets without any problems within a windows running chrome app. However, when I take that app and compile using the cordova/crosswalk tools I can't seem to receive any packets. I see all the packets in wireshark. My packet is transmitted from: 172.24.0.42 and broadcasted on 172.24.255.255 (a broadcast on 255.255.255.255 does not work on Android, but it does work o

如何在运行Android的Chrome App中接收UDP广播数据包

我可以在运行chrome应用程序的Windows中没有任何问题地接收广播数据包。 但是,当我使用该应用程序并使用cordova / crosswalk工具进行编译时,我似乎无法收到任何数据包。 我看到wireshark中的所有数据包。 我的数据包从172.24.0.42发送,并在172.24.255.255上播放(255.255.255.255上的广播在Android上不起作用,但它可以在windows chrome应用上工作)。 这是我的(manifest.json): "sockets":{ "udp": {

Positioning below absolutely positioned divs

I have two <div> s with absolute position . One is displayed and the other is display: none on load. When the link on the visible one is clicked it is moved and the other is displayed. I have a third <div> with link that I would like to display directly below these. Since they're both position: absolute I have not been able to find a way to do this. I have found various solu

定位在绝对定位的div下面

我有两个absolute position <div> 。 一个显示,另一个display: none负载。 点击可见链接上的链接时,会移动链接,并显示另一个链接。 我有第三个<div>链接,我想直接显示在这些下面。 既然他们都是position: absolute我一直没能找到办法做到这一点。 我找到了各种解决方案,但其中大多数都是使用绝对位置的解决方法。 由于我的<div>需要互相显示ontop,所以我不能删除绝对定位。 因此,我尝试过三种

Multple Criteria in a Single Case inside a Switch Statement

This question already has an answer here: Switch statement multiple cases in JavaScript 15 answers There is one hacky switch style that allows you to specify ranges: switch (true) { case blah >= 0 && blah <= 3: //do this break default: //do that } It sometimes useful in cases like this. Maybe it'll do what you want. This might be what yo

Switch语句中单个案例中的多重标准

这个问题在这里已经有了答案: 在JavaScript中切换语句多个案例15个答案 有一个hacky开关样式可以让你指定范围: switch (true) { case blah >= 0 && blah <= 3: //do this break default: //do that } 它有时在这种情况下很有用。 也许它会做你想做的。 这可能是你正在寻找的。 如果是这样,请更清楚地定义你的问题/问题。 switch (x) { case 0: case 1: ca

D3 histogram, number of occurrences of date from time stamp

Newb here. I have a csv with this data: date, lat, lon 01/01/2015 09:38:14 AM,37.973424,-87.575423 01/01/2015 09:48:27 PM,37.385218,-122.11413 01/01/2015 10:17:34 AM,39.081712,-76.554603 01/02/2015 01:27:17 PM,40.216204,-74.619533 I want to have a histogram where the x axis is by date and the y axis is by number of occurrences. So Jan 1 would have a column height of 3 and Jan 2 would have a

D3直方图,来自时间戳的日期出现次数

Newb在这里。 我有一个csv与这个数据: date, lat, lon 01/01/2015 09:38:14 AM,37.973424,-87.575423 01/01/2015 09:48:27 PM,37.385218,-122.11413 01/01/2015 10:17:34 AM,39.081712,-76.554603 01/02/2015 01:27:17 PM,40.216204,-74.619533 我想要一个直方图,其中x轴是按日期排列的,y轴是按发生次数排列的。 因此,1月1日的柱高为3,而1月2日的柱高为1.一天中的时间不相关。 我需要解析日期,还是设置一个时间间隔

javascript can't access private properties

I have the following code and I don't understand why I can't access the private properties when I redeclare the get method. (function(w,d,a,undefined){ var cfg = { currency: 'GBP', exponent: 2 }; var get = function () { return cfg; }; a.init = function (settings) { for (var k in settings) { cfg[k] = settings[k]; }

javascript无法访问私有属性

我有下面的代码,我不明白为什么我重新声明get方法时无法访问私有属性。 (function(w,d,a,undefined){ var cfg = { currency: 'GBP', exponent: 2 }; var get = function () { return cfg; }; a.init = function (settings) { for (var k in settings) { cfg[k] = settings[k]; } }; a.set = function (args) { get = args.get || get

How to run node.js in my web site server not my pc local server

Last 2 days I spent more time and read 50+ articles and video to understand node.js and after installation now I can see the result in browser by http//:localhost:3000/ But I have confused in many case that I describe below. I do all of my work in my share hosting server where I my keep my web site: www.myweb.com In every article about node.js, they are teaching how to get a result by below c

如何在我的网站服务器上运行node.js而不是我的电脑本地服务器

最近2天,我花了更多时间阅读50多篇文章和视频,以了解node.js,现在我可以通过http//:localhost:3000/在浏览器中看到结果。但是我在下面描述的许多情况下感到困惑。 我在我的共享主机服务器上完成了我的所有工作,我的网站是: www.myweb.com 在关于node.js的每篇文章中,他们都在教导如何通过http//:localhost:3000/在本地pc服务器中的浏览器中通过以下代码获取结果。 test.js var http = require('http'); http.createS

Aggregation with geoNear & subdocuments

I'm using the node-geoip module and performing an aggregation query. The schema against which I am performing the query looks like this: var mongoose = require('mongoose'); require('./location.js'); module.exports = mongoose.model('Region',{ attr1: Number, attr2: String, attr3: String, locations:[mongoose.model('Location').schema] }); and var mongoose = require('mongoose'

与geoNear和子文档聚合

我正在使用node-geoip模块并执行聚合查询。 我正在执行查询的模式如下所示: var mongoose = require('mongoose'); require('./location.js'); module.exports = mongoose.model('Region',{ attr1: Number, attr2: String, attr3: String, locations:[mongoose.model('Location').schema] }); 和 var mongoose = require('mongoose'); module.exports = mongoose.model('Location',{ attr1: Number,

Unwanted overlay of java script picture slide animation with website header

Problem/ Observation My picture slide animation box is placed just below the fixed header ( which is not the problem). When i first load the page, there is no overlay between the fixed header and picture box. However, when i click on the left and right (next & previous ) arrows to change the picture, the hidden part of the picture displays and thus overlays with the fixed header for the per

Java脚本图片幻灯片动画与网站标题不需要的重叠

问题/观察我的图片幻灯片动画框放置在固定标题的正下方(这不是问题)。 当我第一次加载页面时,固定标题和图片框之间没有重叠。 但是,当我点击左右(下一个和上一个)箭头来更改图片时,图片的隐藏部分将显示并与动画期间的固定标题重叠,然后再隐藏在固定标题后面。 我如何阻止这种叠加行为,使图片框始终停留在标题后面? 该网站包含来自以下来源的图片幻灯片动画: 幻灯片动画链接(html,css&js) 我的header.p