mirror of
https://github.com/owntone/owntone-server.git
synced 2025-12-08 08:42:43 -05:00
Move common javascript functions to util.js closes #69
Javascript fixes for Safari
This commit is contained in:
@@ -694,29 +694,6 @@ SelectedRows = {
|
||||
}
|
||||
};
|
||||
|
||||
Object.extend(Element, {
|
||||
removeChildren: function(element) {
|
||||
while(element.hasChildNodes()) {
|
||||
element.removeChild(element.firstChild);
|
||||
}
|
||||
},
|
||||
textContent: function(node) {
|
||||
if ((!node) || !node.hasChildNodes()) {
|
||||
// Empty text node
|
||||
return '';
|
||||
} else {
|
||||
if (node.textContent) {
|
||||
// W3C ?
|
||||
return node.textContent;
|
||||
} else if (node.text) {
|
||||
// IE
|
||||
return node.text;
|
||||
}
|
||||
}
|
||||
// We shouldn't end up here;
|
||||
return '';
|
||||
}
|
||||
});
|
||||
String.prototype.encode = function () {
|
||||
return encodeURIComponent(this).replace(/\'/g,"\\'");
|
||||
};
|
||||
@@ -727,28 +704,3 @@ String.prototype.truncate = function(length, truncation) {
|
||||
var ret = (this.length > length) ? this.slice(0, length - truncation.length) + truncation : this;
|
||||
return '' + ret;
|
||||
};
|
||||
/* Detta script finns att hamta pa http://www.jojoxx.net och
|
||||
far anvandas fritt sa lange som dessa rader star kvar. */
|
||||
function DataDumper(obj,n,prefix){
|
||||
var str=""; prefix=(prefix)?prefix:""; n=(n)?n+1:1; var ind=""; for(var i=0;i<n;i++){ ind+=" "; }
|
||||
if(typeof(obj)=="string"){
|
||||
str+=ind+prefix+"String:\""+obj+"\"\n";
|
||||
} else if(typeof(obj)=="number"){
|
||||
str+=ind+prefix+"Number:"+obj+"\n";
|
||||
} else if(typeof(obj)=="function"){
|
||||
str+=ind+prefix+"Function:"+obj+"\n";
|
||||
} else if(typeof(obj) == 'boolean') {
|
||||
str+=ind+prefix+"Boolean:" + obj + "\n";
|
||||
} else {
|
||||
var type="Array";
|
||||
for(var i in obj){ type=(type=="Array"&&i==parseInt(i))?"Array":"Object"; }
|
||||
str+=ind+prefix+type+"[\n";
|
||||
if(type=="Array"){
|
||||
for(var i in obj){ str+=DataDumper(obj[i],n,i+"=>"); }
|
||||
} else {
|
||||
for(var i in obj){ str+=DataDumper(obj[i],n,i+"=>"); }
|
||||
}
|
||||
str+=ind+"]\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user