1$(function () { 2 window.isMobile = !!("ontouchstart" in window); 3 4 function AddFavorite(sURL, sTitle) { 5 if (/firefox/i.test(navigator.userAgent)) { 6 return false; 7 } else if (window.external && window.external.addFavorite) { 8 window.external.addFavorite(sURL, sTitle); 9 return true; 10 } else if (window.sidebar && window.sidebar.addPanel) { 11 window.sidebar.addPanel(sTitle, sURL, ""); 12 return true; 13 } else { 14 var touch = (navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Command' : 'CTRL'); 15 layer.msg('è¯·ä½¿ç¨ ' + touch + ' + D æ·»å å°æ¶è夹.'); 16 return false; 17 } 18 } 19 20 var len = function (str) { 21 if (!str) 22 return 0; 23 var length = 0; 24 for (var i = 0; i < str.length; i++) { 25 if (str.charCodeAt(i) >= 0x4e00 && str.charCodeAt(i) <= 0x9fa5) { 26 length += 2; 27 } else { 28 length++; 29 } 30 } 31 return length; 32 }; 33 34 //new LazyLoad({elements_selector: ".lazy"}); 35 36 layer.config({focusBtn: false}); 37 38 //æ ç®é«äº® 39 var nav = $("header.header .navbar-nav"); 40 if ($("li.active", nav).length === 0) { 41 var current = nav.data("current"); 42 43 var currentNav = $("a[href='" + location.href + "']", nav)[0] || $("a[href='" + location.pathname + "']", nav)[0] || $("li[value='" + current + "'] > a", nav)[0]; 44 currentNav && $(currentNav, nav).parents("li").addClass("active"); 45 } 46 47 $(".collapse.navbar-collapse.active").on("mousedown click", ".dropdown-menu .dropdown-submenu a[data-toggle='dropdown']", function (e) { 48 e.stopPropagation(); 49 }); 50 51 $("header.header .navbar-right").insertBefore($("header.header .navbar-right").prev()); 52 53 //ç§»å¨æµè§å¨å·¦å³æ»å¨ 54 $(document).on('touchstart', '.carousel', function (event) { 55 const xClick = event.originalEvent.touches[0].pageX; 56 $(this).one('touchmove', function (event) { 57 const xMove = event.originalEvent.touches[0].pageX; 58 const sensitivityInPx = 5; 59 60 if (Math.floor(xClick - xMove) > sensitivityInPx) { 61 $(this).carousel('next'); 62 } else if (Math.floor(xClick - xMove) < -sensitivityInPx) { 63 $(this).carousel('prev'); 64 } 65 }); 66 $(this).on('touchend', function () { 67 $(this).off('touchmove'); 68 }); 69 }); 70 71 // ç¹å»æ¶è 72 $(".addbookbark").attr("rel", "sidebar").click(function () { 73 //ä½¿ç¨æ°æ®åºæ¶è 74 CMS.api.ajax({ 75 url: $(this).data("action"), 76 data: {type: $(this).data("type"), aid: $(this).data("aid")} 77 }); 78 //ä½¿ç¨æµè§å¨æ¶è 79 //return !AddFavorite(window.location.href, $(this).attr("title")); 80 }); 81 82 // ç¹èµ 83 $(document).on("click", ".btn-like", function () { 84 var that = this; 85 var id = $(this).data("id"); 86 var type = $(this).data("type"); 87 if (CMS.api.storage(type + "vote." + id)) { 88 layer.msg("ä½ å·²ç»ç¹è¿èµäº"); 89 return false; 90 } 91 CMS.api.ajax({ 92 data: $(this).data() 93 }, function (data, ret) { 94 $("span", that).text(type === 'like' ? ret.data.likes : ret.data.dislikes); 95 CMS.api.storage(type + "vote." + id, true); 96 return false; 97 }, function () { 98 return false; 99 }); 100 }); 101 102 // å è½½æ´å¤ 103 $(document).on("click", ".btn-loadmore", function () { 104 var that = this; 105 var page = parseInt($(this).data("page")); 106 var container = $(this).data("container"); 107 container = container ? $(container) : $(".article-list,.product-list"); 108 var loadmoreText = $(this).text(); 109 $(that).text("æ£å¨å è½½").prop("disabled", true); 110 CMS.api.ajax({ 111 url: $(that).attr("href"), 112 }, function (data, ret) { 113 if (data) { 114 $(data).appendTo(container); 115 page++; 116 $(that).attr("href", $(that).data("url").replace("__page__", page)).data("page", page); 117 $(that).text(loadmoreText).prop("disabled", false); 118 } else { 119 $(that).replaceWith('<div class="loadmore loadmore-line loadmore-nodata"><span class="loadmore-tips">ææ æ´å¤æ°æ®</span></div>'); 120 } 121 return false;
122 }, function (data) { 123 $(that).text(loadmoreText).prop("disabled", false); 124 }); 125 return false; 126 }); 127 128 //æ»å¨å è½½æ´å¤ 129 $(window).scroll(function () { 130 var loadmore = $(".btn-loadmore"); 131 if (loadmore.length > 0 && !loadmore.prop("disabled") && (loadmore.data("autoload") === undefined || loadmore.data("autoload"))) { 132 if ($(window).scrollTop() - loadmore.height() > loadmore.offset().top - $(window).height()) { 133 loadmore.trigger("click"); 134 } 135 } 136 }); 137 setTimeout(function () { 138 if ($(window).scrollTop() > 0) { 139 $(window).trigger("scroll"); 140 } 141 }, 500); 142 143 //è¯è®ºå表 144 if ($("#comment-container").length > 0) { 145 var ci, si; 146 $("#commentlist dl dd div,#commentlist dl dd dl dd").on({ 147 mouseenter: function () { 148 clearTimeout(ci); 149 var _this = this; 150 ci = setTimeout(function () { 151 $(_this).find("small:first").find("a").stop(true, true).css('display', 'inline-block'); 152 }, 100); 153 }, 154 mouseleave: function () { 155 clearTimeout(ci); 156 $(this).find("small:first").find("a").stop(true, true).fadeOut(); 157 } 158 }); 159 $(".reply").on("click", function () { 160 $("#pid").val($(this).data("id")); 161 $(this).parent().parent().append($("div#postcomment").detach()); 162 $("#postcomment h3 a").show(); 163 $("#commentcontent").focus().val($(this).attr("title")); 164 }); 165 $("#postcomment h3 a").bind("click", function () { 166 $("#comment-container").append($("div#postcomment").detach()); 167 $(this).hide(); 168 }); 169 $(".expandall a").on("click", function () { 170 $(this).parent().parent().find("dl.hide").fadeIn(); 171 $(this).fadeOut(); 172 }); 173 174 $(document).on("click", "#submit", function () { 175 var btn = $(this); 176 var tips = $("#actiontips"); 177 tips.removeClass(); 178 var content = $("#commentcontent").val(); 179 if (len(content) < 3) { 180 tips.addClass("text-danger").html("è¯è®ºå 容é¿åº¦ä¸æ£ç¡®ï¼æå°3个å符").fadeIn().change(); 181 return false; 182 } 183 if (btn.prop("disabled")) { 184 return false; 185 } 186 var form = $("#postform"); 187 btn.attr("disabled", "disabled"); 188 tips.html('æ£å¨æäº¤...'); 189 $.ajax({ 190 url: form.prop("action"), 191 type: 'POST', 192 data: form.serialize(), 193 dataType: 'json', 194 success: function (json) { 195 btn.removeAttr("disabled"); 196 if (json.code == 1) { 197 $("#pid").val(0); 198 tips.addClass("text-success").html(json.msg || "è¯è®ºæåï¼").fadeIn(300).change(); 199 $("#commentcontent").val(''); 200 $("#commentcount").text(parseInt($("#commentcount").text()) + 1); 201 setTimeout(function () { 202 location.reload(); 203 }, 1500); 204 } else { 205 tips.addClass("text-danger").html(json.msg).fadeIn(); 206 } 207 if (json.data && json.data.token) { 208 $("#postform input[name='__token__']").val(json.data.token); 209 } 210 }, 211 error: function () { 212 btn.removeAttr("disabled"); 213 tips.addClass("text-danger").html("è¯è®ºå¤±è´¥ï¼è¯·å·æ°é¡µé¢éè¯ï¼").fadeIn(); 214 } 215 }); 216 return false; 217 }); 218 $("#commentcontent").on("keydown", function (e) { 219 if ((e.metaKey || e.ctrlKey) && (e.keyCode == 13 || e.keyCode == 10)) { 220 $("#submit").trigger('click'); 221 return false;
222 } 223 }); 224 $("#actiontips").on("change", function () { 225 clearTimeout(si); 226 si = setTimeout(function () { 227 $("#actiontips").fadeOut(); 228 }, 8000); 229 }); 230 $(document).on("keyup change", "#commentcontent", function (e) { 231 if (e.metaKey || e.ctrlKey || [13, 10, 18, 91].indexOf(e.keyCode) > -1) { 232 return false; 233 } 234 var max = 1000; 235 var c = $(this).val(); 236 var length = len(c); 237 var t = $("#actiontips"); 238 if (max >= length) { 239 t.removeClass().show().addClass("loading").html("ä½ è¿å¯ä»¥è¾å ¥ <font color=green>" + (Math.floor((max - length) / 2)) + "</font> å"); 240 $("#submit").removeAttr("disabled"); 241 } else { 242 t.removeClass().show().addClass("loading").html("ä½ å·²ç»è¶ åº <font color=red>" + (Math.ceil((length - max) / 2)) + "</font> å"); 243 $("#submit").attr("disabled", "disabled"); 244 } 245 }); 246 } 247 // ä½é¢æ¯ä»æç¤º 248 $(document).on('click', '.btn-balance', function (e) { 249 var that = this; 250 layer.confirm("确认æ¯ä»ï¿¥" + $(this).data("price") + "å ç¨äºè´ä¹°ï¼", function () { 251 CMS.api.ajax({ 252 url: $(that).attr("href") 253 }, function (data, ret) { 254 CMS.api.msg(ret.msg, ret.url); 255 }, function (data, ret) { 256 if (ret.msg && ret.msg.indexOf("ç»å½") > -1) { 257 layer.alert(ret.msg, {btn: ["å»ç»å½", "æä¸ç»å½"]}, function () { 258 location.href = ret.url; 259 }); 260 return false; 261 } 262 }); 263 }); 264 return false; 265 }); 266 // åå°é¡¶é¨ 267 $('#back-to-top').on('click', function (e) { 268 e.preventDefault(); 269 $('html,body').animate({ 270 scrollTop: 0 271 }, 700); 272 }); 273 274 //妿æ¯PCåç§»é¤navbarçdropdownç¹å»äºä»¶ 275 if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobi/i.test(navigator.userAgent)) { 276 $("#navbar-collapse [data-toggle='dropdown']").removeAttr("data-toggle"); 277 } else { 278 $(".navbar-nav ul li:not(.dropdown-submenu):not(.dropdown) a").removeAttr("data-toggle"); 279 } 280 281 if (!isMobile) { 282 var search = $("#searchinput"); 283 var form = search.closest("form"); 284 search.autoComplete({ 285 minChars: 1, 286 cache: false, 287 menuClass: 'autocomplete-searchmenu', 288 header: '', 289 footer: '', 290 source: function (term, response) { 291 try { 292 xhr.abort(); 293 } catch (e) { 294 } 295 xhr = $.getJSON(search.data("suggestion-url"), {q: term}, function (data) { 296 response(data); 297 }); 298 }, 299 onSelect: function (e, term, item) { 300 if (typeof callback === 'function') { 301 callback.call(elem, term, item); 302 } else { 303 form.trigger("submit"); 304 } 305 } 306 }); 307 } 308 309 // ææºç«¯å·¦å³æ»å¨åæ¢èåæ 310 if (isMobile && 'ontouchstart' in document.documentElement) { 311 var startX, startY, moveEndX, moveEndY, relativeX, relativeY, element; 312 element = $('#navbar-collapse'); 313 $("body").on("touchstart", function (e) { 314 startX = e.originalEvent.changedTouches[0].pageX; 315 startY = e.originalEvent.changedTouches[0].pageY; 316 }); 317 $("body").on("touchend", function (e) { 318 moveEndX = e.originalEvent.changedTouches[0].pageX; 319 moveEndY = e.originalEvent.changedTouches[0].pageY; 320 relativeX = moveEndX - startX; 321 relativeY = moveEndY - startY; 322 323 //峿» 324 if (relativeX > 45) { 325 if ((Math.abs(relativeX) - Math.abs(relativeY)) > 50 && !element.hasClass("active") && startX < ($(window).width() / 4)) { 326 $(".sidebar-toggle").trigger("click"); 327 } 328 } 329 //å·¦æ» 330 else if (relativeX < -45) { 331 if ((Math.abs(relativeX) - Math.abs(relativeY)) > 50 && element.hasClass("active")) { 332 $(".sidebar-toggle").trigger("click"); 333 } 334 } 335 }); 336 } 337 338 // æèµ 339 $(".btn-donate").popover({ 340 trigger: 'hover', 341 placement: 'top', 342 html: true, 343 content: function () { 344 return "<img src='" + $(this).data("image") + "' width='250' height='250'/>"; 345 } 346 }); 347 $(document).on("click", ".btn-paynow", function () { 348 var paytype = $(this).data("paytype"); 349 var price = $(this).data("price"); 350 var nameArr = {wechat: "微信", alipay: "æ¯ä»å®", balance: "ä½é¢"}; 351 var that = this; 352 var tips = function () { 353 layer.confirm("è¯·æ ¹æ®æ¯ä»ç¶æéæ©ä¸é¢çæä½æé®", {title: "温馨æç¤º", icon: 0, btn: ["æ¯ä»æå", "æ¯ä»å¤±è´¥"]}, function () { 354 location.reload(); 355 }); 356 }; 357 if (paytype) { 358 layer.confirm("确认使ç¨" + (typeof nameArr[paytype] !== 'undefined' ? nameArr[paytype] : "æªç¥") + "è¿è¡æ¯ä»?<br>æ¯ä»éé¢ï¼ï¿¥" + price + "å ", {title: "温馨æç¤º", icon: 3, focusBtn: false, btn: ["ç«å³æ¯ä»", "åæ¶æ¯ä»"]}, function (index, layero) { 359 $(".layui-layer-btn0", layero).attr("href", $(that).attr("href")).attr("target", "_blank"); 360 tips(); 361 }); 362 return false;
363 } else { 364 tips(); 365 } 366 }); 367 368 //ç¹å»åæ¢ 369 $(document).on("click", ".sidebar-toggle", function () { 370 var collapse = $("#navbar-collapse"); 371 if (collapse.hasClass("active")) { 372 $(".navbar-collapse-bg").remove(); 373 } else { 374 $("<div />").addClass("navbar-collapse-bg").insertAfter(collapse).on("click", function () { 375 $(".sidebar-toggle").trigger("click"); 376 }); 377 } 378 collapse.toggleClass("active"); 379 $(this).toggleClass("active"); 380 }); 381 382 //å 容ä¸çå¾çç¹å»äºä»¶ 383 $(document).on("click", ".article-text img", function () { 384 if ($(this).closest("a").length > 0) { 385 return; 386 } 387 var that = this; 388 var data = []; 389 var index = 0; 390 $(".article-text img").each(function (i, j) { 391 if (that == this) { 392 index = i; 393 } 394 data.push({ 395 "src": $(this).attr("src") //åå¾å°å 396 }); 397 }); 398 layer.photos({ 399 photos: { 400 "start": index, "data": data 401 }, 402 // scrollbar: true, 403 // full: true, 404 // closeBtn: 1 405 }); 406 return false; 407 }); 408 409 //åäº«åæ°é ç½® 410 var shareConfig = { 411 title: $("meta[property='og:title']").attr("content") || document.title, 412 description: $("meta[property='og:description']").attr("content") || $("meta[name='description']").attr("content") || "", 413 url: $("meta[property='og:url']").attr("content") || location.href, 414 image: $("meta[property='og:image']").attr("content") || "" 415 }; 416 417 //å¾®ä¿¡å ¬ä¼å·å å享 418 if (typeof wx != 'undefined') { 419 shareConfig.url = location.href; 420 CMS.api.ajax({ 421 url: "/addons/cms/ajax/share", 422 data: {url: shareConfig.url}, 423 loading: false 424 }, function (data, ret) { 425 try { 426 wx.config({ 427 appId: data.appId, 428 timestamp: data.timestamp, 429 nonceStr: data.nonceStr, 430 signature: data.signature, 431 jsApiList: [ 432 'checkJsApi', 433 'updateAppMessageShareData', 434 'updateTimelineShareData', 435 ] 436 }); 437 var shareData = { 438 title: shareConfig.title, 439 desc: shareConfig.description, 440 link: shareConfig.url, 441 imgUrl: shareConfig.image, 442 success: function () { 443 layer.closeAll(); 444 }, 445 cancel: function () { 446 layer.closeAll(); 447 } 448 }; 449 wx.ready(function () { 450 wx.updateAppMessageShareData(shareData); 451 wx.updateTimelineShareData(shareData); 452 }); 453 454 } catch (e) { 455 console.log(e); 456 } 457 return false; 458 }, function () { 459 return false; 460 } 461 ); 462 463 $(".social-share").on("click", ".icon-wechat", function () { 464 layer.msg("请ç¹å»å³ä¸è§çâââè¿è¡å享"); 465 return false; 466 }).find(".wechat-qrcode").remove(); 467 } 468});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.