summaryrefslogtreecommitdiffstats
path: root/usr/local
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2008-07-27 04:30:29 +0000
committerScott Ullrich <sullrich@pfsense.org>2008-07-27 04:30:29 +0000
commit626544136e8324e77af198dad26e4ad3e51f0240 (patch)
treed21fc69c7b5b9eaed6c56678080df8865c0523c7 /usr/local
parentaa3f07e6b459c2121147323385115310887a1472 (diff)
downloadpfsense-626544136e8324e77af198dad26e4ad3e51f0240.zip
pfsense-626544136e8324e77af198dad26e4ad3e51f0240.tar.gz
Adding firebug lite
Diffstat (limited to 'usr/local')
-rw-r--r--usr/local/www/javascript/firebug-lite.js1000
-rw-r--r--usr/local/www/javascript/pi.js682
2 files changed, 1682 insertions, 0 deletions
diff --git a/usr/local/www/javascript/firebug-lite.js b/usr/local/www/javascript/firebug-lite.js
new file mode 100644
index 0000000..e1e4cf2
--- /dev/null
+++ b/usr/local/www/javascript/firebug-lite.js
@@ -0,0 +1,1000 @@
+/**
+ * firebug lite <http://www.getfirebug.com/lite.html>
+ * v1.0
+ * 04.11.2008, 8:25 PM ~
+ * v1.0a
+ * 03.27.2008, 5:44 AM ~ 04.01.2008, 21:32 PM
+ * Azer Koçulu <http://azer.kodfabrik.com>
+ */
+
+var firebug = {
+ env:{ "cache":{}, "ctmp":[], "dIndex":"console", "init":false, "ml":false, "objCn":[] },
+ init:function(){
+ firebug.el = {}; // elements
+ firebug.el.content = {};
+ with(firebug){
+
+ document.documentElement.childNodes[0].appendChild(
+ new pi.element("link").attribute.set("rel","stylesheet").attribute.set("href","http://firebuglite.appspot.com/firebug-lite.css").environment.getElement()
+ );
+
+ /*
+ * main interface
+ */
+ el.main = new pi.element("DIV").attribute.set("id","Firebug").environment.addStyle({ "width":pi.util.GetWindowSize().width+"px" }).insert(document.body);
+ el.header = new pi.element("DIV").attribute.addClass("Header").insert(el.main);
+ el.left = {};
+ el.left.container = new pi.element("DIV").attribute.addClass("Left").insert(el.main);
+ el.right = {};
+ el.right.container = new pi.element("DIV").attribute.addClass("Right").insert(el.main);
+ el.main.child.add(new pi.element("DIV").environment.addStyle({ "clear":"both" }));
+
+ /*
+ * buttons
+ */
+ el.button = {};
+ el.button.container = new pi.element("DIV").attribute.addClass("ButtonContainer").insert(el.header);
+ el.button.logo = new pi.element("A").attribute.set("title","Firebug Lite").attribute.set("target","_blank").attribute.set("href","http://getfirebug.com/lite.html").update("&nbsp;").attribute.addClass("Button Logo").insert(el.button.container);
+ el.button.inspect = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.inspector.toggle).update("Inspect").insert(el.button.container);
+ el.button.maximize = new pi.element("A").attribute.addClass("Button Maximize").event.addListener("click",win.maximize).insert(el.button.container);
+ el.button.minimize = new pi.element("A").attribute.addClass("Button Minimize").event.addListener("click",win.minimize).insert(el.button.container);
+ el.button.close = new pi.element("A").attribute.addClass("Button Close").event.addListener("click",win.close).insert(el.button.container);;
+
+ if(pi.env.ie||pi.env.webkit){
+ el.button.container.environment.addStyle({ "paddingTop":"12px" });
+ }
+
+ /*
+ * navigation
+ */
+ el.nav = {};
+ el.nav.container = new pi.element("DIV").attribute.addClass("Nav").insert(el.left.container);
+ el.nav.console = new pi.element("A").attribute.addClass("Tab Selected").event.addListener("click",d.navigate.curry(window,"console")).update("Console").insert(el.nav.container);
+ el.nav.html = new pi.element("A").attribute.addClass("Tab").update("HTML").event.addListener("click",d.navigate.curry(window,"html")).insert(el.nav.container);
+ el.nav.css = new pi.element("A").attribute.addClass("Tab").update("CSS").event.addListener("click",d.navigate.curry(window,"css")).insert(el.nav.container);
+ el.nav.scripts = new pi.element("A").attribute.addClass("Tab").update("Script").event.addListener("click",d.navigate.curry(window,"scripts")).insert(el.nav.container);
+ el.nav.dom = new pi.element("A").attribute.addClass("Tab").update("DOM").event.addListener("click",d.navigate.curry(window,"dom")).insert(el.nav.container);
+ el.nav.xhr = new pi.element("A").attribute.addClass("Tab").update("XHR").event.addListener("click",d.navigate.curry(window,"xhr")).insert(el.nav.container);
+
+ /*
+ * inspector
+ */
+
+ el.borderInspector = new pi.element("DIV").attribute.set("id","FirebugBorderInspector").event.addListener("click",listen.inspector).insert(document.body);
+ el.bgInspector = new pi.element("DIV").attribute.set("id","FirebugBGInspector").insert(document.body);
+
+ /*
+ * console
+ */
+ el.left.console = {};
+ el.left.console.container = new pi.element("DIV").attribute.addClass("Console").insert(el.left.container);
+ el.left.console.mlButton = new pi.element("A").attribute.addClass("MLButton").event.addListener("click",d.console.toggleML).insert(el.left.console.container);
+ el.left.console.monitor = new pi.element("DIV").insert(
+ new pi.element("DIV").attribute.addClass("Monitor").insert(el.left.console.container)
+ );
+ el.left.console.container.child.add(
+ new pi.element("DIV").attribute.addClass("InputArrow").update(">>>")
+ );
+ el.left.console.input = new pi.element("INPUT").attribute.set("type","text").attribute.addClass("Input").event.addListener("keydown",listen.consoleTextbox).insert(
+ new pi.element("DIV").attribute.addClass("InputContainer").insert(el.left.console.container)
+ );
+
+ el.right.console = {};
+ el.right.console.container = new pi.element("DIV").attribute.addClass("Console Container").insert(el.right.container);
+ el.right.console.mlButton = new pi.element("A").attribute.addClass("MLButton CloseML").event.addListener("click",d.console.toggleML).insert(el.right.console.container);
+ el.right.console.input = new pi.element("TEXTAREA").attribute.addClass("Input").insert(el.right.console.container);
+ el.right.console.run = new pi.element("A").attribute.addClass("Button").event.addListener("click",listen.runMultiline).update("Run").insert(el.right.console.container);
+
+ el.right.console.clear = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.clean.curry(window,el.right.console.input)).update("Clear").insert(el.right.console.container);
+
+ el.button.console = {};
+ el.button.console.container = new pi.element("DIV").attribute.addClass("ButtonSet").insert(el.button.container);
+ el.button.console.clear = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.clean.curry(window,el.left.console.monitor)).update("Clear").insert(el.button.console.container);
+
+ /*
+ * html
+ */
+
+ el.left.html = {};
+ el.left.html.container = new pi.element("DIV").attribute.addClass("HTML").insert(el.left.container);
+
+ el.right.html = {};
+ el.right.html.container = new pi.element("DIV").attribute.addClass("HTML Container").insert(el.right.container);
+
+ el.right.html.nav = {};
+ el.right.html.nav.container = new pi.element("DIV").attribute.addClass("Nav").insert(el.right.html.container);
+ el.right.html.nav.computedStyle = new pi.element("A").attribute.addClass("Tab Selected").event.addListener("click",d.html.navigate.curry(firebug,"computedStyle")).update("Computed Style").insert(el.right.html.nav.container);
+ if(!pi.env.ie6)
+ el.right.html.nav.dom = new pi.element("A").attribute.addClass("Tab").event.addListener("click",d.html.navigate.curry(firebug,"dom")).update("DOM").insert(el.right.html.nav.container);
+
+ el.right.html.content = new pi.element("DIV").attribute.addClass("Content").insert(el.right.html.container);
+
+ el.button.html = {};
+ el.button.html.container = new pi.element("DIV").attribute.addClass("ButtonSet HTML").insert(el.button.container);
+
+ /*
+ * css
+ */
+
+ el.left.css = {};
+ el.left.css.container = new pi.element("DIV").attribute.addClass("CSS").insert(el.left.container);
+
+ el.right.css = {};
+ el.right.css.container = new pi.element("DIV").attribute.addClass("CSS Container").insert(el.right.container);
+
+ el.right.css.nav = {};
+ el.right.css.nav.container = new pi.element("DIV").attribute.addClass("Nav").insert(el.right.css.container);
+ el.right.css.nav.runCSS = new pi.element("A").attribute.addClass("Tab Selected").update("Run CSS").insert(el.right.css.nav.container);
+
+ el.right.css.mlButton = new pi.element("A").attribute.addClass("MLButton CloseML").event.addListener("click",d.console.toggleML).insert(el.right.css.container);
+ el.right.css.input = new pi.element("TEXTAREA").attribute.addClass("Input").insert(el.right.css.container);
+ el.right.css.run = new pi.element("A").attribute.addClass("Button").event.addListener("click",listen.runCSS).update("Run").insert(el.right.css.container);
+ el.right.css.clear = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.clean.curry(window,el.right.css.input)).update("Clear").insert(el.right.css.container);
+
+ el.button.css = {};
+ el.button.css.container = new pi.element("DIV").attribute.addClass("ButtonSet CSS").insert(el.button.container);
+ el.button.css.selectbox = new pi.element("SELECT").event.addListener("change",listen.cssSelectbox).insert(el.button.css.container);
+
+ /*
+ * scripts
+ */
+
+ el.left.scripts = {};
+ el.left.scripts.container = new pi.element("DIV").attribute.addClass("Scripts").insert(el.left.container);
+
+ el.right.scripts = {};
+ el.right.scripts.container = new pi.element("DIV").attribute.addClass("Scripts Container").insert(el.right.container);
+
+ el.button.scripts = {};
+ el.button.scripts.container = new pi.element("DIV").attribute.addClass("ButtonSet Scripts").insert(el.button.container);
+ el.button.scripts.selectbox = new pi.element("SELECT").event.addListener("change",listen.scriptsSelectbox).insert(el.button.scripts.container);
+ el.button.scripts.lineNumbers = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.scripts.toggleLineNumbers).update("Show Line Numbers").insert(el.button.scripts.container);
+
+ /*
+ * dom
+ */
+
+ el.left.dom = {};
+ el.left.dom.container = new pi.element("DIV").attribute.addClass("DOM").insert(el.left.container);
+
+ el.right.dom = {};
+ el.right.dom.container = new pi.element("DIV").attribute.addClass("DOM Container").insert(el.right.container);
+
+ el.button.dom = {};
+ el.button.dom.container = new pi.element("DIV").attribute.addClass("ButtonSet DOM").insert(el.button.container);
+ el.button.dom.label = new pi.element("LABEL").update("Object Path:").insert(el.button.dom.container);
+ el.button.dom.textbox = new pi.element("INPUT").event.addListener("keydown",listen.domTextbox).update("window").insert(el.button.dom.container);
+
+ /*
+ * str
+ */
+
+ el.left.str = {};
+ el.left.str.container = new pi.element("DIV").attribute.addClass("STR").insert(el.left.container);
+
+ el.right.str = {};
+ el.right.str.container = new pi.element("DIV").attribute.addClass("STR").insert(el.left.container);
+
+ el.button.str = {};
+ el.button.str.container = new pi.element("DIV").attribute.addClass("ButtonSet XHR").insert(el.button.container);
+ el.button.str.watch = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.navigate.curry(window,"xhr")).update("Back").insert(el.button.str.container);
+
+ /*
+ * xhr
+ */
+
+ el.left.xhr = {};
+ el.left.xhr.container = new pi.element("DIV").attribute.addClass("XHR").insert(el.left.container);
+
+ el.right.xhr = {};
+ el.right.xhr.container = new pi.element("DIV").attribute.addClass("XHR").insert(el.left.container);
+
+
+ el.button.xhr = {};
+ el.button.xhr.container = new pi.element("DIV").attribute.addClass("ButtonSet XHR").insert(el.button.container);
+ el.button.xhr.label = new pi.element("LABEL").update("XHR Path:").insert(el.button.xhr.container);
+ el.button.xhr.textbox = new pi.element("INPUT").event.addListener("keydown",listen.xhrTextbox).insert(el.button.xhr.container);
+ el.button.xhr.watch = new pi.element("A").attribute.addClass("Button").event.addListener("click",listen.addXhrObject).update("Watch").insert(el.button.xhr.container);
+
+ // fix ie6 a:hover bug
+ if(pi.env.ie6)
+ {
+ var buttons = [
+ el.button.inspect,
+ el.button.close,
+ el.button.inspect,
+ el.button.console.clear,
+ el.right.console.run,
+ el.right.console.clear,
+ el.right.css.run,
+ el.right.css.clear
+ ];
+ for(var i=0; i<buttons.length; i++)
+ buttons[i].attribute.set("href","#");
+ }
+ //
+
+ env.init = true;
+
+ for(var i=0; i<env.ctmp.length; i++)
+ {
+ d.console.log.apply(window,env.ctmp[i]);
+ }
+ }
+ },
+ win:{
+ close:function(){
+ with(firebug){
+ el.main.update("");
+ el.main.remove();
+ }
+ },
+ minimize:function(){
+ with(firebug){
+ el.main.environment.addStyle({ "height":"35px" });
+ el.button.maximize.environment.addStyle({ "display":"block" });
+ el.button.minimize.environment.addStyle({ "display":"none" });
+ d.refreshSize();
+ }
+ },
+ maximize:function(){
+ with(firebug){
+ el.main.environment.addStyle({ "height":"295px" });
+ el.button.minimize.environment.addStyle({ "display":"block" });
+ el.button.maximize.environment.addStyle({ "display":"none" });
+ d.refreshSize();
+ }
+ }
+ },
+ watchXHR:function(){
+ with(firebug){
+ d.xhr.addObject.apply(window,arguments);
+ if(env.dIndex!="xhr"){
+ d.navigate("xhr");
+ }
+ }
+ },
+ d: {
+ clean:function(_element){
+ with(firebug){
+ _element.update("");
+ }
+ },
+ console:{
+ dir:function(_value){
+ with(firebug){
+ d.console.addLine().attribute.addClass("Arrow").update(">>> console.dir("+_value+")");
+ d.dom.open(_value,d.console.addLine());
+ }
+ },
+ addLine:function(){
+ with (firebug) {
+ return new pi.element("DIV").attribute.addClass("Row").insert(el.left.console.monitor);
+ }
+ },
+ openObject:function(_index){
+ with (firebug) {
+ d.dom.open(env.objCn[_index], el.left.dom.container, pi.env.ie);
+ d.navigate("dom");
+ }
+ },
+ historyIndex:0,
+ history:[],
+ log:function(_values){
+ with (firebug) {
+ if(env.init==false){
+ env.ctmp.push(arguments);
+ return;
+ }
+
+ var value = "";
+ for(var i=0; i<arguments.length; i++){
+ value += (i>0?" ":"")+d.highlight(arguments[i],false,false,true);
+ }
+
+ d.console.addLine().update(value);
+ d.console.scroll();
+
+ }
+ },
+ print: function(_cmd,_text){
+ with (firebug){
+ d.console.addLine().attribute.addClass("Arrow").update(">>> "+_cmd);
+ d.console.addLine().update(d.highlight(_text,false,false,true));
+ d.console.scroll();
+ d.console.historyIndex = d.console.history.push(_cmd);
+ }
+ },
+ run:function(cmd){
+ with(firebug){
+ if(cmd.length==0)return;
+ el.left.console.input.environment.getElement().value = "";
+ try {
+ var result = eval.call(window,cmd);
+ d.console.print(cmd,result);
+ } catch(e){
+ d.console.addLine().attribute.addClass("Arrow").update(">>> "+cmd);
+ if(!pi.env.ff){
+ d.console.scroll();
+ return d.console.addLine().attribute.addClass("Error").update("<strong>Error: </strong>"+(e.description||e),true);
+ }
+ if(e.fileName==null){
+ d.console.addLine().attribute.addClass("Error").update("<strong>Error: </strong>"+e.message,true);
+ }
+ var fileName = e.fileName.split("\/").getLastItem();
+ d.console.addLine().attribute.addClass("Error").update("<strong>Error: </strong>"+e.message+" (<em>"+fileName+"</em>,"+e.lineNumber+")",true);
+ d.console.scroll();
+ }
+ d.console.scroll();
+ }
+ },
+ scroll:function(){
+ with(firebug){
+ el.left.console.monitor.environment.getElement().parentNode.scrollTop = Math.abs(el.left.console.monitor.environment.getSize().offsetHeight-200);
+ }
+ },
+ toggleML:function(){
+ with(firebug){
+ var open = !env.ml;
+ env.ml = !env.ml;
+ d.navigateRightColumn("console",open);
+ el[open?"left":"right"].console.mlButton.environment.addStyle({ display:"none" });
+ el[!open?"left":"right"].console.mlButton.environment.addStyle({ display:"block" });
+ el.left.console.monitor.environment.addStyle({ "height":(open?233:210)+"px" });
+ el.left.console.mlButton.attribute[(open?"add":"remove")+"Class"]("CloseML");
+ }
+ }
+ },
+ css:{
+ index:-1,
+ open:function(_index){
+ with (firebug) {
+ var item = document.styleSheets[_index];
+ var uri = item.href;
+ if(uri.indexOf("http:\/\/")>-1&&getDomain(uri)!=document.domain){
+ el.left.css.container.update("<em>Access to restricted URI denied</em>");
+ return;
+ }
+ var rules = item[pi.env.ie ? "rules" : "cssRules"];
+ var str = "";
+ for (var i=0; i<rules.length; i++) {
+ var item = rules[i];
+ var selector = item.selectorText;
+ var cssText = pi.env.ie?item.style.cssText:item.cssText.match(/\{(.*)\}/)[1];
+ str+=d.css.printRule(selector, cssText.split(";"), el.left.css.container);
+ }
+ el.left.css.container.update(str);
+ }
+ },
+ printRule:function(_selector,_css,_layer){
+ with(firebug){
+ var str = "<div class='Selector'>"+_selector+" {</div>";
+ for(var i=0; i<_css.length; i++){
+ var item = _css[i];
+ str += "<div class='CSSText'>"+item.replace(/(.+\:)(.+)/,"<span class='CSSProperty'>$1</span><span class='CSSValue'>$2;</span>")+"</div>";
+ }
+ str+="<div class='Selector'>}</div>";
+ return str;
+ }
+ },
+ refresh:function(){
+ with(firebug){
+ el.button.css.selectbox.update("");
+ var collection = document.styleSheets;
+ for(var i=0; i<collection.length; i++){
+ var uri = collection[i].href;
+ d.css.index=d.css.index<0?i:d.css.index;
+ el.button.css.selectbox.child.add(
+ new pi.element("OPTION").attribute.set("value",i).update(uri)
+ )
+ };
+ d.css.open(d.css.index);
+ }
+ }
+ },
+ dom: {
+ open: function(_object,_layer){
+ with (firebug) {
+ _layer.clean();
+ var container = new pi.element("DIV").attribute.addClass("DOMContent").insert(_layer);
+ d.dom.print(_object, container);
+ }
+ },
+ print:function(_object,_parent, _inTree){
+ with (firebug) {
+ var obj = _object || window, parentElement = _parent;
+ parentElement.update("");
+
+ if(parentElement.opened&&parentElement!=el.left.dom.container){
+ parentElement.environment.getParent().pi.child.get()[0].pi.child.get()[0].pi.attribute.removeClass("Opened");
+ parentElement.opened = false;
+ parentElement.environment.addStyle({ "display":"none" });
+ return;
+ }
+ if(_inTree)
+ parentElement.environment.getParent().pi.child.get()[0].pi.child.get()[0].pi.attribute.addClass("Opened");
+ parentElement.opened = true;
+
+ for (var key in obj) {
+ try {
+
+ var value = obj[key], property = key, container = new pi.element("DIV").attribute.addClass("DOMRow").insert(parentElement),
+ left = new pi.element("DIV").attribute.addClass("DOMRowLeft").insert(container), right = new pi.element("DIV").attribute.addClass("DOMRowRight").insert(container);
+
+ container.child.add(
+ new pi.element("DIV").environment.addStyle({ "clear":"both" })
+ );
+
+ var link = new pi.element("A").attribute.addClass(
+ typeof value=="object"&&Boolean(value)?"Property Object":"Property"
+ ).update(property).insert(left);
+
+ right.update(
+ d.highlight(value,false,true)
+ );
+
+ var subContainer = new pi.element("DIV").attribute.addClass("DOMRowSubContainer").insert(container);
+
+ if(typeof value!="object"||Boolean(value)==false)
+ continue;
+
+ link.event.addListener("click",d.dom.print.curry(window,value, subContainer, true));
+ }catch(e){
+ }
+ }
+ parentElement.environment.addStyle({ "display":"block" });
+ }
+ }
+ },
+ highlight:function(_value,_inObject,_inArray,_link){
+ with(firebug){
+ var isArray = false, isElement = false;
+ try {
+ isArray = pi.util.IsArray(_value);
+ isElement = _value!=undefined&&Boolean(_value.nodeName)&&Boolean(_value.nodeType);
+ }catch(e){};
+
+ // number, string, boolean, null, function
+ if(_value==null||["boolean","function","number","string"].indexOf(typeof _value)>-1){
+ // NULL
+ if(_value==null){
+ return "<span class='Null'>null</span>";
+ }
+
+ // BOOLEAN & NUMBER
+ if (["boolean", "number"].indexOf(typeof _value) > -1) {
+ return "<span class='DarkBlue'>" + _value + "</span>";
+ }
+
+ // FUNCTION
+ if(typeof _value=="function"){
+ return "<span class='"+(_inObject?"Italic Gray":"Green")+"'>function()</span>";
+ }
+
+ // STRING
+ return "<span class='Red'>\""+( !_inObject&&!_inArray?_value : _value.substring(0,35) ).replace(/\n/g,"\\n").replace(/\s/g,"&nbsp;").replace(/>/g,"&#62;").replace(/</g,"&#60;")+"\"</span>";
+ }
+ // element
+ else if(isElement){
+ if(_value.nodeType==3)return d.highlight(_value.nodeValue);
+
+ if(_inArray||_inObject){
+ var result = "<span class='Blue'>"+_value.nodeName.toLowerCase();
+ if(_value.getAttribute&&_value.getAttribute("id"))result += "<span class='DarkBlue'>#"+_value.getAttribute("id")+"</span>";
+ var elClass = _value.getAttribute?_value.getAttribute(pi.env.ie?"className":"class"):"";
+ if(elClass)result += "<span class='Red'>."+elClass.split(" ")[0]+"</span>";
+ return result+"</span>";
+ }
+
+ var result = "<span class='Blue'>&#60;"+_value.nodeName.toLowerCase()+"";
+ if(_value.attributes)
+ for(var i=0; i<_value.attributes.length; i++){
+ var item = _value.attributes[i];
+ if(pi.env.ie&&Boolean(item.nodeValue)==false)continue;
+ result += " <span class='DarkBlue'>"+item.nodeName+"=\"<span class='Red'>"+item.nodeValue+"</span>\"</span>";
+ }
+ result += "&#62;</span>";
+ return result;
+ }
+ // array & object
+ else if(isArray||["object","array"].indexOf(typeof _value)>-1){
+ var result = "";
+ if(isArray||_value instanceof Array){
+ if(_inObject)return "<span class='Gray Italic'>["+_value.length+"]</span>";
+ result += "<span class='Strong'>[ ";
+
+ for(var i=0; i<_value.length; i++){
+ if((_inObject||_inArray)&&pi.env.ie&&i>3)break;
+ result += (i > 0 ? ", " : "") + d.highlight(_value[i], false, true, true);
+ }
+ result += " ]</span>";
+ return result;
+ }
+ if(_inObject)return "<span class='Gray Italic'>Object</span>";
+ result += "<span class='Strong Green"+ ( !_link?"'":" ObjectLink' onmouseover='this.className=this.className.replace(\"ObjectLink\",\"ObjectLinkHover\")' onmouseout='this.className=this.className.replace(\"ObjectLinkHover\",\"ObjectLink\")' onclick='firebug.d.console.openObject(" +( env.objCn.push( _value ) -1 )+")'" ) + ">Object";
+ var i=0;
+ for(var key in _value){
+ var value = _value[key];
+ if((_inObject||_inArray)&&pi.env.ie&&i>3)
+ break;
+ result += " "+key+"="+d.highlight(value,true);
+ i++;
+ };
+ result += "</span>";
+ return result;
+ } else {
+ if(_inObject)
+ return "<span class='Gray Italic'>"+_value+"</span>";
+ return _value;
+ }
+
+ }
+ },
+ html:{
+ nIndex:"computedStyle",
+ current:null,
+ highlight:function(_element,_clear,_event){
+ with(firebug){
+ if(_clear){
+ el.bgInspector.environment.addStyle({ "display":"none" });
+ return;
+ }
+ d.inspector.inspect(_element,true);
+ }
+ },
+ inspect:function(_element){
+ var el = _element, map = [], parent = _element;
+ while(parent){
+ map.push(parent);
+ if(parent==document.body)break;
+ parent = parent.parentNode;
+ }
+ map = map.reverse();
+ with(firebug){
+ d.inspector.toggle();
+ var parentLayer = el.left.html.container.child.get()[1].childNodes[1].pi;
+ for(var t=0; map[t];){
+ if(t==map.length-1){
+
+ var link = parentLayer.environment.getElement().previousSibling.pi;
+ link.attribute.addClass("Selected");
+
+ if(d.html.current)d.html.current[1].attribute.removeClass("Selected");
+
+ d.html.current = [_element,link];
+
+ return;t
+ }
+ parentLayer = d.html.openHtmlTree(map[t],parentLayer,map[t+1]);
+ t++;
+ }
+ }
+ },
+ navigate:function(_index,_element){
+ with(firebug){
+ el.right.html.nav[d.html.nIndex].attribute.removeClass("Selected");
+ el.right.html.nav[_index].attribute.addClass("Selected");
+ d.html.nIndex = _index;
+ d.html.openProperties();
+
+ }
+ },
+ openHtmlTree:function(_element,_parent,_returnParentElementByElement,_event){
+ with(firebug){
+ var element = _element || document.documentElement,
+ parent = _parent || el.left.html.container,
+ returnParentEl = _returnParentElementByElement || null,
+ returnParentVal = null;
+
+ if(parent!=el.left.html.container){
+ var nodeLink = parent.environment.getParent().pi.child.get()[0].pi;
+ if(d.html.current)d.html.current[1].attribute.removeClass("Selected");
+ nodeLink.attribute.addClass("Selected");
+
+ d.html.current = [_element,nodeLink];
+ d.html.openProperties();
+ }
+
+ if(element.childNodes&&(element.childNodes.length==0||(element.childNodes.length==1&&element.childNodes[0].nodeType==3)))return;
+ parent.clean();
+
+ if(parent.opened&&Boolean(_returnParentElementByElement)==false){
+ parent.opened = false;
+ parent.environment.getParent().pi.child.get()[0].pi.attribute.removeClass("Open");
+ return;
+ }
+ if (parent != el.left.html.container) {
+ parent.environment.getParent().pi.child.get()[0].pi.attribute.addClass("Open");
+ parent.opened = true;
+
+ }
+
+ for(var i=0; i<element.childNodes.length; i++){
+ var item = element.childNodes[i];
+
+ if(item.nodeType==3)continue;
+ var container = new pi.element().attribute.addClass("Block").insert(parent);
+ var link = new pi.element("A").attribute.addClass("Link").update(d.highlight(item)).insert(container);
+ var subContainer = new pi.element("DIV").attribute.addClass("SubContainer").insert(container);
+ link.event.addListener("click",d.html.openHtmlTree.curry(window,item,subContainer,false));
+ link.event.addListener("mouseover",d.html.highlight.curry(window,item, false));
+ link.event.addListener("mouseout",d.html.highlight.curry(window,item,true));
+
+ returnParentVal = returnParentEl==item?subContainer:returnParentVal;
+
+ if(d.html.current==null&&item==document.body){
+ link.attribute.addClass("Selected");
+ d.html.current = [item,link];
+ d.html.openHtmlTree(item,subContainer);
+ }
+
+ if(item.childNodes&&item.childNodes.length==1&&item.childNodes[0].nodeType==3){
+ link.child.get()[0].appendChild(document.createTextNode(item.childNodes[0].nodeValue.substring(0,100)));
+ link.child.get()[0].appendChild(document.createTextNode("</"));
+ link.child.get()[0].appendChild(new pi.element("span").attribute.addClass("Blue").update(item.nodeName.toLowerCase()).environment.getElement());
+ link.child.get()[0].appendChild(document.createTextNode(">"));
+ continue;
+ }
+ else if(item.childNodes&&item.childNodes.length==0)continue;
+ link.attribute.addClass("ParentLink");
+
+ }
+ return returnParentVal;
+ }
+ },
+ openProperties:function(){
+ with(firebug){
+
+ var index = d.html.nIndex;
+ var node = d.html.current[0];
+ d.clean(el.right.html.content);
+ var str = "";
+ switch(index){
+ case "computedStyle":
+ var property = ["opacity","filter","azimuth","background","backgroundAttachment","backgroundColor","backgroundImage","backgroundPosition","backgroundRepeat","border","borderCollapse","borderColor","borderSpacing","borderStyle","borderTop","borderRight","borderBottom","borderLeft","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderWidth","bottom","captionSide","clear","clip","color","content","counterIncrement","counterReset","cue","cueAfter","cueBefore","cursor","direction","display","elevation","emptyCells","cssFloat","font","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","height","left","letterSpacing","lineHeight","listStyle","listStyleImage","listStylePosition","listStyleType","margin","marginTop","marginRight","marginBottom","marginLeft","markerOffset","marks","maxHeight","maxWidth","minHeight","minWidth","orphans","outline","outlineColor","outlineStyle","outlineWidth","overflow","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","page","pageBreakAfter","pageBreakBefore","pageBreakInside","pause","pauseAfter","pauseBefore","pitch","pitchRange","playDuring","position","quotes","richness","right","size","speak","speakHeader","speakNumeral","speakPunctuation","speechRate","stress","tableLayout","textAlign","textDecoration","textIndent","textShadow","textTransform","top","unicodeBidi","verticalAlign","visibility","voiceFamily","volume","whiteSpace","widows","width","wordSpacing","zIndex"].sort();
+ var view = document.defaultView?document.defaultView.getComputedStyle(node,null):node.currentStyle;
+ for(var i=0; i<property.length; i++){
+ var item = property[i];
+ if(!view[item])continue;
+ str+="<div class='CSSItem'><div class='CSSProperty'>"+item+"</div><div class='CSSValue'>"+d.highlight(view[item])+"</div></div>";
+ }
+ el.right.html.content.update(str);
+ break;
+ case "dom":
+ d.dom.open(node,el.right.html.content,pi.env.ie);
+ break;
+ }
+ }
+ }
+ },
+ inspector:{
+ enabled:false,
+ el:null,
+ inspect:function(_element,_bgInspector){
+ var el = _element, top = el.offsetTop, left = el.offsetLeft, parent = _element.offsetParent;
+ while(Boolean(parent)&&parent!=document.firstChild){
+ top += parent.offsetTop;
+ left += parent.offsetLeft;
+ parent = parent.offsetParent;
+ if(parent==document.body)break;
+ };
+
+ with(firebug){
+ el[_bgInspector?"bgInspector":"borderInspector"].environment.addStyle({
+ "width":_element.offsetWidth+"px", "height":_element.offsetHeight+"px",
+ "top":top-(_bgInspector?0:2)+"px", "left":left-(_bgInspector?0:2)+"px",
+ "display":"block"
+ });
+
+ if(!_bgInspector){
+ d.inspector.el = _element;
+ }
+ };
+ },
+ toggle:function(){
+ with (firebug) {
+ d.inspector.enabled = !d.inspector.enabled;
+ el.button.inspect.attribute[(d.inspector.enabled ? "add" : "remove") + "Class"]("Enabled");
+ if(d.inspector.enabled==false){
+ el.borderInspector.environment.addStyle({ "display":"none" });
+ d.inspector.el = null;
+ } else if(pi.env.dIndex!="html") {
+ d.navigate("html");
+ }
+ }
+ }
+ },
+ scripts:{
+ index:-1,
+ lineNumbers:false,
+ open:function(_index){
+ with(firebug){
+ d.scripts.index = _index;
+ el.left.scripts.container.update("");
+ var script = document.getElementsByTagName("script")[_index],uri = script.src||document.location.href,source;
+
+ if(uri.indexOf("http:\/\/")>-1&&getDomain(uri)!=document.domain){
+ el.left.scripts.container.update("<em>Access to restricted URI denied</em>");
+ return;
+ }
+
+ if(uri!=document.location.href){
+ source = env.cache[uri]||pi.xhr.get(uri).responseText;
+ env.cache[uri] = source;
+ } else
+ source = script.innerHTML;
+ source = source.replace(/\n|\t|<|>/g,function(_ch){
+ return ({"<":"&#60;",">":"&#62;","\t":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;","\n":"<br />"})[_ch];
+ });
+
+ if (!d.scripts.lineNumbers)
+ el.left.scripts.container.child.add(
+ new pi.element("DIV").attribute.addClass("CodeContainer").update(source)
+ );
+ else {
+ source = source.split("<br />");
+ for (var i = 0; i < source.length; i++) {
+ el.left.scripts.container.child.add(new pi.element("DIV").child.add(new pi.element("DIV").attribute.addClass("LineNumber").update(i + 1), new pi.element("DIV").attribute.addClass("Code").update("&nbsp;" + source[i]), new pi.element("DIV").environment.addStyle({
+ "clear": "both"
+ })));
+ };
+ };
+ }
+ },
+ toggleLineNumbers:function(){
+ with(firebug){
+ d.scripts.lineNumbers = !d.scripts.lineNumbers;
+ el.button.scripts.lineNumbers.attribute[(d.scripts.lineNumbers ? "add" : "remove") + "Class"]("Enabled");
+ d.scripts.open( d.scripts.index );
+
+ }
+ },
+ refresh:function(){
+ with(firebug){
+ el.button.scripts.selectbox.clean();
+ var collection = document.getElementsByTagName("script");
+ for(var i=0; i<collection.length; i++){
+ var item = collection[i];
+ d.scripts.index=d.scripts.index<0?i:d.scripts.index;
+ el.button.scripts.selectbox.child.add(
+ new pi.element("OPTION").attribute.set("value",i).update(item.src||item.baseURI||"..")
+ );
+ }
+ d.scripts.open( d.scripts.index );
+ }
+ }
+ },
+ str: {
+ open:function(_str){
+ with(firebug){
+ d.navigate("str");
+ el.left.str.container.update(_str.replace(/\n/g,"<br />"))
+ }
+ }
+ },
+ xhr:{
+ objects:[],
+ addObject:function(){
+ with(firebug){
+ for(var i=0; i<arguments.length; i++){
+ try {
+ var item = arguments[i];
+ var val = eval(item);
+ d.xhr.objects.push([
+ item, val
+ ]);
+ } catch(e){
+ continue;
+ }
+ }
+ }
+ },
+ open:function(){
+ with(firebug){
+ el.left.xhr.container.update("");
+ el.left.xhr.name = new pi.element("DIV").attribute.addClass("BlockContent").insert(new pi.element("DIV").attribute.addClass("Block").environment.addStyle({ "width":"20%" }).insert(el.left.xhr.container));
+ el.left.xhr.nameTitle = new pi.element("STRONG").update("Object Name:").insert(el.left.xhr.name);
+ el.left.xhr.nameContent = new pi.element("DIV").insert(el.left.xhr.name);
+ el.left.xhr.status = new pi.element("DIV").attribute.addClass("BlockContent").insert(new pi.element("DIV").attribute.addClass("Block").environment.addStyle({ "width":"10%" }).insert(el.left.xhr.container));
+ el.left.xhr.statusTitle = new pi.element("STRONG").update("Status:").insert(el.left.xhr.status);
+ el.left.xhr.statusContent = new pi.element("DIV").insert(el.left.xhr.status);
+ el.left.xhr.readystate = new pi.element("DIV").attribute.addClass("BlockContent").insert(new pi.element("DIV").environment.addStyle({ "width":"15%" }).attribute.addClass("Block").insert(el.left.xhr.container));
+ el.left.xhr.readystateTitle =el.left.xhr.nameTitle = new pi.element("STRONG").update("Ready State:").insert(el.left.xhr.readystate);
+ el.left.xhr.readystateContent = new pi.element("DIV").insert(el.left.xhr.readystate);
+ el.left.xhr.response = new pi.element("DIV").attribute.addClass("BlockContent").insert(new pi.element("DIV").environment.addStyle({ "width":(pi.env.ie?"50":"55")+"%" }).attribute.addClass("Block").insert(el.left.xhr.container));
+ el.left.xhr.responseTitle = new pi.element("STRONG").update("Response:").insert(el.left.xhr.response);
+ el.left.xhr.responseContent = new pi.element("DIV").insert(el.left.xhr.response);
+ setTimeout(d.xhr.refresh,500);
+ }
+ },
+ refresh:function(){
+ with(firebug){
+ el.left.xhr.nameContent.update("");
+ el.left.xhr.statusContent.update("");
+ el.left.xhr.readystateContent.update("");
+ el.left.xhr.responseContent.update("");
+ for(var i=0; i<d.xhr.objects.length; i++){
+ var item = d.xhr.objects[i];
+ var response = item[1].responseText;
+ if(Boolean(item[1])==false)continue;
+ el.left.xhr.nameContent.child.add(new pi.element("span").update(item[0]));
+ try { 
+ el.left.xhr.statusContent.child.add(new pi.element("span").update(item[1].status));
+ } catch(e){ el.left.xhr.statusContent.child.add(new pi.element("span").update("&nbsp;")); }
+ el.left.xhr.readystateContent.child.add(new pi.element("span").update(item[1].readyState));
+
+ el.left.xhr.responseContent.child.add(new pi.element("span").child.add(
+ new pi.element("A").event.addListener("click",d.str.open.curry(window,response)).update("&nbsp;"+response.substring(0,50))
+ ));
+ };
+ if(env.dIndex=="xhr")
+ setTimeout(d.xhr.refresh,500);
+ }
+ }
+ },
+ navigateRightColumn:function(_index,_open){
+ with(firebug){
+ el.left.container.environment.addStyle({ "width":_open?"70%":"100%" });
+ el.right.container.environment.addStyle({ "display":_open?"block":"none" });
+ }
+ },
+ navigate:function(_index){
+ with(firebug){
+
+ var open = _index, close = env.dIndex;
+ env.dIndex = open;
+
+ el.button[close].container.environment.addStyle({ "display":"none" });
+ el.left[close].container.environment.addStyle({ "display":"none" });
+ el.right[close].container.environment.addStyle({ "display":"none" });
+
+ el.button[open].container.environment.addStyle({ "display":"inline" });
+ el.left[open].container.environment.addStyle({ "display":"block" });
+ el.right[open].container.environment.addStyle({ "display":"block" });
+
+ if(el.nav[close])
+ el.nav[close].attribute.removeClass("Selected");
+ if(el.nav[open])
+ el.nav[open].attribute.addClass("Selected");
+
+ switch(open){
+ case "console":
+ d.navigateRightColumn(_index);
+ break;
+ case "html":
+ d.navigateRightColumn(_index,true);
+ d.html.openHtmlTree();
+ break;
+ case "css":
+ d.navigateRightColumn(_index,true);
+ d.css.refresh();
+ break;
+ case "scripts":
+ d.navigateRightColumn(_index);
+ d.scripts.refresh();
+ break;
+ case "dom":
+ d.navigateRightColumn(_index);
+ if(el.left.dom.container.environment.getElement().innerHTML=="")
+ d.dom.open(eval(el.button.dom.textbox.environment.getElement().value),el.left.dom.container);
+ break;
+ case "xhr":
+ d.navigateRightColumn(_index);
+ d.xhr.open();
+ break;
+ }
+
+ }
+ },
+ refreshSize:function(){
+ with(firebug){
+ el.main.environment.addStyle({ "width":pi.util.GetWindowSize().width+"px"});
+ if(pi.env.ie6)
+ el.main.environment.addStyle({ "top":pi.util.GetWindowSize().height-el.main.environment.getSize().offsetHeight+"px" });
+ }
+ }
+ },
+ getDomain:function(_url){
+ return _url.match(/http:\/\/(www.)?([\.\w]+)/)[2];
+ },
+ listen: {
+ addXhrObject:function(){
+ with(firebug){
+ d.xhr.addObject.apply(window, el.button.xhr.textbox.environment.getElement().value.split(","));
+ }
+ },
+ consoleTextbox:function(_event){
+ with(firebug){
+ if(_event.keyCode==13&&(env.multilinemode==false||_event.shiftKey==false)){
+ d.console.historyIndex = d.console.history.length;
+ d.console.run(el.left.console.input.environment.getElement().value);
+ return false;
+ }
+ if([13,38,40].indexOf(_event.keyCode)==-1)
+ return;
+ d.console.historyIndex+=_event.keyCode!=40?0:d.console.historyIndex==d.console.history.length?0:1;
+ d.console.historyIndex-=_event.keyCode!=38?0:d.console.historyIndex==0?0:1;
+ el.left.console.input.update(
+ d.console.history.length > d.console.historyIndex ?
+ d.console.history[d.console.historyIndex] :
+ ""
+ );
+ }
+ },
+ cssSelectbox:function(){
+ with(firebug){
+ d.css.open(el.button.css.selectbox.environment.getElement().selectedIndex);
+ }
+ },
+ domTextbox:function(_event){
+ with(firebug){
+ if(_event.keyCode==13){
+ d.dom.open(eval(el.button.dom.textbox.environment.getElement().value),el.left.dom.container);
+ }
+ }
+ },
+ inspector:function(){
+ with(firebug){
+ d.html.inspect(d.inspector.el);
+ }
+ },
+ keyboard:function(_event){
+ with(firebug){
+ if(_event.keyCode==27&&d.inspector.enabled)
+ d.inspector.toggle();
+ }
+ },
+ mouse:function(_event){
+ with(firebug){
+ var target = _event[pi.env.ie?"srcElement":"target"];
+ if(
+ d.inspector.enabled&&
+ target!=document.body&&
+ target!=document.firstChild&&
+ target!=document.childNodes[1]&&
+ target!=el.borderInspector.environment.getElement()&&
+ target!=el.main.environment.getElement()&&
+ target.offsetParent!=el.main.environment.getElement()
+ )
+ d.inspector.inspect(target);
+ }
+ },
+ runMultiline:function(){
+ with(firebug){
+ d.console.run.call(window,el.right.console.input.environment.getElement().value);
+ }
+ },
+ runCSS:function(){
+ with(firebug){
+ var source = el.right.css.input.environment.getElement().value.replace(/\n|\t/g,"").split("}");
+ for(var i=0; i<source.length; i++){
+ var item = source[i]+"}", rule = !pi.env.ie?item:item.split(/{|}/), collection = document.getElementsByTagName("style"),
+ style = collection.length>0?collection[0]:document.body.appendChild( document.createElement("style") );
+ if(!item.match(/.+\{.+\}/))continue;
+ if(pi.env.ie)
+ style.styleSheet.addRule(rule[0],rule[1]);
+ else
+ style.sheet.insertRule( rule, style.sheet.cssRules.length );
+ }
+ }
+ },
+ scriptsSelectbox:function(){
+ with(firebug){
+ d.scripts.open(parseInt(el.button.scripts.selectbox.environment.getElement().value));
+ }
+ },
+ xhrTextbox:function(_event){
+ with(firebug){
+ if(_event.keyCode==13){
+ d.xhr.addObject.apply(window, el.button.xhr.textbox.environment.getElement().value.split(","));
+ }
+ }
+ }
+ }
+};
+
+window.console = firebug.d.console;
+pi.util.AddEvent(window,"resize",firebug.d.refreshSize);
+pi.util.AddEvent(document,"mousemove",firebug.listen.mouse);
+pi.util.AddEvent(document,"keydown",firebug.listen.keyboard);
+pi.util.DOMContentLoaded.push(firebug.init); \ No newline at end of file
diff --git a/usr/local/www/javascript/pi.js b/usr/local/www/javascript/pi.js
new file mode 100644
index 0000000..0c37c4c
--- /dev/null
+++ b/usr/local/www/javascript/pi.js
@@ -0,0 +1,682 @@
+(function(_scope){
+
+ /*
+ * pi.js
+ * 1.0
+ * Azer Koçulu <http://azer.kodfabrik.com>
+ * http://pi-js.googlecode.com
+ */
+
+ _scope.pi = Object(3.14159265358979323846);
+ var pi = _scope.pi;
+ pi.version = 1.0;
+
+ pi.env = {
+ ie: /MSIE/i.test(navigator.userAgent),
+ ie6: /MSIE 6/i.test(navigator.userAgent),
+ ie7: /MSIE 7/i.test(navigator.userAgent),
+ ie8: /MSIE 8/i.test(navigator.userAgent),
+ firefox: /Firefox/i.test(navigator.userAgent),
+ opera: /Opera/i.test(navigator.userAgent),
+ webkit: /Webkit/i.test(navigator.userAgent)
+ };
+
+ pi.util = {
+ IsArray:function(_object){
+ return _object && _object != window && ( _object instanceof Array || ( typeof _object.length == "number" && typeof _object.item =="function" ) )
+ },
+ IsHash:function(_object){
+ return _object && typeof _object=="object"&&(_object==window||_object instanceof Object)&&!_object.nodeName&&!pi.util.IsArray(_object)
+ },
+ DOMContentLoaded:[],
+ AddEvent: function(_element,_eventName,_fn,_useCapture){
+ _element[pi.env.ie.toggle("attachEvent","addEventListener")](pi.env.ie.toggle("on","")+_eventName,_fn,_useCapture||false);
+ return pi.util.AddEvent.curry(this,_element);
+ },
+ RemoveEvent: function(_element,_eventName,_fn,_useCapture){
+ return _element[pi.env.ie.toggle("detachEvent","removeEventListener")](pi.env.ie.toggle("on","")+_eventName,_fn,_useCapture||false);
+ },
+ GetWindowSize:function(){
+ return {
+ height:pi.env.ie?Math.max(document.documentElement.clientHeight,document.body.clientHeight):window.innerHeight,
+ width:pi.env.ie?Math.max(document.documentElement.clientWidth,document.body.clientWidth):window.innerWidth
+ }
+ },
+ Include:function(_url,_callback){
+ var script = new pi.element("script").attribute.set("src",_url), callback = _callback||new Function, done = false, head = pi.get.byTag("head")[0];
+ script.environment.getElement().onload = script.environment.getElement().onreadystatechange = function(){
+ if(!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")){
+ callback.call(this);
+ done = true;
+ head.removeChild(script.environment.getElement());
+ }
+ };
+ script.insert(head);
+ },
+ Element:{
+ addClass:function(_element,_class){
+ if( !pi.util.Element.hasClass(_element,_class) )
+ pi.util.Element.setClass(_element, pi.util.Element.getClass(_element) + " " + _class );
+ },
+ getClass:function(_element){
+ return _element.getAttribute(pi.env.ie.toggle("className","class"))||"";
+ },
+ hasClass:function(_element,_class){
+ return pi.util.Element.getClass(_element).split(" ").indexOf(_class)>-1;
+ },
+ removeClass:function(_element,_class){
+ if( pi.util.Element.hasClass(_element,_class) )
+ pi.util.Element.setClass(
+ _element,
+ pi.util.Element.getClass(_element,_class).split(" ").removeValue(_class).join(" ")
+ );
+ },
+ setClass:function(_element,_value){
+ _element.setAttribute( pi.env.ie.toggle("className","class"), _value );
+ },
+ toggleClass:function(){
+ if(pi.util.Element.hasClass.apply(this,arguments))
+ pi.util.Element.removeClass.apply(this,arguments);
+ else
+ pi.util.Element.addClass.apply(this,arguments);
+ },
+ getOpacity:function(_styleObject){
+ var styleObject = _styleObject;
+ if(!pi.env.ie)
+ return styleObject["opacity"];
+
+ var alpha = styleObject["filter"].match(/opacity\=(\d+)/i);
+ return alpha?alpha[1]/100:1;
+ },
+ setOpacity:function(_element,_value){
+ if(!pi.env.ie)
+ return pi.util.Element.addStyle(_element,{ "opacity":_value });
+ _value*=100;
+ pi.util.Element.addStyle(_element,{ "filter":"alpha(opacity="+_value+")" });
+ return this._parent_;
+ },
+ getPosition:function(_element){
+ var parent = _element,offsetLeft = 0, offsetTop = 0, view = pi.util.Element.getView(_element);
+ while(parent&&parent!=document.body&&parent!=document.firstChild){
+ offsetLeft +=parseInt(parent.offsetLeft);
+ offsetTop += parseInt(parent.offsetTop);
+ parent = parent.offsetParent;
+ };
+ return {
+ "bottom":view["bottom"],
+ "left":view["left"],
+ "marginTop":view["marginTop"],
+ "marginLeft":view["marginLeft"],
+ "offsetLeft":offsetLeft,
+ "offsetTop":offsetTop,
+ "position":view["position"],
+ "right":view["right"],
+ "top":view["top"],
+ "z-index":view["zIndex"]
+ };
+ },
+ getSize:function(_element){
+ var view = pi.util.Element.getView(_element);
+ return {
+ "height":view["height"],
+ "offsetHeight":_element.offsetHeight,
+ "offsetWidth":_element.offsetWidth,
+ "width":view["width"]
+ }
+ },
+ addStyle:function(_element,_style){
+ for(var key in _style){
+ key = key=="float"?pi.env.ie.toggle("styleFloat","cssFloat"):key;
+ if (key == "opacity" && pi.env.ie) {
+ pi.util.Element.setOpacity(_element,_style[key]);
+ continue;
+ }
+ _element.style[key] = _style[key];
+ }
+ },
+ getStyle:function(_element,_property){
+ _property = _property=="float"?pi.env.ie.toggle("styleFloat","cssFloat"):_property;
+ if(_property=="opacity"&&pi.env.ie)
+ return pi.util.Element.getOpacity(_element.style);
+ return typeof _property=="string"?_element.style[_property]:_element.style;
+ },
+ getView:function(_element,_property){
+ var view = document.defaultView?document.defaultView.getComputedStyle(_element,null):_element.currentStyle;
+ _property = _property=="float"?pi.env.ie.toggle("styleFloat","cssFloat"):_property;
+ if(_property=="opacity"&&pi.env.ie)
+ return pi.util.Element.getOpacity(_element,view);
+ return typeof _property=="string"?view[_property]:view;
+ }
+ },
+ CloneObject:function(_object,_fn){
+ var tmp = {};
+ for(var key in _object)
+ {
+ if( pi.util.IsArray( _object[key] ) ){
+ tmp[key] = Array.prototype.clone.apply( _object[key] );
+ } else
+ if( pi.util.IsHash( _object[key] ) ){
+ tmp[ key ] = pi.util.CloneObject(_object[key]);
+ if(_fn)_fn.call(tmp,key,_object);
+ } else
+ tmp[key] = _object[key];
+ }
+ return tmp;
+ },
+ MergeObjects:function(_object,_source){
+ for(var key in _source){
+ var value = _source[key];
+ if (pi.util.IsArray(_source[key])) {
+ if(pi.util.IsArray( _object[key] )){
+ Array.prototype.push.apply( _source[key], _object[key] )
+ }
+ else
+ value = _source[key].clone();
+ }
+ else
+ if (pi.util.IsHash(_source[key])) {
+ if (pi.util.IsHash(_object[key])) {
+ value = pi.util.MergeObjects(_object[key], _source[key]);
+ } else {
+ value = pi.util.CloneObject( _source[key] );
+ }
+ }
+ _object[key] = value;
+ };
+ return _object;
+ }
+ };
+
+ pi.get = function(){
+ return document.getElementById(arguments[0]);
+ };
+ pi.get.byTag = function(){
+ return document.getElementsByTagName(arguments[0]);
+ };
+ pi.get.byClass = function(){ return document.getElementsByClassName.apply(document,arguments); };
+
+ pi.base = function(){
+ this.body = {};
+ this.constructor = null;
+
+ this.build = function(_skipClonning){
+ var base = this, skipClonning = _skipClonning||false, _private = {},
+ fn = function(){
+ var _p = pi.util.CloneObject(_private);
+ if(!skipClonning){
+ for(var key in this){
+
+ if(pi.util.IsArray( this[ key ] ) ){
+ this[key] = Array.prototype.clone.apply( this[key] );
+ } else
+ if( pi.util.IsHash(this[key]) ){
+ this[key] = pi.util.CloneObject(
+ this[ key ],
+ function(_key,_object){
+ this[ _key ]._parent_ = this;
+ }
+ );
+ this[key]._parent_ = this;
+ }
+ }
+ };
+ base.createAccessors( _p, this );
+ if(base.constructor)
+ return base.constructor.apply(this,arguments);
+ return this;
+ };
+ this.movePrivateMembers(this.body,_private);
+ if(this.constructor){
+ fn["$Constructor"] = this.constructor;
+ }
+ fn.prototype = this.body;
+ return fn;
+ };
+
+ this.createAccessors = function(_p, _branch){
+ var getter = function(_property){ return this[_property]; },
+ setter = function(_property,_value){ this[_property] = _value; return _branch._parent_||_branch; };
+
+ for (var name in _p) {
+ var isPrivate = name.substring(0, 1) == "_", title = name.substring(1, 2).toUpperCase() + name.substring(2);
+ if (isPrivate) {
+ _branch["get" + title] = getter.curry(_p,name);
+ _branch["set" + title] = setter.curry(_p,name);
+ }
+ else
+ if (pi.util.IsHash(_p[name])){
+ if(!_branch[name])
+ _branch[name] = {};
+ this.createAccessors(_p[name], _branch[name]);
+ }
+ };
+ };
+
+ this.movePrivateMembers = function(_object, _branch){
+ for (var name in _object) {
+ var isPrivate = name.substring(0, 1) == "_";
+
+ if (isPrivate) {
+ _branch[name] = _object[name];
+ delete _object[name];
+ }
+ else
+ if (pi.util.IsHash(_object[name])){
+ _branch[name] = {};
+ this.movePrivateMembers(_object[name], _branch[name]);
+ }
+ };
+ };
+ };
+
+ Function.prototype.extend = function(_prototype,_skipClonning){
+ var object = new pi.base, superClass = this;
+ if(_prototype["$Constructor"]){
+ object.constructor = _prototype["$Constructor"];
+ delete _prototype["$Constructor"];
+ };
+
+ object.body = superClass==pi.base?_prototype:pi.util.MergeObjects(_prototype,superClass.prototype,2);
+ object.constructor=object.constructor||function(){
+ if(superClass!=pi.base)
+ superClass.apply(this,arguments);
+ };
+
+ return object.build(_skipClonning);
+ };
+
+ Function.prototype.curry = function(_scope){
+ var fn = this, scope = _scope||window, args = Array.prototype.slice.call(arguments,1);
+ return function(){
+ return fn.apply(scope,args.concat( Array.prototype.slice.call(arguments,0) ));
+ };
+ };
+
+ pi.element = pi.base.extend({
+ "$Constructor":function(_tag){
+ this.environment.setElement(document.createElement(_tag||"DIV"));
+ this.environment.getElement().pi = this;
+ return this;
+ },
+ "clean":function(){
+ var childs = this.child.get();
+ while(childs.length){
+ childs[0].parentNode.removeChild(childs[0]);
+ }
+ },
+ "clone":function(_deep){
+ return this.environment.getElement().cloneNode(_deep);
+ },
+ "insert":function(_element){
+ _element = _element.environment?_element.environment.getElement():_element;
+ _element.appendChild(this.environment.getElement());
+ return this;
+ },
+ "insertAfter":function(_referenceElement){
+ _referenceElement = _referenceElement.environment?_referenceElement.environment.getElement():_referenceElement;
+ _referenceElement.nextSibling?this.insertBefore(_referenceElement.nextSibling):this.insert(_referenceElement.parentNode);
+ return this;
+ },
+ "insertBefore":function(_referenceElement){
+ _referenceElement = _referenceElement.environment?_referenceElement.environment.getElement():_referenceElement;
+ _referenceElement.parentNode.insertBefore(this.environment.getElement(),_referenceElement);
+ return this;
+ },
+ "query":function(_expression,_resultType,namespaceResolver,_result){
+ return pi.xpath(_expression,_resultType||"ORDERED_NODE_SNAPSHOT_TYPE",this.environment.getElement(),_namespaceResolver,_result);
+ },
+ "remove":function(){
+ this.environment.getParent().removeChild(
+ this.environment.getElement()
+ );
+ },
+ "update":function(_value){
+ ["TEXTAREA","INPUT"].indexOf(this.environment.getName())>-1?
+ (this.environment.getElement().value = _value):
+ (this.environment.getElement().innerHTML = _value);
+ return this;
+ },
+ "attribute":{
+ "getAll":function(_name){
+ return this._parent_.environment.getElement().attributes;
+ },
+ "clear":function(_name){
+ this.set(_name,"");
+ return this._parent_;
+ },
+ "get":function(_name){
+ return this._parent_.environment.getElement().getAttribute(_name);
+ },
+ "has":function(_name){
+ return pi.env.ie?(this.get(_name)!=null):this._parent_.environment.getElement().hasAttribute(_name);
+ },
+ "remove":function(_name){
+ this._parent_.environment.getElement().removeAttribute(_name);
+ return this._parent_;
+ },
+ "set":function(_name,_value){
+ this._parent_.environment.getElement().setAttribute(_name,_value);
+ return this._parent_;
+ },
+ "addClass":function(_classes){
+ for (var i = 0; i < arguments.length; i++) {
+ pi.util.Element.addClass(this._parent_.environment.getElement(),arguments[i]);
+ };
+ return this._parent_;
+ },
+ "clearClass":function(){
+ this.setClass("");
+ this._parent_;
+ },
+ "getClass":function(){
+ return pi.util.Element.getClass( this._parent_.environment.getElement() );
+ },
+ "hasClass":function(_class){
+ return pi.util.Element.hasClass( this._parent_.environment.getElement(), _class );
+ },
+ "setClass":function(_value){
+ return pi.util.Element.setClass( this._parent_.environment.getElement(), _value );
+ },
+ "removeClass":function(_class){
+ pi.util.Element.removeClass( this._parent_.environment.getElement(), _class );
+ return this._parent_;
+ },
+ "toggleClass":function(_class){
+ pi.util.Element.toggleClass( this._parent_.environment.getElement(), _class );
+ }
+ },
+ "child":{
+ "get":function(){
+ return this._parent_.environment.getElement().childNodes;
+ },
+ "add":function(_elements){
+ for (var i = 0; i < arguments.length; i++) {
+ var el = arguments[i];
+ this._parent_.environment.getElement().appendChild(
+ el.environment ? el.environment.getElement() : el
+ );
+ }
+ return this._parent_;
+ },
+ "addAfter":function(_element,_referenceElement){
+ this.addBefore(
+ _element.environment?_element.environment.getElement():_element,
+ (_referenceElement.environment?_referenceElement.environment.getElement():_referenceElement).nextSibling
+ );
+ return this._parent_;
+ },
+ "addBefore":function(_element,_referenceElement){
+ this._parent_.environment.getElement().insertBefore(
+ _element.environment?_element.environment.getElement():_element,
+ _referenceElement.environment?_referenceElement.environment.getElement():_referenceElement
+ );
+ return this._parent_;
+ },
+ "query":function(_tag,_attributeName,_attributeValue){
+ return this._parent_.query(
+ "{0}{1}".format( (_tag?"{0}".format(_tag):"/*"), _attributeName||_attributeValue?"[contains(concat(' ', @{0}, ' '),' {1} ')]".format(_attributeName||"",_attributeValue||""):"" )
+ );
+ },
+ "remove":function(_element){
+ this._parent_.environment.getElement().removeChild(_element.environment?_element.environment.getElement():_element);
+ }
+ },
+ "environment":{
+ "_element":null,
+ "getParent":function(){
+ return this.getElement().parentNode;
+ },
+ "getPosition":function(){
+ return pi.util.Element.getPosition(this.getElement());
+ },
+ "getSize":function(){
+ return pi.util.Element.getSize( this.getElement() );
+ },
+ "addStyle":function(_styleObject){
+ pi.util.Element.addStyle(this.getElement(),_styleObject);
+ return this._parent_;
+ },
+ "getStyle":function(_property){
+ return pi.util.Element.getStyle(_property);
+ },
+ "getName":function(){
+ return this.getElement().nodeName;
+ },
+ "getType":function(){
+ return this.getElement().nodeType;
+ },
+ "getView":function(_property){
+ return pi.util.Element.getView(this.getElement(),_property);
+ }
+ },
+ "event":{
+ "addListener":function(_event,_fn,_useCapture){
+ pi.util.AddEvent(this._parent_.environment.getElement(),_event,_fn,_useCapture);
+ return this._parent_;
+ },
+ "removeListener":function(_event,_fn,_useCapture){
+ pi.util.RemoveEvent(this._parent_.environment.getElement(),_event,_fn,_useCapture);
+ return this._parent_;
+ }
+ }
+ });
+
+ pi.xhr = new pi.base;
+ pi.xhr.constructor = function(){
+ var api;
+ if(!window.XMLHttpRequest){
+ var names = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];
+ for (var i = 0; i < names.length; i++) {
+ try {
+ this.environment.setApi(new ActiveXObject(names[i]));
+ break;
+ } catch (e) { continue; }
+ }
+ }
+ else
+ this.environment.setApi(new XMLHttpRequest());
+ this.environment.getApi().onreadystatechange=this.event.readystatechange.curry(this);
+ return this;
+ };
+ pi.xhr.body = {
+ "abort":function(){
+ this.environment.getApi().abort();
+ },
+ "send":function(){
+ var url = this.environment.getUrl(), data = this.environment.getData(),dataUrl = "";
+
+ for (var key in data)
+ dataUrl += "{0}={1}&".format(key, data[key]);
+
+ if (this.environment.getType()=="GET")
+ url += (url.search("\\?")==-1?"?":"&")+"{0}".format(dataUrl);
+
+ this.environment.getApi().open(this.environment.getType(),url,this.environment.getAsync());
+
+ for(var key in this.environment.getHeader())
+ this.environment.getApi().setRequestHeader(key,this.environment.getHeader()[key]);
+
+ this.environment.getApi().send(this.environment.getType()=="GET"?"":dataUrl);
+ }
+ };
+ pi.xhr.body.environment = {
+ "_async":true, "_api":null, "_cache":true, "_callback":[], "_channel":null, "_data":{}, "_header":{}, "_mimeType":null, "_multipart":false, "_type":"GET", "_timeout":0, "_url":"",
+ "addCallback": function(_options,_fn){
+ this.getCallback().push({ "fn":_fn, "options":_options });
+ },
+ "addHeader": function(_key,_value){
+ this.getHeader()[_key] = _value;
+ },
+ "addData": function(_key,_value){
+ this.getData()[_key] = _value;
+ },
+ "changeCache":function(_value){
+ if(_value==false){
+ this.addData("forceCache",Math.round(Math.random()*10000));
+ }
+ this.setCache(_value);
+ },
+ "changeType": function(_value){
+ if(_value=="POST"){
+ this.addHeader("Content-Type","application/x-www-form-urlencoded");
+ }
+ this.setType(_value);
+ }
+ };
+ pi.xhr.body.event = {
+ "readystatechange":function(){
+ var readyState = this.environment.getApi().readyState;
+ var callback=this.environment.getCallback();
+
+ for (var i = 0; i < callback.length; i++) {
+ if(callback[i].options.readyState.indexOf(readyState)>-1)
+ callback[i].fn.apply(this);
+ }
+ }
+ };
+ pi.xhr = pi.xhr.build();
+
+ /*
+ * xml.xhr.get
+ */
+
+ pi.xhr.get = function(_url,_returnPiObject){
+ var request = new pi.xhr();
+ request.environment.setAsync(false);
+ request.environment.setUrl(_url);
+ request.send();
+ return _returnPiObject?request:request.environment.getApi();
+ };
+
+ /*
+ * pi.xpath
+ */
+
+ pi.xpath = function(_expression,_resultType,_contextNode,_namespaceResolver,_result){
+ var contextNode = _contextNode||document,
+ expression = _expression||"",
+ namespaceResolver = _namespaceResolver||null,
+ result=_result||null,
+ resultType=_resultType||"ANY_TYPE";
+ return document.evaluate(expression, contextNode, namespaceResolver, XPathResult[resultType], result);
+ };
+
+ Array.prototype.clone = function(){
+ var tmp = [];
+ Array.prototype.push.apply(tmp,this);
+ tmp.forEach(function(item,index,object){
+ if(item instanceof Array)
+ object[index] = object[index].clone();
+ });
+ return tmp;
+ };
+ Array.prototype.count = function(_value){
+ var count = 0;
+ this.forEach(function(){
+ count+=Number(arguments[0]==_value);
+ });
+ return count;
+ };
+
+ Array.prototype.forEach = Array.prototype.forEach||function(_function){
+ for(var i=0; i<this.length; i++)
+ _function.apply(this,[this[i],i,this]);
+ };
+
+ Array.prototype.getLastItem = function(){
+ return this[this.length-1];
+ };
+
+ Array.prototype.indexOf = Array.prototype.indexOf||function(_value){
+ var index = -1;
+ for(var i=0; i<this.length; i++)
+ if(this[i]==_value){
+ index = i;
+ break;
+ }
+ return index;
+ };
+
+ Array.prototype.remove = function(_index){
+ var array = this.slice(0,_index);
+ Array.prototype.push.apply(array,this.slice(_index+1));
+ return array;
+ };
+
+ Array.prototype.removeValue = function(_value){
+ return this.remove(this.indexOf(_value));
+ };
+
+ Boolean.prototype.toggle = function(){
+ return this==true?arguments[0]:arguments[1];
+ };
+
+ Number.prototype.base = function(_system){
+ var remain = this%_system;
+ if(this==remain)return String.fromCharCode(this+(this>9?87:48));
+ return ((this-remain)/_system).base(_system)+String.fromCharCode(remain+(remain>9?87:48));
+ };
+ Number.prototype.decimal = function(_system){
+ var result = 0, digit = String(this).split("");
+ for(var i=0; i<digit.length; i++)
+ {
+ digit[i]=parseInt((digit[i].charCodeAt(0)>58)?digit[i].charCodeAt(0)-87:digit[i]);
+ result += digit[i]*(Math.pow(_system,digit.length-1-i));
+ }
+ return result;
+ };
+ Number.prototype.range = function(_pattern){
+ for(
+ var value = String(this), isFloat = /\./i.test(value),
+ i = isFloat.toggle(parseInt(value.split(".")[0]),0),
+ end = parseInt(value.split(".")[isFloat.toggle(1,0)]),
+ array = []; i<end; i++
+ ){
+ array.push(
+ Boolean(_pattern)==false?i:(typeof _pattern=="function"?_pattern(i):_pattern[i])
+ );
+ }
+ return array;
+ };
+
+ String.prototype.escape = function(){
+ return escape(this);
+ };
+
+ String.prototype.format = function(){
+ var values = arguments;
+ return this.replace(/\{(\d)\}/g,function(){
+ return values[arguments[1]];
+ })
+ };
+
+ String.prototype.leftpad = function(_len,_ch){
+ var str=this;
+ var ch = Boolean(_ch)==false?" ":_ch;
+ while(str.length<_len)
+ str=ch+str;
+ return str;
+ };
+
+ String.prototype.toggle = function(_value,_other){
+ return this==_value?_value:_other;
+ };
+
+ String.prototype.unicode = function(){
+ var str="", obj = this.split("");
+ for(var i=obj.length-1; i>=0; i--)
+ str="\\u{0}{1}".format(String(obj[i].charCodeAt(0).base(16)).leftpad(4,"0"),str);
+ return str;
+ };
+
+ pi.util.AddEvent(
+ pi.env.ie?window:document,
+ pi.env.ie?"load":"DOMContentLoaded",
+ function(){
+ for(var i=0; i<pi.util.DOMContentLoaded.length; i++){
+ pi.util.DOMContentLoaded[ i ]();
+ }
+ }
+ );
+
+})(window); \ No newline at end of file
OpenPOWER on IntegriCloud