jQuery.cookie = function (name, value, options) {
if (typeof value != 'undefined') {
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString();
}
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};
// JavaScript Document
$(function () {
var mydate = new Date();
var thisyear = mydate.getFullYear();
var thismonth = mydate.getMonth() + 1;
var thisday = mydate.getDate();
//鏃ユ湡鍒濆濉厖
function initdata() {
var days = getdaysinonemonth(thisyear, thismonth);//杩欎釜鏈堢殑澶╂暟
var preDays = getdaysinonemonth(thisyear, thismonth - 1);//涓婁釜鏈堢殑澶╂暟
var weekday = getfirstday(thisyear, thismonth);//绗竴澶╂槦鏈熷嚑
if (weekday == 0) {
weekday = 7;
}
$('.month_name').text(thismonth + '鏈堜唤');
$('.year_name').text(thisyear);
setcalender(days, weekday, preDays, thisday, thisyear, thismonth);
}
initdata();
//鐐瑰嚮涓婁釜鏈
$('.month .prev').click(function (e) {
thismonth--;
if (thismonth == 0) {
thismonth = 12;
thisyear--;
}
initdata();
});
//鐐瑰嚮涓嬩釜鏈
$('.month .next').click(function (e) {
thismonth++;
if (thismonth == 13) {
thismonth = 1;
thisyear++;
}
initdata();
});
//鐐瑰嚮鍘诲勾
$('.year .prev').click(function (e) {
thisyear--;
initdata();
});
//鐐瑰嚮鏄庡勾
$('.year .next').click(function (e) {
thisyear++;
initdata();
});
//濉厖鏃ユ湡琛ㄦ牸
function setcalender(days, weekday, preDays, thisday, thisyear, thismonth) {
//$(".data_table tbody tr:even td").css('background', '#ebeefd');
var a = 1;
var b = 1;
var c = preDays - weekday + 1;
var trNum = days + weekday - 1;
if (trNum < 27) {
//$('.calendar').height(217);
$('.calendar table tbody tr:eq(4),.calendar table tbody tr:eq(5)').hide();
} else if (trNum > 35) {
$('.calendar table tbody tr').show();
} else {
$('.calendar table tbody tr:eq(5)').hide();
}
//杞崲骞存湀鏃ヤ负瀛楃涓
thisyear = thisyear.toString();
if (thismonth < 10) {
thismonth = "0" + thismonth.toString();
}
for (var j = 0; j < 6; j++) {
for (var i = 0; i < 7; i++) {
if (j == 0 && i < weekday - 1) {
//绗竴琛屼笂涓湀鐨
c++;
$(".data_table tbody tr").eq(0).find("td").eq(i).html(c);
$(".data_table tbody tr").eq(0).find("td").eq(i).addClass("unselected_month preM");
} else {
//杩欎釜鏈堢殑鍐呭
if (a > days) {
//涓嬩釜鏈堝姞鐏板鐞
$(".data_table tbody tr").eq(j).find("td").eq(i).html(b);
$(".data_table tbody tr").eq(j).find("td").eq(i).addClass("unselected_month nextM");
b++;
} else {
//濡傛灉鏄?0鍙蜂互鍓嶇殑鍔?
if (a < 10) {
a = "0" + a.toString();
}
//娣诲姞琛ㄦ牸鏃ユ湡鍐呭
var thisValue = thisyear + thismonth + a;
$(".data_table tbody tr").eq(j).find("td").eq(i).html("
" + a + "
").attr('value', thisValue);
$(".data_table tbody tr").eq(j).find("td").eq(i).addClass('usual_day').removeClass("unselected_month preM nextM");
/*if(a==thisday){//浠婂ぉ
$(".data_table tbody tr").eq(j).find("td").eq(i).find(".riqi").addClass("bgHover");
$(".data_table tbody tr").eq(j).find("td").eq(i).find(".riqi").has('.piaofu ul li').addClass('current');
}*/
a++;
}
}
}
}
var sitedomain = document.getElementsByTagName('meta')['SiteDomain'].getAttribute('content') + "";
var cataid = "";
var contextpath = "/szinf/interfacesWebLdzc/common?websiteId=d1a6129dfff94475b389f8da120deb79&channelCode=ldszwqw&month=" + thisyear + '-' + thismonth;
cataid = $("#strcolumnid").val();
var htmlobj = $.ajax({
url: contextpath, // 鎻愪氦鍒癱ontroller鐨剈rl璺緞
type: "get", // 鎻愪氦鏂瑰紡
async: false,
// data: {"cataid": cataid, "strDate": thisyear}, // data涓篠tring绫诲瀷锛屽繀椤讳负 Key/Value 鏍煎紡銆
dataType: "String", // 鏈嶅姟鍣ㄧ杩斿洖鐨勬暟鎹被鍨
success: function (result) {
// console.log(result);
return result;
}
});
var jsonText = htmlobj.responseText;
// console.log(jsonText)
// var front = parseInt(jsonText.indexOf("["));
// var end = parseInt(jsonText.indexOf("]"));
// if (front >= 0 && end >= 0) {
// jsonText = jsonText.substring(front, end + 1);
// } else {
// jsonText = "";
// }
//var json1=eval(jsonText);
//if($.trim(json1)){
// var json1 = eval($.trim(jsonText));
var json1 = JSON.parse(jsonText) && JSON.parse(jsonText).data && JSON.parse(jsonText).data.list;
// console.log(json1)
if (json1) {
for (var j = 0; j < 6; j++) {
for (var i = 0; i < 7; i++) {
var thisValue = $(".data_table tbody tr").eq(j).find("td").eq(i).attr('value');
// console.log(thisValue)
for (k = 0; k < json1.length; k++) {
var SUB_TITLE = json1[k].publishedTimeFormat;
var URL = json1[k].url;
var TITLE = json1[k].title;
// console.log(SUB_TITLE.replaceAll('-', '').substr(0, 8))
if (thisValue == SUB_TITLE.replaceAll('-', '').substr(0, 8)) {
// console.log(thisValue, SUB_TITLE)
$(".data_table tbody tr").eq(j).find("td").eq(i).find('.riqi .piaofu ul').append("
" + TITLE + "");
}
}
}
}
}
$(".data_table tbody tr td .riqi").has('.piaofu ul li').css({
'text-decoration': 'underline',
'color': '#2a82e4'
});
$(".sz-cal").show();
// $(".sz-cal").css('display','block');
// $('.ldxx-right ul:first').css({
// 'width': '45%', 'float': 'left'
// })
// $('.ldxx-right .sz-cal').css({
// 'float': 'right',
// 'margin-top': '5px'
// })
$('.xxgk_boxh1').css({'min-height': '540px',/*'overflow':'visible',*/})
}
//绠楁煇涓湀鐨勬€诲ぉ鏁
function getdaysinonemonth(year, month) {
month = parseInt(month, 10);
var d = new Date(year, month, 0);
return d.getDate();
}
//绠楁煇涓湀鐨勭涓€澶╂槸鏄熸湡鍑
function getfirstday(year, month) {
month = month - 1;
var d = new Date(year, month, 1);
return d.getDay();
}
var parentOffset = $('.calendar').offset().left + $('.calendar').outerWidth()
//榧犳爣婊戣繃鏃ユ湡
$(".data_table tr td").on('mouseover tap',function (e) {
$('.data_table tr td .riqi').removeClass('current bgHover');
$(this).find('.riqi').addClass('bgHover');
$(this).find('.riqi').has('.piaofu ul li').addClass('current');
/* 寮圭獥瓒呰繃宸﹁竟鐣?/
var cur = $(this).find('.riqi.current')
var curPiaofu = cur.find('.piaofu')
if(cur.length > 0 && curPiaofu.offset().left + curPiaofu.outerWidth() > parentOffset){
curPiaofu.addClass('right-over')
}else if(cur.length > 0 && curPiaofu.offset().left < $('.calendar').offset().left){
curPiaofu.addClass('left-over')
}
});
//榧犳爣绂诲紑鏃ユ湡
$(".data_table").mouseleave(function (e) {
$('.data_table tr td .riqi').removeClass('current bgHover');
});
});