function list() {//全部年份
$.ajax({
url : "http://www.dg.gov.cn/u/zfgb/getdate/wxqkh",
type : "POST",
dataType : "jsonp",
jsonp : "JsonpCallBack",
success : function(result) {
for ( var i = 0; i < result.length; i++) {
if (result[i].tyep == "1") {
$("#all_year").append(
"
"
+ result[i].name + "")
}
}
}
});
}
var title="";
function search(){
$(".tcc_search").show();
$(".td2").hide();
$(".td4").show();
var words = encodeURI($(".words").val());
title=$(".words").val();
$("#keywords").val(title);
$
.ajax({
url : "http://www.dg.gov.cn/u/zfgb/getdate/getZFGBNDWX",
type : "POST",
data : {
"keywords" : words,
"currentPage" : 6
},
dataType : "jsonp",
jsonp : "JsonpCallBack",
success : function(data) {
$(".journal_list").hide();
$(".keywords_list").show();
$(".keywords_list li").remove();
$(".keywords_list p").remove();
$("#search_rule option").remove();
$("#search_rule").append("");
if (data.value.length <= 0) {
$(".keywords_list")
.append(
"---未找到相关内容---
");
} else if (data.value.length == 1) {
$(".keywords_list")
.append(
"
"
+ data.value[0].title
+ "发布时间:"
+ (new Date(
data.value[0].published_time.time))
.Format("yyyy-MM-dd")
+ "")
} else {
for ( var i = data.value.length - 1; i > 0; i--) {// 按时间进行降序排列
$(".keywords_list")
.append(
""
+ data.value[i].title
+ "发布时间:"
+ (new Date(
data.value[i].published_time.time))
.Format("yyyy-MM-dd")
+ "")
}
}
}
});
}
function theYear(value) {//搜索列表里的年份跳转
$.ajax({
url : "http://www.dg.gov.cn/u/zfgb/getdate/wxqkh",
type : "POST",
dataType : "jsonp",
jsonp : "JsonpCallBack",
success : function(result) {
$(".journal_list").show();
$(".keywords_list").hide();
$("#search_journal li").remove();//清除每次append标签添加的元素
for ( var i = 0; i < result.length; i++) {
if (result[i].tyep == "2"
&& result[i].value.substring(0, 4) == value) {
$("#search_journal").append(
""
+ result[i].value.substring(0, 4)
+ "年" + result[i].name
+ "
")
}
}
}
});
}
function journal(value) {//每一个年份对应的期刊
$.ajax({
url : "http://www.dg.gov.cn/u/zfgb/getdate/wxqkh",
type : "POST",
dataType : "jsonp",
jsonp : "JsonpCallBack",
success : function(result) {
$(".tcc").show();
$(".tcc_list.mar-t4").show();
$(".sfwj.mar-search").hide();
$("#all_journal li").remove();//清除每次append标签添加的元素
$(".tcc_search").hide();
for ( var i = 0; i < result.length; i++) {
if (result[i].tyep == "2"
&& result[i].value.substring(0, 4) == value) {
$("#all_journal").append(
""
+ result[i].value.substring(0, 4)
+ "年" + result[i].name
+ "
")
}
}
}
});
}
Date.prototype.Format = function(fmt) { //把毫秒数时间转化成需要的格式化时间
var o = {
"M+" : this.getMonth() + 1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth() + 3) / 3), //季度
"S" : this.getMilliseconds()
//毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "")
.substr(4 - RegExp.$1.length));
for ( var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
: (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
};
function catalog(value) {//每一份期刊对应的具体目录
$
.ajax({
url : "https://www.dg.gov.cn/u/zfgb/getdate/getZFGBWX",
type : "GET",
data : {
"issue" : value
},
dataType : "jsonp",
jsonp : "JsonpCallBack",
success : function(result) {
$(".tc").show();
$(".detail_data p").remove();
$(".detail_data span").remove();
$(".sfwj.mar-t3 li").remove();
$(".zfwj").html("");
$(".zfbgs").html("");
$(".rsrm").html("");
$(".dl_div p").html("东莞市人民政府公报-" + result.name);
$(".detail_data").append(""+result.name.substring(0, 5)+"
"+result.name.substring(5, 9)+"");
$(".checkPDF span").remove();//清除每次append标签添加的元素
$(".checkPDF")
.append(
"点击查看PDF");
if (result.zfwj.length > 0) {
$(".zfwj").html("市政府文件");
for ( var i = 0; i < result.zfwj.length; i++) {
$(".zfwj + ul")
.append(
""
+ "发布时间:"
+ (new Date(
result.zfwj[i].published_time.time))
.Format("yyyy-MM-dd")
+ ""+ result.zfwj[i].title+"")
}
}
if (result.zfbgs.length > 0) {
$(".zfbgs").html("市政府办公室文件");
for ( var i = 0; i < result.zfbgs.length; i++) {
$(".zfbgs + ul")
.append(
""
+ "发布时间:"
+ (new Date(
result.zfbgs[i].published_time.time))
.Format("yyyy-MM-dd")
+ ""+ result.zfbgs[i].title+"")
}
}
if (result.rsrm.length > 0) {
$(".rsrm").html("人事任免")
for ( var i = 0; i < result.rsrm.length; i++) {
$(".rsrm + ul")
.append(
""
+ "发布时间:"
+ (new Date(
result.rsrm[i].published_time.time))
.Format("yyyy-MM-dd")
+ ""+ result.rsrm[i].title+"")
}
}
}
});
}
function checkPDF(id) {//查看PDF
$
.ajax({
url : "https://www.dg.gov.cn/u/zfgb/getPdf",
type : "POST",
data : {
"issue" : id
},
dataType : "jsonp",
jsonp : "JsonpCallBack",
success : function(result) {
if (result.list.length == 0) {
alert("暂无PDF")
} else {
window.open("http://www.dg.gov.cn"
+ result.list[0].IMGURL);
}
}
});
}
function detail(id) { //标题对应的具体内容
window.open("http://www.dg.gov.cn"+ id);
}
function searchList() { //按期查询的期刊列表
$.ajax({
url : "https://www.dg.gov.cn/u/zfgb/getdate/wxqkh",
type : "POST",
dataType : "jsonp",
jsonp : "JsonpCallBack",
success : function(data) {
for ( var i = 0; i < data.length; i++) {
if (data[i].name.length == 4) {
$("#searchByData").append(
"");
} else {
$("#searchByData").append(
"");
}
}
}
});
}
function searchByData() {//选中option的跳转事件
var myselect = document.getElementById("searchByData");
var index = myselect.selectedIndex;
if(myselect.options[index].value.length==4){
theYear(myselect.options[index].value);
}else{
catalog(myselect.options[index].value);
}
}
function keywordsSearch() {//关键字查询
var keyword = encodeURI($(".keywords").val());
title=$(".keywords").val();
$("#keywords").val(title);
$.ajax({
url : "http://www.dg.gov.cn/u/zfgb/getdate/getZFGBNDWX",
type : "POST",
data : {
"keywords" : keyword,
"currentPage":6
},
dataType : "jsonp",
jsonp : "JsonpCallBack",
success : function(data) {
$(".journal_list").hide();
$(".keywords_list").show();
$(".keywords_list li").remove();
$(".keywords_list p").remove();
if (data.value.length <= 0) {
$(".keywords_list")
.append(
"---未找到相关内容---
");
} else if (data.value.length == 1) {
$(".keywords_list")
.append(
"
"
+ data.value[0].title
+ "发布时间:"
+ (new Date(
data.value[0].published_time.time))
.Format("yyyy-MM-dd")
+ "")
} else {
for ( var i = data.value.length - 1; i > 0; i--) {// 按时间进行降序排列
$(".keywords_list")
.append(
""
+ data.value[i].title
+ "发布时间:"
+ (new Date(
data.value[i].published_time.time))
.Format("yyyy-MM-dd")
+ "")
}
}
}
});
}
function search_rule(){
var myselect = document.getElementById("search_rule");
var index = myselect.selectedIndex;
if(myselect.options[index].value==1){
$(".td2").hide();
$(".td4").show();
}
if(myselect.options[index].value==2){
$(".td2").show();
$(".td4").hide();
}
}