12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- $(function () {
- /*
- fetchJSON("/api/tag/hot", {}, "get", function (ret) {
- if (ret.code === 0) {
- if (ret.data.length > 0) {
- var maxCount = ret.data.length > 6 ? 6 : ret.data.length;
- $("#hotTag").empty();
- $("#hotTag").html("热门关键字:");
- for (var i = 0; i < maxCount; i++) {
- $("#hotTag").append(
- $("<a>", {href: "list_index.html?q=" + ret.data[i].keyword, text: ret.data[i].keyword})
- );
- }
- }
- } else {
- console.log(ret.msg);
- }
- });
- */
- $("#search").on("click", function (e) {
- e.preventDefault();
- submitSearch($("#keyword"));
- });
- $("#keyword").on("keyup", function (e) {
- e.preventDefault();
- if (e.keyCode === 13) submitSearch($("#keyword"));
- });
- function submitSearch(control) {
- var inputValue = control.val().trim();
- if (inputValue === "" || inputValue.replace(/[-_—]/g, "") === "") {
- control.focus();
- return;
- }
- var keylist = encodeURIComponent(control.val().trim());
- window.location.href = "list_index.html?q=" + keylist;
- }
- /*
- fetchJSON("/api/tag/visit", {}, "get", function (ret) {
- if (ret.code === 0) {
- $("#visit").html(ret.data);
- }
- });
- */
- function relocationElement() {
- var baseLeft = $('#bk').position().left;
- var baseTop = $('#bk').position().top;
- $('#navbar').css('left', baseLeft + 120);
- $('#keyword').css('left', baseLeft + 790);
- $('#search').css('left', baseLeft + 1165);
- $('#tel').css('left', baseLeft + 540);
- $('#visit').css('left', baseLeft + 1160);
- }
- relocationElement();
- $(window).resize(function (e) {
- relocationElement();
- });
- });
|