67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
// JavaScript Document
|
|
$.extend($.expr[':'], {
|
|
'containsi': function (elem, i, match, array) {
|
|
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
|
}
|
|
});
|
|
$.fn.sort = function(c) {
|
|
return this.pushStack([].sort.apply(this, arguments), []);
|
|
};
|
|
var sortAscending = function(a, b) {
|
|
return $(a).find("h1").text() > $(b).find("h1").text() ? 1 : -1;
|
|
};
|
|
var sortDescending = function(a, b) {
|
|
return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1;
|
|
};
|
|
var orbitDesktopAPI = function(){
|
|
o = this;
|
|
this.notify = function(msg,type,time){
|
|
var $notify = $("#orbitnote");
|
|
var img, n_height;
|
|
if(!type)type="";
|
|
switch(type){
|
|
case "alert":
|
|
img = "note_alert.png";
|
|
break;
|
|
case "imp":
|
|
img = "note_imp.png";
|
|
break;
|
|
case "success":
|
|
img = "note_success.png";
|
|
break;
|
|
default:
|
|
img = "note_alert.png";
|
|
break;
|
|
}
|
|
$notify.find("img#note_img").attr("src",o.notifyImgPath+img);
|
|
$notify.find(".note_message").text(msg);
|
|
n_height = $notify.outerHeight();
|
|
if(!time)time=5000; else time=time*1000;
|
|
$notify
|
|
.css({'top':-n_height, 'display':'block', 'opacity':0})
|
|
.animate({top:0,opacity:1},200)
|
|
.delay(time)
|
|
.animate({top:-n_height,opacity:0},200);
|
|
};
|
|
this.executeFunc = function(func,callbackFn){
|
|
func.call(this);
|
|
if(callbackFn){
|
|
callbackFn.call(this,func);
|
|
}
|
|
};
|
|
this.sortJSON = function(field, reverse, primer){
|
|
var key = function (x) {return primer ? primer(x[field]) : x[field]};
|
|
return function (a,b) {
|
|
var A = key(a), B = key(b);
|
|
return ((A < B) ? -1 : (A > B) ? +1 : 0) * [-1,1][+!!reverse];
|
|
}
|
|
};
|
|
this.rgb2hex = function(rgb) {
|
|
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
|
var hex = function(x) {
|
|
return ("0" + parseInt(x).toString(16)).slice(-2);
|
|
}
|
|
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
|
|
};
|
|
};
|