home
-
log
- v0.4.9 :+: blAjax.
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.boss = oBoss; xmlhttp.src = src; xmlhttp.parseData = function(txt) { xmlhttp.boss.innerHTML = txt; xmlhttp.boss.ajax.getData(xmlhttp.boss,xmlhttp.src); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { xmlhttp.parseData(xmlhttp.responseText); } } xmlhttp.open("GET",src,true); xmlhttp.send(); } } } var o = document.getElementById("d11"); o.ajax = new blAjax(); o.ajax.getData(o,"http://api.baidao.com/api/hq/npdata.do?ids=201");
function blObj(oBoss,obj){ if(!oBoss){ alert("boss error!");return; } oBoss.innerHTML = ""; for(i in obj) { var b = document.createElement("button"); b.innerHTML = i; oBoss.appendChild(b); var d = document.createElement("div"); d.innerHTML = obj[i]; d.style.border = "blue 1px solid"; oBoss.appendChild(d); } } var o = document.getElementById("d11"); f.dbgDiv = o; var a = blObj(o,f);
function blKlines(idBossDiv,id,src){ var r = document.getElementById(id); if(!r){ r = document.createElement("canvas"); r.id = id; } r.src = src; r.style.border = "red 1px solid"; var boss = document.getElementById(idBossDiv); if(!boss) {alert("need exist div as boss.");return r; } boss.appendChild(r); r.boss = boss; r.onclick = function(){alert("Klines click");} return r; } var k1 = blKlines("d2","k1","k.js"); k1.boss.onclick = function(){k1.click();alert("k1.boss");}
function blScript(id,src){ var r = document.getElementById(id); if(!r){ r = document.createElement("script"); r.id = id; } r.src = src; document.body.appendChild(r); return r; } var s1 = blScript("s1","m.js");
function blMp4Player(id,src){ var r = document.getElementById(id); if(!r){ r = document.createElement("video"); r.id = id; r.style.border = "1px solid green"; } r.src = src; document.body.appendChild(r); return r; } var mp4p = blMp4Player("mp4p","dvd2_3_1.mp4");
function blIframe(id,src){ var r = document.getElementById(id); if(!r){ r = document.createElement("iframe"); r.id = id; r.style.border = "1px solid red"; } r.src = src; document.body.appendChild(r); return r; } var i1 = blIframe("i1","mi.bat"); var i2 = blIframe("i2","mp4i.bat");
function blCanvas(id,html){ var r = document.getElementById(id); if(!r){ r = document.createElement("canvas"); r.id = id; r.style.border = "1px solid blue"; } r.innerHTML = html; r.onclick = function(){alert(id);} document.body.appendChild(r); return r; } var c1 = blCanvas("c1","c1"); var c2 = blCanvas("c2","c2"); c2.onclick = function(){alert("CCCC2");} c2.onmousemove = function(){ var c = document.getElementById("c2"); var ctx = c.getContext("2d"); ctx.beginPath(); var w = this.width; var h = this.height; ctx.fillStyle = "red"; ctx.fillRect(0,0,w,h); var coord = coordinate(event); var x = coord.coord_X; var y = coord.coord_Y; ctx.moveTo(0,0); ctx.lineTo(x,y); var r = 20; ctx.arc(x,y,r,0,2*Math.PI); ctx.stroke(); ctx.font = "20px Arial"; ctx.fillStyle = "blue"; var s = "("+x+","+y+")"; ctx.fillText(s,x,y); }
function blDiv(id,html){ var r = document.getElementById(id); if(!r){ r = document.createElement("div"); r.id = id; r.style.border = "1px solid #3d3d3d"; } r.innerHTML = html; r.onclick = function(){alert(id);} document.body.appendChild(r); return r; } var d1 = blDiv("d11","d1b"); var d2 = blDiv("d2","d2"); d2.onclick = function(){alert("ddfdd2");}
function blBtn(id,html){ var r = document.getElementById(id); if(!r){ r = document.createElement("button"); r.id = id; } r.innerHTML = html; r.onclick = function(){alert(id);} document.body.appendChild(r); return r; } var b1 = blBtn("b1","b1b"); var b2 = blBtn("b2","x2"); b2.onclick = function(){alert("x2");}