/*! * CT-BOX JavaScript * v1.0.9.4 CT-BOX 版 * http://www.ct-box.net/ * Copyright 2011, CT-BOX service * Date: 2011-12-22 * 更改: * 改$.getJSON的參數傳遞方式,寫在第二參數和callback處理, 參數不用encodeURIComponent */ Array.prototype.unique = function() { var a = []; var l = this.length; for(var i=0; i>> (32 - iShiftBits)); }; var addUnsigned = function (lX, lY) { var lX4, lY4, lX8, lY8, lResult; lX8 = (lX & 0x80000000); lY8 = (lY & 0x80000000); lX4 = (lX & 0x40000000); lY4 = (lY & 0x40000000); lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF); if (lX4 & lY4) { return (lResult ^ 0x80000000 ^ lX8 ^ lY8); } if (lX4 | lY4) { if (lResult & 0x40000000) { return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); } else { return (lResult ^ 0x40000000 ^ lX8 ^ lY8); } } else { return (lResult ^ lX8 ^ lY8); } }; var _F = function (x, y, z) { return (x & y) | ((~x) & z); }; var _G = function (x, y, z) { return (x & z) | (y & (~z)); }; var _H = function (x, y, z) { return (x ^ y ^ z); }; var _I = function (x, y, z) { return (y ^ (x | (~z))); }; var _FF = function (a, b, c, d, x, s, ac) { a = addUnsigned(a, addUnsigned(addUnsigned(_F(b, c, d), x), ac)); return addUnsigned(rotateLeft(a, s), b); }; var _GG = function (a, b, c, d, x, s, ac) { a = addUnsigned(a, addUnsigned(addUnsigned(_G(b, c, d), x), ac)); return addUnsigned(rotateLeft(a, s), b); }; var _HH = function (a, b, c, d, x, s, ac) { a = addUnsigned(a, addUnsigned(addUnsigned(_H(b, c, d), x), ac)); return addUnsigned(rotateLeft(a, s), b); }; var _II = function (a, b, c, d, x, s, ac) { a = addUnsigned(a, addUnsigned(addUnsigned(_I(b, c, d), x), ac)); return addUnsigned(rotateLeft(a, s), b); }; var convertToWordArray = function (str) { var lWordCount; var lMessageLength = str.length; var lNumberOfWords_temp1 = lMessageLength + 8; var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64; var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16; var lWordArray = new Array(lNumberOfWords - 1); var lBytePosition = 0; var lByteCount = 0; while (lByteCount < lMessageLength) { lWordCount = (lByteCount - (lByteCount % 4)) / 4; lBytePosition = (lByteCount % 4) * 8; lWordArray[lWordCount] = (lWordArray[lWordCount] | (str.charCodeAt(lByteCount) << lBytePosition)); lByteCount++; } lWordCount = (lByteCount - (lByteCount % 4)) / 4; lBytePosition = (lByteCount % 4) * 8; lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition); lWordArray[lNumberOfWords - 2] = lMessageLength << 3; lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29; return lWordArray; }; var wordToHex = function (lValue) { var wordToHexValue = "", wordToHexValue_temp = "", lByte, lCount; for (lCount = 0; lCount <= 3; lCount++) { lByte = (lValue >>> (lCount * 8)) & 255; wordToHexValue_temp = "0" + lByte.toString(16); wordToHexValue = wordToHexValue + wordToHexValue_temp.substr(wordToHexValue_temp.length - 2, 2); } return wordToHexValue; }; var utf8_encode =function (argString) { // http://kevin.vanzonneveld.net // + original by: Webtoolkit.info (http://www.webtoolkit.info/) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: sowberry // + tweaked by: Jack // + bugfixed by: Onno Marsman // + improved by: Yves Sucaet // + bugfixed by: Onno Marsman // + bugfixed by: Ulrich // + bugfixed by: Rafal Kukawski // * example 1: utf8_encode('Kevin van Zonneveld'); // * returns 1: 'Kevin van Zonneveld' if (argString === null || typeof argString === "undefined") { return ""; } var string = (argString + ''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n"); var utftext = "", start, end, stringl = 0; start = end = 0; stringl = string.length; for (var n = 0; n < stringl; n++) { var c1 = string.charCodeAt(n); var enc = null; if (c1 < 128) { end++; } else if (c1 > 127 && c1 < 2048) { enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128); } else { enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128); } if (enc !== null) { if (end > start) { utftext += string.slice(start, end); } utftext += enc; start = end = n + 1; } } if (end > start) { utftext += string.slice(start, stringl); } return utftext; } var x = [], k, AA, BB, CC, DD, a, b, c, d, S11 = 7, S12 = 12, S13 = 17, S14 = 22, S21 = 5, S22 = 9, S23 = 14, S24 = 20, S31 = 4, S32 = 11, S33 = 16, S34 = 23, S41 = 6, S42 = 10, S43 = 15, S44 = 21; str = utf8_encode(str); x = convertToWordArray(str); a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; xl = x.length; for (k = 0; k < xl; k += 16) { AA = a; BB = b; CC = c; DD = d; a = _FF(a, b, c, d, x[k + 0], S11, 0xD76AA478); d = _FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756); c = _FF(c, d, a, b, x[k + 2], S13, 0x242070DB); b = _FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE); a = _FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF); d = _FF(d, a, b, c, x[k + 5], S12, 0x4787C62A); c = _FF(c, d, a, b, x[k + 6], S13, 0xA8304613); b = _FF(b, c, d, a, x[k + 7], S14, 0xFD469501); a = _FF(a, b, c, d, x[k + 8], S11, 0x698098D8); d = _FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF); c = _FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1); b = _FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE); a = _FF(a, b, c, d, x[k + 12], S11, 0x6B901122); d = _FF(d, a, b, c, x[k + 13], S12, 0xFD987193); c = _FF(c, d, a, b, x[k + 14], S13, 0xA679438E); b = _FF(b, c, d, a, x[k + 15], S14, 0x49B40821); a = _GG(a, b, c, d, x[k + 1], S21, 0xF61E2562); d = _GG(d, a, b, c, x[k + 6], S22, 0xC040B340); c = _GG(c, d, a, b, x[k + 11], S23, 0x265E5A51); b = _GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA); a = _GG(a, b, c, d, x[k + 5], S21, 0xD62F105D); d = _GG(d, a, b, c, x[k + 10], S22, 0x2441453); c = _GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681); b = _GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8); a = _GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6); d = _GG(d, a, b, c, x[k + 14], S22, 0xC33707D6); c = _GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87); b = _GG(b, c, d, a, x[k + 8], S24, 0x455A14ED); a = _GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905); d = _GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8); c = _GG(c, d, a, b, x[k + 7], S23, 0x676F02D9); b = _GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A); a = _HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942); d = _HH(d, a, b, c, x[k + 8], S32, 0x8771F681); c = _HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122); b = _HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C); a = _HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44); d = _HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9); c = _HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60); b = _HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70); a = _HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6); d = _HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA); c = _HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085); b = _HH(b, c, d, a, x[k + 6], S34, 0x4881D05); a = _HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039); d = _HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5); c = _HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8); b = _HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665); a = _II(a, b, c, d, x[k + 0], S41, 0xF4292244); d = _II(d, a, b, c, x[k + 7], S42, 0x432AFF97); c = _II(c, d, a, b, x[k + 14], S43, 0xAB9423A7); b = _II(b, c, d, a, x[k + 5], S44, 0xFC93A039); a = _II(a, b, c, d, x[k + 12], S41, 0x655B59C3); d = _II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92); c = _II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D); b = _II(b, c, d, a, x[k + 1], S44, 0x85845DD1); a = _II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F); d = _II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0); c = _II(c, d, a, b, x[k + 6], S43, 0xA3014314); b = _II(b, c, d, a, x[k + 13], S44, 0x4E0811A1); a = _II(a, b, c, d, x[k + 4], S41, 0xF7537E82); d = _II(d, a, b, c, x[k + 11], S42, 0xBD3AF235); c = _II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB); b = _II(b, c, d, a, x[k + 9], S44, 0xEB86D391); a = addUnsigned(a, AA); b = addUnsigned(b, BB); c = addUnsigned(c, CC); d = addUnsigned(d, DD); } var temp = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d); return temp.toLowerCase(); } //Javascript Punycode converter derived from example in RFC3492. //This implementation is created by some@domain.name and released into public domain var punycode = new function Punycode() { // This object converts to and from puny-code used in IDN // // punycode.ToASCII ( domain ) // // Returns a puny coded representation of "domain". // It only converts the part of the domain name that // has non ASCII characters. I.e. it dosent matter if // you call it with a domain that already is in ASCII. // // punycode.ToUnicode (domain) // // Converts a puny-coded domain name to unicode. // It only converts the puny-coded parts of the domain name. // I.e. it dosent matter if you call it on a string // that already has been converted to unicode. // // this.utf16 = { // The utf16-class is necessary to convert from javascripts internal character representation to unicode and back. decode:function(input){ var output = [], i=0, len=input.length,value,extra; while (i < len) { value = input.charCodeAt(i++); if ((value & 0xF800) === 0xD800) { extra = input.charCodeAt(i++); if ( ((value & 0xFC00) !== 0xD800) || ((extra & 0xFC00) !== 0xDC00) ) { throw new RangeError("UTF-16(decode): Illegal UTF-16 sequence"); } value = ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000; } output.push(value); } return output; }, encode:function(input){ var output = [], i=0, len=input.length,value; while (i < len) { value = input[i++]; if ( (value & 0xF800) === 0xD800 ) { throw new RangeError("UTF-16(encode): Illegal UTF-16 value"); } if (value > 0xFFFF) { value -= 0x10000; output.push(String.fromCharCode(((value >>>10) & 0x3FF) | 0xD800)); value = 0xDC00 | (value & 0x3FF); } output.push(String.fromCharCode(value)); } return output.join(""); } } //Default parameters var initial_n = 0x80; var initial_bias = 72; var delimiter = "\x2D"; var base = 36; var damp = 700; var tmin=1; var tmax=26; var skew=38; var maxint = 0x7FFFFFFF; // decode_digit(cp) returns the numeric value of a basic code // point (for use in representing integers) in the range 0 to // base-1, or base if cp is does not represent a value. function decode_digit(cp) { return cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 : cp - 97 < 26 ? cp - 97 : base; } // encode_digit(d,flag) returns the basic code point whose value // (when used for representing integers) is d, which needs to be in // the range 0 to base-1. The lowercase form is used unless flag is // nonzero, in which case the uppercase form is used. The behavior // is undefined if flag is nonzero and digit d has no uppercase form. function encode_digit(d, flag) { return d + 22 + 75 * (d < 26) - ((flag != 0) << 5); // 0..25 map to ASCII a..z or A..Z // 26..35 map to ASCII 0..9 } //** Bias adaptation function ** function adapt(delta, numpoints, firsttime ) { var k; delta = firsttime ? Math.floor(delta / damp) : (delta >> 1); delta += Math.floor(delta / numpoints); for (k = 0; delta > (((base - tmin) * tmax) >> 1); k += base) { delta = Math.floor(delta / ( base - tmin )); } return Math.floor(k + (base - tmin + 1) * delta / (delta + skew)); } // encode_basic(bcp,flag) forces a basic code point to lowercase if flag is zero, // uppercase if flag is nonzero, and returns the resulting code point. // The code point is unchanged if it is caseless. // The behavior is undefined if bcp is not a basic code point. function encode_basic(bcp, flag) { bcp -= (bcp - 97 < 26) << 5; return bcp + ((!flag && (bcp - 65 < 26)) << 5); } // Main decode this.decode=function(input,preserveCase) { // Dont use utf16 var output=[]; var case_flags=[]; var input_length = input.length; var n, out, i, bias, basic, j, ic, oldi, w, k, digit, t, len; // Initialize the state: n = initial_n; i = 0; bias = initial_bias; // Handle the basic code points: Let basic be the number of input code // points before the last delimiter, or 0 if there is none, then // copy the first basic code points to the output. basic = input.lastIndexOf(delimiter); if (basic < 0) basic = 0; for (j = 0; j < basic; ++j) { if(preserveCase) case_flags[output.length] = ( input.charCodeAt(j) -65 < 26); if ( input.charCodeAt(j) >= 0x80) { throw new RangeError("Illegal input >= 0x80"); } output.push( input.charCodeAt(j) ); } // Main decoding loop: Start just after the last delimiter if any // basic code points were copied; start at the beginning otherwise. for (ic = basic > 0 ? basic + 1 : 0; ic < input_length; ) { // ic is the index of the next character to be consumed, // Decode a generalized variable-length integer into delta, // which gets added to i. The overflow checking is easier // if we increase i as we go, then subtract off its starting // value at the end to obtain delta. for (oldi = i, w = 1, k = base; ; k += base) { if (ic >= input_length) { throw RangeError ("punycode_bad_input(1)"); } digit = decode_digit(input.charCodeAt(ic++)); if (digit >= base) { throw RangeError("punycode_bad_input(2)"); } if (digit > Math.floor((maxint - i) / w)) { throw RangeError ("punycode_overflow(1)"); } i += digit * w; t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias; if (digit < t) { break; } if (w > Math.floor(maxint / (base - t))) { throw RangeError("punycode_overflow(2)"); } w *= (base - t); } out = output.length + 1; bias = adapt(i - oldi, out, oldi === 0); // i was supposed to wrap around from out to 0, // incrementing n each time, so we'll fix that now: if ( Math.floor(i / out) > maxint - n) { throw RangeError("punycode_overflow(3)"); } n += Math.floor( i / out ) ; i %= out; // Insert n at position i of the output: // Case of last character determines uppercase flag: if (preserveCase) { case_flags.splice(i, 0, input.charCodeAt(ic -1) -65 < 26);} output.splice(i, 0, n); i++; } if (preserveCase) { for (i = 0, len = output.length; i < len; i++) { if (case_flags[i]) { output[i] = (String.fromCharCode(output[i]).toUpperCase()).charCodeAt(0); } } } return this.utf16.encode(output); }; //** Main encode function ** this.encode = function (input,preserveCase) { //** Bias adaptation function ** var n, delta, h, b, bias, j, m, q, k, t, ijv, case_flags; if (preserveCase) { // Preserve case, step1 of 2: Get a list of the unaltered string case_flags = this.utf16.decode(input); } // Converts the input in UTF-16 to Unicode input = this.utf16.decode(input.toLowerCase()); var input_length = input.length; // Cache the length if (preserveCase) { // Preserve case, step2 of 2: Modify the list to true/false for (j=0; j < input_length; j++) { case_flags[j] = input[j] != case_flags[j]; } } var output=[]; // Initialize the state: n = initial_n; delta = 0; bias = initial_bias; // Handle the basic code points: for (j = 0; j < input_length; ++j) { if ( input[j] < 0x80) { output.push( String.fromCharCode( case_flags ? encode_basic(input[j], case_flags[j]) : input[j] ) ); } } h = b = output.length; // h is the number of code points that have been handled, b is the // number of basic code points if (b > 0) output.push(delimiter); // Main encoding loop: // while (h < input_length) { // All non-basic code points < n have been // handled already. Find the next larger one: for (m = maxint, j = 0; j < input_length; ++j) { ijv = input[j]; if (ijv >= n && ijv < m) m = ijv; } // Increase delta enough to advance the decoder's // state to , but guard against overflow: if (m - n > Math.floor((maxint - delta) / (h + 1))) { throw RangeError("punycode_overflow (1)"); } delta += (m - n) * (h + 1); n = m; for (j = 0; j < input_length; ++j) { ijv = input[j]; if (ijv < n ) { if (++delta > maxint) return Error("punycode_overflow(2)"); } if (ijv == n) { // Represent delta as a generalized variable-length integer: for (q = delta, k = base; ; k += base) { t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias; if (q < t) break; output.push( String.fromCharCode(encode_digit(t + (q - t) % (base - t), 0)) ); q = Math.floor( (q - t) / (base - t) ); } output.push( String.fromCharCode(encode_digit(q, preserveCase && case_flags[j] ? 1:0 ))); bias = adapt(delta, h + 1, h == b); delta = 0; ++h; } } ++delta, ++n; } return output.join(""); } this.ToASCII = function ( domain ) { var domain_array = domain.split("."); var out = []; for (var i=0; i < domain_array.length; ++i) { var s = domain_array[i]; out.push( s.match(/[^A-Za-z0-9-]/) ? "xn--" + punycode.encode(s) : s ); } return out.join("."); } this.ToUnicode = function ( domain ) { var domain_array = domain.split("."); var out = []; for (var i=0; i < domain_array.length; ++i) { var s = domain_array[i]; out.push( s.match(/^xn--/) ? punycode.decode(s.slice(4)) : s ); } return out.join("."); } }(); function ctb(){} //2010.12.06 處理url有參數帶&的問題 &=>+++ //加入domain punycode處理中文網址問題 ctb.domain = punycode.ToASCII(window.location.href.match(/:\/\/(.[^/]+)/)[1]); ctb.url = ctb.domain + window.location.href.match(/:\/\/.[^/]+(.+)/)[1]; ctb.url = ctb.url.replace(/[?&]/g, "__"); //GET傳輸長度限制,以瀏覽器為主 ctb.strlen ; //blog標題文字 ctb.titleStr ; //blog內容文字 ctb.contentStr ; //blog smarty xml內容 ctb.ctbContent ; //ct1~5 xml內容 ctb.ctbTagContent ; //偵測在哪個Blog ctb.blogName ; //md5碼, url + xml + user_key ctb.md5 ; //判斷如為IE9以下且字數超過限制,則傳rl=1,否則rl=0 ctb.rl = 0; //最慢顯示隱藏div的時間 ctb.showTime = 3000; //RE表達,照順序取代 //去除空白,包含全型空白 var spaceReg = /^[\s]+|[\s]+| |\u3000+/gi ; //去除tag var tagReg = /<[^>]*>/gi ; //2010.12.10去除連接符號和]]> var andReg = /&|]]>|<|>/gi ; ctb.tag = { 0:"ct0",1:"ct1",2:"ct2",3:"ct3",4:"ct4",5:"ct5",6:"ct6",7:"ct7",8:"ct8",9:"ct9",10:"ct10" } ctb.jQueryStyle = { "yam": {"title": ".post_titlediv", "content": ".post_body .post_content" }, "pixnet": {"title": ".article-head .title", "content": ".article-body .article-content" }, "xuite": {"title": ".title .titlename", "content": ".blogbody #content_all" }, "blogspot": {"title": ".post-title", "content": ".post-body" }, "roodo": {"title": ".title", "content": ".main" }, "sina": {"title": "h3.title", "content": ".blogbody" }, "udn": {"title": ".main-topic", "content": ".main-text" }, "imtv": {"title": ".PostTitle", "content": ".postshortcontent" }, "liontravel": {"title": ".post h3", "content": ".post-content" } } ctb.cssStyle = { "yam": {"title": ".post_titlediv", "content": ".post_content" }, "pixnet": {"title": ".title", "content": ".article-content" }, "xuite": {"title": "span.titlename", "content": "#content_all" }, "blogspot": {"title": "h3.post-title,h3.post-title a", "content": ".post-body" }, "roodo": {"title": "h3.title", "content": ".main" }, "sina": {"title": "h3.title", "content": ".blogbody" }, "udn": {"title": ".main-topic", "content": ".main-text" }, "imtv": {"title": ".PostTitle", "content": ".postshortcontent" }, "liontravel": {"title": ".post h3", "content": ".post-content" } } //取得blog文字 ctb.getBlogText = function(){ ctb.titleStr = $(ctb.jQueryStyle[ctb.blogName]['title']).text(); ctb.contentStr = $(ctb.jQueryStyle[ctb.blogName]['content']).text(); //處理xuite首頁問題 if(ctb.blogName == "xuite") ctb.contentStr += $('div:regex(id,mainSubContent_.*)').text(); //去除空白和重複字 ctb.titleStr = ctb.titleStr.replace( spaceReg , "").replace( tagReg , "").replace( andReg , "").split('').unique().join(''); ctb.contentStr = ctb.contentStr.replace( spaceReg , "").replace( tagReg , "").replace( andReg , "").split('').unique().join(''); } //判斷在哪個Blog ctb.isBlog = function(url){ //以下為yam的blog樣式 if(url.match(/(blog\.yam\.com).*/)) ctb.blogName = 'yam'; else //以下為pixnet的blog樣式 if(url.match(/pixnet\.net.*/)) ctb.blogName = 'pixnet'; else //以下為Xuite的blog樣式 if(url.match(/blog\.xuite\.net.*/)) ctb.blogName = 'xuite'; else //以下為blogger的blog樣式 if(url.match(/blogspot\.com.*/)) ctb.blogName = 'blogspot'; else //以下為roodo的blog樣式 if(url.match(/blog\.roodo\.com.*/)) ctb.blogName = 'roodo'; else //以下為sina的blog樣式 if(url.match(/blog\.sina\.com\.tw.*/)) ctb.blogName = 'sina'; else //以下為udn的blog樣式 if(url.match(/blog\.udn\.com.*/)) ctb.blogName = 'udn'; else //以下為imtv的blog樣式 if(url.match(/www\.im\.tv.*/)) ctb.blogName = 'imtv'; else //以下為liontravel的blog樣式 if(url.match(/blog\.liontravel\.com.*/)) ctb.blogName = 'liontravel'; else return false; return true; } //顯示CTB標籤內文字 ctb.showCTBText = function(){ var i = 0; for(_obj in ctb.tag) { var ctbnumID = '#' + ctb.tag[i]; var ctbnumClass = '.' + ctb.tag[i]; if($(ctbnumID).is(":visible")){ $(ctbnumID).css({"visibility":"visible"}); } if($(ctbnumClass).is(":visible")){ $(ctbnumClass).css({"visibility":"visible"}); } i++; } } //取得CTB文字 ctb.getCTBText = function(){ //定義傳輸之XML格式 ctb.ctbTagContent = ""; //進行迴圈處理, 取得id="ct1"的定義 var i = 0; var sendFlag = false ; var strlen = ctb.strlen; var strlenall = 0 ; for(_obj in ctb.tag) { var ctbnumID = '#' + ctb.tag[i]; var ctbnumClass = '.' + ctb.tag[i]; var str = ""; var strTmp = ""; $(ctbnumID).each(function(n) { //取得ctb tag定義的內容並簡化,去除tag,去除空白和  strTmp += this.innerHTML; }); $(ctbnumClass).each(function(n) { //取得ctb tag定義的內容並簡化,去除tag,去除空白和  strTmp += this.innerHTML; }); str += strTmp.replace( spaceReg , "").replace( tagReg , "").replace( andReg , "").split('').unique().join(''); //如果有字串,則要發送 if(str && sendFlag == false ) sendFlag = true; strlenall += str.length; //20121220 ctb.ctbTagContent += '' + str + ''; if(str && str.length <= strlen){ strlen -= str.length; } i++; } ctb.ctbTagContent += ""; //有任何超過則設定rl = 1 ctb.rl = strlenall > ctb.strlen ? 1 : 0; //md5編碼,xml+url+key ctb.md5 = md5(ctb.ctbTagContent + ctb.url + 'd76fb1caQI7oUkjd1WlOspNJJCMJiL5QJgYt-E2PxxrP0uSngfY7tqlXxCO14ksVpmdh56qU86FBMd44cq-9-Z2XsCXKAkmCz79-q836IcpYMPGWKUPjgb0hAo64f4QFAZ2BVLEeZPPtaAauc4s_FiY_6oaf-JTYrAt-TKYsBT3IBRQG6IY='); if(sendFlag == true) return true; else return false; } ctb.sendNormal = function(){ //如果網頁上有定義內容 if (ctb.ctbContent != "") { $.ajaxSetup({ "cache": false }); $.getJSON('http://dhs.justfont.com/data/recept/?callback=?' , { key: "d76fb1caQI7oUkjd1WlOspNJJCMJiL5QJgYt-E2PxxrP0uSngfY7tqlXxCO14ksVpmdh56qU86FBMd44cq-9-Z2XsCXKAkmCz79-q836IcpYMPGWKUPjgb0hAo64f4QFAZ2BVLEeZPPtaAauc4s_FiY_6oaf-JTYrAt-TKYsBT3IBRQG6IY=" , addr: ctb.url , r: ctb.rl , md5: ctb.md5 , xml: ctb.ctbTagContent }, function(json){ $.each(json , function(key , val) { //取得font的網址定義 if(key == 'font') { $.each(this , function(k , v){ //alert(k + " = " + v); //網頁append css定義 $('head').append( "" ); }); } //將隱藏顯示 ctb.showCTBText(); }); }); } } //顯示錯誤訊息用 ctb.sendTrace = function(){ $.ajaxSetup({ cache: false}); $.getJSON('http://dhs.justfont.com/trace/recept/?callback=?' , { key: "d76fb1caQI7oUkjd1WlOspNJJCMJiL5QJgYt-E2PxxrP0uSngfY7tqlXxCO14ksVpmdh56qU86FBMd44cq-9-Z2XsCXKAkmCz79-q836IcpYMPGWKUPjgb0hAo64f4QFAZ2BVLEeZPPtaAauc4s_FiY_6oaf-JTYrAt-TKYsBT3IBRQG6IY=" , addr: ctb.url , trace: "noCTBText" } ); //除錯 if(ctb.url.match(/debug/)){ /*var strall; $(".ct1").each(function(n) { //取得ctb tag定義的內容 strall += this.innerHTML; }); alert(strall);*/ alert("aaa"); } } //產生XML ctb.genBlogXML = function() { if(ctb.titleStr || ctb.contentStr) { var strlen = ctb.strlen; //定義傳輸之XML格式 ctb.ctbContent = ""; if(ctb.titleStr && ctb.titleStr.length <= strlen){ ctb.ctbContent += '' + ctb.titleStr + ''; strlen -= ctb.titleStr.length; } if(ctb.contentStr && ctb.contentStr.length <= strlen){ ctb.ctbContent += '' + ctb.contentStr + ''; strlen -= ctb.contentStr.length; } ctb.ctbContent += ""; //md5編碼,xml+url+key ctb.md5 = md5(ctb.ctbContent + ctb.url + 'd76fb1caQI7oUkjd1WlOspNJJCMJiL5QJgYt-E2PxxrP0uSngfY7tqlXxCO14ksVpmdh56qU86FBMd44cq-9-Z2XsCXKAkmCz79-q836IcpYMPGWKUPjgb0hAo64f4QFAZ2BVLEeZPPtaAauc4s_FiY_6oaf-JTYrAt-TKYsBT3IBRQG6IY='); //傳輸長度超過限制 ctb.rl = ctb.strlen < ctb.titleStr.length + ctb.contentStr.length ? 1 : 0 ; } } //傳送資料 ctb.sendSmarty = function() { //如果有定義內容 if (ctb.ctbContent) { $.ajaxSetup({ cache: false}); $.getJSON('http://dhs.justfont.com/smarty/recept/?callback=?' , { key: "d76fb1caQI7oUkjd1WlOspNJJCMJiL5QJgYt-E2PxxrP0uSngfY7tqlXxCO14ksVpmdh56qU86FBMd44cq-9-Z2XsCXKAkmCz79-q836IcpYMPGWKUPjgb0hAo64f4QFAZ2BVLEeZPPtaAauc4s_FiY_6oaf-JTYrAt-TKYsBT3IBRQG6IY=" , addr: ctb.url , r: ctb.rl , md5: ctb.md5 , xml: ctb.ctbContent }, function(json){ //將content的font-family設定成content $.each(json , function(key , val) { var cssStr = ''; //取得font的網址定義 if(key == 'font') { $.each(this , function(k , v){ if(k == 'title') cssStr = ctb.cssStyle[ctb.blogName]['title']; if(k == 'content') cssStr = ctb.cssStyle[ctb.blogName]['content']; //處理xuite首頁問題 if(k == 'content' && ctb.blogName == "xuite") { //加入首頁樣式 $('div:regex(id,mainSubContent_.*)').each(function() { cssStr += ',#' + $(this).attr('id'); }); } //網頁append css定義 $('head').append( "" ); }); } //alert($("head").html()); }); //設定content style,等css load後再改,不然有時會失效 //$("#content_all *").css('font-family','content'); }); } } //依據URL開始處理事項 ctb.main = function(data){ //jQuery selector RE $.expr[':'].regex = function(elem, index, match) { var matchParams = match[3].split(','), validLabels = /^(data|css):/, attr = { method: matchParams[0].match(validLabels) ? matchParams[0].split(':')[0] : 'attr', property: matchParams.shift().replace(validLabels,'') }, regexFlags = 'ig', regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags); return regex.test($(elem)[attr.method](attr.property)); } //修正 jQuery.browser.version 比對問題 var userAgent = window.navigator.userAgent.toLowerCase(); $.browser.version = (userAgent.match( /.(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0, '0'])[1]; //判斷瀏覽器,IE, 如果有IE兼容模式,則為9以上版本 則為800, 其他5000 ctb.strlen = $.browser.msie && parseInt($.browser.version, 10) < 9 && navigator.userAgent.indexOf('Trident/5') < 0 ? 800 : 5000; //如果判斷是blog網址,則送出smarty + 送ct tag內容 if(ctb.isBlog(ctb.url)){ ctb.getBlogText(); ctb.genBlogXML(); ctb.sendSmarty(); //如果有ct tag則送出 if(ctb.getCTBText()) ctb.sendNormal(); }else{ //如果有ct tag則送出 if(ctb.getCTBText()) ctb.sendNormal(); else ctb.sendTrace(); } /* * 10秒後判斷執行是否隱藏=>顯示 */ setTimeout("ctb.showCTBText();" , ctb.showTime); } if(typeof jQuery != 'function') { _unique_doc = document.getElementsByTagName('head')[0]; _unique_js = document.createElement('script'); _unique_js.setAttribute('type', 'text/javascript'); _unique_js.setAttribute('src', "http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"); _unique_doc.appendChild(_unique_js); } _unique_ctb = function() { if(typeof jQuery == 'function' && typeof ctb.flag == "undefined" ) { ctb.flag = true; $ = jQuery.noConflict(); //$(document).ready(function() { clearInterval(_unique_mainIntv); ctb.main(); //}); } } var _unique_mainIntv = setInterval(_unique_ctb, 500);