User:Irukaza/js/editConflict.js:修订间差异
跳到导航
跳到搜索
无编辑摘要
imported>=海豚= ([InPageEdit] 没有编辑摘要) |
imported>=海豚= 无编辑摘要 |
||
| 第11行: | 第11行: | ||
const wpSave = $("#wpSave"); | const wpSave = $("#wpSave"); | ||
const editform = $("#editform"); | const editform = $("#editform"); | ||
const conflictAlert = "提示:如果 | const conflictAlert = "提示:如果 快快快"; | ||
const SYMBOL_UNDEFINED = Symbol("SYMBOL_UNDEFINED"); | const SYMBOL_UNDEFINED = Symbol("SYMBOL_UNDEFINED"); | ||
wpSave.val = (value = SYMBOL_UNDEFINED) => { | wpSave.val = (value = SYMBOL_UNDEFINED) => { | ||
| 第37行: | 第37行: | ||
if (pageid > 0 && result.query.pages[pageid].revisions[0].revid > wgCurRevisionId) { | if (pageid > 0 && result.query.pages[pageid].revisions[0].revid > wgCurRevisionId) { | ||
wpSave.val("提交失败,存在编辑冲突!"); | wpSave.val("提交失败,存在编辑冲突!"); | ||
$("body").append(`<div style="background: #3366CC; color: white; text-align: center; padding: .5rem; position: fixed; top: 0; left: 0; right: 0; z-index: 9999;"><p>本页面已被他人更改。请 | $("body").append(`<div style="background: #3366CC; color: white; text-align: center; padding: .5rem; position: fixed; top: 0; left: 0; right: 0; z-index: 9999;"><p>本页面 在您编辑的这段时间内 已被他人更改。请 复制 您的编辑内容 刷新页面 后重新开始编辑,以避免这中间的编辑丢失。</p><p><span id="copyCurrentRawCode" class="mw-ui-button">复制当前编辑内容</span> <span id="showNewestRevisionDiff" class="mw-ui-button">查看最新版本差异</span> <span id="refreshPage" class="mw-ui-button mw-ui-destructive">不保存内容,直接刷新页面(慎重!)</span></div>`); | ||
const pre = $("<pre/>", { | const pre = $("<pre/>", { | ||
css: { | css: { | ||
| 第71行: | 第71行: | ||
} | } | ||
}); | }); | ||
disable($("#wpPreview, #wpDiff").on("click", () => { | |||
setTimeout(() => { | |||
alert(conflictAlert); | |||
}, 1); | |||
return false; | |||
}).attr("title", conflictAlert)); | |||
await mw.loader.using('mediawiki.notification'); | await mw.loader.using('mediawiki.notification'); | ||
$("#mw-notification-area").css({ | $("#mw-notification-area").css({ | ||
| 第83行: | 第89行: | ||
} catch (e) { | } catch (e) { | ||
console.error("editConflict", e); | console.error("editConflict", e); | ||
wpSave.val(i <= 3 ? `提交失败!可能存在编辑冲突,正在检测(第${i}次)……` : "提交失败,请刷新界面 | wpSave.val(i <= 3 ? `提交失败!可能存在编辑冲突,正在检测(第${i}次)……` : "提交失败,请 备份您的编辑内容后 刷新界面重 新编辑"); | ||
} | } | ||
} | } | ||