?? boot.js
字號:
/** * @author stan | chaoliang@staff.sina.com.cn *///- debug -var __dev_mode = false; //should be falsevar __debug_mode = false; //should be falsevar __decode_mode = false; //should be falsevar __author = "xinyu";//- env -var $BASE = "http://blogjs.sinajs.cn/v5/";var $BASECSS = "http://blogimg.sinajs.cn/v5/";var imgPath="http://bj.static.photo.sina.com.cn/orignal/";/** 存儲出錯提示信息內容對象 */var $SYSMSG = {};var scope = {};//- pre process -checkAuthor();if(typeof $uid == "undefined") { $uid = $UID || "0000000000";}uid = $uid;var $uidhex = window.parseInt($uid).toString(16);$uidhex = new Array(9-$uidhex.length).join("0") + $uidhex; // 將不足十六進制 UID 進行補全/** * 提供$setDomain變量,用來標明是否需要設置domain * 如果不想設置domain,請在跟$pageid變量一起設置$setDomain = false; */if (typeof($setDomain) == "undefined" || $setDomain == true) { document.domain = "blog.sina.com.cn";}//- base function -function dw(s) { window.document.write(s);}/** * Fucking confusing name of this function.. */function dwSwf(_sName, _sSrc, _sWidth, _sHeight, _sMode, _aValue) { var sValue = ''; var aFlashVars = []; if (_aValue) { for (var key in _aValue) { aFlashVars[aFlashVars.length] = key + "=" + _aValue[key]; } sValue = aFlashVars.join('&'); } _sMode = _sMode ? 'wmode="transparent"' : ''; if(_sName == "calendar" || _sName =="musicFlash2" ){ return '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + _sWidth + '" height="' + _sHeight + '" id="' + _sName + '" align="middle" ><param name="movie" value="' + _sSrc + '?' + sValue + '" /><param name=allowScriptAccess value=always><param name=wmode value=transparent><embed name="' + _sName + '" src="' + _sSrc + '" ' + _sMode + ' quality="high" align="top" salign="lt" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + _sWidth + '" height="' + _sHeight + '" flashVars="' + sValue + '" \/><\/object>'; }else{ return '<embed id="' + _sName + '" name="' + _sName + '" src="' + _sSrc + '" ' + _sMode + ' quality="high" align="top" salign="lt" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + _sWidth + '" height="' + _sHeight + '" flashVars="' + sValue + '" \/>'; }}/** * @author xp * write script tag to document. Can be used only in page-loading phase. * only script text or script url can be accepted. u cant specify none or two of them or an error will be raised * * 以document.write的方式向頁面中寫入js * @param o { * id : id of the created tag, * url : String, * script : String * } */function dwScript(o){ o.id = o.id || ""; o.charset = o.charset || "utf-8"; var def = ""; if(o.defer != null){ def = "defer='true'"; } if (o.script && o.script != "") { document.write("<script id='" + o.id + "' " + def + ">" + o.script + "<\/script>"); } else if (o.url && o.url != "") { document.write("<script id='" + o.id + "' src='" + o.url + "' charset='" + o.charset + "' " + def + "><\/script>"); } else { throw new Error("no script content or url specified"); }}/** * @author xp * write link tag or style tag to document. Can be used only in page-loading phase. * only script text or script url can be accepted. u cant specify none or two of them or an error will be raised * * 以document.write的方式向頁面中寫入css * @param o { * id : id of the created tag, * url : String, * styles : styles text * } */function dwCSS(o){ o.id = o.id || ""; if (o.url){ document.write('<link id="' + o.id + '" rel="stylesheet" type="text/css" href="' + o.url + '" />'); } else if (o.styles){ document.write('<style id="' + o.id + '" >'+o.styles+'<\/style>'); } }/** * @author stan | chaoliang@staff.sina.com.cn * fangchao | fangchao@staff.sina.com.cn * @param {Object} url * @desc load the souce files * * @modify 相同文件載入一份 */function $import(url){ if(window.scriptHash == null) { window.scriptHash = {}; } if (window.scriptHash[url] != true) { window.scriptHash[String(url)] = true; var pk = __decode_mode && __dev_mode ? ".packed" : ""; url = 'http://blogjs.sinajs.cn/v5dev/js/' + __author + '/' + url + pk; var o = {}; o.url = url + "?" + new Date().valueOf(); dwScript(o); }}/** * @author xp | yanbo@staff.sina.com.cn * @desc determine which page it is in */function $getPageId(win){ return $pageid;}/** * @author stan | chaoliang@staff.sina.com.cn * @desc get cookie by name */function getCookie(name) { var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); if (arr != null) { return unescape(arr[2]); } return null;}/** * check user status by cookie * @author stan * return Boolean true if the author is visiting its own blog */function checkAuthor(){ var AuthorInfo = getCookie("nick"); scope.AuthorUID = AuthorInfo ? AuthorInfo.match(/\(\d{5,10}\)/g)[0].replace(/\(|\)/g, "") : null; $UID = scope.AuthorUID || null; $isLogin = !!($UID); if(typeof $uid == "undefined") { $isAdmin = false; } else { $isAdmin = $uid == $UID; }}var cssReapetConf = { "none" : "no-repeat", "default":"repeat", "h":"repeat-x", "v":"repeat-y"};var cssPositionXConf = { "default" : "center", "left":"left", "center":"center", "right":"right"};var cssPositionYConf = { "default" : "top", "top":"top", "center":"center", "bottom":"bottom"};/** * 加載前端頁面全部css */function loadCss(){ fixConfig(); var cfg = config; var cssVer = cfg.v.c+".css"; var templateNum,tempArray=cfg.s.t.split("_"); if(cfg.s.r==1 && tempArray[0]!=9){ templateNum=randomTheme(tempArray[0]); }else{ templateNum=tempArray; } var dev = __dev_mode ? ".dev" : ""; dwCSS({url : $BASECSS + 'css/' + 'v5' + dev + '.css?'+cssVer}); dwCSS({url : $BASECSS + 'css/' + templateNum[0] + "_" + templateNum[1] + '/t.css?'+cssVer,id:"themeLink"}); writeDiyCss();}function writeDiyCss(){ //writer diy css //var path=$isAdmin?imgPath:"http://static.photo.sina.com.cn/orignal/";原有頭圖方式 if(config.s.head && config.s.head.usepic == "1"){ //修改訪問頭圖方式 var num=parseInt(config.s.head.currpic.substring(config.s.head.currpic.length-2,config.s.head.currpic.length),16)%16+1; var path=$isAdmin?imgPath:"http://static"+num+".photo.sina.com.cn/orignal/"; var diycss = {id:"diy_banner"}; diycss.styles = '.bannerLayout{background:url('+path+config.s.head.currpic+') '+ cssReapetConf[config.s.head.tiled]+' '+cssPositionXConf[config.s.head.align_h]+' '+cssPositionYConf[config.s.head.align_v]+';height:'+config.s.head.height+'px}'; dwCSS(diycss); } if(config.s.bg && config.s.bg.usepic == "1"){ //修改頭圖訪問方式 var num=parseInt(config.s.bg.currpic.substring(config.s.bg.currpic.length-2,config.s.bg.currpic.length),16)%16+1; var path=$isAdmin?imgPath:"http://static"+num+".photo.sina.com.cn/orignal/"; var diycss = {id:"diy_bg"}; diycss.styles = 'body{background-image:url('+path+config.s.bg.currpic+');background-repeat: '+ cssReapetConf[config.s.bg.tiled]+'; background-position:'+cssPositionXConf[config.s.bg.align_h]+' '+cssPositionYConf[config.s.bg.align_v]+'} .sinaBottom {background:transparent url()}'; dwCSS(diycss); }}/** * 加載后端頁面css * 1.不加載模板css * 2.只配置較少的css * 3.不加載自定義css */function loadMiniCss(){ fixConfig(); var cfg = config; var cssVer = cfg.v.c+".css"; var dev = __dev_mode ? ".dev" : ""; dwCSS({url : $BASECSS + 'css/' + 'v5' + dev + '.css?'+cssVer});}/** * 模板各個分類的length */var themeLength=[30,30,30,20,20,20,22,30];/** * 隨即模板(首頁每次刷新都隨即,其頁面根據cookie隨機) * @param {Object} themeNum */function randomTheme(themeNum){ var num,length=themeLength[themeNum-1],cookieTheme=getCookie("sina_blog_random_theme"); if(/index/.test($pageid)||cookieTheme==null){ num=getRandomNum(1,length-1); setCookie("sina_blog_random_theme",num,2,"/","blog.sina.com.cn",false); }else{ num=cookieTheme; } //避免因為cookie存儲了超過范圍的num而引起的亂碼問題 if (num > themeLength[themeNum - 1]) { num = themeLength[themeNum - 1] -1; } return [themeNum,num];}/** * 取得隨即數,>=min,<=max * @param {Object} min * @param {Object} max */getRandomNum=function(min,max){ return min+Math.floor(Math.random()*(max-min+1)); };/** * 保存cookie */function setCookie(sName,sValue,objHours,sPath,sDomain,bSecure){ var sCookie = sName + "=" + encodeURIComponent(sValue); if (objHours) { var date = new Date(); var ms = objHours * 3600 * 1000; date.setTime(date.getTime() + ms); sCookie += ";expires=" + date.toGMTString(); } if (sPath) { sCookie += ";path=" + sPath; } if (sDomain) { sCookie += ";domain=" + sDomain; } if (bSecure) { sCookie += ";secure"; } document.cookie=sCookie;}/** * @author stan | chaoliang@staff.sina.com.cn * @desc load the js file base the usr login status & page */function loadResource(){ fixConfig(); if (__debug_mode) { $import('Sina/Sina.js'); $import('Sina/debug.js'); } if(__dev_mode) { $import('Sina/Sina.js'); $import('Sina/io/io.js') $import('Sina/system.base.js');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -