/** * 涓昏涓轰簡瀹炵幇鏂囩珷璇勪环鍔熻兘 * add by lcfeng */ ; (function($) { $.fn.wpvisitcount = function(options) { var defaults = {}; var options = $.extend(defaults, options); $(this).each(function() { var url = $(this).attr("url"); if (url) { initvisitcount(url, $(this)); } }); //鍒濆鍖栬闂鏁? function initvisitcount(url, obj) { $.ajax({ type: "post", datatype: "text", url: url, success: function(result) { if (result !== '' && result !== '0' && result !== '0') { obj.html(result); obj.show(); } }, error: function(error) { } }); } }; $.fn.wpcollistvisitcount = function(options) { var defaults = {}; var options = $.extend(defaults, options); var colid = new array(); var colids = ""; $(this).each(function() { var id = $(this).attr("colid"); var siteid = $(this).attr("siteid"); id += "_" + siteid; colid.push(id); colid = unique(colid); }); colids = colid.join(","); if (colids == "") { return; } var url = ""; var con = $("script[sudy-wp-context]").attr("sudy-wp-context"); if (con) { con = "/" + con; url += con; } // url += "/_visitcountdisplay?columnids=" + colids; url += "/_visitcountdisplay?funtype=0"; var type = $("span[class=wp_colsvisitcount]").attr("type"); if (type) { url += "&type=" + type; } // url += "&funtype=0"; initcollistvisitcount(url, colids); }; function initcollistvisitcount(url, colids) { $.ajax({ url: url, datatype: 'json', type: 'post', data: {columnids: colids}, success: function(result) { if (result !== '' && result !== null) { $.each(result, function(n, value) { var listvisitcount = $("span[collistvisitcountid=wp_collistvisitcount_" + value.columnid + "]"); var oldcount = listvisitcount.html(); var num = oldcount > value.count ? (oldcount - value.count) : (value.count - oldcount); var total = value.count + num; listvisitcount.html(total); listvisitcount.css('visibility', 'visible'); }); } } }); } ; $.fn.wparticlereadstatus = function(options) { var defaults = {}; var options = $.extend(defaults, options); var artid = new array(); var articleids = ""; $(this).each(function() { var id = $(this).attr("artid"); artid.push(id); artid = unique(artid); }); articleids = artid.join(","); if (articleids != null && articleids != '') { var url = ""; var con = $("script[sudy-wp-context]").attr("sudy-wp-context"); if (con) { con = "/" + con; url += con; } url += "/_visitcountdisplay?articleids=" + articleids; var siteid = $("script[sudy-wp-siteid]").attr("sudy-wp-siteid"); if (siteid) { url += "&siteid=" + siteid; } url += "&funtype=1"; initreadstatus(url); } }; function unique(arr) { var res = []; var json = {}; for (var i = 0; i < arr.length; i++) { if (!json[arr[i]]) { res.push(arr[i]); json[arr[i]] = 1; } } return res; } function initreadstatus(url) { $.ajax({ url: url, datatype: 'text', type: "post", success: function(result) { if (result !== "") { var artids = result.split(","); for (var i = 0; i < artids.length; i++) { $("span[readstatusid=wp_artreadstauts_" + artids[i] + "]").addclass("wp_artreadstatus_unread"); } } } }); } ; $.fn.wplistvisitcount = function(options) { var defaults = {}; var options = $.extend(defaults, options); var artid = new array(); var articleids = ""; $(this).each(function() { var id = $(this).attr("artid"); artid.push(id); artid = unique(artid); }); articleids = artid.join(","); if (articleids != null && articleids != '') { var url = ""; var con = $("script[sudy-wp-context]").attr("sudy-wp-context"); if (con) { con = "/" + con; url += con; } url += "/_visitcountdisplay?articleids=" + articleids; var siteid = $("script[sudy-wp-siteid]").attr("sudy-wp-siteid"); if (siteid) { url += "&siteid=" + siteid; } var type = $("span[class=wp_listvisitcount]").attr("type"); if (type) { url += "&type=" + type; } url += "&funtype=0"; initlistvisitcount(url); } }; function initlistvisitcount(url) { $.ajax({ url: url, datatype: 'json', type: 'post', success: function(result) { if (result !== '' && result !== null) { $.each(result, function(n, value) { var listvisitcount = $("span[listvisitcountid=wp_listvisitcount_" + value.articleid + "]"); listvisitcount.html(value.count); listvisitcount.css('visibility', 'visible'); }); } } }); } ; })(jquery); $(document).ready(function() { if ($('.wp_visitcount').hasclass('wp_visitcount')) { $('.wp_visitcount').wpvisitcount(); } if ($('.wp_artreadstatus').hasclass('wp_artreadstatus')) { $('.wp_artreadstatus').wparticlereadstatus(); } if ($('.wp_listvisitcount').hasclass('wp_listvisitcount')) { $('.wp_listvisitcount').wplistvisitcount(); } if ($('.wp_colsvisitcount').hasclass('wp_colsvisitcount')) { $('.wp_colsvisitcount').wpcollistvisitcount(); } }); //涓嬮潰杩欎釜鏍规嵁ip鑾峰彇鍦板潃鐨勬帴鍙e潖浜嗭紝濡傛灉瑕佷娇鐢紝闇€瑕佸彟鎵炬帴鍙? //$().ready(function() { // $.ajax({ // type: 'get', // datatype: 'jsonp', // //url: "http://ip.chinaz.com/ajaxsync.aspx?at=ip&ip=" + ip, //杩欓噷鏄痷rl // url: "http://ip.chinaz.com/getip.aspx",//璋冪敤url杩斿洖ip鍜屾潵璁垮湴鍧€ 杩斿洖鍊納ip:'xxx.xxx.xxx.xxx',address:'姹熻嫃鐪佸崡浜競 鐢典俊'} // success: function(data) { // var address = data.address.replace("鐢典俊", "").replace("绉诲姩","").replace("鑱旈€?","");//鍙栧嚭鍦板潃骞朵笖灏嗛噷闈㈢殑杩愯惀鍟嗗幓鎺? // document.cookie = "ipaddressname=" + escape(address) + ";path=/; ";//灏嗗湴鍧€淇℃伅濉炲叆cookie // }, // error: function() { // // } // }); //})