小编h3c*_*t0r的帖子

在Leaflet L.Draw插件中以编程方式添加多边形

有没有办法使用Leaflet绘图插件以编程方式添加多边形?https://github.com/Leaflet/Leaflet.draw

例如:单击一个按钮并添加一个可由插件编辑的正方形.

谢谢!

javascript leaflet

6
推荐指数
1
解决办法
3888
查看次数

在 JavaScript 中向事件侦听器添加计时器

我在 Firefox 扩展中管理站点负载时遇到了一些麻烦。

我正在使用 JavaScript 并开发 Firefox 扩展来搜索我自己的网站列表中的字符串,以查找坏词。问题是我正在一一搜索列表。这意味着,我正在加载一个网页并向 DOMContentLoaded 添加一个事件侦听器;当 DOM 加载一个函数被调用来搜索字符串。但是,如果页面未加载(例如网络问题),则永远不会调用该函数。

有没有办法将计时器设置为事件侦听器?如果事件没有在 5 秒内触发,那么做一些事情。或者如果有其他方法可以做到这一点,请指教!我把代码最小化了很多,但我认为你可以在这里得到这个想法。

function main_(){
            //do some stuff here and if needed call to open a new page
            waitForDOM();
}

function waitForDOM(){
            //if the list of pages is grather than 0 then
    //add the new tab here and create the event listener
    gBrowser.addEventListener('DOMContentLoaded',pageLoaded,true);
 }

function pageLoaded(aEvent) {
        //do the search here and calls the function waitForDOM to load a new page and a event listener
    waitForDOM();
}
Run Code Online (Sandbox Code Playgroud)

javascript events listener firefox-addon

5
推荐指数
1
解决办法
6537
查看次数

Arduino:将十六进制字符串转换为uint64或十进制字符串

我想使用uint64变量将十六进制字符串(如"43a2be2a42380")转换为十进制表示形式.我需要这个,因为我正在实现一个充当键盘的RFID阅读器,按键必须是十进制数字.

我已经看到了其他答案( HEduino中将HEX字符串转换为Decimal)并使用strtoul实现解决方案,但它仅适用于32位整数并且strtoull不可用.

uint64_t res = 0;
String datatosend = String("43a2be2a42380");
char charBuf[datatosend.length() + 1];
datatosend.toCharArray(charBuf, datatosend.length() + 1) ;
res = strtoul(charBuf, NULL, 16);
Run Code Online (Sandbox Code Playgroud)

如何使用Arduino获取大十六进制字符串/字节数组的十进制数?

c string hex arduino

3
推荐指数
2
解决办法
2111
查看次数

标签 统计

javascript ×2

arduino ×1

c ×1

events ×1

firefox-addon ×1

hex ×1

leaflet ×1

listener ×1

string ×1