From b692dc0ba8e8940844eb647a1f15e435a55ce4eb Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 11 Mar 2011 23:41:40 +0100 Subject: closed #259, #250 --- module/web/media/default/js/funktions.js | 65 ++++++++++++++++---------------- 1 file changed, 33 insertions(+), 32 deletions(-) (limited to 'module/web/media/default/js') diff --git a/module/web/media/default/js/funktions.js b/module/web/media/default/js/funktions.js index 6240d32ad..8d9d332b3 100644 --- a/module/web/media/default/js/funktions.js +++ b/module/web/media/default/js/funktions.js @@ -1,41 +1,42 @@ // JavaScript Document -function HumanFileSize(size) -{ - var filesizename = new Array("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"); - var loga = Math.log(size)/Math.log(1024); - var i = Math.floor(loga); - var a = Math.pow(1024, i); - return (size == 0) ? "0 B" : (Math.round( size / a , 2) + " " + filesizename[i]); +function HumanFileSize(size) { + var filesizename = new Array("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"); + var loga = Math.log(size) / Math.log(1024); + var i = Math.floor(loga); + var a = Math.pow(1024, i); + return (size == 0) ? "0 B" : (Math.round(size / a, 2) + " " + filesizename[i]); } function parseUri() { - var oldString = $("add_links").value; - var regxp= new RegExp('(ht|f)tp(s?):\/\/[a-zA-Z0-9\-\.\/\?=]+[<| |\"|\'|\r|\n|\t]{1}', 'g'); - var resu=oldString.match(regxp); - if (resu == null) return; - var res=""; - for(var i=0; i < resu.length; i++){ - // remove the last char, if ... - if (resu[i].indexOf(" ") != -1){ - res = res + resu[i].replace(" ","\n"); - } else if (resu[i].indexOf("\t") != -1){ - res = res + resu[i].replace("\t","\n"); - } else if (resu[i].indexOf("\r") != -1){ - res = res + resu[i].replace("\r","\n"); - } else if (resu[i].indexOf("\"") != -1){ - res = res + resu[i].replace("\"","\n"); - } else if (resu[i].indexOf("<") != -1){ - res = res + resu[i].replace("<","\n"); - } else { - res = res + "\n" + resu[i].replace("'","\n"); - } + var oldString = $("add_links").value; + var regxp = new RegExp('(ht|f)tp(s?):\/\/[a-zA-Z0-9\-\.\/\?=_&%#]+[<| |\"|\'|\r|\n|\t]{1}', 'g'); + var resu = oldString.match(regxp); + if (resu == null) return; + var res = ""; + for (var i = 0; i < resu.length; i++) { + // remove the last char, if ... + if (resu[i].indexOf(" ") != -1) { + res = res + resu[i].replace(" ", " \n"); + } else if (resu[i].indexOf("\t") != -1) { + res = res + resu[i].replace("\t", " \n"); + } else if (resu[i].indexOf("\r") != -1) { + res = res + resu[i].replace("\r", " \n"); + } else if (resu[i].indexOf("\"") != -1) { + res = res + resu[i].replace("\"", " \n"); + } else if (resu[i].indexOf("<") != -1) { + res = res + resu[i].replace("<", " \n"); + } else if (resu[i].indexOf("'") != -1) { + res = res + resu[i].replace("'", " \n"); + } else { + res = res + resu[i].replace("\n", " \n"); } - $("add_links").value = res; + } + $("add_links").value = res; } Array.prototype.remove = function(from, to) { - var rest = this.slice((to || from) + 1 || this.length); - this.length = from < 0 ? this.length + from : from; - if (this.length == 0) return []; - return this.push.apply(this, rest); + var rest = this.slice((to || from) + 1 || this.length); + this.length = from < 0 ? this.length + from : from; + if (this.length == 0) return []; + return this.push.apply(this, rest); }; \ No newline at end of file -- cgit v1.2.3