"use strict"; /* * @Author: lvjing * @Date: 2018-12-18 10:58:56 * @LastEditTime: 2019-08-07 11:34:11 * @Version: 1.0 * @Description: clould * @Import: require('../mods/cloud') */ (function () { var radius = 60; //半径 var dtr = Math.PI / 300; //速度 var d = 250; //字体差 var mcList = []; var active = false; var lasta = 1; var lastb = 1; var distr = true; var tspeed = 10; var size = 250; var mouseX = 0; var mouseY = 0; var howElliptical = 1; var aA = null; var otagClouds = document.getElementById('tags_cloud'); var obody = document.getElementsByTagName('body')[0]; var sa, ca, sb, cb, sc, cc; function init() { var oTag = null; if (!otagClouds) { return false; } aA = otagClouds.getElementsByTagName('a'); for (var i = 0; i < aA.length; i++) { oTag = {}; oTag.offsetWidth = aA[i].offsetWidth; oTag.offsetHeight = aA[i].offsetHeight; mcList.push(oTag); } sineCosine(0, 0, 0); positionAll(); otagClouds.onmouseover = function () { active = true; }; otagClouds.onmouseout = function () { active = false; }; otagClouds.onmousemove = function (ev) { var oEvent = window.event || ev; // mouseX = oEvent.clientX - ($("#tags_cloud").offset().left + otagClouds.offsetWidth / 2); mouseX = oEvent.clientX - (otagClouds.offsetLeft + otagClouds.offsetWidth / 2); mouseY = oEvent.clientY - (otagClouds.offsetTop - obody.scrollTop + otagClouds.offsetHeight / 2); // mouseY = oEvent.clientY - ($("#tags_cloud").offset().top - $("body").scrollTop() + otagClouds.offsetHeight / 2); mouseX /= 5; mouseY /= 5; }; setInterval(update, 30); } init(); function cloudDataInit() { var TPL_CLOUD = '{{~it:data}}\ {{=data.name}}\ {{~}}'; var tpl = doT.template(TPL_CLOUD); var htmlStr = tpl(cloudDatas); otagClouds.innerHTML = htmlStr; } ; function update() { var a; var b; if (active) { a = -Math.min(Math.max(-mouseY, -size), size) / radius * tspeed; b = Math.min(Math.max(-mouseX, -size), size) / radius * tspeed; } else { a = lasta * 0.98; b = lastb * 0.98; } lasta = a; lastb = b; if (Math.abs(a) <= 0.01 && Math.abs(b) <= 0.01) { return; } var c = 0; sineCosine(a, b, c); for (var j = 0; j < mcList.length; j++) { var rx1 = mcList[j].cx; var ry1 = mcList[j].cy * ca + mcList[j].cz * -sa; var rz1 = mcList[j].cy * sa + mcList[j].cz * ca; var rx2 = rx1 * cb + rz1 * sb; var ry2 = ry1; var rz2 = rx1 * -sb + rz1 * cb; var rx3 = rx2 * cc + ry2 * -sc; var ry3 = rx2 * sc + ry2 * cc; var rz3 = rz2; mcList[j].cx = rx3; mcList[j].cy = ry3; mcList[j].cz = rz3; var per = d / (d + rz3); mcList[j].x = howElliptical * rx3 * per - howElliptical * 2; mcList[j].y = ry3 * per; mcList[j].scale = per; mcList[j].alpha = per; mcList[j].alpha = (mcList[j].alpha - 0.6) * (10 / 6); } doPosition(); depthSort(); } function depthSort() { var i = 0; var aTmp = []; for (i = 0; i < aA.length; i++) { aTmp.push(aA[i]); } aTmp.sort(function (vItem1, vItem2) { if (vItem1.cz > vItem2.cz) { return -1; } else if (vItem1.cz < vItem2.cz) { return 1; } else { return 0; } }); for (i = 0; i < aTmp.length; i++) { aTmp[i].style.zIndex = i; } } function positionAll() { var phi = 0; var theta = 0; var max = mcList.length; var i = 0; var aTmp = []; var oFragment = document.createDocumentFragment(); //随机排序 for (i = 0; i < aA.length; i++) { aTmp.push(aA[i]); } aTmp.sort(function () { return Math.random() < 0.5 ? 1 : -1; }); for (i = 0; i < aTmp.length; i++) { oFragment.appendChild(aTmp[i]); } otagClouds.appendChild(oFragment); for (var i = 1; i < max + 1; i++) { if (distr) { phi = Math.acos(-1 + (2 * i - 1) / max); theta = Math.sqrt(max * Math.PI) * phi; } else { phi = Math.random() * Math.PI; theta = Math.random() * (2 * Math.PI); } //坐标变换 mcList[i - 1].cx = radius * Math.cos(theta) * Math.sin(phi); mcList[i - 1].cy = radius * Math.sin(theta) * Math.sin(phi); mcList[i - 1].cz = radius * Math.cos(phi); aA[i - 1].style.left = mcList[i - 1].cx + otagClouds.offsetWidth / 2 - mcList[i - 1].offsetWidth / 2 + 'px'; aA[i - 1].style.top = mcList[i - 1].cy + otagClouds.offsetHeight / 2 - mcList[i - 1].offsetHeight / 2 + 'px'; } } function doPosition() { var l = otagClouds.offsetWidth / 2; var t = otagClouds.offsetHeight / 2; for (var i = 0; i < mcList.length; i++) { aA[i].style.left = mcList[i].cx * 3 + l - mcList[i].offsetWidth / 2 + 'px'; aA[i].style.top = mcList[i].cy + t - mcList[i].offsetHeight / 2 + 'px'; aA[i].style.fontSize = Math.ceil(12 * mcList[i].scale / 2) + 8 + 'px'; aA[i].style.filter = "alpha(opacity=" + 100 * mcList[i].alpha + ")"; aA[i].style.opacity = mcList[i].alpha; } } function sineCosine(a, b, c) { sa = Math.sin(a * dtr); ca = Math.cos(a * dtr); sb = Math.sin(b * dtr); cb = Math.cos(b * dtr); sc = Math.sin(c * dtr); cc = Math.cos(c * dtr); } })(); "use strict"; /* * @Author: lvjing * @Date: 2018-12-14 14:25:05 * @LastEditTime: 2020-07-09 17:41:16 * @Version: 1.0 * @Description: 侧边导航 * @Import: require('../mods/nav') */ (function () { var W = { name: 'NavAside', version: 1.0 }; var navArr = document.querySelectorAll('.js-aside-item'); W.init = function () { if (navArr.length < 1) { return false; } this.bindEvents(); if (!IS_WAP) { this.navChange(); this.navScroll(); this.shareToggle(); } ; }; W.navChange = function () { for (var i = 0; i < navArr.length; i++) { navArr[i].onclick = function (e) { for (var j = 0; j < navArr.length; j++) { navArr[j].className = 'js-aside-item m-aside-item'; } this.className += ' selected'; }; } }; W.navScroll = function () { window.onscroll = function (delay, callback) { var timer = null; return function () { var context = this; clearTimeout(timer); timer = setTimeout(function () { mouseScroll.call(context); }, 1000); }(); }; function mouseScroll() { var navChoose = document.querySelectorAll('.nav_choose'); var scroll = document.documentElement.scrollTop || document.body.scrollTop; var conID = ''; for (var i = 0; i < navChoose.length; i++) { var top = navChoose[i].offsetTop; if (scroll >= top - 50) { conID = navChoose[i].id; } else { break; } } if (conID) { for (var j = 0; j < navArr.length; j++) { var href = navArr[j].getElementsByTagName('a')[0].href.split('#')[1]; if (href == conID) { W.remove(navArr[j], 'selected'); W.add(navArr[j], 'selected'); } else { navArr[j].className = 'js-aside-item m-aside-item'; } } } } }; W.shareToggle = function () { var sharebtn = document.getElementById('sharebtn'); var nav_share = document.querySelector('.m-aside-item-share-c'); sharebtn.onmouseover = nav_share.onmouseover = function (e) { nav_share.style.opacity = 1; nav_share.style.filter = 'alpha(opacity:' + 100 + ')'; // sharebtn.style.transform = 'rotate(38deg)'; nav_share.style.display = 'block'; }; sharebtn.onmouseout = nav_share.onmouseout = function (e) { // sharebtn.style.transform = 'rotate(0deg)'; nav_share.style.opacity = 0; nav_share.style.filter = 'alpha(opacity:' + 0 + ')'; nav_share.style.display = 'none'; }; }; W.bindEvents = function () { $("#page_share_wb").click('on', function () { page_share.shareWeibo(); }); $("#page_share_wx").click('on', function () { page_share.shareWeixin(); }); $("#page_share_qzone").click('on', function () { page_share.shareQzone(); }); $("#go_top").click('on', function () { _goto(); }); function _goto() { $('body,html').animate({ scrollTop: 0 }, 50); return false; } ; var win = window; win.onscroll = function () { if (win.scrollY > 1000) { $(".m-aside-nav").show(); } ; }; }; W.remove = function (element, value) { var value = ' ' + value; var newClassList = element.getAttribute('class').replace(value, ''); element.setAttribute('class', newClassList); }; W.add = function (element, value) { var value = ' ' + value; var newClassList = element.getAttribute('class').concat(value); element.setAttribute('class', newClassList); }; window.NavAside = W; $(function () { window.NavAside.init(); }); })(); "use strict"; /* * @Author: lvjing * @Date: 2018-12-14 14:25:05 * @LastEditTime: 2022-05-11 10:27:35 * @Version: 1.0 * @Description: 侧边导航 * @Import: require('../mods/nav2'); */ (function () { $("#share_btn").click(function () { page_share.showMenu(); }); $("#page_share_wb2").click(function () { page_share.shareWeibo(); }); $("#page_share_wx2").click(function () { page_share.shareWeixin(); }); $("#page_share_qzone2").click(function () { page_share.shareQzone(); }); $("#go_top2").click(function () { _goto(); }); function _goto() { $('body,html').animate({ scrollTop: 0 }, 50); return false; } ; $(window).scroll(function () { if ($(window).scrollTop() > 1000) { $(".m-money2").fadeIn(1000); $(".m-aside-nav").fadeIn(1000); $(".m-aside-nav2").fadeIn(1000); } else { $(".m-money2").fadeOut(1000); $(".m-aside-nav").fadeOut(1000); $(".m-aside-nav2").fadeOut(1000); } }); })(); "use strict"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } /** * 图集组件 1,694,46 2019-05-27 17:22:29 * 评论数拿图集的总数total daichang 201312061626 */ (function (host) { var doc = host.document, _ie = !!host.ActiveXObject, _ie6 = _ie && !host.XMLHttpRequest, _queryClass = doc.getElementsByClassName ? function (name, root) { return (root || doc).getElementsByClassName(name); } : function (name, root) { root = root || doc; var result = [], tags = root.getElementsByTagName('*'), len = tags.length, i, re = new RegExp("(^|\\s)" + name + "(\\s|$)"); for (i = 0; i < len; i++) { if (re.test(tags[i].className)) { result.push(tags[i]); } } return result; }, _defView = doc.defaultView, _getStyle = _defView && _defView.getComputedStyle ? function (el, name) { var style = _defView.getComputedStyle(el, null), value = ''; if (style) { value = style.getPropertyValue(name); } return value; } : function (el, name) { var style = el.currentStyle, value = ''; if (style) { value = style[name]; } return value; }, _pagePos = function _pagePos(elem) { var op = elem.offsetParent, x = elem.offsetLeft, y = elem.offsetTop, scrX = 0, scrY = 0, bd = doc.body; while (op) { x += op.offsetLeft; y += op.offsetTop; op = op.offsetParent; } op = elem.parentNode; while (op && op !== bd) { scrX += op.scrollLeft; scrY += op.scrollTop; op = op.parentNode; } return { x: x - scrX, y: y - scrY }; }, _create = function _create(tag, className) { var el = doc.createElement(tag); if (className) { el.className = className; } return el; }, _scriptOnload = doc.createElement('script').readyState ? function (node, callback) { var oldCallback = node.onreadystatechange; node.onreadystatechange = function () { var rs = node.readyState; if (rs === 'loaded' || rs === 'complete') { node.onreadystatechange = null; oldCallback && oldCallback(); callback.call(this); } }; } : function (node, callback) { node.addEventListener('load', callback, false); }, head = doc.getElementsByTagName('head')[0] || doc.documentElement, _getScript = function _getScript(url, fn) { var node = doc.createElement('script'); node.src = url; node.async = true; _scriptOnload(node, function () { fn && fn.call(node, ''); if (head && node.parentNode) { head.removeChild(node); } }); head.insertBefore(node, head.firstChild); return node; }, _createImg = function _createImg(url, callback) { var img = new Image(); img.onload = function () { this.setAttribute('data-w', img.width); this.setAttribute('data-h', img.height); callback(img); //img.onload = null; }; img.src = url; img.chkLoad = function () { //this.src = this.getAttribute('data-src'); //this.removeAttribute('data-src'); this.chkLoad = function () {}; this.onload = null; }; }, _setOpacity = doc.documentElement.filters ? function (elem, level) { elem.style.filter = 'alpha(opacity=' + level + ')'; } : function (elem, level) { elem.style.opacity = level / 100; }, _simpleFadeIn = function _simpleFadeIn(elem, time) { var n = Math.ceil(time * 1000 / 20), i, step = 100 / n; if (elem.__timeArr) { for (i = 0; i < elem.__timeArr.length; i++) { host.clearTimeout(elem.__timeArr[i]); } } ; elem.__timeArr = []; _setOpacity(elem, 0); for (i = 1; i <= n; i++) { (function (i) { elem.__timeArr.push(host.setTimeout(function () { _setOpacity(elem, i * step); }, i * 20)); })(i); } }, AP = Array.prototype, _indexOf = AP.indexOf ? function (arr, item) { return arr.indexOf(item); } : function (arr, item) { for (var i = 0, len = arr.length; i < len; i++) { if (arr[i] === item) { return i; } } return -1; }, APPKEY = '2894297679', CLICK = 'click', HOVER = 'hover', PX = 'px', SPACE = ' ', CLASS = 'imgslide', PREFIX = CLASS + '-', CONTENT_CLASS = PREFIX + 'content', SLIDE_CLASS = PREFIX + 'slide', MAIN_CLASS = PREFIX + 'main', IMG_CLASS = PREFIX + 'img', TXTBG_CLASS = PREFIX + 'txt-bg', TXT_CLASS = PREFIX + 'txt', NUM_CLASS = PREFIX + 'num', LDBG_CLASS = PREFIX + 'loading-bg', LD_CLASS = PREFIX + 'loading', ACTION_CLASS = PREFIX + 'action', PREV_CLASS = ACTION_CLASS + SPACE + PREFIX + 'prev', NEXT_CLASS = ACTION_CLASS + SPACE + PREFIX + 'next', LIST_CLASS = PREFIX + 'list', LIST_TITLE_CLASS = PREFIX + 'list-tit', LISTACTION_CLASS = LIST_CLASS + '-action', LISTP_CLASS = LISTACTION_CLASS + SPACE + LIST_CLASS + '-p', LISTN_CLASS = LISTACTION_CLASS + SPACE + LIST_CLASS + '-n', SCROLL_CLASS = PREFIX + 'scroll', SCROLLINNER_CLASS = SCROLL_CLASS + '-inner', SELECTED_CLASS = PREFIX + 'selected', CMT_CLASS = PREFIX + 'cmt', SEP_CLASS = PREFIX + 'sep', ACTIONS_CLASS = CMT_CLASS + '-actions', SHARE_CLASS = CMT_CLASS + '-share', DOWN_CLASS = CMT_CLASS + '-down', COUNT_CLASS = CMT_CLASS + '-count', CLEARFIX = 'clearfix', DIV = 'div', UL = 'ul', LI = 'li', A = 'a', SPAN = 'span', IMG_O = '', /** * 图片滚动控件 * @param container 容器, DOM 结点或字符串 (元素 ID) * @param config 配置对象, 包括以下配置参数: */ Slide = function Slide(container, config) { if (!(this instanceof Slide)) { return new Slide(container, config); } if (typeof container === 'string') { container = doc.getElementById(container); } if (!container || container.nodeType !== 1) { throw new Error('容器元素非法'); } container.innerHTML = ''; //清空内容 // defaults this._C = { width: 0, height: 0, slideWidth: 0, slideHeight: 0, thumbCount: 5, thumbWidth: 80, thumbHeight: 0, showText: false, auto: false, // TODO loop: false, // TODO interval: 0.4, comment: false, event: CLICK }; this._container = container; this._init(config); //debugger; if (typeof config.slide_url === 'string' && config.slide_url.match(/slide_\d+_(\d+)_(\d+)/i)) { var idInfo = config.slide_url.match(/slide_\d+_(\d+)_(\d+).html/i); this.sid = idInfo[1]; this.album_id = idInfo[2]; } ; if (this.data) { this._render(); } else if (!this.sid || !this.album_id) { throw new Error('数据为空'); } else { this._getAPIData(); } ; }, proto = Slide.prototype; // static Slide.commentCountUrl = '//comment5.news.sina.com.cn/cmnt/count?format=js&jsvar=g_clist&newslist='; // prototype proto.WIDTH_DIFF = 50; proto._init = function (config) { config = config || {}; var c = this._C, w = config.width, h = config.height, sw = config.slideWidth, sh = config.slideHeight, tc = config.thumbCount, tw = config.thumbWidth, th = config.thumbHeight, dImg = config.downloadImg, auto = config.auto, loop = config.loop, interval = config.interval, text = config.showText, comment = config.comment, imgOverflow = config.imgOverflow, urlListener = config.urlListener, listType = config.listType, listPos = config.listPos, ev = config.event, sid = config.sid, album_id = config.album_id, data = config.data, i, len, container = this._container, DIFF = typeof config.diff === 'number' ? config.diff : this.WIDTH_DIFF; this.onready = config.onready; if (w && sw) { c.width = w; c.slideWidth = sw; } else if (w && !sw) { c.width = w; c.slideWidth = w - DIFF; } else if (!w && sw) { c.width = sw + DIFF; c.slideWidth = sw; } else { w = parseInt(_getStyle(container, 'width'), 10) || 0; c.width = w; c.slideWidth = w - DIFF; } if (h) { c.height = h; } if (sh) { c.slideHeight = sh; } if (tc) { c.thumbCount = tc; } if (tw) { c.thumbWidth = tw; } if (dImg) { c.dImg = dImg; } if (th) { c.thumbHeight = th; } if (interval) { c.interval = interval; } if (ev && ev !== CLICK) { c.event = HOVER; } c.comment = comment || false; c.auto = auto || false; c.loop = loop || false; c.showText = text || false; c.urlListener = urlListener || false; this.data = data || null; this.sid = sid || null; this.album_id = album_id || null; this.imgMaxWidth = imgOverflow === 'zoom' ? w - DIFF : null; c.listType = listType == 'title' ? 'title' : 'pic'; c.listPos = listPos == 'top' ? 'top' : 'bot'; }; proto._getAPIData = function () { var me = this; this._dataCallbackName = 'imgs' + Math.round(1000000 * Math.random()); host[this._dataCallbackName] = function (data) { me._fillData(data); }; _getScript('//api.slide.news.sina.com.cn/interface/api_image.php?app_key=' + APPKEY + '&format=json&num=300&sid=' + this.sid + '&album_id=' + this.album_id + '&jsoncallback=' + this._dataCallbackName); }; proto._fillData = function (json) { host[this._dataCallbackName] = null; var d = [], item, i; if (json.status.code != 0) { throw new Error('接口返回错误:' + json.status.msg); } ; if (json.album.manual) { this.PVUrl_m = json.album.manual; } if (json.album.auto) { this.PVUrl_a = json.album.auto; } for (i = 0; i < json.data.item.length; i++) { item = {}; item.title = json.data.item[i].title; item.text = json.data.item[i].intro || json.album.intro; item.commentUrl = json.album.cmnt_url.replace(/\-album-(\d+)\-\d+$/, '-$1-' + json.data.item[i].id); item.d_id = json.data.item[i].id; item.thumb = json.data.item[i].thumb_url; item.image = json.data.item[i].img_url; d.push(item); } ; json.album.cmnt_url = json.album.cmnt_url + '&style=1'; this.album = json.album; this.data = d; this._render(); }; proto._render = function () { var me = this, container = me._container, c = me._C, w = c.width, h = c.height, sw = c.slideWidth, sh = c.slideHeight, tc = c.thumbCount, tw = c.thumbWidth, th = c.thumbHeight, auto = c.auto, loop = c.loop, interval = c.interval, text = c.showText, comment = c.comment, ev = c.event, data = me.data, el, wrap, content, main, img, txtbg, txt, ldbg, ld, num, prev, next, list, listp, listn, scroll, ul, thumbs = [], cmt, act, share, down, cmtCount, sep, cmtDlg, i, len, item, scrollev, bdw = 2, scrw, minMargin = 20, margin, listType = c.listType, listPos = c.listPos, dImg = c.dImg; wrap = _create(DIV, CLASS); content = _create(DIV, CONTENT_CLASS); main = _create(DIV, MAIN_CLASS); img = _create(DIV, IMG_CLASS); txtbg = _create(DIV, TXTBG_CLASS); txt = _create(DIV, TXT_CLASS); num = _create(DIV, NUM_CLASS); prev = _create(DIV, PREV_CLASS); next = _create(DIV, NEXT_CLASS); ldbg = _create(DIV, LDBG_CLASS); ld = _create(DIV, LD_CLASS); ldbg.style.display = 'none'; ld.style.display = 'none'; list = _create(DIV, listType == 'pic' ? LIST_CLASS : LIST_TITLE_CLASS); listp = _create(DIV, LISTP_CLASS); listn = _create(DIV, LISTN_CLASS); scroll = _create(DIV, SCROLLINNER_CLASS); ul = _create(UL, CLEARFIX); prev.setAttribute('title', '上一张'); next.setAttribute('title', '下一张'); main.appendChild(img); main.appendChild(txtbg); main.appendChild(txt); main.appendChild(num); main.appendChild(prev); main.appendChild(next); main.appendChild(ldbg); main.appendChild(ld); el = _create(DIV, SLIDE_CLASS); el.appendChild(main); if (comment) { cmt = _create(DIV, CMT_CLASS + ' ' + CLEARFIX); act = _create(DIV, ACTIONS_CLASS); share = _create(A, SHARE_CLASS); share.href = 'javascript:void(0)'; share.innerHTML = ' '; if (dImg) { down = _create(A, DOWN_CLASS); down.href = 'javascript:void(0)'; down.innerHTML = '下载'; } ; cmtCount = _create(A, COUNT_CLASS); cmtCount.href = '#'; cmtCount.innerHTML = '已有0条评论'; cmtCount.target = '_blank'; act.appendChild(share); if (dImg) { sep = _create(SPAN, SEP_CLASS); sep.innerHTML = '|'; act.appendChild(sep); act.appendChild(down); } sep = _create(SPAN, SEP_CLASS); sep.innerHTML = '|'; act.appendChild(sep); act.appendChild(cmtCount); sep = _create(SPAN, SEP_CLASS); cmt.appendChild(act); el.appendChild(cmt); } var c_slide = el; content.appendChild(el); scroll.appendChild(ul); el = _create(DIV, SCROLL_CLASS); el.appendChild(scroll); list.appendChild(listp); list.appendChild(el); list.appendChild(listn); content.appendChild(list); if (listPos == 'top') { content.insertBefore(list, c_slide); } else { content.appendChild(list); } wrap.appendChild(content); scrw = w - 60; if (w) { wrap.style.width = w + PX; scroll.style.width = scrw + PX; } if (h) { wrap.style.height = h + PX; } if (sw) { img.style.width = sw + PX; /*if (_ie6 && comment) { cmt.style.width = sw - 10 + PX; }*/ } if (sh) { img.style.height = sh + PX; } ul.style.width = '30000px'; // ? if (!text) { txtbg.style.display = 'none'; txt.style.display = 'none'; } me.selected = 0; me.imageCache = []; me.elements = { wrapper: wrap, content: content, main: main, imageWrap: img, text: txt, num: num, textBg: txtbg, loadingBg: ldbg, loading: ld, comment: cmt, cmtCount: cmtCount, prev: prev, next: next, list: list, listPrev: listp, listNext: listn, thumbWrap: scroll, thumbList: ul, thumbs: thumbs }; if (data && data.length) { if (!tw || tc * (tw + minMargin) - minMargin > scrw || listType == 'title') { tw = Math.floor((scrw + minMargin) / tc) - minMargin - bdw; margin = minMargin; } else { margin = Math.floor((scrw - tc * (tw + bdw)) / (tc - 1)); } item = data[0]; ldbg.style.display = ''; ld.style.display = ''; _createImg(item.image, function (image) { me.imageCache[0] = image; image.chkLoad(); if (me.selected === 0) { me._showImage(image); } }); txt.innerHTML = item.text; num.innerHTML = "1/" + data.length; // cmtCount.innerHTML = '已有' + (item.commentCount || 0) + '条评论'; if (cmtCount) cmtCount.href = item.commentUrl; el = _create(LI); el.style.width = tw + PX; el.style.marginRight = margin + PX; if (th) { el.style.height = th + PX; } if (listType == 'pic') { el.innerHTML = IMG_O + item.thumb + '" style="width:' + tw + PX + IMG_C; } else { el.innerHTML = item.title; } ; el.className = SELECTED_CLASS; ul.appendChild(el); thumbs.push(el); for (i = 1, len = data.length; i < len; i++) { item = data[i]; el = _create(LI); el.style.width = tw + PX; el.style.marginRight = margin + PX; if (th) { el.style.height = th + PX; } if (listType == 'pic') { el.innerHTML = IMG_O + item.thumb + '" style="width:' + tw + PX + IMG_C; } else { el.innerHTML = item.title; } ul.appendChild(el); thumbs.push(el); (function (i) { _createImg(item.image, function (image) { me.imageCache[i] = image; if (me.selected + 1 === i) { image.chkLoad(); } ; if (me.selected - 1 === i) { image.chkLoad(); } ; if (me.selected + (len - 1) === i) { image.chkLoad(); } ; if (me.selected === i) { image.chkLoad(); me._showImage(image); } }); })(i); } } container.insertBefore(wrap, container.firstChild); me._getCommentCount(); // thumbnails me.thumbnails = function () { var single = tw + margin + bdw, total = thumbs.length, left = Math.floor((tc - 1) / 2), right = total - tc + left, diff = right - left, o, i, instance; // for (i = 0; i <= left; i++) { // offset.push(0); // } // for (i = 1; i <= diff; i++) { // os = i * single; // offset.push(os); // } // for (i = right + 1; i < total; i++) { // offset.push(os); // } // for (i = diff + 1; i < total; i++) { // offset.push(os); // } instance = { diff: total - tc, current: 0, timer: null, scrollLeft: function scrollLeft() { var c = this.current, n = c - 1; // if (n >= 0 && n < total) { if (n >= 0 && n <= this.diff) { this._scroll(c, n); this.current = n; } else if (n < 0) { this._scroll(c, this.diff); this.current = this.diff; } }, scrollRight: function scrollRight() { var c = this.current, n = c + 1; // if (n >= 0 && n < total) { if (n >= 0 && n <= this.diff) { this._scroll(c, n); this.current = n; } else if (n > this.diff) { this._scroll(c, 0); this.current = 0; } }, scrollTo: function scrollTo(n) { n = n - left; if (n < 0) { n = 0; } if (n > this.diff) { n = this.diff; } this._scroll(this.current, n); this.current = n; }, _scroll: function _scroll(from, to) { if (me.timer) { host.clearInterval(me.timer); me.timer = null; } var t = 20, totalMs = interval * 1000, times = Math.ceil(totalMs / t), ml1 = from * (el.offsetWidth + margin), ml2 = to * (el.offsetWidth + margin), step = (ml2 - ml1) / times, steps = [], i, count = 0; if (ml2 > (el.offsetWidth + margin) * total) { ml2 = (el.offsetWidth + margin) * total; } ; if (ml1 === ml2) { return; } for (i = 1; i < times; i++) { steps.push(ml1 + step * i); } steps.push(ml2); ul.style.marginLeft = '-' + ml1 + PX; me.timer = setInterval(function () { if (count < times) { ul.style.marginLeft = '-' + steps[count] + PX; count++; } else { host.clearInterval(me.timer); me.timer = null; } }, t); } }; return instance; }(); // events prev.onmousedown = function () { me.prev(); return false; }; next.onmousedown = function () { me.next(); return false; }; listp.onmousedown = function () { me.thumbnails.scrollLeft(); return false; }; listn.onmousedown = function () { me.thumbnails.scrollRight(); return false; }; //iPad if (_typeof(window.ontouchstart)) { var addEvent = function addEvent(obj, eventType, func) { if (obj.attachEvent) { obj.attachEvent("on" + eventType, func); } else { obj.addEventListener(eventType, func, false); } }; var iPadX = 0, iPadLastX = 0, iPadScrollX = 0, iPadScrollY = 0, iPadStatus = 'ok'; addEvent(me.elements.main, 'touchstart', function (e) { iPadX = e.touches[0].pageX; iPadScrollX = window.pageXOffset; iPadScrollY = window.pageYOffset; }); addEvent(me.elements.main, 'touchmove', function (e) { iPadLastX = e.touches[0].pageX; var cX = iPadX - iPadLastX; if (iPadStatus == 'ok') { if (iPadScrollY == window.pageYOffset && iPadScrollX == window.pageXOffset && Math.abs(cX) > 20) { iPadStatus = 'touch'; } else { return; } } ; e.preventDefault(); }); addEvent(me.elements.main, 'touchend', function (e) { if (iPadStatus != 'touch') { return; } ; iPadStatus = 'ok'; var cX = iPadX - iPadLastX; if (cX < 0) { me.prev(); } else { me.next(); } ; }); } //iPad end scrollev = function scrollev(e) { e = e || host.event; var target = e.target || e.srcElement, n; if (target.nodeName.toUpperCase() === 'IMG') { target = target.parentNode; } if (target.nodeName.toUpperCase() === 'LI') { n = _indexOf(thumbs, target); me["goto"](n); } }; if (ev === CLICK) { ul.onclick = scrollev; } else if (ev === HOVER) { ul.onmouseover = scrollev; } // TODO if (share) share.onclick = function () { var pic = data[me.selected].image; me.gShareTblog(pic); }; if (c.urlListener) { var page = window.location.hash.match(/p=(\d+)/i); if (page) { page = page[1]; if (page < 1 || page >= data.length) { page = 1; } ; this["goto"](page - 1); } ; } ; if (down) down.onclick = function () { var pic = data[me.selected].image; me.gDownloadPic(pic); }; if (typeof this.onready == 'function') { this.onready(); } ; }; //added by zy, pv统计 proto.PVCount = function (type, imgurl) { if (type == "auto") { if (this.PVUrl_a == null) { return; } ; } else { if (this.PVUrl_m == null) { return; } ; } ; /*if(!this.firstPage){ //第一次不请求PV this.firstPage = true; return; };*/ //移除iframe if (this.PVFrame) { this.PVFrame.parentNode.removeChild(this.PVFrame); } ; //create new iframe this.PVFrame = document.createElement("iframe"); //style="height:0px;width:1px;overflow:hidden;" this.PVFrame.style.height = "0px"; this.PVFrame.style.width = "1px"; this.PVFrame.style.overflow = "hidden"; this.PVFrame.frameBorder = 0; //sina.$(this.mainBoxId).appendChild(this.PVFrame); document.body.appendChild(this.PVFrame); var a = window.location.href; var b = Math.random(); this.PVFrame.src = (type == "auto" ? a.indexOf('2010.') !== -1 ? b < 0 ? this.PVUrl_AC : this.PVUrl_a : this.PVUrl_a : this.PVUrl_m) + "?p=" + imgurl + "&r=" + Math.random(); //set page }; proto["goto"] = function (n) { var elements = this.elements, thumbs = elements.thumbs, c = this._C, img = elements.imageWrap, txt = elements.text, num = elements.num, ldbg = elements.loadingBg, ld = elements.loading, count = elements.cmtCount, total = thumbs.length, ev = this._C.event, selected = this.selected, thumbnails = this.thumbnails, data = this.data, d, imageCache = this.imageCache, i; if (n < 0) { n = total - 1; } else if (n >= total) { n = 0; } if (n !== selected && n >= 0 && n < total) { if (n - 1 >= 0) { if (n == total - 1) { imageCache[total - 1].chkLoad(); } imageCache[n - 1].chkLoad(); } if (n + 1 < total) { imageCache[n + 1].chkLoad(); //预载下一张 } ; d = data[n]; i = imageCache[n]; i.chkLoad(); if (i) { this._showImage(i); } else { ldbg.style.display = ''; ld.style.display = ''; } txt.innerHTML = d.text; num.innerHTML = "" + (n + 1) + "/" + total; if (count) count.innerHTML = '已有' + this.album.cmnt_total + '条评论'; if (count) count.href = this.album.cmnt_url; thumbs[selected].className = ''; thumbs[n].className = SELECTED_CLASS; if (ev === CLICK) { thumbnails.scrollTo(n); } this.selected = n; this.PVCount('', imageCache[n].src); if (c.urlListener) { window.location.hash = "p=" + (n + 1); } } }; proto.prev = function () { var n = this.selected - 1; this["goto"](n); // this.thumbnails.scrollTo(n); }; proto.next = function () { var n = this.selected + 1; this["goto"](n); // this.thumbnails.scrollTo(n); }; proto._showImage = function (image) { var me = this, elements = this.elements, img = elements.imageWrap, txt = elements.text, ldbg = elements.loadingBg, ld = elements.loading, prev = elements.prev, next = elements.next, sum = 0; ldbg.style.display = 'none'; ld.style.display = 'none'; img.innerHTML = ''; image.style.width = 'auto'; image.style.height = 'auto'; var imgObj; (function () { var h = image.height; if (h == 0) { if (sum >= 300) { return; } setTimeout(arguments.callee, 100); sum++; return; } //debugger; if (me.imgMaxWidth && image.width > me.imgMaxWidth) { h = Math.round(image.height * me.imgMaxWidth / image.width); image.style.width = me.imgMaxWidth + 'px'; } ; //img.style.height = h + PX; //prev.style.height = h + PX; //next.style.height = h + PX; //ldbg.style.height = h + PX; })(); if (_ie6) { var span = doc.createElement(SPAN); img.appendChild(span); span.style.background = '#000'; //修正IE6下的问题 imgObj = span.appendChild(image); } else { imgObj = img.appendChild(image); } ; _simpleFadeIn(image, this._C.interval); }; proto.gDownloadPic = function (picUrl) { try { var src = picUrl.replace(/http\:\/\/(i0|i1|i2|i3|www)\.sinaimg\.cn\//i, ''); var iframe = document.getElementById('iframe-download-pic'); if (!iframe) { var div = document.createElement('div'); div.style.display = 'none'; div.innerHTML = ''; if (div.firstElementChild) { iframe = div.firstElementChild; } else { iframe = div.firstChild; while (iframe && iframe.nodeType !== 1) { iframe = iframe.nextSibling; } } document.body.insertBefore(div, document.body.firstChild); } iframe.src = '//slide.news.sina.com.cn/iframe/download.php?img=' + src; } catch (e) {} ; }; proto.gShareTblog = function (picUrl) { (function (s, d, e, r, l, p, t, z, c) { var f = 'http://v.t.sina.com.cn/share/share.php?', u = z || d.location, p = ['url=', e(u), '&title=', e(document.title), '&source=', e(r), '&sourceUrl=', e(l), '&content=', c || 'gb2312', '&pic=', e(p || '')].join(''); function a() { if (!window.open([f, p].join(''), 'mb', ['toolbar=0,status=0,resizable=1,width=440,height=430,left=', (s.width - 440) / 2, ',top=', (s.height - 430) / 2].join(''))) u.href = [f, p].join(''); } ; if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);else a(); })(screen, document, encodeURIComponent, '新浪新闻中心', 'http://news.sina.com.cn', picUrl, null, null, null); }; proto._getCommentCount = function () { var me = this, data = me.data, selected = me.selected, countDom = me.elements.cmtCount, i, j, len = data && data.length || 0, len2, item, url, channel, newsid, key, temp, keys = []; // 拿图集的评论数 var albumCmntUrl = this.album.cmnt_url; var temp = albumCmntUrl.match(/channel\=(.*?)\&newsid\=(.*?)(\&|$)/); var params = temp[1] + ':' + temp[2] + ':1'; if (countDom) { _getScript(Slide.commentCountUrl + params, function () { var list = g_clist.result.count; var count = list[params]; var total = count.total; me.album.cmnt_total = total; countDom.innerHTML = '已有' + total + '条评论'; countDom.href = albumCmntUrl; }); } }; var getJsonp = function () { function _getJsData(url, dispose) { var scriptNode = document.createElement("script"); scriptNode.type = "text/javascript"; scriptNode.onreadystatechange = scriptNode.onload = function () { if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") { if (dispose) { dispose(); } ; scriptNode.onreadystatechange = scriptNode.onload = null; scriptNode.parentNode.removeChild(scriptNode); } }; scriptNode.src = url; document.getElementsByTagName("head")[0].appendChild(scriptNode); } ; function randomStr() { return new Date().getTime() + '' + Math.round(Math.random() * 1000); } ; function jsonp(url, callback, callbackName, lastParam) { if (!url) return; var rdm = 'sinajsonp' + randomStr(); while (window[rdm] != undefined) { rdm = 'sinajsonp' + randomStr(); } window[rdm] = function (rt) { if (typeof callback === 'function') callback(rt); setTimeout(function () { try { delete window[rdm]; } catch (__err) {} }, 500); }; callbackName = callbackName || 'callback'; _getJsData(url + (url.indexOf('?') >= 0 ? '&' : '?') + callbackName + '=' + rdm + (lastParam ? '&' + lastParam : '')); } ; return jsonp; }(); host.ImageSlide = Slide; host._getScript = _getScript; host.highDefinition = getJsonp; })(window); "use strict"; // function video_play(vid, id, title, width, height) { // var $FlashConfig = { // container: id, // id: "myMovie" + id, // width: width || 1000, // height: height || 650, // params: { // allowNetworking: "all", // allowScriptAccess: "always", // wmode: "opaque", // allowFullScreen: "true", // quality: "high" // }, // attributes: {}, // flashvars: { // autoPlay: 0, //是否自动播放 // loop: 0, // autoLoad: 1, // // thumbUrl: 'http://p1.v.iask.com/0/267/137089255_2.jpg',//视频加载前欲加载的图片地址,即播放器一开始显示的截图 // tj: 1, // as: 0 // }, // h5attr: { // autoPlay: false, //是否自动播放 // controls: true, //是否显示控制条 // loop: false, // // poster: 'http://p1.v.iask.com/0/267/137089255_2.jpg', //视频加载前欲加载的图片地址,即播放器一开始显示的截图 // preload: 'auto' // } // }; // var $SCOPE = { // video1: { // video_id: vid, // pid: '1', // url: window.location.href, // title: title, // swfOutsideUrl: '' // } // }; // var player = playVideo($FlashConfig); // player.playVideo($SCOPE['video1']); // } $(function () { $('[data-vid]').each(function () { var _this = $(this); var _vid = _this.attr('data-vid'); var _id = _this.attr('id'); // var _id = 'video_' + (_this.attr('id') || +new Date()); // _this.attr('id', _id); var _type = _this.attr('data-type'); // var _width = _this.attr('data-width'); // var _height = _this.attr('data-height'); // var _title = _this.attr('data-title') || ''; if (_vid && _id) { // if (_type == 'live') { // window.$LivePlayer.playerInit({ // liveid: _vid, //视频id // container: _id, //播放器容器id // srckey: '0' //引用来源key值,默认是0 // }); // } else { // video_play(_vid, _id, _title, _width, _height) // } if (_type == 'live') { // 直播 sfv.live({ id: _id, vid: _vid }); } else { //录播 sfv.video({ id: _id, vid: _vid, //poster: "{{$params.pic}}", //poster图 autoplay为true无效 autoPlay: false }); } } }); });