Removed redundant functions

This commit is contained in:
Timothy Warren 2011-10-24 19:19:29 -04:00
parent ab99f79b2c
commit 3d241c2f8b
3 changed files with 21 additions and 357 deletions

View File

@ -1085,173 +1085,6 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
$_.ext('util', u);
}());
function strtr (str, from, to) {
// http://kevin.vanzonneveld.net
// + original by: Brett Zamir (http://brett-zamir.me)
// + input by: uestla
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Alan C
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Taras Bogach
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// + input by: jpfle
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// - depends on: krsort
// - depends on: ini_set
// * example 1: $trans = {'hello' : 'hi', 'hi' : 'hello'};
// * example 1: strtr('hi all, I said hello', $trans)
// * returns 1: 'hello all, I said hi'
// * example 2: strtr('äaabaåccasdeöoo', 'äåö','aao');
// * returns 2: 'aaabaaccasdeooo'
// * example 3: strtr('ääääääää', 'ä', 'a');
// * returns 3: 'aaaaaaaa'
// * example 4: strtr('http', 'pthxyz','xyzpth');
// * returns 4: 'zyyx'
// * example 5: strtr('zyyx', 'pthxyz','xyzpth');
// * returns 5: 'http'
// * example 6: strtr('aa', {'a':1,'aa':2});
// * returns 6: '2'
var fr = '',
i = 0,
j = 0,
lenStr = 0,
lenFrom = 0,
tmpStrictForIn = false,
fromTypeStr = '',
toTypeStr = '',
istr = '';
var tmpFrom = [];
var tmpTo = [];
var ret = '';
var match = false;
// Received replace_pairs?
// Convert to normal from->to chars
if (typeof from === 'object') {
//tmpStrictForIn = this.ini_set('phpjs.strictForIn', false); // Not thread-safe; temporarily set to true
from = this.krsort(from);
//this.ini_set('phpjs.strictForIn', tmpStrictForIn);
for (fr in from) {
if (from.hasOwnProperty(fr)) {
tmpFrom.push(fr);
tmpTo.push(from[fr]);
}
}
from = tmpFrom;
to = tmpTo;
}
// Walk through subject and replace chars when needed
lenStr = str.length;
lenFrom = from.length;
fromTypeStr = typeof from === 'string';
toTypeStr = typeof to === 'string';
for (i = 0; i < lenStr; i++) {
match = false;
if (fromTypeStr) {
istr = str.charAt(i);
for (j = 0; j < lenFrom; j++) {
if (istr == from.charAt(j)) {
match = true;
break;
}
}
} else {
for (j = 0; j < lenFrom; j++) {
if (str.substr(i, from[j].length) == from[j]) {
match = true;
// Fast forward
i = (i + from[j].length) - 1;
break;
}
}
}
if (match) {
ret += toTypeStr ? to.charAt(j) : to[j];
} else {
ret += str.charAt(i);
}
}
return ret;
}
function krsort (inputArr) {
// http://kevin.vanzonneveld.net
// + original by: GeekFG (http://geekfg.blogspot.com)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Brett Zamir (http://brett-zamir.me)
// % note 1: The examples are correct, this is a new way
// % note 2: This function deviates from PHP in returning a copy of the array instead
// % note 2: of acting by reference and returning true; this was necessary because
// % note 2: IE does not allow deleting and re-adding of properties without caching
// % note 2: of property position; you can set the ini of "phpjs.strictForIn" to true to
// % note 2: get the PHP behavior, but use this only if you are in an environment
// % note 2: such as Firefox extensions where for-in iteration order is fixed and true
// % note 2: property deletion is supported. Note that we intend to implement the PHP
// % note 2: behavior by default if IE ever does allow it; only gives shallow copy since
// % note 2: is by reference in PHP anyways
// % note 3: Since JS objects' keys are always strings, and (the
// % note 3: default) SORT_REGULAR flag distinguishes by key type,
// % note 3: if the content is a numeric string, we treat the
// % note 3: "original type" as numeric.
// - depends on: i18n_loc_get_default
// * example 1: data = {d: 'lemon', a: 'orange', b: 'banana', c: 'apple'};
// * example 1: data = krsort(data);
// * results 1: {d: 'lemon', c: 'apple', b: 'banana', a: 'orange'}
// * example 2: ini_set('phpjs.strictForIn', true);
// * example 2: data = {2: 'van', 3: 'Zonneveld', 1: 'Kevin'};
// * example 2: krsort(data);
// * results 2: data == {3: 'Kevin', 2: 'van', 1: 'Zonneveld'}
// * returns 2: true
var tmp_arr = {},
keys = [],
sorter, i, k, that = this,
strictForIn = false,
populateArr = {};
//sorter = ;
// Make a list of key names
for (k in inputArr) {
if (inputArr.hasOwnProperty(k)) {
keys.push(k);
}
}
keys.sort(function (b, a) {
var aFloat = parseFloat(a),
bFloat = parseFloat(b),
aNumeric = aFloat + '' === a,
bNumeric = bFloat + '' === b;
if (aNumeric && bNumeric) {
return aFloat > bFloat ? 1 : aFloat < bFloat ? -1 : 0;
} else if (aNumeric && !bNumeric) {
return 1;
} else if (!aNumeric && bNumeric) {
return -1;
}
return a > b ? 1 : a < b ? -1 : 0;
});
// Rebuild array with sorted key names
for (i = 0; i < keys.length; i++) {
k = keys[i];
tmp_arr[k] = inputArr[k];
}
for (i in tmp_arr) {
if (tmp_arr.hasOwnProperty(i)) {
populateArr[i] = tmp_arr[i];
}
}
return populateArr;
}
// --------------------------------------------------------------------------

44
kis-min.js vendored
View File

@ -1,24 +1,22 @@
(function(){if(document.querySelectorAll){var c,d,f,b;d=function(a){if(typeof a!=="string"||typeof a==="undefined")return a;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);else a=a.match(/^([\w\-]+)$/)?document.getElementsByTagName(a):document.querySelectorAll(a);return a.length===1?a[0]:a};c=function(a){b=typeof a==="undefined"?typeof c.el!=="undefined"?c.el:document.documentElement:typeof a!=="object"?d(a):a;c.prototype.el=b;var a=f(c),e;for(e in a)if(typeof a[e]==="object")a[e].el=
b;a.el=b;return a};f=function(a){var e;if(typeof a!=="undefined"){if(typeof Object.create!=="undefined")return Object.create(a);e=typeof a;if(!(e!=="object"&&e!=="function"))return e=function(){},e.prototype=a,new e}};c.ext=function(a,e){e.el=b;c[a]=e};c.ext("each",function(a){if(typeof b.length!=="undefined"&&b!==window){var e=b.length;if(e!==0)for(var c,d=0;d<e;d++)c=b.item(d)?b.item(d):b[d],a(c)}else a(b)});c.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():
(function(){if(document.querySelectorAll){var c,d,e,b;d=function(a){if(typeof a!=="string"||typeof a==="undefined")return a;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);else a=a.match(/^([\w\-]+)$/)?document.getElementsByTagName(a):document.querySelectorAll(a);return a.length===1?a[0]:a};c=function(a){b=typeof a==="undefined"?typeof c.el!=="undefined"?c.el:document.documentElement:typeof a!=="object"?d(a):a;c.prototype.el=b;var a=e(c),f;for(f in a)if(typeof a[f]==="object")a[f].el=
b;a.el=b;return a};e=function(a){var b;if(typeof a!=="undefined"){if(typeof Object.create!=="undefined")return Object.create(a);b=typeof a;if(!(b!=="object"&&b!=="function"))return b=function(){},b.prototype=a,new b}};c.ext=function(a,f){f.el=b;c[a]=f};c.ext("each",function(a){if(typeof b.length!=="undefined"&&b!==window){var f=b.length;if(f!==0)for(var c,d=0;d<f;d++)c=b.item(d)?b.item(d):b[d],a(c)}else a(b)});c.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():
{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};c=window.$_=window.$_||c;c.$=d;if(typeof window.console==="undefined")window.console={log:function(){}};if(typeof String.prototype.trim==="undefined")String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}})();
typeof document!=="undefined"&&!("classList"in document.createElement("a"))&&function(c){var c=(c.HTMLElement||c.Element).prototype,d=Object,f=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},b=Array.prototype.indexOf||function(a){for(var e=0,b=this.length;e<b;e++)if(e in this&&this[e]===a)return e;return-1},a=function(a,e){this.name=a;this.code=DOMException[a];this.message=e},e=function(e,d){if(d==="")throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(d))throw new a("INVALID_CHARACTER_ERR",
"String contains an invalid character");return b.call(e,d)},h=function(a){for(var e=f.call(a.className),e=e?e.split(/\s+/):[],b=0,d=e.length;b<d;b++)this.push(e[b]);this._updateClassName=function(){a.className=this.toString()}},g=h.prototype=[],l=function(){return new h(this)};a.prototype=Error.prototype;g.item=function(a){return this[a]||null};g.contains=function(a){a+="";return e(this,a)!==-1};g.add=function(a){a+="";e(this,a)===-1&&(this.push(a),this._updateClassName())};g.remove=function(a){a+=
"";a=e(this,a);a!==-1&&(this.splice(a,1),this._updateClassName())};g.toggle=function(a){a+="";e(this,a)===-1?this.add(a):this.remove(a)};g.toString=function(){return this.join(" ")};if(d.defineProperty){g={get:l,enumerable:true,configurable:true};try{d.defineProperty(c,"classList",g)}catch(j){if(j.number===-2146823252)g.enumerable=false,d.defineProperty(c,"classList",g)}}else d.prototype.__defineGetter__&&c.__defineGetter__("classList",l)}(self);
(function(){function c(b,a,e){var d,c;if(typeof b.hasAttribute!=="undefined")b.hasAttribute(a)&&(d=b.getAttribute(a)),c=true;else if(typeof b[a]!=="undefined")d=b[a],c=false;else if(a==="class"&&typeof b.className!=="undefined")a="className",d=b.className,c=false;if(typeof d==="undefined"&&(typeof e==="undefined"||e===null))console.log(e),console.log(b),console.log("Element does not have the selected attribute");else{if(typeof e==="undefined")return d;typeof e!=="undefined"&&e!==null?c===true?b.setAttribute(a,
e):b[a]=e:e===null&&(c===true?b.removeAttribute(a):delete b[a]);return typeof e!=="undefined"?e:d}}function d(b){return b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function f(b,a,e){var c,a=d(a);c={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof e==="undefined"&&b.style[a]!=="undefined")return b.style[a];else if(typeof e==="undefined"&&b.style[c[a]]!=="undefined")return b.style[c[a]];typeof b.style[a]!=="undefined"?b.style[a]=e:b.style[c[a]]?
b.style[c[a]]=e:console.log("Property "+a+" nor an equivalent seems to exist")}$_.ext("dom",{addClass:function(b){$_.each(function(a){a.classList.add(b)})},removeClass:function(b){$_.each(function(a){a.classList.remove(b)})},hide:function(){this.css("display","none")},show:function(b){typeof b==="undefined"&&(b="block");this.css("display",b)},attr:function(b,a){var e=this.el;if(e.length>1&&typeof a==="undefined")console.log(e),console.log("Must be a singular element");else if(e.length>1&&typeof a!==
"undefined")$_.each(function(e){return c(e,b,a)});else return c(e,b,a)},text:function(b){var a,e,d;d=this.el;e=typeof d.innerText!=="undefined"?"innerText":typeof d.textContent!=="undefined"?"textContent":"innerHTML";a=d[e];return typeof b!=="undefined"?d[e]=b:a},css:function(b,a){if(typeof a==="undefined")return f(this.el,b);$_.each(function(e){f(e,b,a)})}})})();
(function(){$_.ext("store",{get:function(c){return JSON.parse(localStorage.getItem(c))},set:function(c,d){typeof d!=="string"&&(d=JSON.stringify(d));localStorage.setItem(c,d)},remove:function(c){localStorage.removeItem(c)},getAll:function(){var c,d,f;d=localStorage.length;f={};for(c=0;c<d;c++){var b=localStorage.key(c),a=localStorage.getItem(b);f[b]=a}return f}})})();
(function(){$_.hb=history.pushState?false:true;$_.ext("qs",{parse:function(c){var c=c||$_.hb,d,f,b,a;b={};if(c===true)c=location.hash.split("#!/"),c=c.length>1?c[1]:"";else if(c===false||c===void 0)c=window.location.search.substring(1);else return false;d=c.split("&");f=d.length;for(c=0;c<f;c++){a=d[c].split("=");if(a.length<2)break;b[a[0]]=a[1]}return b},set:function(c,d,f){var f=f||$_.hb,b=this.parse(f);c!==void 0&&d!==void 0&&(b[c]=d);var c=[],a;for(a in b)b.hasOwnProperty(a)&&c.push(a+"="+b[a]);
b=c.join("&");if(f===true)b="!/"+b,location.hash=b;return b},get:function(c,d){var d=d||$_.hb,f=this.parse(d);return f[c]?f[c]:""}})})();
(function(){var c={_do:function(d,c,b,a){typeof b==="undefined"&&(b=function(){});var e=typeof window.XMLHttpRequest!=="undefined"?new XMLHttpRequest:false,a=a?"POST":"GET";d+=a==="GET"?"?"+this._serialize(c):"";e.open(a,d);e.onreadystatechange=function(){e.readyState===4&&b(e.responseText)};a==="POST"?(e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.send(this._serialize(c))):e.send(null)},_serialize:function(d){var c=[],b;for(b in d)if(d.hasOwnProperty(b)&&typeof d[b]!==
"function"){var a=d[b].toString();b=encodeURIComponent(b);a=encodeURIComponent(a);c.push(b+"="+a)}return c.join("&")}};$_.ext("get",function(d,f,b){c._do(d,f,b,false)});$_.ext("post",function(d,f,b){c._do(d,f,b,true)})})();
(function(){$_.ext("util",{reverse_key_sort:function(c){var d=[],f=0,b={},a,d=this.object_keys(c);d.sort(function(a,b){var d=parseFloat(b),c=parseFloat(a),f=d+""===b,i=c+""===a;if(f&&i)return d>c?1:d<c?-1:0;else if(f&&!i)return 1;else if(!f&&i)return-1;return b>a?1:b<a?-1:0});f=d.length;for(a=0;a<f;a++)b[d[a]]=c[d[a]];return b},object_keys:function(c){var d=[],f;for(f in c)c.hasOwnProperty(f)&&d.push(f);return d},object_values:function(c){var d=[],f;for(f in c)d.push(c[f]);return d},array_combine:function(c,
d){var f={},b,a=0;$_.type(c)!=="array"&&(c=this.object_values(c));$_.type(d)!=="array"&&(d=this.object_values(d));b=c.length;if(b!==d.length)return console.log("Object combine requires two arrays of the same size"),false;for(a=0;a<b;a++)f[c[a]]=d[a];return f},object_merge:function(){var c=Array.prototype.slice.call(arguments),d=c.length,f={},b,a=0,e,h,g;b=true;for(e=0;e<d;e++)if($_.type(c[e])!=="array"){b=false;break}if(b){f=[];for(e=0;e<d;e++)f=f.contact(c[e]);return f}for(e=0,g=0;e<d;e++)if(b=c[e],
$_.type(b)=="array")for(h=0,a=b.length;h<a;h++)f[g++]=b[h];else for(h in b)b.hasOwnProperty(h)&&(parseInt(h,10)+""===h?f[g++]=b[h]:f[h]=b[h]);return f},str_trans:function(c,d,f){var b=[],a=[],e=false,h=0,g=0,l="",j="",i="",k="",m;if(typeof d==="object"){d=this.reverse_key_sort(d);for(m in d)d.hasOwnProperty(m)&&(b.push(m),a.push(d[m]));d=b;f=a}g=c.length;h=d.length;l=typeof f==="string";j=typeof d==="string";for(b=0;b<g;b++){e=false;if(j){c.charAt(b-1);i=c.charAt(b);c.charAt(b+1);for(a=0;a<h;a++)if(i==
d.charAt(a)){e=true;break}}else for(a=0;a<h;a++)if(c.substr(b,d[a].length)==d[a]){e=true;b=b+d[a].length-1;break}k+=e?l?f.charAt(a):f[a]:c.charAt(b)}return k}})})();
function strtr(c,d,f){var b="",a=0,e=0,h=0,g=0,l="",j="",i="",a=[],e=[],k="",m=false;if(typeof d==="object"){d=this.krsort(d);for(b in d)d.hasOwnProperty(b)&&(a.push(b),e.push(d[b]));d=a;f=e}h=c.length;g=d.length;l=typeof d==="string";j=typeof f==="string";for(a=0;a<h;a++){m=false;if(l){i=c.charAt(a);for(e=0;e<g;e++)if(i==d.charAt(e)){m=true;break}}else for(e=0;e<g;e++)if(c.substr(a,d[e].length)==d[e]){m=true;a=a+d[e].length-1;break}k+=m?j?f.charAt(e):f[e]:c.charAt(a)}return k}
function krsort(c){var d={},f=[],b,a,e={};for(a in c)c.hasOwnProperty(a)&&f.push(a);f.sort(function(a,e){var b=parseFloat(e),d=parseFloat(a),c=b+""===e,f=d+""===a;if(c&&f)return b>d?1:b<d?-1:0;else if(c&&!f)return 1;else if(!c&&f)return-1;return e>a?1:e<a?-1:0});for(b=0;b<f.length;b++)a=f[b],d[a]=c[a];for(b in d)d.hasOwnProperty(b)&&(e[b]=d[b]);return e}
(function(){var c,d,f,b,a;typeof document.addEventListener!=="undefined"?(c=function(a,b,d){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,d,false)},d=function(a,b,d){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,d,false)}):typeof document.attachEvent!=="undefined"&&(c=function(a,b,c){var e;function f(){c.apply(arguments)}typeof a.attachEvent!=="undefined"?(d(b,c),a.attachEvent("on"+b,f),e=a.KIS_0_3_0=a.KIS_0_3_0||{},a=e,a.listeners=a.listeners||{},a.listeners[b]=
a.listeners[b]||[],a.listeners[b].push({callback:c,listener:f})):console.log("Failed to attach event:"+b+" on "+a)},d=function(a,b,d){if(typeof a.detachEvent!=="undefined"){var c=a.KIS_0_3_0;if(c&&c.listeners&&c.listeners[b])for(var f=c.listeners[b],i=f.length,k=0;k<i;k++)if(f[k].callback===d){a.detachEvent("on"+b,f[k].listener);f.splice(k,1);f.length===0&&delete c.listeners[b];break}}});f=function(a,b,g,l){var j,i;if(typeof a==="undefined")return console.log(arguments),console.log(b),false;if(b.match(/^([\w\-]+)$/))l===
true?c(a,b,g):d(a,b,g);else{b=b.split(" ");i=b.length;for(j=0;j<i;j++)f(a,b[j],g,l)}};b=function(a,b,c){f(a,c,function(){a=$_.$(a)},true)};a=function(a,c,d){b(document.documentElement,a,c,d)};$_.ext("event",{add:function(a,b){$_.each(function(c){f(c,a,b,true)})},remove:function(a,b){$_.each(function(c){f(c,a,b,false)})},live:function(b,c){$_.each(function(d){a(d,b,c)})},delegate:function(a,c,d){$_.each(function(f){b(f,a,c,d)})}})})();
typeof document!=="undefined"&&!("classList"in document.createElement("a"))&&function(c){var c=(c.HTMLElement||c.Element).prototype,d=Object,e=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},b=Array.prototype.indexOf||function(a){for(var b=0,f=this.length;b<f;b++)if(b in this&&this[b]===a)return b;return-1},a=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},f=function(f,c){if(c==="")throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(c))throw new a("INVALID_CHARACTER_ERR",
"String contains an invalid character");return b.call(f,c)},h=function(a){for(var b=e.call(a.className),b=b?b.split(/\s+/):[],f=0,c=b.length;f<c;f++)this.push(b[f]);this._updateClassName=function(){a.className=this.toString()}},g=h.prototype=[],l=function(){return new h(this)};a.prototype=Error.prototype;g.item=function(a){return this[a]||null};g.contains=function(a){a+="";return f(this,a)!==-1};g.add=function(a){a+="";f(this,a)===-1&&(this.push(a),this._updateClassName())};g.remove=function(a){a+=
"";a=f(this,a);a!==-1&&(this.splice(a,1),this._updateClassName())};g.toggle=function(a){a+="";f(this,a)===-1?this.add(a):this.remove(a)};g.toString=function(){return this.join(" ")};if(d.defineProperty){g={get:l,enumerable:true,configurable:true};try{d.defineProperty(c,"classList",g)}catch(j){if(j.number===-2146823252)g.enumerable=false,d.defineProperty(c,"classList",g)}}else d.prototype.__defineGetter__&&c.__defineGetter__("classList",l)}(self);
(function(){function c(b,a,f){var c,d;if(typeof b.hasAttribute!=="undefined")b.hasAttribute(a)&&(c=b.getAttribute(a)),d=true;else if(typeof b[a]!=="undefined")c=b[a],d=false;else if(a==="class"&&typeof b.className!=="undefined")a="className",c=b.className,d=false;if(typeof c==="undefined"&&(typeof f==="undefined"||f===null))console.log(f),console.log(b),console.log("Element does not have the selected attribute");else{if(typeof f==="undefined")return c;typeof f!=="undefined"&&f!==null?d===true?b.setAttribute(a,
f):b[a]=f:f===null&&(d===true?b.removeAttribute(a):delete b[a]);return typeof f!=="undefined"?f:c}}function d(b){return b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function e(b,a,f){var c,a=d(a);c={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof f==="undefined"&&b.style[a]!=="undefined")return b.style[a];else if(typeof f==="undefined"&&b.style[c[a]]!=="undefined")return b.style[c[a]];typeof b.style[a]!=="undefined"?b.style[a]=f:b.style[c[a]]?
b.style[c[a]]=f:console.log("Property "+a+" nor an equivalent seems to exist")}$_.ext("dom",{addClass:function(b){$_.each(function(a){a.classList.add(b)})},removeClass:function(b){$_.each(function(a){a.classList.remove(b)})},hide:function(){this.css("display","none")},show:function(b){typeof b==="undefined"&&(b="block");this.css("display",b)},attr:function(b,a){var f=this.el;if(f.length>1&&typeof a==="undefined")console.log(f),console.log("Must be a singular element");else if(f.length>1&&typeof a!==
"undefined")$_.each(function(f){return c(f,b,a)});else return c(f,b,a)},text:function(b){var a,f,c;c=this.el;f=typeof c.innerText!=="undefined"?"innerText":typeof c.textContent!=="undefined"?"textContent":"innerHTML";a=c[f];return typeof b!=="undefined"?c[f]=b:a},css:function(b,a){if(typeof a==="undefined")return e(this.el,b);$_.each(function(f){e(f,b,a)})}})})();
(function(){$_.ext("store",{get:function(c){return JSON.parse(localStorage.getItem(c))},set:function(c,d){typeof d!=="string"&&(d=JSON.stringify(d));localStorage.setItem(c,d)},remove:function(c){localStorage.removeItem(c)},getAll:function(){var c,d,e;d=localStorage.length;e={};for(c=0;c<d;c++){var b=localStorage.key(c),a=localStorage.getItem(b);e[b]=a}return e}})})();
(function(){$_.hb=history.pushState?false:true;$_.ext("qs",{parse:function(c){var c=c||$_.hb,d,e,b,a;b={};if(c===true)c=location.hash.split("#!/"),c=c.length>1?c[1]:"";else if(c===false||c===void 0)c=window.location.search.substring(1);else return false;d=c.split("&");e=d.length;for(c=0;c<e;c++){a=d[c].split("=");if(a.length<2)break;b[a[0]]=a[1]}return b},set:function(c,d,e){var e=e||$_.hb,b=this.parse(e);c!==void 0&&d!==void 0&&(b[c]=d);var c=[],a;for(a in b)b.hasOwnProperty(a)&&c.push(a+"="+b[a]);
b=c.join("&");if(e===true)b="!/"+b,location.hash=b;return b},get:function(c,d){var d=d||$_.hb,e=this.parse(d);return e[c]?e[c]:""}})})();
(function(){var c={_do:function(c,e,b,a){typeof b==="undefined"&&(b=function(){});var f=typeof window.XMLHttpRequest!=="undefined"?new XMLHttpRequest:false,a=a?"POST":"GET";c+=a==="GET"?"?"+this._serialize(e):"";f.open(a,c);f.onreadystatechange=function(){f.readyState===4&&b(f.responseText)};a==="POST"?(f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.send(this._serialize(e))):f.send(null)},_serialize:function(c){var e=[],b;for(b in c)if(c.hasOwnProperty(b)&&typeof c[b]!==
"function"){var a=c[b].toString();b=encodeURIComponent(b);a=encodeURIComponent(a);e.push(b+"="+a)}return e.join("&")}};$_.ext("get",function(d,e,b){c._do(d,e,b,false)});$_.ext("post",function(d,e,b){c._do(d,e,b,true)})})();
(function(){$_.ext("util",{reverse_key_sort:function(c){var d=[],e=0,b={},a,d=this.object_keys(c);d.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),e=c+""===b,i=d+""===a;if(e&&i)return c>d?1:c<d?-1:0;else if(e&&!i)return 1;else if(!e&&i)return-1;return b>a?1:b<a?-1:0});e=d.length;for(a=0;a<e;a++)b[d[a]]=c[d[a]];return b},object_keys:function(c){var d=[],e;for(e in c)c.hasOwnProperty(e)&&d.push(e);return d},object_values:function(c){var d=[],e;for(e in c)d.push(c[e]);return d},array_combine:function(c,
d){var e={},b,a=0;$_.type(c)!=="array"&&(c=this.object_values(c));$_.type(d)!=="array"&&(d=this.object_values(d));b=c.length;if(b!==d.length)return console.log("Object combine requires two arrays of the same size"),false;for(a=0;a<b;a++)e[c[a]]=d[a];return e},object_merge:function(){var c=Array.prototype.slice.call(arguments),d=c.length,e={},b,a=0,f,h,g;b=true;for(f=0;f<d;f++)if($_.type(c[f])!=="array"){b=false;break}if(b){e=[];for(f=0;f<d;f++)e=e.contact(c[f]);return e}for(f=0,g=0;f<d;f++)if(b=c[f],
$_.type(b)=="array")for(h=0,a=b.length;h<a;h++)e[g++]=b[h];else for(h in b)b.hasOwnProperty(h)&&(parseInt(h,10)+""===h?e[g++]=b[h]:e[h]=b[h]);return e},str_trans:function(c,d,e){var b=[],a=[],f=false,h=0,g=0,l="",j="",i="",k="",m;if(typeof d==="object"){d=this.reverse_key_sort(d);for(m in d)d.hasOwnProperty(m)&&(b.push(m),a.push(d[m]));d=b;e=a}g=c.length;h=d.length;l=typeof e==="string";j=typeof d==="string";for(b=0;b<g;b++){f=false;if(j){c.charAt(b-1);i=c.charAt(b);c.charAt(b+1);for(a=0;a<h;a++)if(i==
d.charAt(a)){f=true;break}}else for(a=0;a<h;a++)if(c.substr(b,d[a].length)==d[a]){f=true;b=b+d[a].length-1;break}k+=f?l?e.charAt(a):e[a]:c.charAt(b)}return k}})})();
(function(){var c,d,e,b,a;typeof document.addEventListener!=="undefined"?(c=function(a,b,c){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,c,false)},d=function(a,b,c){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,c,false)}):typeof document.attachEvent!=="undefined"&&(c=function(a,b,c){var f;function e(){c.apply(arguments)}typeof a.attachEvent!=="undefined"?(d(b,c),a.attachEvent("on"+b,e),f=a.KIS_0_3_0=a.KIS_0_3_0||{},a=f,a.listeners=a.listeners||{},a.listeners[b]=
a.listeners[b]||[],a.listeners[b].push({callback:c,listener:e})):console.log("Failed to attach event:"+b+" on "+a)},d=function(a,b,c){if(typeof a.detachEvent!=="undefined"){var d=a.KIS_0_3_0;if(d&&d.listeners&&d.listeners[b])for(var e=d.listeners[b],i=e.length,k=0;k<i;k++)if(e[k].callback===c){a.detachEvent("on"+b,e[k].listener);e.splice(k,1);e.length===0&&delete d.listeners[b];break}}});e=function(a,b,g,l){var j,i;if(typeof a==="undefined")return console.log(arguments),console.log(b),false;if(b.match(/^([\w\-]+)$/))l===
true?c(a,b,g):d(a,b,g);else{b=b.split(" ");i=b.length;for(j=0;j<i;j++)e(a,b[j],g,l)}};b=function(a,b,c){e(a,c,function(){a=$_.$(a)},true)};a=function(a,c,d){b(document.documentElement,a,c,d)};$_.ext("event",{add:function(a,b){$_.each(function(c){e(c,a,b,true)})},remove:function(a,b){$_.each(function(c){e(c,a,b,false)})},live:function(b,c){$_.each(function(d){a(d,b,c)})},delegate:function(a,c,d){$_.each(function(e){b(e,a,c,d)})}})})();

View File

@ -294,170 +294,3 @@
$_.ext('util', u);
}());
function strtr (str, from, to) {
// http://kevin.vanzonneveld.net
// + original by: Brett Zamir (http://brett-zamir.me)
// + input by: uestla
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Alan C
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Taras Bogach
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// + input by: jpfle
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// - depends on: krsort
// - depends on: ini_set
// * example 1: $trans = {'hello' : 'hi', 'hi' : 'hello'};
// * example 1: strtr('hi all, I said hello', $trans)
// * returns 1: 'hello all, I said hi'
// * example 2: strtr('äaabaåccasdeöoo', 'äåö','aao');
// * returns 2: 'aaabaaccasdeooo'
// * example 3: strtr('ääääääää', 'ä', 'a');
// * returns 3: 'aaaaaaaa'
// * example 4: strtr('http', 'pthxyz','xyzpth');
// * returns 4: 'zyyx'
// * example 5: strtr('zyyx', 'pthxyz','xyzpth');
// * returns 5: 'http'
// * example 6: strtr('aa', {'a':1,'aa':2});
// * returns 6: '2'
var fr = '',
i = 0,
j = 0,
lenStr = 0,
lenFrom = 0,
tmpStrictForIn = false,
fromTypeStr = '',
toTypeStr = '',
istr = '';
var tmpFrom = [];
var tmpTo = [];
var ret = '';
var match = false;
// Received replace_pairs?
// Convert to normal from->to chars
if (typeof from === 'object') {
//tmpStrictForIn = this.ini_set('phpjs.strictForIn', false); // Not thread-safe; temporarily set to true
from = this.krsort(from);
//this.ini_set('phpjs.strictForIn', tmpStrictForIn);
for (fr in from) {
if (from.hasOwnProperty(fr)) {
tmpFrom.push(fr);
tmpTo.push(from[fr]);
}
}
from = tmpFrom;
to = tmpTo;
}
// Walk through subject and replace chars when needed
lenStr = str.length;
lenFrom = from.length;
fromTypeStr = typeof from === 'string';
toTypeStr = typeof to === 'string';
for (i = 0; i < lenStr; i++) {
match = false;
if (fromTypeStr) {
istr = str.charAt(i);
for (j = 0; j < lenFrom; j++) {
if (istr == from.charAt(j)) {
match = true;
break;
}
}
} else {
for (j = 0; j < lenFrom; j++) {
if (str.substr(i, from[j].length) == from[j]) {
match = true;
// Fast forward
i = (i + from[j].length) - 1;
break;
}
}
}
if (match) {
ret += toTypeStr ? to.charAt(j) : to[j];
} else {
ret += str.charAt(i);
}
}
return ret;
}
function krsort (inputArr) {
// http://kevin.vanzonneveld.net
// + original by: GeekFG (http://geekfg.blogspot.com)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Brett Zamir (http://brett-zamir.me)
// % note 1: The examples are correct, this is a new way
// % note 2: This function deviates from PHP in returning a copy of the array instead
// % note 2: of acting by reference and returning true; this was necessary because
// % note 2: IE does not allow deleting and re-adding of properties without caching
// % note 2: of property position; you can set the ini of "phpjs.strictForIn" to true to
// % note 2: get the PHP behavior, but use this only if you are in an environment
// % note 2: such as Firefox extensions where for-in iteration order is fixed and true
// % note 2: property deletion is supported. Note that we intend to implement the PHP
// % note 2: behavior by default if IE ever does allow it; only gives shallow copy since
// % note 2: is by reference in PHP anyways
// % note 3: Since JS objects' keys are always strings, and (the
// % note 3: default) SORT_REGULAR flag distinguishes by key type,
// % note 3: if the content is a numeric string, we treat the
// % note 3: "original type" as numeric.
// - depends on: i18n_loc_get_default
// * example 1: data = {d: 'lemon', a: 'orange', b: 'banana', c: 'apple'};
// * example 1: data = krsort(data);
// * results 1: {d: 'lemon', c: 'apple', b: 'banana', a: 'orange'}
// * example 2: ini_set('phpjs.strictForIn', true);
// * example 2: data = {2: 'van', 3: 'Zonneveld', 1: 'Kevin'};
// * example 2: krsort(data);
// * results 2: data == {3: 'Kevin', 2: 'van', 1: 'Zonneveld'}
// * returns 2: true
var tmp_arr = {},
keys = [],
sorter, i, k, that = this,
strictForIn = false,
populateArr = {};
//sorter = ;
// Make a list of key names
for (k in inputArr) {
if (inputArr.hasOwnProperty(k)) {
keys.push(k);
}
}
keys.sort(function (b, a) {
var aFloat = parseFloat(a),
bFloat = parseFloat(b),
aNumeric = aFloat + '' === a,
bNumeric = bFloat + '' === b;
if (aNumeric && bNumeric) {
return aFloat > bFloat ? 1 : aFloat < bFloat ? -1 : 0;
} else if (aNumeric && !bNumeric) {
return 1;
} else if (!aNumeric && bNumeric) {
return -1;
}
return a > b ? 1 : a < b ? -1 : 0;
});
// Rebuild array with sorted key names
for (i = 0; i < keys.length; i++) {
k = keys[i];
tmp_arr[k] = inputArr[k];
}
for (i in tmp_arr) {
if (tmp_arr.hasOwnProperty(i)) {
populateArr[i] = tmp_arr[i];
}
}
return populateArr;
}