var _thunder_id_ = 37361; var SHARE = {}; SHARE.ParseTpl = function(str, data) { var tplEngine = function(tpl, data) { var reg = /\{([^|}]+)?\}/g, regOut = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g, code = 'var r=[];\n', cursor = 0; var add = function(line, js) { js? (code += line.match(regOut) ? line + '\n' : 'typeof '+line+'=="undefined"||'+line+'=="null"||typeof '+line+'=="object"?"":r.push('+line+');\n') : (code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : ''); return add; } while(match = reg.exec(tpl)) { add(tpl.slice(cursor, match.index))(match[1], true); cursor = match.index + match[0].length; } add(tpl.substr(cursor, tpl.length - cursor)); code += 'return r.join("");'; return new Function('data',code.replace(/[\r\t\n]/g, '')).call(this,data); } //获取元素 var element = document.getElementById(str); if (element) { var html = /^(textarea|input)$/i.test(element.nodeName) ? element.value : element.innerHTML; return tplEngine(html, data); } else { return tplEngine(str, data); } } SHARE.FloatMiddel = function($obj,width,height){ if(typeof width=='undefined') width = 0; if(typeof height=='undefined') height = 0; var h_width = width!=''?width:$obj.outerWidth(); var h_height = height!=''?height:$obj.outerHeight(); var w_width = $(window).width(); var w_height = $(window).height(); $obj.css({'position':'absolute','right':(w_width-h_width)/2,'top':(w_height-h_height)/2+$(document).scrollTop()}); } SHARE.ThunderEncode = function(url){ var thunderPrefix="AA"; var thunderPosix="ZZ"; var thunderTitle="thunder://"; var thunderUrl=thunderTitle+Base64.encodeURI(thunderPrefix+url+thunderPosix); return thunderUrl; } SHARE.TimeOut = function($obj,expire_time){ var timefunc = function(expire_time){ var now = Math.round((new Date().getTime())/1000); var dist = expire_time-now; if(dist<0) return; var day = Math.floor(dist/60/60/24); var hour = Math.floor(dist/60/60-day*24); var min = Math.floor(dist/60-hour*60-day*24*60); var sec = Math.floor(dist-min*60-hour*60*60-day*24*60*60); var html = ''+day+'天'+hour+'时'+min+'分'+sec+'秒'; $obj.html(html); window.setTimeout(timefunc,1000,expire_time); } timefunc(expire_time); } SHARE.Copy=function($obj,string){ var flash_copy = false; var copy_success = function(){ alert('已复制到粘贴板中',1); } var text_default = '对不起,没有可复制的内容'; try{ if(document.queryCommandSupported('Copy')){ $obj.click(function(){ var text = document.createElement('textarea'); text.value = typeof string=='string'?string:string.call(this); if(!text.value){ alert(text_default);return false; }; text.style.width = 1; text.style.height = 1; $obj.after(text); text.focus();text.select(); document.execCommand('Copy',false,null); $('textarea').remove(); copy_success(); }) }else{ flash_copy = true; } }catch(e){ flash_copy = true; } if(flash_copy){ var flush_copy_func = function(){ $obj.mouseenter(function(){ var _text = typeof string=='string'?string:string.call(this); if(_text){ ZeroClipboard.setMoviePath(GLOBAL.CONST.RES_URL+'ZeroClipboard10.swf'); clip = new ZeroClipboard.Client(); clip.glue($(this).get(0)); clip.addEventListener('complete',copy_success); clip.addEventListener('mouseout',function(client){ client.hide(); }); clip.setText(_text); }else{ $(this).one('click',function(){ alert(text_default); }) } }); } if(typeof ZeroClipboard!='object'){ $.ajax({url:GLOBAL.CONST.RES_URL+'js/ZeroClipboard.js',type:'get',async:false,dataType:'script',success:function(){flush_copy_func()}}) }else{ flush_copy_func(); } } } SHARE.item_app_download = function($obj){ $('.pop_app_down').remove(); var html = '