mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
bd097b0eff
This changes the HTML part of GitX to be more consistent -- we now use a "views" directory where every web view has it's own directory. Furthermore, GitX-wide Javascript is added in the "lib" directory. The same is true for CSS in the "css" directory. Every view can have its own custom CSS and JS, and those are put in the views directory (without JS or CSS prefix directories).
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
/*
|
|
* GitX Javascript library
|
|
* This library contains functions that can be shared across all
|
|
* webviews in GitX.
|
|
* It is written only for Safari 3 and higher.
|
|
*/
|
|
|
|
function $(element) {
|
|
return document.getElementById(element);
|
|
}
|
|
|
|
String.prototype.escapeHTML = function() {
|
|
return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
|
};
|
|
|
|
String.prototype.unEscapeHTML = function() {
|
|
return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
|
};
|
|
|
|
Array.prototype.indexOf = function(item, i) {
|
|
i || (i = 0);
|
|
var length = this.length;
|
|
if (i < 0) i = length + i;
|
|
for (; i < length; i++)
|
|
if (this[i] === item) return i;
|
|
return -1;
|
|
};
|
|
|
|
var notify = function(text, state) {
|
|
var n = $("notification");
|
|
n.style.display = "";
|
|
$("notification_message").innerHTML = text;
|
|
|
|
// Change color
|
|
if (!state) { // Busy
|
|
$("spinner").style.display = "";
|
|
n.setAttribute("class", "");
|
|
}
|
|
else if (state == 1) { // Success
|
|
$("spinner").style.display = "none";
|
|
n.setAttribute("class", "success");
|
|
} else if (state == -1) {// Fail
|
|
$("spinner").style.display = "none";
|
|
n.setAttribute("class", "fail");
|
|
}
|
|
}
|