var supporttouch = "ontouchend" in document; !supporttouch && (window.location.href = 'forum.php?mobile=1'); var platform = navigator.platform; var ua = navigator.userAgent; var ios = /iPhone|iPad|iPod/.test(platform) && ua.indexOf( "AppleWebKit" ) > -1; var andriod = ua.indexOf( "Android" ) > -1; (function($, window, document, undefined) { var dataPropertyName = "virtualMouseBindings", touchTargetPropertyName = "virtualTouchID", virtualEventNames = "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "), touchEventProps = "clientX clientY pageX pageY screenX screenY".split( " " ), mouseHookProps = $.event.mouseHooks ? $.event.mouseHooks.props : [], mouseEventProps = $.event.props.concat( mouseHookProps ), activeDocHandlers = {}, resetTimerID = 0, startX = 0, startY = 0, didScroll = false, clickBlockList = [], blockMouseTriggers = false, blockTouchTriggers = false, eventCaptureSupported = "addEventListener" in document, $document = $(document), nextTouchID = 1, lastTouchID = 0, threshold; $.vmouse = { moveDistanceThreshold: 10, clickDistanceThreshold: 10, resetTimerDuration: 1500 }; function getNativeEvent(event) { while( event && typeof event.originalEvent !== "undefined" ) { event = event.originalEvent; } return event; } function createVirtualEvent(event, eventType) { var t = event.type, oe, props, ne, prop, ct, touch, i, j, len; event = $.Event(event); event.type = eventType; oe = event.originalEvent; props = $.event.props; if(t.search(/^(mouse|click)/) > -1 ) { props = mouseEventProps; } if(oe) { for(i = props.length, prop; i;) { prop = props[ --i ]; event[ prop ] = oe[ prop ]; } } if(t.search(/mouse(down|up)|click/) > -1 && !event.which) { event.which = 1; } if(t.search(/^touch/) !== -1) { ne = getNativeEvent(oe); t = ne.touches; ct = ne.changedTouches; touch = (t && t.length) ? t[0] : (( ct && ct.length) ? ct[0] : undefined); if(touch) { for(j = 0, len = touchEventProps.length; j < len; j++) { prop = touchEventProps[j]; event[prop] = touch[prop]; } } } return event; } function getVirtualBindingFlags(element) { var flags = {}, b, k; while(element) { b = $.data(element, dataPropertyName); for(k in b) { if(b[k]) { flags[k] = flags.hasVirtualBinding = true; } } element = element.parentNode; } return flags; } function getClosestElementWithVirtualBinding(element, eventType) { var b; while(element) { b = $.data( element, dataPropertyName ); if(b && (!eventType || b[eventType])) { return element; } element = element.parentNode; } return null; } function enableTouchBindings() { blockTouchTriggers = false; } function disableTouchBindings() { blockTouchTriggers = true; } function enableMouseBindings() { lastTouchID = 0; clickBlockList.length = 0; blockMouseTriggers = false; disableTouchBindings(); } function disableMouseBindings() { enableTouchBindings(); } function startResetTimer() { clearResetTimer(); resetTimerID = setTimeout(function() { resetTimerID = 0; enableMouseBindings(); }, $.vmouse.resetTimerDuration); } function clearResetTimer() { if(resetTimerID ) { clearTimeout(resetTimerID); resetTimerID = 0; } } function triggerVirtualEvent(eventType, event, flags) { var ve; if((flags && flags[eventType]) || (!flags && getClosestElementWithVirtualBinding(event.target, eventType))) { ve = createVirtualEvent(event, eventType); $(event.target).trigger(ve); } return ve; } function mouseEventCallback(event) { var touchID = $.data(event.target, touchTargetPropertyName); if(!blockMouseTriggers && (!lastTouchID || lastTouchID !== touchID)) { var ve = triggerVirtualEvent("v" + event.type, event); if(ve) { if(ve.isDefaultPrevented()) { event.preventDefault(); } if(ve.isPropagationStopped()) { event.stopPropagation(); } if(ve.isImmediatePropagationStopped()) { event.stopImmediatePropagation(); } } } } function handleTouchStart(event) { var touches = getNativeEvent(event).touches, target, flags; if(touches && touches.length === 1) { target = event.target; flags = getVirtualBindingFlags(target); if(flags.hasVirtualBinding) { lastTouchID = nextTouchID++; $.data(target, touchTargetPropertyName, lastTouchID); clearResetTimer(); disableMouseBindings(); didScroll = false; var t = getNativeEvent(event).touches[0]; startX = t.pageX; startY = t.pageY; triggerVirtualEvent("vmouseover", event, flags); triggerVirtualEvent("vmousedown", event, flags); } } } function handleScroll(event) { if(blockTouchTriggers) { return; } if(!didScroll) { triggerVirtualEvent("vmousecancel", event, getVirtualBindingFlags(event.target)); } didScroll = true; startResetTimer(); } function handleTouchMove(event) { if(blockTouchTriggers) { return; } var t = getNativeEvent(event).touches[0], didCancel = didScroll, moveThreshold = $.vmouse.moveDistanceThreshold, flags = getVirtualBindingFlags(event.target); didScroll = didScroll || (Math.abs(t.pageX - startX) > moveThreshold || Math.abs(t.pageY - startY) > moveThreshold); if(didScroll && !didCancel) { triggerVirtualEvent("vmousecancel", event, flags); } triggerVirtualEvent("vmousemove", event, flags); startResetTimer(); } function handleTouchEnd(event) { if(blockTouchTriggers) { return; } disableTouchBindings(); var flags = getVirtualBindingFlags(event.target), t; triggerVirtualEvent("vmouseup", event, flags); if(!didScroll) { var ve = triggerVirtualEvent("vclick", event, flags); if(ve && ve.isDefaultPrevented()) { t = getNativeEvent(event).changedTouches[0]; clickBlockList.push({ touchID: lastTouchID, x: t.clientX, y: t.clientY }); blockMouseTriggers = true; } } triggerVirtualEvent("vmouseout", event, flags); didScroll = false; startResetTimer(); } function hasVirtualBindings(ele) { var bindings = $.data( ele, dataPropertyName ), k; if(bindings) { for(k in bindings) { if(bindings[k]) { return true; } } } return false; } function dummyMouseHandler() {} function getSpecialEventObject(eventType) { var realType = eventType.substr(1); return { setup: function(data, namespace) { if(!hasVirtualBindings(this)) { $.data(this, dataPropertyName, {}); } var bindings = $.data(this, dataPropertyName); bindings[eventType] = true; activeDocHandlers[eventType] = (activeDocHandlers[eventType] || 0) + 1; if(activeDocHandlers[eventType] === 1) { $document.bind(realType, mouseEventCallback); } $(this).bind(realType, dummyMouseHandler); if(eventCaptureSupported) { activeDocHandlers["touchstart"] = (activeDocHandlers["touchstart"] || 0) + 1; if(activeDocHandlers["touchstart"] === 1) { $document.bind("touchstart", handleTouchStart) .bind("touchend", handleTouchEnd) .bind("touchmove", handleTouchMove) .bind("scroll", handleScroll); } } }, teardown: function(data, namespace) { --activeDocHandlers[eventType]; if(!activeDocHandlers[eventType]) { $document.unbind(realType, mouseEventCallback); } if(eventCaptureSupported) { --activeDocHandlers["touchstart"]; if(!activeDocHandlers["touchstart"]) { $document.unbind("touchstart", handleTouchStart) .unbind("touchmove", handleTouchMove) .unbind("touchend", handleTouchEnd) .unbind("scroll", handleScroll); } } var $this = $(this), bindings = $.data(this, dataPropertyName); if(bindings) { bindings[eventType] = false; } $this.unbind(realType, dummyMouseHandler); if(!hasVirtualBindings(this)) { $this.removeData(dataPropertyName); } } }; } for(var i = 0; i < virtualEventNames.length; i++) { $.event.special[virtualEventNames[i]] = getSpecialEventObject(virtualEventNames[i]); } if(eventCaptureSupported) { document.addEventListener("click", function(e) { var cnt = clickBlockList.length, target = e.target, x, y, ele, i, o, touchID; if(cnt) { x = e.clientX; y = e.clientY; threshold = $.vmouse.clickDistanceThreshold; ele = target; while(ele) { for(i = 0; i < cnt; i++) { o = clickBlockList[i]; touchID = 0; if((ele === target && Math.abs(o.x - x) < threshold && Math.abs(o.y - y) < threshold) || $.data(ele, touchTargetPropertyName) === o.touchID) { e.preventDefault(); e.stopPropagation(); return; } } ele = ele.parentNode; } } }, true); } })(jQuery, window, document); (function($, window, undefined) { function triggercustomevent(obj, eventtype, event) { var origtype = event.type; event.type = eventtype; $.event.handle.call(obj, event); event.type = origtype; } $.event.special.tap = { setup : function() { var thisobj = this; var obj = $(thisobj); obj.on('vmousedown', function(e) { if(e.which && e.which !== 1) { return false; } var origtarget = e.target; var origevent = e.originalEvent; var timer; function cleartaptimer() { clearTimeout(timer); } function cleartaphandlers() { cleartaptimer(); obj.off('vclick', clickhandler) .off('vmouseup', cleartaptimer); $(document).off('vmousecancel', cleartaphandlers); } function clickhandler(e) { cleartaphandlers(); if(origtarget === e.target) { triggercustomevent(thisobj, 'tap', e); } return false; } obj.on('vmouseup', cleartaptimer) .on('vclick', clickhandler) $(document).on('touchcancel', cleartaphandlers); timer = setTimeout(function() { triggercustomevent(thisobj, 'taphold', $.Event('taphold', {target:origtarget})); }, 750); return false; }); } }; $.each(('tap').split(' '), function(index, name) { $.fn[name] = function(fn) { return this.on(name, fn); }; }); })(jQuery, this); var page = { converthtml : function() { var prevpage = $('div.pg .prev').prop('href'); var nextpage = $('div.pg .nxt').prop('href'); var lastpage = $('div.pg label span').text().replace(/[^\d]/g, '') || 0; var curpage = $('div.pg input').val() || 1; if(!lastpage) { prevpage = $('div.pg .pgb a').prop('href'); } var prevpagehref = nextpagehref = ''; if(prevpage == undefined) { prevpagehref = 'javascript:;" class="grey'; } else { prevpagehref = prevpage; } if(nextpage == undefined) { nextpagehref = 'javascript:;" class="grey'; } else { nextpagehref = nextpage; } var selector = ''; if(lastpage) { selector += ''; selector += ''; selector += '第'+curpage+'页'; } $('div.pg').removeClass('pg').addClass('page').html('上一页'+ selector +'下一页'); $('#dumppage').on('change', function() { var href = (prevpage || nextpage); window.location.href = href.replace(/page=\d+/, 'page=' + $(this).val()); }); }, }; var scrolltop = { obj : null, init : function(obj) { scrolltop.obj = obj; var fixed = this.isfixed(); obj.css('opacity', '.618'); if(fixed) { obj.css('bottom', '8px'); } else { obj.css({'visibility':'visible', 'position':'absolute'}); } $(window).on('resize', function() { if(fixed) { obj.css('bottom', '8px'); } else { obj.css('top', ($(document).scrollTop() + $(window).height() - 40) + 'px'); } }); obj.on('tap', function() { $(document).scrollTop($(document).height()); }); $(document).on('scroll', function() { if(!fixed) { obj.css('top', ($(document).scrollTop() + $(window).height() - 40) + 'px'); } if($(document).scrollTop() >= 400) { obj.removeClass('bottom') .off().on('tap', function() { window.scrollTo('0', '1'); }); } else { obj.addClass('bottom') .off().on('tap', function() { $(document).scrollTop($(document).height()); }); } }); }, isfixed : function() { var offset = scrolltop.obj.offset(); var scrollTop = $(window).scrollTop(); var screenHeight = document.documentElement.clientHeight; if(offset == undefined) { return false; } if(offset.top < scrollTop || (offset.top - scrollTop) > screenHeight) { return false; } else { return true; } } }; var img = { init : function(is_err_t) { var errhandle = this.errorhandle; $('img').on('load', function() { var obj = $(this); obj.attr('zsrc', obj.attr('src')); if(obj.width() < 5 && obj.height() < 10 && obj.css('display') != 'none') { return errhandle(obj, is_err_t); } obj.css('display', 'inline'); obj.css('visibility', 'visible'); if(obj.width() > window.innerWidth) { obj.css('width', window.innerWidth); } obj.parent().find('.loading').remove(); obj.parent().find('.error_text').remove(); }) .on('error', function() { var obj = $(this); obj.attr('zsrc', obj.attr('src')); errhandle(obj, is_err_t); }); }, errorhandle : function(obj, is_err_t) { if(obj.attr('noerror') == 'true') { return; } obj.css('visibility', 'hidden'); obj.css('display', 'none'); var parentnode = obj.parent(); parentnode.find('.loading').remove(); parentnode.append('
'); var loadnums = parseInt(obj.attr('load')) || 0; if(loadnums < 3) { obj.attr('src', obj.attr('zsrc')); obj.attr('load', ++loadnums); return false; } if(is_err_t) { var parentnode = obj.parent(); parentnode.find('.loading').remove(); parentnode.append('