html.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. //google 统计start
  2. var _gaq = _gaq || [];
  3. _gaq.push(['_setAccount', 'UA-535605-6']);
  4. _gaq.push(['_addOrganic', 'm.baidu', 'word']);
  5. _gaq.push(['_addOrganic', 'wap.baidu', 'word']);
  6. _gaq.push(['_addOrganic', 'baidu.mobi', 'word']);
  7. _gaq.push(['_addOrganic', 'news.baidu', 'word']);
  8. _gaq.push(['_addOrganic', 'opendata.baidu', 'wd']);
  9. _gaq.push(['_addOrganic', 'post.baidu', 'kw']);
  10. _gaq.push(['_addOrganic', 'mp3.baidu', 'word']);
  11. _gaq.push(['_addOrganic', 'mp3.baidu', 'song']);
  12. _gaq.push(['_addOrganic', 'box.zhangmen.baidu', 'word']);
  13. _gaq.push(['_addOrganic', 'image.baidu', 'word']);
  14. _gaq.push(['_addOrganic', 'top.baidu', 'w']);
  15. _gaq.push(['_addOrganic', 'baidu', 'wd']);
  16. _gaq.push(['_addOrganic', 'baidu', 'word']);
  17. _gaq.push(['_addOrganic', 'baidu', 'kw']);
  18. _gaq.push(['_addOrganic', 'baidu', 'q1']);
  19. _gaq.push(['_addOrganic', 'baidu', 'q2']);
  20. _gaq.push(['_addOrganic', 'baidu', 'q3']);
  21. _gaq.push(['_addOrganic', 'baidu', 'q4']);
  22. _gaq.push(['_addOrganic', 'baidu', 'q5']);
  23. _gaq.push(['_addOrganic', 'baidu', 'q6']);
  24. _gaq.push(['_addOrganic', 'news.google', 'q']);
  25. _gaq.push(['_addOrganic', 'image.soso', 'w']);
  26. _gaq.push(['_addOrganic', 'wenwen.soso', 'sp']);
  27. _gaq.push(['_addOrganic', 'wenwen.soso', 'w']);
  28. _gaq.push(['_addOrganic', 'wap.soso', 'key']);
  29. _gaq.push(['_addOrganic', 'soso', 'w']);
  30. _gaq.push(['_addOrganic', 'bing', 'q']);
  31. _gaq.push(['_addOrganic', 'youdao', 'q']);
  32. _gaq.push(['_addOrganic', 'vnet', 'kw']);
  33. _gaq.push(['_addOrganic', 'so.360', 'q']);
  34. _gaq.push(['_addOrganic', 'so', 'q']);
  35. _gaq.push(['_addOrganic', '360sou', 'q']);
  36. _gaq.push(['_addOrganic', '360so', 'q']);
  37. _gaq.push(['_addOrganic', '360', 'q']);
  38. _gaq.push(['_addOrganic', 'image.so', 'q']);
  39. _gaq.push(['_addOrganic', 'news.sogou', 'query']);
  40. _gaq.push(['_addOrganic', 'mp3.sogou', 'query']);
  41. _gaq.push(['_addOrganic', 'pic.sogou', 'query']);
  42. _gaq.push(['_addOrganic', 'blogsearch.sogou', 'query']);
  43. _gaq.push(['_addOrganic', 'wap.sogou', 'keyword']);
  44. _gaq.push(['_addOrganic', 'm.sogou', 'keyword']);
  45. _gaq.push(['_addOrganic', 'sogou', 'query']);
  46. _gaq.push(['_setDomainName', 'csdn.net']);
  47. _gaq.push(['_trackPageview']);
  48. (function() {
  49. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  50. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  51. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  52. })();
  53. //google 统计end
  54. //tag推荐弹窗
  55. (function(){
  56. var protocol = location.protocol.substr(0, 4) === 'http' ? '' : 'http:';
  57. $.getScript(protocol + '//csdnimg.cn/public/common/tag-suggest-pop/js/main.js?'+(new Date()/120000|0));
  58. })();
  59. !(function(){
  60. var currUser={
  61. userName:"",
  62. userNick:'<a class="set-nick" href="https://passport.csdn.net/account/profile">设置昵称<span class="write-icon"></span></a>',
  63. userInfo:"",
  64. desc : '<a class="fill-dec" href="//my.csdn.net" target="_blank">编辑自我介绍,让更多人了解你<span class="write-icon"></span></a>',
  65. avatar:"//static.csdn.net/public/common/toolbar/images/100x100.jpg"
  66. };
  67. var prodLogo = "none";
  68. var $oScriptTag =$("#toolbar-tpl-scriptId");
  69. var skin =$oScriptTag.attr("skin")=="black"?" csdn-toolbar-skin-black ":"";
  70. var fixed = $oScriptTag.attr("fixed")=="top"?" navbar-fixed-top ":"";
  71. var prodIndex= $oScriptTag.attr("domain")?$oScriptTag.attr("domain"):window.location.protocol+"//"+window.location.host;
  72. prodIndex+='?ref=toolbar_logo';
  73. var getCookie =function (objName){//获取指定名称的cookie的值
  74. var arrStr = document.cookie.split("; ");
  75. for(var i = 0;i < arrStr.length;i ++){
  76. var temp = arrStr[i].split("=");
  77. if(temp[0] == objName) return decodeURI(temp[1]);
  78. }
  79. }
  80. var HTMLEncode =function(str) {
  81. var s = "";
  82. if(str.length == 0) return "";
  83. s = str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\'/g, "&#39;").replace(/\"/g, "&quot;");
  84. return s;
  85. }
  86. var AUtoAvatar = function(AU){
  87. if(!AU||!currUser.userName){
  88. return false;
  89. }
  90. var _AUPath = AU.split("").join("/");
  91. var userName = currUser.userName&&currUser.userName.toLowerCase();
  92. return "http://avatar.csdn.net/"+_AUPath+"/2_"+userName+".jpg";
  93. }
  94. var hasLogin = false;
  95. var loginMark ="unlogin";
  96. function checkLogin(callback) {
  97. currUser.userNick = getCookie("UserNick") ||currUser.userNick;
  98. currUser.userName = getCookie("UserName") || currUser.userName;
  99. currUser.userInfo = getCookie("UserInfo") || currUser.userInfo;
  100. currUser.avatar = AUtoAvatar(getCookie("AU")) || currUser.avatar;
  101. currUser.desc = getCookie("UD") || currUser.desc;
  102. if(getCookie("UD")){
  103. currUser.desc = HTMLEncode(decodeURIComponent(currUser.desc).replace(/\+/g," "));
  104. }
  105. callback(currUser);
  106. }
  107. checkLogin(function(currUser){
  108. if(currUser.userName&&currUser.userInfo){
  109. hasLogin = true;
  110. }
  111. loginMark = hasLogin?"":"unlogin";
  112. })
  113. /*
  114. * init pord logo
  115. */
  116. var prodJSON = {
  117. "blog" : "blog-icon",
  118. "download" : "down-icon",
  119. "bbs" : "bbs-icon",
  120. "my" :"space-icon",
  121. "code" : "code-icon",
  122. "share" : "share-icon",
  123. "tag" : "tag-icon",
  124. "dashboard":"dashboard-icon",
  125. "news" : "news-icon",
  126. "tag" : "tag-icon",
  127. "ask" : "ask-icon",
  128. "notify" : "notify-icon"
  129. }
  130. if(prodJSON[$oScriptTag.attr("prod")]){
  131. prodLogo=prodJSON[$oScriptTag.attr("prod")]||$oScriptTag.attr("prod");
  132. }
  133. // $( 'head' ).append( '<link rel="stylesheet" href="//csdnimg.cn/public/common/toolbar/css/font-awesome.min.css">' );
  134. var tpl ='\<div class="csdn-toolbar'+skin+fixed+'">\
  135. <div class="container row center-block ">\
  136. <div class="col-md-3 pull-left logo clearfix"><a href="http://www.csdn.net?ref=toolbar" title="CSDN首页" target="_blank" class="icon"></a><a title="频道首页" href="'+prodIndex+'" target="_blank" class="img '+prodLogo+'"></a></div>\
  137. <div class="pull-right login-wrap '+loginMark+'">\
  138. <ul class="btns">\
  139. <li class="loginlink"><a href="https://passport.csdn.net/account/login?ref=toolbar" target="_top">登录&nbsp;</a>|<a target="_top" href="https://passport.csdn.net/account/register?ref=toolbar">&nbsp;注册</a></li>\
  140. <li class="search">\
  141. <div class="icon on-search-icon">\
  142. <div class="wrap">\
  143. <div class="curr-icon-wrap">\
  144. <div class="curr-icon"></div>\
  145. </div>\
  146. <form action="http://so.csdn.net/search" method="get" target="_blank">\
  147. <input type="hidden" value="toolbar" name="ref" accesskey="2">\
  148. <div class="border">\
  149. <input placeholder="搜索" type="text" value="" name="q" accesskey="2"><span class="icon-enter-sm"></span>\
  150. </div>\
  151. </form>\
  152. </div>\
  153. </div>\
  154. </li>\
  155. <li class="favor">\
  156. <div class="icon on-favor-icon">\
  157. <div class="wrap">\
  158. <div class="curr-icon-wrap">\
  159. <div class="curr-icon"></div>\
  160. </div>\
  161. <div style="display:none;" class="favor-success"><span class="msg">收藏成功</span>\
  162. <div class="btns"><span class="btn btn-primary ok">确定</span></div>\
  163. </div>\
  164. <div style="display:none;" class="favor-failed"><span class="icon-danger-lg"></span><span class="msg">收藏失败,请重新收藏</span>\
  165. <div class="btns"><span class="btn btn-primary ok">确定</span></div>\
  166. </div>\
  167. <form role="form" class="form-horizontal favor-form">\
  168. <div class="form-group">\
  169. <div class="clearfix">\
  170. <label for="input-title" class="col-sm-2 control-label">标题</label>\
  171. <div class="col-sm-10">\
  172. <input id="inputTitle" type="text" placeholder="" class="title form-control">\
  173. </div>\
  174. </div>\
  175. <div class="alert alert-danger"><strong></strong>标题不能为空</div>\
  176. </div>\
  177. <div class="form-group">\
  178. <label for="input-url" class="col-sm-2 control-label">网址</label>\
  179. <div class="col-sm-10">\
  180. <input id="input-url" type="text" placeholder="" class="url form-control">\
  181. </div>\
  182. </div>\
  183. <div class="form-group">\
  184. <label for="input-tag" class="col-sm-2 tag control-label">标签</label>\
  185. <div class="col-sm-10">\
  186. <input id="input-tag" type="text" class="form-control tag">\
  187. </div>\
  188. </div>\
  189. <div class="form-group">\
  190. <label for="input-description" class="description col-sm-2 control-label">摘要</label>\
  191. <div class="col-sm-10">\
  192. <textarea id="input-description" class="form-control description"></textarea>\
  193. </div>\
  194. </div>\
  195. <div class="form-group">\
  196. <div class="col-sm-offset-2 col-sm-10 ft">\
  197. <div class="col-sm-4 pull-left">\
  198. <div class="checkbox">\
  199. <label>\
  200. <input type="checkbox" name="share" checked="checked" class="share">公开\
  201. </label>\
  202. </div>\
  203. </div>\
  204. <div class="col-sm-8 pull-right favor-btns">\
  205. <button type="button" class="cancel btn btn-default">取消</button>\
  206. <button type="submit" class="submit btn btn-primary">收藏</button>\
  207. </div>\
  208. </div>\
  209. </div>\
  210. </form>\
  211. </div>\
  212. </div>\
  213. </li>\
  214. <li class="notify">\
  215. <div style="display:none" class="number"></div>\
  216. <div style="display:none" class="icon-hasnotes-sm"></div>\
  217. <div id="header_notice_num"></div>\
  218. <div class="icon on-notify-icon">\
  219. <div class="wrap">\
  220. <div class="curr-icon-wrap">\
  221. <div class="curr-icon"></div>\
  222. </div>\
  223. <div id="note1" class="csdn_note">\
  224. <div class="box"></div>\
  225. </div>\
  226. </div>\
  227. </div>\
  228. </li>\
  229. <li class="ugc">\
  230. <div class="icon on-ugc-icon">\
  231. <div class="wrap clearfix">\
  232. <div class="curr-icon-wrap">\
  233. <div class="curr-icon"></div>\
  234. </div>\
  235. <dl>\
  236. <dt><a href="http://geek.csdn.net/news/expert?ref=toolbar" target="_blank" class="p-news clearfix"><em class="icon"></em><span>分享资讯</span></a></dt>\
  237. <dt><a href="http://share.csdn.net/slides/new?ref=toolbar" target="_blank" class="p-doc clearfix"><em class="icon"></em><span>传PPT/文档</span></a></dt>\
  238. <dt><a href="http://bbs.csdn.net/topics/new?ref=toolbar" target="_blank" class="p-ask clearfix"><em class="icon"></em><span>提问题</span></a></dt>\
  239. <dt><a href="http://write.blog.csdn.net/postedit?ref=toolbar" target="_blank" class="p-blog clearfix"><em class="icon"></em><span>写博客</span></a></dt>\
  240. <dt><a href="http://u.download.csdn.net/upload?ref=toolbar" target="_blank" class="p-src clearfix"><em class="icon"></em><span>传资源</span></a></dt>\
  241. <dt><a href="https://code.csdn.net/projects/new?ref=toolbar" target="_blank" class="c-obj clearfix"><em class="icon"></em><span>创建项目</span></a></dt>\
  242. <dt><a href="https://code.csdn.net/snippets/new?ref=toolbar" target="_blank" class="c-code clearfix"><em class="icon"></em><span>创建代码片</span></a></dt>\
  243. </dl>\
  244. </div>\
  245. </div>\
  246. </li>\
  247. <li class="profile">\
  248. <div class="icon on-profile-icon"><img src="'+currUser.avatar+'" class="curr-icon-img">\
  249. <div class="wrap clearfix">\
  250. <div class="curr-icon-wrap">\
  251. <div class="curr-icon"></div>\
  252. </div>\
  253. <div class="bd">\
  254. <dl class="clearfix">\
  255. <dt class="pull-left img"><a target="_blank" href="http://my.csdn.net?ref=toolbar" class="avatar"><img src="'+currUser.avatar+'"></a></dt>\
  256. <dd class="info"><a target="_blank" href="http://my.csdn.net?ref=toolbar" class="nickname">'+currUser.userNick+'</a><span class="dec">'+currUser.desc+'</span></dd>\
  257. </dl>\
  258. </div>\
  259. <div class="ft clearfix"><a target="_blank" href="http://my.csdn.net/my/account/changepwd?ref=toolbar" class="pull-left"><span class="icon-cog"></span>帐号设置</a><a href="https://passport.csdn.net/account/logout?ref=toolbar" target="_top" class="pull-right "><span class="icon-signout"></span><span class="out">退出</span></a></div>\
  260. </div>\
  261. </div>\
  262. </li>\
  263. <li class="apps">\
  264. <div class="icon on-apps-icon">\
  265. <div class="wrap clearfix">\
  266. <div class="curr-icon-wrap">\
  267. <div class="curr-icon"></div>\
  268. </div>\
  269. <div class="detail">\
  270. <dl>\
  271. <dt>\
  272. <h5>社区</h5>\
  273. </dt>\
  274. <dd> <a href="http://blog.csdn.net?ref=toolbar" target="_blank">博客</a></dd>\
  275. <dd> <a href="http://bbs.csdn.net?ref=toolbar" target="_blank">论坛</a></dd>\
  276. <dd> <a href="http://download.csdn.net?ref=toolbar" target="_blank">下载</a></dd>\
  277. <dd><a href="http://share.csdn.net?ref=toolbar" target="_blank">Share</a></dd>\
  278. <dd><a href="http://geek.csdn.net?ref=toolbar" target="_blank">极客头条</a></dd>\
  279. </dl>\
  280. </div>\
  281. <div class="detail">\
  282. <dl>\
  283. <dt>\
  284. <h5>服务</h5>\
  285. </dt>\
  286. <dd> <a href="https://code.csdn.net?ref=toolbar" target="_blank">CODE</a></dd>\
  287. <dd> <a href="http://hero.csdn.net?ref=toolbar" target="_blank">英雄会</a></dd>\
  288. <dd> <a href="http://huiyi.csdn.net/?ref=toolbar" target="_blank">活动</a></dd>\
  289. <dd> <a href="http://www.csto.com?ref=toolbar" target="_blank">CSTO</a></dd>\
  290. </dl>\
  291. </div>\
  292. <div class="detail last">\
  293. <dl>\
  294. <dt>\
  295. <h5>俱乐部</h5>\
  296. </dt>\
  297. <dd> <a href="http://cto.csdn.net?ref=toolbar" target="_blank">CTO俱乐部</a></dd>\
  298. <dd> <a href="http://student.csdn.net?ref=toolbar" target="_blank">高校俱乐部</a></dd>\
  299. </dl>\
  300. </div>\
  301. </div>\
  302. </div>\
  303. </li>\
  304. </ul>\
  305. </div>\
  306. </div>\
  307. </div>';
  308. $(document.body).append($(tpl));
  309. })();