function getPosition(e) {
e = e || window.event;
var cursor = {x:0, y:0};
if (e.pageX || e.pageY) {
cursor.x = e.pageX;
cursor.y = e.pageY;
}
else {
var de = document.documentElement;
var b = document.body;
cursor.x = e.clientX +
(de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
cursor.y = e.clientY +
(de.scrollTop || b.scrollTop) - (de.clientTop || 0);
}
return cursor;
}
function getWindowSize() {
return {
x: $(window).width(),
y: $(window).height(),
o: window.orientation
};
}
function zeroPad(num, count)
{
var numZeropad = num + '';
while(numZeropad.length < count) {
numZeropad = "0" + numZeropad;
}
return numZeropad;
}
function cloneObject(obj) {
return JSON.parse(JSON.stringify(obj));
}
function rawurlencode (str) {
str = (str+'').toString();
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A');
}
function htmlspecialchars_decode(string) {
string = string.toString().replace(/</g, '<').replace(/>/g, '>').replace(/*39;/g, "'").replace(/"/g, '"');
string = string.replace(/&/g, '&');
return string;
}
function formatTimeString(duration) {
if (duration > 0) {
var secs=duration%60;
var mins = (duration/60)%60;
var hours = duration/3600;
if (hours >= 1) {
return parseInt(hours.toString()) + ":" + zeroPad(parseInt(mins.toString()), 2) + ":" + zeroPad(parseInt(secs.toString()),2);
} else {
return parseInt(mins.toString()) + ":" + zeroPad(parseInt(secs.toString()),2);
}
} else {
return "";
}
}
function getArray(data) {
try {
switch (typeof data) {
case "object":
if (data.length) {
return data;
} else {
return [data];
}
break;
case "undefined":
return [];
break;
default:
return [data];
break;
}
} catch(err) {
return [];
}
}
function utf8_encode(s) {
return unescape(encodeURIComponent(s));
}
function escapeHtml(text) {
if (!text) return '';
return text
.replace(/&/g, "&")
.replace(//g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
function unescapeHtml(text) {
if (!text) return '';
return text
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, '"')
.replace(/'/g, "'");
}
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
String.prototype.initcaps = function() {
return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase();
}
String.prototype.removePunctuation = function() {
var punctRE = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#\$%&\(\)\*\+,\-\.\/:;<=>\?@\[\]\^_`\{\|\}~]/g;
return this.replace(/\s*\&\s*/, ' and ').replace(punctRE,'').replace(/\s+/g, ' ');
}
String.prototype.fixDodgyLinks = function() {
var regexp = /([^"])(https*:\/\/.*?)([<|\n|\r|\s|\)])/g;
return this.replace(regexp, '$1$2$3');
}
String.prototype.isArtistOrAlbum = function() {
if (this.indexOf(':artist:') > -1 || this.indexOf(':album:') > -1) {
return true;
} else {
return false;
}
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires + '; path=/';
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i 0.5) {
return 1;
} else {
return -1;
}
}