jQuery(function(){var pop=function(){jQuery("#screen").css({display:"block",opacity:0.7,width:jQuery(document).width(),height:jQuery(document).height()});jQuery("#box").css({display:"block"})};pop();jQuery(window).resize(function(){jQuery("#box").css("display")=="block"?pop.call(jQuery("#button")):""})});var reset=function(obj,name,idObj,ori_name){jQuery(idObj).contents().find("#"+name).each(function(){var temp=this.contentWindow.test;if(typeof temp!="undefined"){jQuery(idObj).contents().find("#selectors-title").append("<th class='framework "+name+"'>"+ori_name+"</th>");jQuery(idObj).contents().find("#score-title").append("<td class='score "+name+"'>0</td>");jQuery(idObj).contents().find(".selector-row").each(function(){jQuery(this).append("<td class='empty "+name+"'></td>")});obj.activate()}else{setTimeout(function(){reset(obj,name,idObj,ori_name)},2000)}})};function isUrl(s){var regexp=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;return regexp.test(s)}function IsNumeric(input){return(input-0)==input&&input.length>0}function utf8_encode(argString){var string=(argString+"");var utftext="";var start,end;var stringl=0;start=end=0;stringl=string.length;for(var n=0;n<stringl;n++){var c1=string.charCodeAt(n);var enc=null;if(c1<128){end++}else{if(c1>127&&c1<2048){enc=String.fromCharCode((c1>>6)|192)+String.fromCharCode((c1&63)|128)}else{enc=String.fromCharCode((c1>>12)|224)+String.fromCharCode(((c1>>6)&63)|128)+String.fromCharCode((c1&63)|128)}}if(enc!==null){if(end>start){utftext+=string.substring(start,end)}utftext+=enc;start=end=n+1}}if(end>start){utftext+=string.substring(start,string.length)}return utftext}function base64_encode(data){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var o1,o2,o3,h1,h2,h3,h4,bits,i=0,ac=0,enc="",tmp_arr=[];if(!data){return data}data=this.utf8_encode(data+"");do{o1=data.charCodeAt(i++);o2=data.charCodeAt(i++);o3=data.charCodeAt(i++);bits=o1<<16|o2<<8|o3;h1=bits>>18&63;h2=bits>>12&63;h3=bits>>6&63;h4=bits&63;tmp_arr[ac++]=b64.charAt(h1)+b64.charAt(h2)+b64.charAt(h3)+b64.charAt(h4)}while(i<data.length);enc=tmp_arr.join("");switch(data.length%3){case 1:enc=enc.slice(0,-2)+"==";break;case 2:enc=enc.slice(0,-1)+"=";break}return enc}var add=function(){var ori_name=jQuery("#name").attr("value");name=ori_name.toLowerCase();name=name.replace(/(\s|\.)/g,"");var path=jQuery("#path").attr("value");var func=jQuery("#function").attr("value");if(ori_name.length<=0||path.length<=0||func.length<=0){alert("All field must be fill");return}if(!isUrl(path)){alert("Not a path");return}if(IsNumeric(func)){alert("Shouldn't be a number right?");return}jQuery("#test").each(function(){var tmpObj=this;var obj=this.contentWindow;if(jQuery(this).contents().find("."+name).length>0){alert("Please select a different name");return}jQuery(this).contents().find("#framebase").append("<iframe name='"+name+"' class='"+name+"' id='"+name+"' src='system/template.php?include="+base64_encode(path)+"&function="+func+"&nocache='></iframe>");timer=setTimeout(function(){reset(obj,name,tmpObj,ori_name)},2000)})};var remove=function(){var name=jQuery("#name").attr("value");if(name.length<=0){alert("Name must be fill");return}name=name.replace(/(\s|\.)/g,"");classname="."+name.toLowerCase();id="#"+name.toLowerCase();jQuery("#test").contents().find(classname).each(function(){jQuery(this).remove()});var obj=jQuery("#test").each(function(){var obj=this.contentWindow;obj.activate()})};window.onload=function(){jQuery("#box").css("display","none");jQuery("#screen").css("display","none");var addObj=document.getElementById("add");var removeObj=document.getElementById("remove");addObj.onclick=add;removeObj.onclick=remove};
