「User:Irukaza/js/editConflict.js」:修訂間差異

跳至導覽 跳至搜尋
移除 939 位元組 、​ 2021年2月24日 (星期三)
無編輯摘要
imported>=海豚=
無編輯摘要
imported>=海豚=
無編輯摘要
第20行: 第20行:
        needCheckFlag = false;
        needCheckFlag = false;
        setTimeout(async () => {
        setTimeout(async () => {
          disable(wpSave.attr("disabled", "disabled").val("正在保存..."));
          disable(wpSave.attr("disabled", "disabled").val("正在保存......"));
          for (let i = 1; i <= 4; i++) {
          for (let i = 1; i <= 4; i++) {
            try {
            try {
第32行: 第32行:
              const pageid = Object.keys(result.query.pages)[0];
              const pageid = Object.keys(result.query.pages)[0];
              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>本页面已被他人更改。请复制您的编辑到剪贴板,然后刷新页面,重新开始编辑,以避免编辑冲突。</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></p></div>`);
                const pre = $("<pre/>", {
                const pre = $("<pre/>", {
                  css: {
                  css: {
第48行: 第47行:
                    top: 0,
                    top: 0,
                  }).appendTo("body");
                  }).appendTo("body");
                 if ($(".ace_editor").length > 0) {
                   mw.notify("当前已开启代码编辑器,无法获取真实编辑内容,请手动复制。");
                   return;
                 }
                  const selection = window.getSelection();
                  const selection = window.getSelection();
                  const rangeCount = selection.rangeCount;
                  const rangeCount = selection.rangeCount;
第85行: 第80行:
                }).attr("title", conflictAlert));
                }).attr("title", conflictAlert));
              } else {
              } else {
                wpSave.val(" 没有编辑冲突, 正在保存 ……");
                wpSave.val("正在保存......");
                editform.submit();
                editform.submit();
              }
              }
第92行: 第87行:
            } catch (e) {
            } catch (e) {
              console.error("editConflict", e);
              console.error("editConflict", e);
              wpSave.val(i <= 3 ? ` 编辑冲突检查 失败,正在重试(第${i}次) ……` : " 编辑冲突检查 失败,请 稍后重试……");
              wpSave.val(i <= 3 ? ` 保存 失败,正在重试(第${i}次)...` : " 保存 失败,请 检查您的网络!");
            }
            }
          }
          }
匿名用戶

導覽菜單