Pebble.js 菜单项呈现缓慢
Pebble.js Menu Items Slow to Render
我已经为工作中的服务器创建了一个接口,以验证打印服务器和打印机是否动态启动,并将其反馈给 Pebble。功能很好,我遇到的问题是菜单。我将加载菜单,然后开始向下滚动,突然间项目不存在了。大约需要 6 秒,然后它们就会出现。上下滚动都是如此。有很多菜单选项,但即使菜单中有六个项目也可以。
这只是处理能力的限制,还是 pebble.js 脚本,还是我做错了什么?
-- 更新 -- 供将来参考,重新启动 Pebble 使渲染速度显着加快。菜鸟错误...
var UI = require('ui');
var ajax = require('ajax');
var main = new UI.Card({
title: 'Pebble Interface',
icon: 'images/mattec.png',
body: 'Press Top Button to open Cell Picker.'
});
main.show();
main.on('click', 'up', function(e) {
var menu = new UI.Menu({
sections: [{
items: [{
title: 'ALMSC1'
}, {
title: 'ALMSC2'
}, {
title: 'DL 1'
}, {
title: 'DL 2'
}, {
title: 'DL 3'
}, {
title: 'DL 4'
}, {
title: 'EDGER'
}, {
title: 'EPOXYA'
}, {
title: 'EPOXYP'
}, {
title: 'FORK 1'
}, {
title: 'FORK 2'
}, {
title: 'HICK 1'
}, {
title: 'HICK 2'
}, {
title: 'LG 1'
}, {
title: 'LG 2'
}, {
title: 'LG 3'
}, {
title: 'LG 4'
}, {
title: 'LG 5'
}, {
title: 'LG 6'
}, {
title: 'PHD 1'
}, {
title: 'PHD 2'
}, {
title: 'PHD 3'
}, {
title: 'PHD 4'
}, {
title: 'SPRLTE'
}, {
title: 'STEEL1'
}, {
title: 'STEEL2'
}, {
title: 'STEEL3'
}, {
title: 'STEEL4'
}, {
title: 'STEEL5'
}, {
title: 'STEEL6'
}, {
title: 'SVL 01'
}, {
title: 'SVL 02'
}, {
title: 'SVL 03'
}, {
title: 'SVL 04'
}, {
title: 'SVL 05'
}, {
title: 'SVL 06'
}, {
title: 'SVL 07'
}, {
title: 'SVL 08'
}, {
title: 'SVL 09'
}, {
title: 'SVL 10'
}, {
title: 'SVL 11'
}, {
title: 'SVL 12'
}, {
title: 'SVL 13'
}, {
title: 'SVL 14'
}, {
title: 'SVL 15'
}, {
title: 'SVL 16'
}, {
title: 'SVL 17'
}, {
title: 'SVL 18'
}, {
title: 'SVLCUB'
}, {
title: 'TAMP 1'
}, {
title: 'TAMP 2'
}, {
title: 'WEEDER'
}]
}]
});
menu.on('select', function(e) {
ajax({ url: 'http://myserver/test/pebble/oldpebble.php?cell=' + e.item.title, type:'xml' }, function(data){
var istag = data.match(/<istag>(.*?)<\/istag>/)[1];
istag = istag.replace(/"/g, "\"");
var psname = data.match(/<psname>(.*?)<\/psname>/)[1];
psname = psname.replace(/"/g, "\"");
var psip = data.match(/<psip>(.*?)<\/psip>/)[1];
psip = psip.replace(/"/g, "\"");
var upcstatus = data.match(/<upcstatus>(.*?)<\/upcstatus>/)[1];
upcstatus = upcstatus.replace(/"/g, "\"");
var i2of5status = data.match(/<i2of5status>(.*?)<\/i2of5status>/)[1];
i2of5status = i2of5status.replace(/"/g, "\"");
var content = istag + "\n\nPrint Server\n" + psname + "\n" + psip + "\n" + "UPC - " + upcstatus + "\nI2of5 - " + i2of5status;
var detailCard = new UI.Card({
title:e.item.title,
body: content,
scrollable: true,
style: 'small'
});
detailCard.show();
});
});
menu.show();
});
Pebble.js 将列表数据按需流式传输到手表。六秒听起来很多,我没有看到那么多的延迟,但除了使用 C SDK 重新构建您的应用程序之外,您无能为力。
我已经为工作中的服务器创建了一个接口,以验证打印服务器和打印机是否动态启动,并将其反馈给 Pebble。功能很好,我遇到的问题是菜单。我将加载菜单,然后开始向下滚动,突然间项目不存在了。大约需要 6 秒,然后它们就会出现。上下滚动都是如此。有很多菜单选项,但即使菜单中有六个项目也可以。
这只是处理能力的限制,还是 pebble.js 脚本,还是我做错了什么?
-- 更新 -- 供将来参考,重新启动 Pebble 使渲染速度显着加快。菜鸟错误...
var UI = require('ui');
var ajax = require('ajax');
var main = new UI.Card({
title: 'Pebble Interface',
icon: 'images/mattec.png',
body: 'Press Top Button to open Cell Picker.'
});
main.show();
main.on('click', 'up', function(e) {
var menu = new UI.Menu({
sections: [{
items: [{
title: 'ALMSC1'
}, {
title: 'ALMSC2'
}, {
title: 'DL 1'
}, {
title: 'DL 2'
}, {
title: 'DL 3'
}, {
title: 'DL 4'
}, {
title: 'EDGER'
}, {
title: 'EPOXYA'
}, {
title: 'EPOXYP'
}, {
title: 'FORK 1'
}, {
title: 'FORK 2'
}, {
title: 'HICK 1'
}, {
title: 'HICK 2'
}, {
title: 'LG 1'
}, {
title: 'LG 2'
}, {
title: 'LG 3'
}, {
title: 'LG 4'
}, {
title: 'LG 5'
}, {
title: 'LG 6'
}, {
title: 'PHD 1'
}, {
title: 'PHD 2'
}, {
title: 'PHD 3'
}, {
title: 'PHD 4'
}, {
title: 'SPRLTE'
}, {
title: 'STEEL1'
}, {
title: 'STEEL2'
}, {
title: 'STEEL3'
}, {
title: 'STEEL4'
}, {
title: 'STEEL5'
}, {
title: 'STEEL6'
}, {
title: 'SVL 01'
}, {
title: 'SVL 02'
}, {
title: 'SVL 03'
}, {
title: 'SVL 04'
}, {
title: 'SVL 05'
}, {
title: 'SVL 06'
}, {
title: 'SVL 07'
}, {
title: 'SVL 08'
}, {
title: 'SVL 09'
}, {
title: 'SVL 10'
}, {
title: 'SVL 11'
}, {
title: 'SVL 12'
}, {
title: 'SVL 13'
}, {
title: 'SVL 14'
}, {
title: 'SVL 15'
}, {
title: 'SVL 16'
}, {
title: 'SVL 17'
}, {
title: 'SVL 18'
}, {
title: 'SVLCUB'
}, {
title: 'TAMP 1'
}, {
title: 'TAMP 2'
}, {
title: 'WEEDER'
}]
}]
});
menu.on('select', function(e) {
ajax({ url: 'http://myserver/test/pebble/oldpebble.php?cell=' + e.item.title, type:'xml' }, function(data){
var istag = data.match(/<istag>(.*?)<\/istag>/)[1];
istag = istag.replace(/"/g, "\"");
var psname = data.match(/<psname>(.*?)<\/psname>/)[1];
psname = psname.replace(/"/g, "\"");
var psip = data.match(/<psip>(.*?)<\/psip>/)[1];
psip = psip.replace(/"/g, "\"");
var upcstatus = data.match(/<upcstatus>(.*?)<\/upcstatus>/)[1];
upcstatus = upcstatus.replace(/"/g, "\"");
var i2of5status = data.match(/<i2of5status>(.*?)<\/i2of5status>/)[1];
i2of5status = i2of5status.replace(/"/g, "\"");
var content = istag + "\n\nPrint Server\n" + psname + "\n" + psip + "\n" + "UPC - " + upcstatus + "\nI2of5 - " + i2of5status;
var detailCard = new UI.Card({
title:e.item.title,
body: content,
scrollable: true,
style: 'small'
});
detailCard.show();
});
});
menu.show();
});
Pebble.js 将列表数据按需流式传输到手表。六秒听起来很多,我没有看到那么多的延迟,但除了使用 C SDK 重新构建您的应用程序之外,您无能为力。