var showLoading = true; $(function () { var classid=getClassID(); var aid=getInfoID(); if(aid!="0"){ artclick(classid,aid) }else{ if(classid!="0"){ classclick(classid); } } }) function getinterface_data(id,key,lti){ $.ajax({ type: "post", url: "/index.php?a=getdata_interface", data: { key: key, lti: lti }, success: function (msg) { var obj = eval('(' + msg + ')'); $("#"+id).html(obj.ListHtml); } }) } /*栏目点击率方法*/ function classclick(cid){ $.ajax({ type: "POST", dataType: "json", url: '/index.php?a=hits', data: {catid:cid}, success: function (data) { } }); } /*文章页浏览量*/ function artclick(cid,aid){ $.ajax({ type: "POST", dataType: "json", url: '/index.php?a=hit', data: { id:aid, catid:cid }, success: function (data) { $("#views").html(data); } }); } /*-------------------------没有内容自动隐藏-------------------------*/ $(function () { $('.IFHide').map(function (index) { if ($(this).html().trim().length <= 0) { $(this).hide(); $('.DivHide:eq(' + index + ')').hide(); } }); }); var Request = { QueryString: function (key) { var svalue = window.location.search.match(new RegExp("[\?\&]" + key + "=([^\&]*)(\&?)", "i")); return svalue ? svalue[1] : svalue; } } //回车事件 function EnterFunction(ElementInput, ElementBtn) { $(ElementInput).keydown(function (e) { var curKey = e.which; if (curKey == 13) { $(ElementBtn).click(); } }); } $(function () { EnterFunction("#formd_search_id", "#btnSearch"); EnterFunction("#formd_search_id1", "#btnSearch1"); EnterFunction("#formd_search_id2", "#btnSearch2"); EnterFunction("#formd_search_id3", "#btnSearch3"); EnterFunction("#search-field", "#btnSearch"); EnterFunction("#keywords", ".go_page"); EnterFunction("#title", "#public_submit"); }) $(document).on("click", "#public_submit,.publicSearch", function () { productSearch(1); }) function productSearch(pageindex) { var pageindex = pageindex; var pagesize = 10; var isRelationChild = 0; var catid = $.trim($("#catid").val()); var title = $("#title").val(); var pagecmd = "productSearch"; var condition = '[{"condition":[{"field":"catid","value":"' + catid + '","symbol":"=","isRelationChild":' + isRelationChild + '},{"field":"title","value":"' + title + '","symbol":"like","isRelationChild":' + isRelationChild + '}],"condition_type":1,"pagesize":' + pagesize + ',"pageindex":' + pageindex + '}]'; //console.log(condition); var attrArgs = "cmd|search|pagecmd|search|condition|search|catid";//为了转换数组与json中的逗号冲突,此处用|search|分隔 var valArgs = "getConditionResult" + "|search|" + pagecmd + "|search|" + condition + "|search|" + catid; var data = "attrArgs=" + encryption(attrArgs) + "&valArgs=" + encryption(valArgs) + ""; ajaxPublicSearch(data, function (msg) { var obj = eval('(' + msg + ')'); var HtmlList = ''; if (obj.data != null) { for (var i = 0; i < obj.data.length; i++) { if (catid == 40) { HtmlList += ''; HtmlList += ' ' + ((parseInt(pageindex) - 1) * 10 + (i + 1)) + ''; HtmlList += ' ' + obj.data[i]['title'] + ''; HtmlList += ' ' + obj.data[i]['subtitle'] + ''; HtmlList += ' ' + obj.data[i]['text3'] + ''; HtmlList += ' ' + obj.data[i]['text4'] + ''; HtmlList += ' ' + obj.data[i]['year'] + '-' + obj.data[i]['month'] + '-' + obj.data[i]['day'] + ' ' + obj.data[i]['H'] + ':' + obj.data[i]['i'] + ':' + obj.data[i]['s'] + ''; HtmlList += ' ' + obj.data[i]['text5'] + ''; HtmlList += ' '; HtmlList += ''; } else if (catid == 44) { HtmlList += '
  • '; HtmlList += '
    '; HtmlList += ' '; HtmlList += '
    '; HtmlList += '
    '; HtmlList += '

    ' + obj.data[i]['title'] + '

    '; HtmlList += ' ' + obj.data[i]['year'] + '-' + obj.data[i]['month'] + '-' + obj.data[i]['day'] + ''; HtmlList += '

    '; HtmlList += ' ' + obj.data[i]['description'] + '

    '; HtmlList += '
    '; HtmlList += '
  • '; } else { HtmlList += ''; HtmlList += ' ' + obj.data[i]['title'] + ''; HtmlList += ' ' + obj.data[i]['text3'] + ''; HtmlList += ' ' + obj.data[i]['text4'] + ''; HtmlList += ' ' + obj.data[i]['year'] + '-' + obj.data[i]['month'] + '-' + obj.data[i]['day'] + ''; HtmlList += ' '; HtmlList += ''; } } } else { if (catid == 40) { HtmlList = '抱歉,没有找到相关信息'; } else if (catid == 44) { HtmlList = '抱歉,没有找到相关信息'; } else { HtmlList = '抱歉,没有找到相关信息'; } } var PageHtml = ''; if (obj.data_page['recordcount'] > 0 && obj.data_page['pagecount']>1) { PageHtml+='
    '; PageHtml+='
    '; var disable = ''; var prevurl = 'javascript:productSearch(1)'; if (pageindex == 1) { disable = 'disable'; prevurl = 'javascript:void(0);'; } PageHtml += ''; PageHtml += obj.data_page['list']; var nextdisable = ''; var nexturl = 'javascript:productSearch(' + obj.pagecount + ')'; if (pageindex == obj.pagecount) { nextdisable = 'disable'; nexturl = 'javascript:void(0);'; } PageHtml += ''; PageHtml += '' + obj.data_page['pageindex'] + '/' + obj.data_page['pagecount'] + ''; PageHtml += ''; PageHtml += ' '; PageHtml += ' '; PageHtml += 'GO'; PageHtml += '
    '; PageHtml += '
    '; PageHtml += obj.data_page['PageHtml']; } $("#public_AjaxList").html(HtmlList); $("#public_AjaxPage").html(PageHtml); }); } function ajaxPublicSearch(data, fn) { $.ajax({ "type": "post", "url": "/index.php?g=Contents&m=Index&a=public_ajax_search", "data": data, "datatype": "html", "success": function (msg) { if (fn) { fn(msg); } }, "error": function () { /*alert("对不起,服务器繁忙请稍后重试");*/ } }); } /*-----------------------------搜索结果绑定-------------------------------------------------------------------------*/ $(function () { $('#btnSearch').click(function () { search(); }); function search() { if ($.trim($("#formd_search_id").val()) == '' || $.trim($("#formd_search_id").val()) == "search...") { $('#formd_search_id').focus(); alert("请输入关键词!"); return false; } else { window.location = "/other/search.html?key=" + encodeURIComponent($.trim($("#formd_search_id").val())); } } }) $(function () { $('#btnSearch1').click(function () { search1(); }); function search1() { if ($.trim($("#formd_search_id1").val()) == '' || $.trim($("#formd_search_id1").val()) == "search...") { $('#formd_search_id1').focus(); alert("请输入关键词!"); return false; } else { window.location = "/other/search.html?key=" + encodeURIComponent($.trim($("#formd_search_id1").val())); } } }) $(function () { $('#btnSearch2').click(function () { search2(); }); function search2() { if ($.trim($("#formd_search_id2").val()) == '' || $.trim($("#formd_search_id2").val()) == "search...") { $('#formd_search_id2').focus(); alert("请输入关键词!"); return false; } else { window.location = "/other/search.html?key=" + encodeURIComponent($.trim($("#formd_search_id2").val())); } } }) $(function () { $('#btnSearch3').click(function () { search3(); }); function search3() { if ($.trim($("#formd_search_id3").val()) == '' || $.trim($("#formd_search_id3").val()) == "search...") { $('#formd_search_id3').focus(); alert("请输入关键词!"); return false; } else { window.location = "/other/search.html?key=" + encodeURIComponent($.trim($("#formd_search_id3").val())); } } }) //危险字符过滤 $(function () { $(document).on('keyup', 'input[type=text],textarea,input[type=password]', function () { var val = $(this).val().toLocaleLowerCase(); var otherKey = " and | exec | count | chr | mid | master | or | truncate | char | declare | join |<|>|/*|*/|;|\\u|insert|select|delete|update|create|drop|script|javascript|alert"; var goon = true; for (var i = 0; i < otherKey.split('|').length ; i++) { if (goon) { if (val.indexOf(otherKey.split('|')[i]) != -1) { alert("不能包含危险字符!"); $(this).val(''); goon = false; return; } } } }); }) function checkSQL(tempKey) { var val = tempKey; var otherKey = " and | exec | count | chr | mid | master | or | truncate | char | declare | join |<|>|*|/*|*/|;|\\u|insert|select|delete|update|create|drop|script|javascript|alert"; var goon = true; for (var i = 0; i < otherKey.split('|').length ; i++) { if (goon) { if (val.indexOf(otherKey.split('|')[i]) != -1) { goon = false; } } } return goon; } var classid = ''; var key = ''; var ToPage = function (pageIndex) { console.log(pageIndex); if (!checkSQL(key)) { alert("请不要包含危险字符!"); window.location.href="/index.html"; return false; } if(pageIndex==1){ $("#AjaxList").html(""); } var html_start=$("#html_start").val(); var html_end=$("#html_end").val(); var pageclass=$("#pageClass").val(); var pagesize=$("#pagesize").val(); var updatetime=$("#updatetime").val(); var listhtml=$("#listhtml").val(); var pagehtml=$("#pagehtml").val(); $.ajax({ type: "post", url: "/index.php?a=qwsearch", data: { pageindex: pageIndex, pagesize: pagesize, key: key, html_start: html_start, html_end: html_end, pageclass: pageclass, updatetime: updatetime, listhtml: listhtml, pagehtml: pagehtml }, success: function (msg) { var obj = eval('(' + msg + ')'); $('#AjaxList').html(obj.ListHtml.toString()); $('#AjaxPageList').html(obj.PageHtml.toString()); $('#searchNum').html(obj.RecordCount); $('#formd_search_id').val(key); $('#searchText').html('"'+key+'"'); $('#formd_search_id1').val(key); $('#formd_search_id2').val(key); } }) } /*----------------------当前位置定位-------------------*/ $(function () { var MenuName = $.trim($("div.site>a:eq(1)").text()); $('.nav>ul>li>a').map(function () { if ($.trim($(this).text()) == MenuName) { $(this).parent().addClass('on').siblings().removeClass('on'); } }); var MenuName = $.trim($("div.site>span").text()); $('.nav>ul>li>a').map(function () { if ($.trim($(this).text()) == MenuName) { $(this).parent().addClass('on').siblings().removeClass('on'); } }); }) /*----------------------动态加载公共模板--------------------*/ function getAajaxInclude(dataUrl,element) { $.ajax({ "type": "get", "url": "" + dataUrl+"", "datatype": "html", "success": function (msg) { $(element).html(msg); }, "error": function (e) { } }) } /*------------------文字转语音------------------------*/ $(".audio_btn").click(function () { var count = 0; var Timer = null; var target = $("#audiodiv audio:eq(" + count + ")").get(0); if (target.paused) { target.play(); $(".audio_btn").addClass("pause"); } else { target.pause(); $(".audio_btn").removeClass("pause"); } Timer = setInterval(function () { $("#audiodiv audio:eq(" + count + ")").get(0).onended = function () { $("#audiodiv audio:eq(" + count + ")").get(0).pause(); count = count + 1; $("#audiodiv audio:eq(" + count + ")").get(0).play(); }; $("#audiodiv audio:last").get(0).onended = function () { $(".audio_btn").removeClass("pause"); }; }, 10) })