欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

discuz中用到的javascript函數(shù)解析 原創(chuàng)

原創(chuàng)  更新時(shí)間:2008年05月28日 22:26:14   原創(chuàng) 作者:  
discuz中用到的js不論是多瀏覽器兼容性和實(shí)用性都是非常不錯(cuò)的,推薦大家看下

function ajaxupdateevents(obj, tagName) {
    tagName = tagName ? tagName : 'A';
    var objs = obj.getElementsByTagName(tagName);
    for(k in objs) {
        var o = objs[k];
        ajaxupdateevent(o);
    }
}

function ajaxupdateevent(o) {
    if(typeof o == 'object' && o.getAttribute) {
        if(o.getAttribute('ajaxtarget')) {
            if(!o.id) o.id = Math.random();
            var ajaxevent = o.getAttribute('ajaxevent') ? o.getAttribute('ajaxevent') : 'click';
            var ajaxurl = o.getAttribute('ajaxurl') ? o.getAttribute('ajaxurl') : o.href;
            _attachEvent(o, ajaxevent, newfunction('ajaxget', ajaxurl, o.getAttribute('ajaxtarget'), o.getAttribute('ajaxwaitid'), o.getAttribute('ajaxloading'), o.getAttribute('ajaxdisplay')));
            if(o.getAttribute('ajaxfunc')) {
                o.getAttribute('ajaxfunc').match(/(\w+)\((.+?)\)/);
                _attachEvent(o, ajaxevent, newfunction(RegExp.$1, RegExp.$2));
            }
        }
    }
}

/*
 *@ url: 需求請(qǐng)求的 url
 *@ id : 顯示的 id
 *@ waitid: 等待的 id,默認(rèn)為顯示的 id,如果 waitid 為空字符串,則不顯示 loading..., 如果為 null,則在 showid 區(qū)域顯示
 *@ linkid: 是哪個(gè)鏈接觸發(fā)的該 ajax 請(qǐng)求,該對(duì)象的屬性(如 ajaxdisplay)保存了一些 ajax 請(qǐng)求過程需要的數(shù)據(jù)。
*/
function ajaxget(url, showid, waitid, loading, display, recall) {
    waitid = typeof waitid == 'undefined' || waitid === null ? showid : waitid;
    var x = new Ajax();
    x.setLoading(loading);
    x.setWaitId(waitid);
    x.display = typeof display == 'undefined' || display == null ? '' : display;
    x.showId = $(showid);
    if(x.showId) x.showId.orgdisplay = typeof x.showId.orgdisplay === 'undefined' ? x.showId.style.display : x.showId.orgdisplay;

    if(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) {
        evaled = false;
        if(s.indexOf('ajaxerror') != -1) {
            evalscript(s);
            evaled = true;
        }
        if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
            if(x.showId) {
                changedisplay(x.showId, x.showId.orgdisplay);
                changedisplay(x.showId, x.display);
                x.showId.orgdisplay = x.showId.style.display;
                ajaxinnerhtml(x.showId, s);
                ajaxupdateevents(x.showId);
                if(x.autogoto) scroll(0, x.showId.offsetTop);
            }
        }
        if(!evaled)evalscript(s);
        ajaxerror = null;
        if(recall) {eval(recall);}
    });
}

var ajaxpostHandle = 0;
function ajaxpost(formid, showid, waitid) {
    showloading();
    var waitid = typeof waitid == 'undefined' || waitid === null ? showid : (waitid !== '' ? waitid : '');

    if(ajaxpostHandle != 0) {
        return false;
    }
    var ajaxframeid = 'ajaxframe';
    var ajaxframe = $(ajaxframeid);
    if(ajaxframe == null) {
        if (is_ie && !is_opera) {
            ajaxframe = document.createElement("<iframe name='" + ajaxframeid + "' id='" + ajaxframeid + "'></iframe>");
        } else {
            ajaxframe = document.createElement("iframe");
            ajaxframe.name = ajaxframeid;
            ajaxframe.id = ajaxframeid;
        }
        //ajaxframe.id = ajaxframeid;
        ajaxframe.style.display = 'none';
        $('append_parent').appendChild(ajaxframe);

    }
    $(formid).target = ajaxframeid;
    ajaxpostHandle = [showid, ajaxframeid, formid, $(formid).target];
    if(ajaxframe.attachEvent) {
        ajaxframe.detachEvent ('onload', ajaxpost_load);
        ajaxframe.attachEvent('onload', ajaxpost_load);
    } else {
        document.removeEventListener('load', ajaxpost_load, true);
        ajaxframe.addEventListener('load', ajaxpost_load, false);
    }
    $(formid).submit();
    return false;
    //$(waitid).innerHTML = 'Loading...';
}

function ajaxpost_load() {
    showloading('none');
    if(is_ie) {
        var s = $(ajaxpostHandle[1]).contentWindow.document.XMLDocument.text;
    } else {
        var s = $(ajaxpostHandle[1]).contentWindow.document.documentElement.firstChild.nodeValue;
    }
    evaled = false;
    if(s.indexOf('ajaxerror') != -1) {
        evalscript(s);
        evaled = true;
    }
    if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
        ajaxinnerhtml($(ajaxpostHandle[0]), s);
        if(!evaled)evalscript(s);
        setMenuPosition($(ajaxpostHandle[0]).ctrlid, 0);
        setTimeout("hideMenu()", 3000);
    }
    ajaxerror = null;
    if($(ajaxpostHandle[2])) {
        $(ajaxpostHandle[2]).target = ajaxpostHandle[3];
        //$(ajaxpostHandle[2]).removeChild($(ajaxpostHandle[1]));
    }
    ajaxpostHandle = 0;
}

function ajaxmenu(e, ctrlid, timeout, func, cache, duration, ismenu, divclass, optionclass) {
    showloading();
    if(jsmenu['active'][0] && jsmenu['active'][0].ctrlkey == ctrlid) {
        hideMenu();
        doane(e);
        return;
    } else if(is_ie && is_ie < 7 && document.readyState.toLowerCase() != 'complete') {
        return;
    }
    if(isUndefined(timeout)) timeout = 3000;
    if(isUndefined(func)) func = '';
    if(isUndefined(cache)) cache = 1;
    if(isUndefined(divclass)) divclass = 'popupmenu_popup';
    if(isUndefined(optionclass)) optionclass = 'popupmenu_option';
    if(isUndefined(ismenu)) ismenu = 1;
    if(isUndefined(duration)) duration = timeout > 0 ? 0 : 3;
    var div = $(ctrlid + '_menu');
    if(cache && div) {
        showMenu(ctrlid, e.type == 'click', 0, duration, timeout, 0, ctrlid, 400, 1);
        if(func) setTimeout(func + '(' + ctrlid + ')', timeout);
        doane(e);
    } else {
        if(!div) {
            div = document.createElement('div');
            div.ctrlid = ctrlid;
            div.id = ctrlid + '_menu';
            div.style.display = 'none';
            div.className = divclass;
            $('append_parent').appendChild(div);
        }

        var x = new Ajax();
        var href = !isUndefined($(ctrlid).href) ? $(ctrlid).href : $(ctrlid).attributes['href'].value;
        x.div = div;
        x.etype = e.type;
        x.optionclass = optionclass;
        x.duration = duration;
        x.timeout = timeout;
        x.get(href + '&inajax=1&ajaxmenuid='+ctrlid+'_menu', function(s) {
            evaled = false;
            if(s.indexOf('ajaxerror') != -1) {
                evalscript(s);
                evaled = true;
                if(!cache && duration != 3 && x.div.id) setTimeout('$("append_parent").removeChild($(\'' + x.div.id + '\'))', timeout);
            }
            if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
                if(x.div) x.div.innerHTML = '<div class="' + x.optionclass + '">' + s + '</div>';
                showMenu(ctrlid, x.etype == 'click', 0, x.duration, x.timeout, 0, ctrlid, 400, 1);
                if(func) setTimeout(func + '("' + ctrlid + '")', x.timeout);
                //if(!cache && duration != 3 && x.div.id) setTimeout('document.body.removeChild($(\'' + x.div.id + '\'))', timeout);
            }
            if(!evaled) evalscript(s);
            ajaxerror = null;
            showloading('none');
        });
        doane(e);
    }
}

//得到一個(gè)定長(zhǎng)的hash值, 依賴于 stringxor()
function hash(string, length) {
    var length = length ? length : 32;
    var start = 0;
    var i = 0;
    var result = '';
    filllen = length - string.length % length;
    for(i = 0; i < filllen; i++){
        string += "0";
    }
    while(start < string.length) {
        result = stringxor(result, string.substr(start, length));
        start += length;
    }
    return result;
}

function stringxor(s1, s2) {
    var s = '';
    var hash = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var max = Math.max(s1.length, s2.length);
    for(var i=0; i<max; i++) {
        var k = s1.charCodeAt(i) ^ s2.charCodeAt(i);
        s += hash.charAt(k % 52);
    }
    return s;
}

function showloading(display, waiting) {
    var display = display ? display : 'block';
    var waiting = waiting ? waiting : 'Loading...';
    $('ajaxwaitid').innerHTML = waiting;
    $('ajaxwaitid').style.display = display;
}

function ajaxinnerhtml(showid, s) {
    if(showid.tagName != 'TBODY') {
        showid.innerHTML = s;
    } else {
        while(showid.firstChild) {
            showid.firstChild.parentNode.removeChild(showid.firstChild);
        }
        var div1 = document.createElement('DIV');
        div1.id = showid.id+'_div';
        div1.innerHTML = '<table><tbody id="'+showid.id+'_tbody">'+s+'</tbody></table>';
        $('append_parent').appendChild(div1);
        var trs = div1.getElementsByTagName('TR');
        var l = trs.length;
        for(var i=0; i<l; i++) {
            showid.appendChild(trs[0]);
        }
        var inputs = div1.getElementsByTagName('INPUT');
        var l = inputs.length;
        for(var i=0; i<l; i++) {
            showid.appendChild(inputs[0]);
        }
        div1.parentNode.removeChild(div1);
    }
}

var hiddenobj = new Array();
var pmwinposition = new Array();
function pmwin(action, param) {
    var objs = document.getElementsByTagName("OBJECT");
    if(action == 'open') {
        for(i = 0;i < objs.length; i ++) {
            if(objs[i].style.visibility != 'hidden') {
                objs[i].setAttribute("oldvisibility", objs[i].style.visibility);
                objs[i].style.visibility = 'hidden';
            }
        }
        var clientWidth = document.body.clientWidth;
        var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
        var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
        var pmwidth = 800;
        var pmheight = clientHeight * 0.9;
        if(!$('pmlayer')) {
            div = document.createElement('div');div.id = 'pmlayer';
            div.style.width = pmwidth + 'px';
            div.style.height = pmheight + 'px';
            div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
            div.style.position = 'absolute';
            div.style.zIndex = '999';
            $('append_parent').appendChild(div);
            $('pmlayer').innerHTML = '<div style="width: 800px; background: #666666; margin: 5px auto; text-align: left">' +
                '<div style="width: 800px; height: ' + pmheight + 'px; padding: 1px; background: #FFFFFF; border: 1px solid #7597B8; position: relative; left: -6px; top: -3px">' +
                '<div onmouseover="pmwindrag(this)" style="cursor: move; position: relative; left: 0px; top: 0px; width: 800px; height: 30px; margin-bottom: -30px;"></div>' +
                '<a href="###" onclick="pmwin(\'close\')"><img style="position: absolute; right: 20px; top: 15px" src="' + IMGDIR +'/close.gif" title="關(guān)閉" /></a>' +
                '<div id="pmwinmask" style="margin-top: 30px; position: absolute; width: 100%; height: 100%; display: none"></div><iframe id="pmframe" name="pmframe" style="width:' + pmwidth + 'px;height:100%" allowTransparency="true" frameborder="0"></iframe></div></div>';
        }
        $('pmlayer').style.display = '';
        $('pmlayer').style.top = ((clientHeight - pmheight) / 2 + scrollTop) + 'px';
        if(!param) {
            pmframe.location = 'pm.php';
        } else {
            pmframe.location = 'pm.php?' + param;
        }
    } else if(action == 'close') {
        for(i = 0;i < objs.length; i ++) {
            if(objs[i].attributes['oldvisibility']) {
                objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodeValue;
                objs[i].removeAttribute('oldvisibility');
            }
        }
        hiddenobj = new Array();
        $('pmlayer').style.display = 'none';
    }
}

var pmwindragstart = new Array();
function pmwindrag(obj) {
    obj.onmousedown = function(e) {
        if(is_ie) {
            document.body.onselectstart = function() {
                return false;
            }
        }
        pmwindragstart = is_ie ? [event.clientX, event.clientY] : [e.clientX, e.clientY];
        pmwindragstart[2] = parseInt($('pmlayer').style.left);
        pmwindragstart[3] = parseInt($('pmlayer').style.top);
        $('pmwinmask').style.display = '';
        doane(e);
    }
    _attachEvent(document.body, 'mousemove', function(e) {
        if(pmwindragstart[0]) {
            var pmwindragnow = is_ie ? [event.clientX, event.clientY] : [e.clientX, e.clientY];
            with($('pmlayer')) {
                style.left = (pmwindragstart[2] + pmwindragnow[0] - pmwindragstart[0]) + 'px';
                style.top = (pmwindragstart[3] + pmwindragnow[1] - pmwindragstart[1]) + 'px';
            }
            doane(e);
        }
    });
    obj.onmouseup = function(e) {
        if(is_ie) {
            document.body.onselectstart = function() {
                return true;
            }
        }
        pmwindragstart = [];
        $('pmwinmask').style.display = 'none';
        doane(e);
    }
    obj.onmouseover = null;
}

function pmchecknew() {
    ajaxget('pm.php?checknewpm=' + Math.random(), 'pmnotice', 'ajaxwaitid');
}

var discuz_uid = isUndefined(discuz_uid) ? 0 : discuz_uid;
if(discuz_uid && !getcookie('checkpm') && typeof IN_ADMINCP == 'undefined') {
    if(document.attachEvent) {
        window.attachEvent('onload', pmchecknew);
    } else {
        window.addEventListener('load', pmchecknew, false);
    }
}

相關(guān)文章

  • 在JavaScript中如何使用宏詳解

    在JavaScript中如何使用宏詳解

    這篇文章主要給大家介紹了關(guān)于在JavaScript中如何使用宏的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-05-05
  • JavaScript漢諾塔問題解決方法

    JavaScript漢諾塔問題解決方法

    這篇文章主要介紹了JavaScript漢諾塔問題解決方法,涉及javascript遞歸調(diào)用操作的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-04-04
  • JavaScript輸出所選擇起始與結(jié)束日期的方法

    JavaScript輸出所選擇起始與結(jié)束日期的方法

    這篇文章主要介紹了JavaScript輸出所選擇起始與結(jié)束日期的方法,涉及javascript結(jié)合HTML5元素操作日期運(yùn)算的相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2017-07-07
  • JavaScript實(shí)現(xiàn)拼圖式滑塊驗(yàn)證功能

    JavaScript實(shí)現(xiàn)拼圖式滑塊驗(yàn)證功能

    滑塊驗(yàn)證碼是在網(wǎng)站、APP等應(yīng)用中常見的一種驗(yàn)證方式,通過按照一定規(guī)則滑動(dòng)滑塊到指定位置完成驗(yàn)證,才可以進(jìn)行下一步操作,本文給大家分享基于JavaScript實(shí)現(xiàn)拼圖式滑塊驗(yàn)證功能,感興趣的朋友一起看看吧
    2022-06-06
  • javascript實(shí)現(xiàn)貪吃蛇經(jīng)典游戲

    javascript實(shí)現(xiàn)貪吃蛇經(jīng)典游戲

    這篇文章主要為大家詳細(xì)介紹了javascript實(shí)現(xiàn)貪吃蛇經(jīng)典游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-04-04
  • JavaScript Event學(xué)習(xí)第七章 事件屬性

    JavaScript Event學(xué)習(xí)第七章 事件屬性

    為了理解Event屬性,我將在這里給出一些示例代碼。在這個(gè)范疇內(nèi)有非常嚴(yán)重的瀏覽器兼容性問題。
    2010-02-02
  • JS提示:Uncaught SyntaxError:Unexpected token ) 錯(cuò)誤的解決方法

    JS提示:Uncaught SyntaxError:Unexpected token ) 錯(cuò)誤的解決方法

    這篇文章主要介紹了JS提示:Uncaught SyntaxError:Unexpected token ) 錯(cuò)誤的解決方法,結(jié)合實(shí)例形式分析了javascript提示此類異常的常見原因與相關(guān)解決方法,需要的朋友可以參考下
    2016-08-08
  • 原生JavaScript之es6中Class的用法分析

    原生JavaScript之es6中Class的用法分析

    這篇文章主要介紹了原生JavaScript之es6中Class的用法,結(jié)合實(shí)例形式對(duì)比分析了es6與es5相關(guān)class定義、區(qū)別及使用技巧,需要的朋友可以參考下
    2020-02-02
  • JS實(shí)現(xiàn)圖片懶加載(lazyload)過程詳解

    JS實(shí)現(xiàn)圖片懶加載(lazyload)過程詳解

    這篇文章主要介紹了JS實(shí)現(xiàn)圖片懶加載(lazyload)過程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04
  • 基于Leaflet的Webgis經(jīng)緯網(wǎng)格功能實(shí)現(xiàn)

    基于Leaflet的Webgis經(jīng)緯網(wǎng)格功能實(shí)現(xiàn)

    本文將介紹一款Leaflet的經(jīng)緯網(wǎng)插件,基于這款經(jīng)緯網(wǎng)插件,詳細(xì)介紹如何實(shí)現(xiàn)經(jīng)緯網(wǎng)功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧
    2023-12-12

最新評(píng)論