mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-12-25 23:39:23 -05:00
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
|
browserUtil = {
|
||
|
isRhino: true,
|
||
|
|
||
|
pauseAndThen: function (cb) { cb(); },
|
||
|
|
||
|
cpsIterate: function (f, start, end, pause, callback) {
|
||
|
function go() {
|
||
|
var called = false;
|
||
|
if (start >= end) {
|
||
|
callback && callback();
|
||
|
} else {
|
||
|
f(start, function () {
|
||
|
if (!called) { called = true; start++; go(); }
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
go (start);
|
||
|
},
|
||
|
|
||
|
cpsMap: function (map, list, pause, callback) {
|
||
|
browserUtil.cpsIterate(function (i, cb) { map(list[i], i, list.length, cb); },
|
||
|
0, list.length, pause, callback);
|
||
|
},
|
||
|
|
||
|
loadScripts: function(scriptNames, callback) {
|
||
|
for (i=0; i<scriptNames.length; i++) {
|
||
|
load(scriptNames[i]);
|
||
|
callback && callback();
|
||
|
}
|
||
|
},
|
||
|
|
||
|
write: function(type, message) {
|
||
|
print(message);
|
||
|
return { update: function (type2, message2) {
|
||
|
if (type2 === 'pass') { print(" + " + message2); }
|
||
|
else if (type2 === 'unimplemented') { print(" ? " + message2); }
|
||
|
else { print(" - " + message2); }
|
||
|
}};
|
||
|
},
|
||
|
|
||
|
writeNewline: function () { print(""); },
|
||
|
|
||
|
status: function(message) {}
|
||
|
};
|