📄 tmp.js
字号:
/** * @author stan *///interface paras//http://blog.sina.com.cn/control/blog/customize_theme.php?css=f10,k0,e10,d10,c10,b10,m10&theme=4//base function getWinSize(_target) { var windowWidth, windowHeight; if(_target) target = _target.document; else target = document; if (self.innerHeight) { // all except Explorer if(_target) target = _target.self; else target = self; windowWidth = target.innerWidth; windowHeight = target.innerHeight; } else if (target.documentElement && target.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = target.documentElement.clientWidth; windowHeight = target.documentElement.clientHeight; } else if (target.body) { // other Explorers windowWidth = target.body.clientWidth; windowHeight = target.body.clientHeight; } return {width:parseInt(windowWidth),height:parseInt(windowHeight)};}function $(x) {return typeof(x) == 'string' ? document.getElementById(x) : x};function $C(tagName) { return document.createElement(tagName)};function $addEvent2(elm, func, evType, useCapture) { var elm = $(elm); if(typeof useCapture == 'undefined') useCapture = false; if(typeof evType == 'undefined') evType = 'click';try{ if (elm.addEventListener) { elm.addEventListener(evType, func, useCapture); return true; } else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, func); return true; } else { elm['on' + evType] = func; }}catch(e){};};Sina = {};Sina.util = {};Sina.util.Drag = { init : function (_root,_handle) { var o = this; var blk = $(_root); blk.hdl = $(_handle); if(blk.hdl == null || _handle == 'undefined') blk.hdl = o.blk; blk.hdl.onmousedown = start; function start (e) { var o = Sina.util.Drag; v = blk; v.oX = o.getX(e); v.oY = o.getY(e); v.depth = v.style.zIndex; v.style.zIndex = 10000; v.rL = parseInt(v.style.left ? v.style.left : 0); v.rT = parseInt(v.style.top ? v.style.top : 0); document.onmousemove = drag; document.onmouseup = end; return false; }; function drag (e) { var o = Sina.util.Drag; var v = blk; var nX = o.getX(e); var nY = o.getY(e); var ll = v.rL + nX - v.oX; var tt = v.rT + nY - v.oY; v.style.left = ll + 'px'; v.style.top = tt + 'px'; return false; }; function end () { v.style.zIndex = v.depth ; document.onmousemove = null; document.onmouseup = null; }; }, fixE : function (e) { if (typeof e == 'undefined') e = window.event; if (typeof e.layerX == 'undefined') e.layerX = e.offsetX; if (typeof e.layerY == 'undefined') e.layerY = e.offsetY; return e; }, getX : function (e){ return this.fixE(e).clientX; }, getY : function (e){ return this.fixE(e).clientY; } }trace = function(){};//progressvar TPLINIT = true;function saveTpl(code){ if(!TPLINIT) return; TPLINIT = false; var theme = code.split('_')[0]; var sid = code.split('_')[1]; //rm //setRightMark(theme,sid) trace("sid : "+sid); var paraStr = conf.data[theme].conf[sid]; var paraArr = paraStr.split(','); for(var i=0;i<paraArr.length;i++){ paraArr[i] = paraArr[i].replace(/([a-z])(\d+)/ig,function($0,$1,$2){ return $1 + (parseInt($2) - 1); }); } paraStr = paraArr.join(','); $('saveForm').action = 'http://blog.sina.com.cn/control/blog/customize_theme.php?index'; $('saveForm').theme.value = theme; $('saveForm').css.value = paraStr; $('saveForm').submit(); //var url = 'http://blog.sina.com.cn/control/blog/customize_theme.php?css=' + paraStr + '&theme=' + theme+'&index'; //trace(theme+" : "+paraStr); //$('tplIframe').src = url;}function initDom(){ var css = $C('div'); css.innerHTML = tplCssStyle; document.body.appendChild(css); /* if(document.all){ window.style = tplCssStyle; document.createStyleSheet("javascript:style"); }else{ var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = tplCssStyle; document.getElementsByTagName('head')[0].appendChild(style); } */ var tpl_cont = $C('div'); tpl_cont.innerHTML = struc; tpl_cont.id='tpl_cont'; tpl_cont.style.display = "none"; document.body.appendChild(tpl_cont); //var iframeData = $C('iframe'); //iframeData.style.display = "none"; //iframeData.name = "tplIframe"; //document.body.appendChild(iframeData);}function initData(){ var Data = newConf.data;// trace(Data.length); for(var i=0;i<Data.length;i++){ var groupDiv = $C('div'); groupDiv.className = 'group'; groupDiv.innerHTML ='\ <div class="unactive" id="tpl_tab'+ i +'"><span>'+ Data[i].name +'</span></div>\ <div class="tpl_list_div" id="tpl_box'+i+'"></div>\ '; $('tpl_tabs').appendChild(groupDiv); setEvent(i); } $addEvent2('change_btn',function(){ show_tpl(); return false; },'click') $addEvent2('close_btn',function (){ $('tpl_cont').style.display = 'none'; var lr = document.location.href; if(/\?tmpl/.test(lr)){ document.location.href = lr.substr(0,lr.indexOf('?')); } },'click'); $addEvent2('diy_btn',function(){ window.open("/control/theme/step1.html","","width=538,height=525,left=" + (window.screen.width-538)/2 + ",top=" + (window.screen.height-525)/2); },'click'); var shining = setInterval(function(){ $('tpl_msgs').style.color = ($('tpl_msgs').style.color == '#428eff') ? '#005aff' : '#428eff'; },500);}function show_tpl(){ $('tpl_cont').style.display = ''; try{ $('tpl_cont').style.left = (getWinSize().width - 378)/2+'px'; $('tpl_cont').style.top = '210px'; }catch(e){}; if(typeof initOpenFlag == 'undefined'){ initOpen(initCodes); Sina.util.Drag.init('tpl_cont','tpl_titl'); } window.setTimeout(function(){ setRightMark(getInitTheme(THEME),parseInt(sBanner)); },500);}function initOpen(initCodes){ trace('initCode : '+initCodes); for(var i in initCodes) inju(initCodes[i]); initOpenFlag = true;}function setEvent(id){ $('tpl_box'+id).style.display = 'none'; $addEvent2('tpl_tab'+id,function(){ var tab = $('tpl_tab'+id); if(tab.className == 'active') setO(id,false); else setO(id,true); /* //limited if(checkO(id)){ setO(id,false) }else{ for(var i=0;i<conf.data.length;i++){ setO(i,false); } setO(id,true); } */ listPics(id); },'click');}function setO(id,iso){ $('tpl_tab'+id).className = iso == true ? 'active' : 'unactive'; $('tpl_box'+id).style.display = iso == true ? '' : 'none'; shadow();}function checkO(id) { return $('tpl_box'+id).style.display == '';}function inju(id){ setO(id,true); listPics(id);}function shadow(){ var shadowHeight = 259; for(var i=0;i<newConf.data.length;i++){ if($('tpl_tab'+i).className == 'active'){ var Data = newConf.data[i].conf; var row = Math.ceil(Data.length/5); shadowHeight += row*60; shadowHeight += 5; } } $('tpl_shad').style.height = shadowHeight;}function listPics(theme){ var Data = newConf.data[theme].conf; trace(Data.length); var tab = $('tpl_tab'+theme); var box = $('tpl_box'+theme); if(tab.alt == 'init') return true;; tab.alt = 'init'; var table = $C('table'); table.border = 0; table.cellspacing = 0; table.cellpadding = 0; var tbody = $C('tbody'); var row = Math.ceil(Data.length/5); for(var i=0;i<row;i++){ var tr = $C('tr'); for(var j=0;j<5;j++){ var td = $C('td'); var id = i*5+j; if(id>=Data.length) break; var a = $C('a'); var cfg = Data[id]; a.alt = cfg.oTheme+'_'+cfg.oid; a.href = 'javascript:;'; a.innerHTML = '<span><div style="width:60px;height:50px;border:2px solid #FFFFFF;border-bottom:none;background:url(http://image2.sina.com.cn/blog/tmpl/v3/images/templateChange/tpl/'+cfg.oTheme+'/'+(cfg.oid+1)+'.gif) no-repeat;"></div></span>'; a.onclick = function(){ saveTpl(this.alt); this.blur(); }; td.appendChild(a); tr.appendChild(td); } tbody.appendChild(tr); }; table.appendChild(tbody); box.appendChild(table);}function setRightMark(theme,id){ var id = parseInt(id); var vid = null; var dataArr = newConf.data[theme].conf; for(var i=0;i<dataArr.length;i++){ if(dataArr[i].cfg.indexOf('b'+id+',') != -1 && dataArr[i].oTheme == (parseInt(THEME)-1)){ vid = i; trace('##rm_id : '+vid); break; } } removeNode('rm_cont'); if(vid == null) return; var rm = $C('div');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -