MediaWiki:Gadget-warnclosing.js

// **********************************************************************
// **                 ***WARNING GLOBAL GADGET FILE***                 **
// **             changes to this file affect many users.              **
// **           please discuss on the talk page before editing         **
// **                                                                  **
// **********************************************************************
// Imported from [[Thành viên:Mxn/warnclosing.js]], version as of: 2007-01-23T01:08
// Warn when closing an edited page

// Generalized version of hookEvent() in wikibits.js
var hookEvent = function (hookTarget, hookName, hookFunct) {
    if (!hookTarget) return;
    if (hookTarget.addEventListener) {
        hookTarget.addEventListener(hookName, hookFunct, false);
    }
    else if (hookTarget.attachEvent) {
        hookTarget.attachEvent("on" + hookName, hookFunct);
    }
}
 
// Record original text and attach onsubmit event to the form
editFormSubmitting = false;
$(function () {
    var editForm = document.getElementById("editform");
    var editBox = document.getElementById("wpTextbox1");
    if (!editForm || !editBox) return;
 
    wpTextbox1_orig = editBox.value;
    hookEvent(editForm, "submit", function () {
        editFormSubmitting = true;
    });
});
 
// Warn if text has changed or changes are being previewed
hookEvent(window, "beforeunload", function (e) {
    e = (window.event) ? window.event : e;
    var editBox = document.getElementById("wpTextbox1");
    if (editFormSubmitting || !editBox || !wpTextbox1_orig) return;
 
    var preview = document.getElementById("wikiPreview");
    var previewNote = getElementsByClassName(preview, "div", "previewnote");
    var isPreview = previewNote && previewNote.length > 0;
    var textChanged = editBox.value != wpTextbox1_orig;
    if (isPreview || textChanged) {
        return e.returnValue = "Tất cả các sửa đổi sẽ bị hủy vì bạn chưa lưu trang.";
    }
});
Chúng tôi bán
Bài viết liên quan
Giới thiệu Burglar - Sư phụ Goblin Slayer
Giới thiệu Burglar - Sư phụ Goblin Slayer
Sau thảm kịch xảy ra với chị gái và ngôi làng của mình, Goblin Slayer được một mạo hiểm giả tộc Rhea cứu giúp
Giới thiệu AG Izumo the Reinoha - Artery Gear: Fusion
Giới thiệu AG Izumo the Reinoha - Artery Gear: Fusion
Nhìn chung Izumo có năng lực sinh tồn cao, có thể tự buff ATK và xoá debuff trên bản thân, sát thương đơn mục tiêu tạo ra tương đối khủng
14 nguyên tắc trong định luật Murphy
14 nguyên tắc trong định luật Murphy
Bạn có bao giờ nghiệm thấy trong đời mình cứ hôm nào quên mang áo mưa là trời lại mưa; quên đem chìa khóa thì y rằng không ai ở nhà
Làm thế nào để biết bạn có bị trầm cảm hay không?
Làm thế nào để biết bạn có bị trầm cảm hay không?
Lo lắng và trầm cảm có một số biểu hiện tương đối giống nhau. Nhưng các triệu chứng chủ yếu là khác nhau