[..]
blRunJS_v0.2.8
issue
PlugIn
1.blShowObj
2.blAjax
3.blMovableDiv
Ref
+me(github)
+me(bl)
blog
www.beautifullover.org
w3schools.com TryIt
this.blShowObj = showObj; this.blShowObj(this.blShowObj); function showObj(obj){ this.blShowObj.blV = "v0.5.4"; var oBoss = document.getElementById("divBlShowObj"); if(!oBoss) { oBoss = document.createElement("div"); oBoss.id = "divBlShowObj"; oBoss.style.border = "green 1px solid"; document.body.appendChild(oBoss); } if(!oBoss){ alert("boss error!");return; } oBoss.innerHTML = ""; for(i in obj) { var b = document.createElement("button"); b.id = b.innerHTML = i; if(i[0]=="b"&&i[1]=="l") b.style.backgroundColor = "yellow"; oBoss.appendChild(b); var d = document.createElement("div"); d.innerHTML = obj[i]; d.style.border = "blue 1px solid"; d.style.backgroundColor = "green"; d.style.color = "yellow"; oBoss.appendChild(d); } }
function blAjax(){ this.getData = function (oBoss,src) { if(!oBoss){alert("boss error!");return;} if(oBoss){ var xmlhttp; if (window.XMLHttpRequest) {//"code for IE7+, Firefox, Chrome, Opera, Safari" xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { oBoss._2do(xmlhttp.responseText); } } xmlhttp.open("GET",src,true); xmlhttp.send(); } } } var o = document.createElement("div"); document.body.appendChild(o); if(o) { o._2do = function(txt) { var d = document.getElementById("idParseData"); if(!d){ d = document.createElement("div"); d.id = "idParseData"; o.appendChild(d); d.style.border = "green 1px solid"; } d.innerHTML = txt; o.ajax.getData(o,"http://api.baidao.com/api/hq/npdata.do?ids=201"); } o.ajax = new blAjax(); o.ajax.getData(o,"http://api.baidao.com/api/hq/npdata.do?ids=201"); } else { alert("No div"); }
//blPlx3: by Littleflute http://www.beautifullover.org function blMoveDiv(btnThis) { this.blDiv = function (oBoss,id,html){ var r = document.getElementById(id); if(!r){ r = document.createElement("div"); r.id = id; r.style.border = "1px solid #3d3d3d"; // r.style.position = "fixed"; r.style.top =0; r.style.backgroundColor="rgb(0,100,120)"; r.innerHTML = html; if(oBoss!=null) oBoss.appendChild(r); } return r; }//END: this.blDiv this.blBtn = function(oBoss,id,html,clr){ var r = document.getElementById(id); if(!r){ r = document.createElement("button"); r.id = id; r.innerHTML = html; r.style.backgroundColor=clr?clr:"green"; if(oBoss!=null)oBoss.appendChild(r); } return r; }//END: this.blBtn this.blMakeDivMovable = function (elmnt) { var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; if (document.getElementById(elmnt.id + "Header")) { /* if present, the header is where you move the DIV from:*/ document.getElementById(elmnt.id + "Header").onmousedown = dragMouseDown; } else { /* otherwise, move the DIV from anywhere inside the DIV:*/ elmnt.onmousedown = dragMouseDown; } function dragMouseDown(e) { e = e || window.event; // get the mouse cursor position at startup: pos3 = e.clientX; pos4 = e.clientY; document.onmouseup = closeDragElement; // call a function whenever the cursor moves: document.onmousemove = elementDrag; } function elementDrag(e) { e = e || window.event; // calculate the new cursor position: pos1 = pos3 - e.clientX; pos2 = pos4 - e.clientY; pos3 = e.clientX; pos4 = e.clientY; // set the element's new position: elmnt.style.top = (elmnt.offsetTop - pos2) + "px"; elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"; } function closeDragElement() { /* stop moving when mouse button is released:*/ document.onmouseup = null; document.onmousemove = null; } }//END this.blMakeDivMovable }//END: blMoveDiv var o = new blMoveDiv; var main = o.blDiv ( document.body,"moveDivTest","::blPlx3::_v0.0.2"); var style ="position: absolute;"; style += "z-index: 9;"; style += "background-color: #f1f1f1;"; style += "text-align: left;"; style += "border: 1px solid #d3d3d3;"; style += "left: 400px"; style += "top: 140px"; main.style =style; var title = o.blDiv(main,"moveDivTestHeader","header"); style ="padding: 10px;"; style += "z-index: 10;"; style += "cursor: move;"; style += "text-align: center;"; style += "border: 1px solid #fff;"; style += "background-color: #2196F3;"; title.style =style; o.blMakeDivMovable(main); var blPlx3Body = o.blDiv(main,"blPlx3Body","blPlx3Body"); blPlx3Body.style= "width:500px;"; var ClickMsg = o.blDiv(blPlx3Body,"ClickMsg","ClickMsg"); var bottomBar = o.blDiv(blPlx3Body,"goMsg","goMsg"); var b101 = o.blBtn(bottomBar,"b101","b101","green"); var b102 = o.blBtn(bottomBar,"b102","b102","green"); b101.onclick = function(){ main.style.top = "-200px"; main.style.left = "200px"; } b102.onclick = function(){ main.style.top = "200px"; main.style.left = "200px"; }
alert("test");
run