UNPKG

dzxstatic

Version:

The static files of Discuz! X

1 lines 5.45 kB
function _ajaxget(url,showid,waitid,loading,display,recall){waitid=null==waitid?showid:waitid;var x=new Ajax;x.setLoading(loading),x.setWaitId(waitid),x.display=void 0===display||null==display?"":display,x.showId=$(showid),"#"==url.substr(strlen(url)-1)&&(url=url.substr(0,strlen(url)-1),x.autogoto=1);var url=url+"&inajax=1&ajaxtarget="+showid;x.get(url,(function(s,x){var evaled=!1;-1!=s.indexOf("ajaxerror")&&(evalscript(s),evaled=!0),evaled||"undefined"!=typeof ajaxerror&&ajaxerror||x.showId&&(x.showId.style.display=x.display,ajaxinnerhtml(x.showId,s),ajaxupdateevents(x.showId),x.autogoto&&scroll(0,x.showId.offsetTop)),ajaxerror=null,recall&&"function"==typeof recall?recall():recall&&eval(recall),evaled||evalscript(s)}))}function _ajaxpost(formid,showid,waitid,showidclass,submitbtn,recall){var waitid=null==waitid?showid:""!==waitid?waitid:"",showidclass=showidclass||"",ajaxframeid="ajaxframe",ajaxframe=$(ajaxframeid),curform=$(formid),formtarget=curform.target,handleResult=function(){var s="",evaled=!1;showloading("none");try{s=$(ajaxframeid).contentWindow.document.XMLDocument.text}catch(e){try{s=$(ajaxframeid).contentWindow.document.documentElement.firstChild.wholeText}catch(e){try{s=$(ajaxframeid).contentWindow.document.documentElement.firstChild.nodeValue}catch(e){s="内部错误,无法显示此内容"}}}""!=s&&-1!=s.indexOf("ajaxerror")&&(evalscript(s),evaled=!0),showidclass&&("onerror"!=showidclass?$(showid).className=showidclass:(showError(s),ajaxerror=!0)),submitbtn&&(submitbtn.disabled=!1),evaled||"undefined"!=typeof ajaxerror&&ajaxerror||ajaxinnerhtml($(showid),s),ajaxerror=null,curform&&(curform.target=formtarget),"function"==typeof recall?recall():eval(recall),evaled||evalscript(s),ajaxframe.loading=0,!BROWSER.firefox||BROWSER.safari?$("append_parent").removeChild(ajaxframe.parentNode):setTimeout((function(){$("append_parent").removeChild(ajaxframe.parentNode)}),100)};if(ajaxframe){if(ajaxframe.loading)return!1}else{var div=document.createElement("div");div.style.display="none",div.innerHTML='<iframe name="'+ajaxframeid+'" id="'+ajaxframeid+'" loading="1"></iframe>',$("append_parent").appendChild(div),ajaxframe=$(ajaxframeid)}_attachEvent(ajaxframe,"load",handleResult),showloading(),curform.target=ajaxframeid;var action=curform.getAttribute("action");return action=hostconvert(action),curform.action=action.replace(/\&inajax\=1/g,"")+"&inajax=1",curform.submit(),submitbtn&&(submitbtn.disabled=!0),doane(),!1}function _ajaxmenu(ctrlObj,timeout,cache,duration,pos,recall,idclass,contentclass){if(ctrlObj.getAttribute("mid")){var ctrlid=ctrlObj.getAttribute("mid");ctrlObj.id||(ctrlObj.id="ajaxid_"+Math.random())}else{var ctrlid=ctrlObj.id;ctrlid||(ctrlObj.id="ajaxid_"+Math.random())}var menuid=ctrlid+"_menu",menu=$(menuid);isUndefined(timeout)&&(timeout=3e3),isUndefined(cache)&&(cache=1),isUndefined(pos)&&(pos="43"),isUndefined(duration)&&(duration=timeout>0?0:3),isUndefined(idclass)&&(idclass="p_pop"),isUndefined(contentclass)&&(contentclass="p_opt");var func=function(){showMenu({ctrlid:ctrlObj.id,menuid:menuid,duration:duration,timeout:timeout,pos:pos,cache:cache,layer:2}),"function"==typeof recall?recall():eval(recall)};if(menu)""==menu.style.display?hideMenu(menuid):func();else{menu=document.createElement("div"),menu.id=menuid,menu.style.display="none",menu.className=idclass,menu.innerHTML='<div class="'+contentclass+'" id="'+menuid+'_content"></div>',$("append_parent").appendChild(menu);var url=isUndefined(ctrlObj.attributes.shref)?isUndefined(ctrlObj.href)?ctrlObj.attributes.href.value:ctrlObj.href:ctrlObj.attributes.shref.value;url+=(-1!=url.indexOf("?")?"&":"?")+"ajaxmenu=1",ajaxget(url,menuid+"_content","ajaxwaitid","","",func)}doane()}function _appendscript(e,a,t,i){var r=hash(e+a);if(t||!in_array(r,evalscripts)){t&&$(r)&&$(r).parentNode.removeChild($(r)),evalscripts.push(r);var n=document.createElement("script");n.type="text/javascript",n.id=r,n.charset=i||(BROWSER.firefox?document.characterSet:document.charset);try{e?(n.src=e,n.onloadDone=!1,n.onload=function(){n.onloadDone=!0,JSLOADED[e]=1},n.onreadystatechange=function(){"loaded"!=n.readyState&&"complete"!=n.readyState||n.onloadDone||(n.onloadDone=!0,JSLOADED[e]=1)}):a&&(n.text=a),document.getElementsByTagName("head")[0].appendChild(n)}catch(e){}}}function _ajaxupdateevents(e,a){a=a||"A";var t=e.getElementsByTagName(a);for(k in t){var i=t[k];ajaxupdateevent(i)}}function _ajaxupdateevent(e){if("object"==typeof e&&e.getAttribute&&e.getAttribute("ajaxtarget")){e.id||(e.id=Math.random());var a=e.getAttribute("ajaxevent")?e.getAttribute("ajaxevent"):"click",t=e.getAttribute("ajaxurl")?e.getAttribute("ajaxurl"):e.href;_attachEvent(e,a,newfunction("ajaxget",t,e.getAttribute("ajaxtarget"),e.getAttribute("ajaxwaitid"),e.getAttribute("ajaxloading"),e.getAttribute("ajaxdisplay"))),e.getAttribute("ajaxfunc")&&(e.getAttribute("ajaxfunc").match(/(\w+)\((.+?)\)/),_attachEvent(e,a,newfunction(RegExp.$1,RegExp.$2)))}}function _ajaxinnerhtml(e,a){if("TBODY"!=e.tagName)e.innerHTML=a;else{for(;e.firstChild;)e.firstChild.parentNode.removeChild(e.firstChild);var t=document.createElement("DIV");t.id=e.id+"_div",t.innerHTML='<table><tbody id="'+e.id+'_tbody">'+a+"</tbody></table>",$("append_parent").appendChild(t);for(var i=t.getElementsByTagName("TR"),r=i.length,n=0;n<r;n++)e.appendChild(i[0]);var d=t.getElementsByTagName("INPUT");for(r=d.length,n=0;n<r;n++)e.appendChild(d[0]);t.parentNode.removeChild(t)}}