window.location.hash always shows empty

In my phonegap application i updated my datas for that i have the following code in that i got the window.location.hash (* indicate error line) value will be empty. function init() { $("#homePage").live("pageshow", function() { getDatas(); }); $("#editPage").live("pageshow", function() { ***var loc = window.location.hash;*** alert("loc" + loc); if(loc.indexOf("?") >= 0)

window.location.hash总是显示为空

在我的phonegap应用程序,我更新了我的数据,因为我有以下代码,我得到了window.location.hash (*表示错误行)值将为空。 function init() { $("#homePage").live("pageshow", function() { getDatas(); }); $("#editPage").live("pageshow", function() { ***var loc = window.location.hash;*** alert("loc" + loc); if(loc.indexOf("?") >= 0) { var qs = loc.substr(loc.indexOf("?")+1,

Graphing Algorithm for many nodes

I have been trying to develop a web based application to help in the graphing of nodes and their interactions. I have attempted to use the Sigma.Js with the Force Atlas extension. For my simple tests (few nodes) the results are quite good-looking, however with an additional thousand nodes the result becomes quite a mess. Is there any such way to make the result more view able? (easier on t

针对许多节点的图形化算法

我一直在尝试开发一个基于Web的应用程序来帮助绘制节点及其交互图。 我试图用Force Atlas扩展使用Sigma.Js。 对于我的简单测试(很少节点),结果非常好看,但是如果有额外的千个节点,结果会变得相当混乱。 有没有这样的方式可以让结果更具可视性? (更容易在眼睛/不只是一个大块)我怎么去做这件事? 是否有已经编写的算法(我可以实现?) 您可以尝试Fruchterman-Reingold力布局(其中有一个西格玛插件)。 它特

Using jQuery to center a DIV on the screen

我如何使用jQuery在屏幕中心设置<div> ? I like adding functions to jQuery so this function would help: jQuery.fn.center = function () { this.css("position","absolute"); this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px"); this.css("left", Math.max(0, (($(window).width() -

使用jQuery在屏幕上居中放置DIV

我如何使用jQuery在屏幕中心设置<div> ? 我喜欢为jQuery添加函数,所以这个函数将有助于: jQuery.fn.center = function () { this.css("position","absolute"); this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px"); this.css("left", Math.max(0, (($(window).width() - $(this).outerWi

Setting flexbox display with jquery for multiple browsers?

having a bit of trouble. I need to have something switch from display: none to display: flex, display: flex-box, and display: -ms-flexbox but it seems to be breaking my code.. Here's what I have so far: $(elem).css({'display': 'flex', 'display': '-webkit-flex', 'display':'-ms-flexbox'}); and while this works: $(elem).css({'display': 'flex'}) I need to have the other two for safari and IE

使用jQuery为多个浏览器设置flexbox显示?

有点麻烦。 我需要从显示切换:无显示:flex,display:flex-box,并显示:-ms-flexbox,但它似乎打破了我的代码。以下是我到目前为止: $(elem).css({'display': 'flex', 'display': '-webkit-flex', 'display':'-ms-flexbox'}); 这虽然有效: $(elem).css({'display': 'flex'}) 我需要另外两个Safari和IE10。 有没有什么方法可以写这个,这样它就不会破坏我的代码? Jquery似乎被这个语法困惑了。 我只是遇到了同样的

Make body 100% height of browser window

I have this structure: <body> <div id="header">..</div> <div id="content">..</div> <div id="footer">..</div> </body> And this CSS: body { color: white; font-family: 'Play', sans-serif; max-width: 2560px; margin: 0 auto; min-width: 960px; height:100%; padding:0; } #header { position: relative; overflow: hid

使浏览器窗口的身体达到100%的高度

我有这样的结构: <body> <div id="header">..</div> <div id="content">..</div> <div id="footer">..</div> </body> 而这个CSS: 身体{颜色:白色; font-family:'Play',sans-serif; max-width:2560px; 保证金:0汽车; min-width:960px; 高度:100%; 填充:0; } #header { position: relative; overflow: hidden; margin

Execute a forEach like a waterfall in async

I'm trying to retrieve longitude and latitude from a list of addresses with the Google API via a Node.js script. The call itself works fine but since I have around 100 addresses to submit. I use a async.forEach on an array, but the calls are made too fast and I get the error "You have exceeded your rate-limit for this API." I found that the number of calls is limited to 2500 eve

在async中执行forEach,像瀑布一样

我试图通过Node.js脚本从Google API的地址列表中检索经度和纬度。 电话本身工作正常,但因为我有大约100个地址提交。 我在一个数组上使用了async.forEach ,但是调用速度过快,并且出现错误“您已超出此API的速率限制”。 我发现每24小时的通话次数限制为2500次,最长10秒。 虽然我可以每天2500美元,但我的呼叫方式太快而不适用速率限制。 我现在必须写一个功能,这个功能将延迟电话的数量,使其达到极限。 以下是我的代

d3 Zoomable Treemap from CSV

I'm new to working with D3, and I'm finding it very humbling. My goal is to make a treemap from a CSV file. I want to use CSV format because I'll be working with values in a spreadsheet, and it's easy for me to save the files that way. I'm trying to store the data in a hierarchical format, something like this (hier.csv): parent,child,value Homer Simpson,Bart,20 Homer Sim

d3 CSV中的可缩放树形图

我刚刚与D3合作,我发现它非常谦虚。 我的目标是从CSV文件制作树图。 我想使用CSV格式,因为我将在电子表格中处理值,而且我很容易以这种方式保存文件。 我试图以分层格式存储数据,像这样(hier.csv): parent,child,value Homer Simpson,Bart,20 Homer Simpson,Lisa,14 Homer Simpson,Maggie,6 Peter Griffin,Chris,19 Peter Griffin,Meg,12 Peter Griffin,Stewie,9 我正在使用这个Zoomable Treemap示例。 我希望树

Javascript contains case insensitive

I have the following: if (referrer.indexOf("Ral") == -1) { ... } What I like to do is to make Ral case insensitive, so that it can be RAl , rAl , etc. and still match. Is there a way to say that Ral has to be case-insensitive? Add .toLowerCase() after referrer . This method turns the string in a lower case string. Then, use .indexOf() using ral instead of Ral . if (referrer.toLowerCase()

Javascript包含大小写不敏感

我有以下几点: if (referrer.indexOf("Ral") == -1) { ... } 我喜欢做的是让Ral区分大小写的,所以它可以RAl , rAl等,仍然匹配。 有没有办法说Ral必须不区分大小写? 在referrer后添加.toLowerCase() 。 此方法将字符串转换为小写字符串。 然后,使用.indexOf()使用ral而不是Ral 。 if (referrer.toLowerCase().indexOf("ral") === -1) { 使用正则表达式也可以实现同样的效果(当您想要针对动态模式进行测试时特别

How to sort strings in JavaScript

I have a list of objects I wish to sort based on a field attr of type string. I tried using - list.sort(function (a, b) { return a.attr - b.attr }) but found that - doesn't appear to work with strings in JavaScript. How can I sort a list of objects based on an attribute with type string? This should work: if (item1.attr < item2.attr) return -1 if ( item1.attr > item2.attr)

如何在JavaScript中对字符串进行排序

我有一个我希望根据字符串类型的attr进行排序的对象列表。 我试着用- list.sort(function (a, b) { return a.attr - b.attr }) 但发现-似乎不适用于JavaScript中的字符串。 我如何根据类型为string的属性对对象列表进行排序? 这应该工作: if (item1.attr < item2.attr) return -1 if ( item1.attr > item2.attr) return 1 return 0 更好的是,你可以使用String.prototype.localeCompare : return item1

Why is using the JavaScript eval function a bad idea?

eval函数是动态生成代码的一种强大且简单的方法,那么注意事项是什么? Improper use of eval opens up your code for injection attacks Debugging can be more challenging (no line numbers, etc.) eval'd code executes slower (no opportunity to compile/cache eval'd code) Edit: As @Jeff Walden points out in comments, #3 is less true today than it was in 2008. However, while some caching of com

为什么使用JavaScript eval函数是一个坏主意?

eval函数是动态生成代码的一种强大且简单的方法,那么注意事项是什么? 不当使用eval会打开注入攻击代码 调试可能更具挑战性(没有行号等) eval'd代码执行较慢(没有机会编译/缓存eval'd代码) 编辑:正如@Jeff Walden在评论中指出的那样,#3现在比2008年更不真实。但是,尽管可能会发生一些编译脚本的缓存,但这仅限于未经修改而重复评估的脚本。 更可能的情况是,您正在评估每次都经历轻微修改的脚本,因此