This repository has been archived on 2025-08-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Bungloo/WebKit/scripts/main.js
2013-02-10 18:01:55 +01:00

158 lines
No EOL
3.1 KiB
JavaScript

var bungloo_instance;
var bungloo_cache = {};
requirejs.config({
baseUrl: 'scripts'
});
function start(view) {
if (view == "oauth") {
require(["controller/Oauth"], function(Oauth) {
bungloo_instance = new Oauth();
});
} else if (view == "timeline") {
require(["controller/Timeline"], function(Timeline) {
bungloo_instance = new Timeline();
});
} else if (view == "mentions") {
require(["controller/Mentions"], function(Mentions) {
bungloo_instance = new Mentions();
});
} else if (view == "profile") {
require(["controller/Profile"], function(Profile) {
bungloo_instance = new Profile();
});
} else if (view == "follow") {
} else if (view == "conversation") {
require(["controller/Conversation"], function(Conversation) {
bungloo_instance = new Conversation();
});
}
}
String.prototype.startsWith = function(prefix) {
return this.indexOf(prefix) === 0;
}
String.prototype.endsWith = function(suffix) {
return this.match(suffix+"$") == suffix;
};
var __entityMap = {
"&": "&",
"<": "&lt;",
">": "&gt;"
};
String.prototype.escapeHTML = function() {
return String(this).replace(/[&<>]/g, function (s) {
return __entityMap[s];
});
}
var console = {
log: function(s) {
if (OS_TYPE == "mac") {
alert(s)
} else {
__console.log(s);
}
},
error: function(s) {
if (OS_TYPE == "mac") {
alert("ERROR: " + s);
} else {
__console.error(s);
}
},
warn: function (s) {
if (OS_TYPE == "mac") {
alert("WARNING: " + s);
} else {
__console.warning(s);
}
},
notice: function(s) {
if (OS_TYPE == "mac") {
alert("NOTICE: " + s);
} else {
__console.notice(s);
}
},
debug: function(s) {
if (OS_TYPE == "mac") {
alert("DEBUG: " + s);
} else {
__console.debug(s);
}
}
};
function loadJsPlugin(js_url) {
if (js_url) {
var js_plugin = document.createElement("script");
js_plugin.type = "text/javascript";
js_plugin.src = js_url;
document.getElementsByTagName("head")[0].appendChild(js_plugin);
}
}
function loadCssPlugin(css_url) {
if (css_url) {
var css_plugin = document.createElement("link");
css_plugin.rel = 'stylesheet';
css_plugin.type = 'text/css'
css_plugin.href = css_url;
document.getElementsByTagName("head")[0].appendChild(css_plugin);
}
}
function debug(string) {
if (typeof string != "string") {
string = JSON.stringify(string);
}
console.debug(string);
}
function go() { // wait untill everything is loaded
setTimeout(function() {
if (typeof HostAppGo != typeof __not_defined__) {
HostAppGo();
} else {
go();
}
}, 500);
}
go();