Skip to content
Snippets Groups Projects
Commit 9ac4bcaa authored by echicken's avatar echicken
Browse files

Asynchronously load onelinerz so that bbs-scene slowness won't affect the...

Asynchronously load onelinerz so that bbs-scene slowness won't affect the loading of the rest of the page.
(Updated documentation; name of sidebar module script must be supplied for this to work.)
parent 3263a8f2
No related branches found
No related tags found
No related merge requests found
load("http.js");
// bbs-scene.org global onelinerz for ecweb
// echicken -at- bbs.electronicchicken.com
var f = new File(system.ctrl_dir + "modopts.ini");
f.open("r");
if(!f.is_open)
exit;
var bbsScene = f.iniGetObject("bbs-scene.org");
f.close();
var scriptname = "onelinerz.ssjs";
if(http_request.query.hasOwnProperty('action') && http_request.query.action == 'showOnelinerz') {
load("http.js");
var http = new HTTPRequest(bbsScene.username, bbsScene.password);
var response = http.Get("http://bbs-scene.org/api/onelinerzjson.php?limit=10&ansi=0");
try {
if(response === undefined || response === null)
throw("Empty response");
}
catch(err) {
if(err)
var f = new File(system.ctrl_dir + "modopts.ini");
f.open("r");
if(!f.is_open)
exit;
}
var onelinerz = JSON.parse(response);
print("<b>BBS-Scene.org Global Onelinerz</b><br><br>");
var n = 0;
for(var o in onelinerz) {
if(n % 2 == 0)
print("<div style='padding:5px;background-color:#585858;color:#FFFFFF;'>");
else
print("<div style='padding:5px;background-color:#2E2E2E;color:#FFFFFF;'>");
print("<b>" + onelinerz[o].alias + "@" + onelinerz[o].bbsname + "</b>:<br>" + onelinerz[o].oneliner);
print("</div>");
n++;
var bbsScene = f.iniGetObject("bbs-scene.org");
f.close();
var http = new HTTPRequest(bbsScene.username, bbsScene.password);
var response = http.Get("http://bbs-scene.org/api/onelinerzjson.php?limit=10&ansi=0");
try {
if(response === undefined || response === null)
throw("Empty response");
}
catch(err) {
if(err)
exit;
}
var onelinerz = JSON.parse(response);
print("<b>BBS-Scene.org Global Onelinerz</b><br><br>");
var n = 0;
for(var o in onelinerz) {
if(n % 2 == 0)
print("<div style='padding:5px;background-color:#000060;color:#FFFFFF;word-wrap:break-word;'>");
else
print("<div style='padding:5px;background-color:#000080;color:#FFFFFF;word-wrap:break-word;'>");
print("<b>" + onelinerz[o].alias + "@" + onelinerz[o].bbsname + "</b>:<br>" + onelinerz[o].oneliner);
print("</div>");
n++;
}
} else {
print("<div id='bbssceneonelinerz'></div>");
print("<script type='text/javascript'>");
print("function xhrbbssceneonelinerz() {");
print("var XMLReq = new XMLHttpRequest();");
print("XMLReq.open('GET', './sidebar/" + scriptname + "?action=showOnelinerz', true);");
print("XMLReq.send(null);");
print("XMLReq.onreadystatechange = function() { if(XMLReq.readyState == 4) { document.getElementById('bbssceneonelinerz').innerHTML = XMLReq.responseText; } }");
print("}");
print("xhrbbssceneonelinerz();");
print("</script>");
}
\ No newline at end of file
......@@ -96,7 +96,8 @@ onelinerz.ssjs
Users of ecWeb can copy 'onelinerz.ssjs' into the sidebar/ directory of their
ecWeb installation. Prepending a string of digits to the filename (eg.
renaming it to "005-onelinerz.ssjs") will affect the order in which it is
loaded into the sidebar.
loaded into the sidebar. If you rename the file, edit the "scriptname"
variable at the top of the script to reflect the new filename.
Users of the default or custom web interfaces may be able to add the command:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment