js: initial contented implementation

This commit is contained in:
mappu 2017-10-15 20:56:47 +13:00
parent 37014f7f52
commit 447e8c2591
1 changed files with 37 additions and 0 deletions

View File

@ -942,6 +942,43 @@ var tab_mark_unread = function(tabref) {
}
}
//
var contented_url = "";
var contented_loaded_sdk = false;
var contented_load = function() {
if (contented_url.length === 0) {
return;
}
var onceSDKLoaded = function() {
contented.init("#inner-tab-main", function(items) {
var val = el("#chatbox").value;
for (var i = 0; i < items.length; ++i) {
if (val.length > 0) {
val.length += " ";
}
val += contented.getPreviewURL(items[i]);
}
el("#chatbox").value = val;
});
};
if (contented_loaded_sdk) {
onceSDKLoaded();
} else {
var scriptElement = document.createElement('script');
scriptElement.onload = function() {
contented_loaded_sdk = true;
onceSDKLoaded();
};
scriptElement.src = contented_url + "sdk.js";
document.body.appendChild(scriptElement);
}
};
//
window.onload = function() {
write("tab-main").system("Communicating with server...");