MediaWiki討論:Common.js/edit.js

頁面內容不支援其他語言。
維基百科,自由的百科全書

修改建議[編輯]

{{editprotected}}

jQuery('#wpSummary').val(jQuery.trim(jQuery('#wpSummary').val()) + ' ' + jQuery(this).val());
替换为
jQuery('#wpSummary').val(jQuery.trim(jQuery.trim(jQuery('#wpSummary').val()) + ' ' + jQuery(this).val()));

避免只點擊一次項目時編輯摘要開頭會多一個空格--YFdyh000 2012年10月4日 (四) 07:04 (UTC)[回覆]

直接換我在客棧提的了,好像沒人說有意見……Liangent留言 2012年10月5日 (五) 18:24 (UTC)[回覆]

請求修改頁面[編輯]

請求已處理

@Chiefwei此JavaScript頁面也沒有做好在地化。「工具欄」、「主題欄」、「客戶端」、「軟件」、「文本框」、「界面」。-- By LNDDYL.(留言2014年11月12日 (三) 07:07 (UTC)[回覆]

完成。—Chiefwei - - 2014年11月12日 (三) 07:40 (UTC)[回覆]
記得改狀態……--廣雅 范 2014年11月12日 (三) 09:26 (UTC)[回覆]

關於2017版編輯器 快捷編輯摘要 點擊後新打開標籤頁的問題[編輯]

下列討論已經關閉,請勿修改。如有任何意見,請至合適的討論頁進行,並不要再次編輯本討論。

之前好像在tg問過這個問題,然後推薦我反饋bug,然後我在此處反饋了,得到wmf的答覆是「這是由於中文Wikipedia上的自定義系統消息錯誤導致的」,所以請問一下,誰接觸這塊能否幫忙修一下啦(詳細請看那邊的topic)--Air7538(留言) 2020年4月6日 (一) 23:35 (UTC)[回覆]

應該是沒對2017版編輯器做專門優化--百無一用是書生 () 2020年4月7日 (二) 06:44 (UTC)[回覆]

其他幾個中文計劃也需要排查一下類似代碼,同步調整。--高文海留言2020年4月7日 (二) 14:26 (UTC)[回覆]

「發佈更改」按鈕不會在頁面載入時就存在,所以這個修正沒有解決問題。--Xiplus#Talk 2020年4月8日 (三) 02:42 (UTC)[回覆]
@Xiplus:上面代碼已修改。--高文海留言2020年4月8日 (三) 03:20 (UTC)[回覆]
已部署。--Xiplus#Talk 2020年4月8日 (三) 10:19 (UTC)[回覆]
所以,是問題修復了嘛?但我好像還是不好使。--Air7538(留言) 2020年4月8日 (三) 11:11 (UTC)[回覆]
附帶一提,這個是否移動到小工具比較好?--百無一用是書生 () 2020年4月8日 (三) 11:57 (UTC)[回覆]
有什麼差別嗎?--Xiplus#Talk 2020年4月8日 (三) 12:57 (UTC)[回覆]
我試了下,問題並沒有修復。—— Eric Liu留言留名學生會 2020年4月9日 (四) 00:35 (UTC)[回覆]
從我幾天前發現這個編輯器開始,問題就存在着。我試圖去MW反饋問題,但是我在MW沒有IPBE。另外,現在仍然不好使。--🍀 CLOVER YAN (^_^) 2020年4月9日 (四) 00:51 (UTC)簽名真麻煩,懶得切中文英文,結果還要點兩下,「插入」——「您的簽名」,還不帶「--」。[回覆]
@Xiplus:做成小工具可以用戶選擇是否關閉這個功能,技術上也便於管理維護--百無一用是書生 () 2020年4月9日 (四) 02:38 (UTC)[回覆]
Shizhao這個功能似乎不應該允許關閉。--Xiplus#Talk 2020年4月9日 (四) 02:42 (UTC)[回覆]
Xiplus不明白為何不能關閉?--百無一用是書生 () 2020年4月9日 (四) 02:48 (UTC)[回覆]
Shizhao關閉的話就會出現如上方報告類似於Bug的情況,點擊連結會開啟新分頁。--Xiplus#Talk 2020年4月9日 (四) 02:51 (UTC)[回覆]
Xiplus編輯衝突了....我明白你的意思了。我說的移動大概也包括了重構這部分代碼的問題....--百無一用是書生 () 2020年4月9日 (四) 02:56 (UTC)[回覆]

本討論已經關閉,請勿修改。如有任何意見,請至合適的討論頁進行,並不要再次編輯本討論。

說是MediaWiki:Common.js/edit.js中的問題導致了這個錯誤?--百無一用是書生 () 2020年5月12日 (二) 03:01 (UTC)[回覆]

確實如此, 已修復。--Xiplus#Talk 2020年5月12日 (二) 03:16 (UTC)[回覆]
刪掉不會造成其他問題嗎?--百無一用是書生 () 2020年5月12日 (二) 03:23 (UTC)[回覆]
已檢查沒有其他地方使用。--Xiplus#Talk 2020年5月12日 (二) 03:43 (UTC)[回覆]

編輯請求 2021-06-30[編輯]

請求已處理。--安憶Talk 2021年7月1日 (四) 00:12 (UTC)[回覆]

根據Wikipedia:互助客棧/技術#優化強制預覽代碼公示結果,請求將第108行第148行替換為以下內容:

/**
 * -------------------------------------------------------------------------------
 *  Force Preview JavaScript code - Start
 *
 *  For MediaWiki >= 1.23
 *
 *  To allow any group to bypass being forced to preview,
 *  enter the group name in the permittedGroups array.
 *  E.g.
 *    var permittedGroups = [];                        // force everyone
 *    var permittedGroups = [ 'user' ];                // permit logged-in users
 *    var permittedGroups = [ 'sysop', 'bureaucrat' ]; // permit sysop, bureaucrat
 * -------------------------------------------------------------------------------
 */

( function () {
    var permittedGroups = [ 'confirmed', 'autoconfirmed' ];
    if (
        mw.config.get( 'wgAction' ) !== 'edit' ||
        permittedGroups.some( function ( val ) {
            return mw.config.get( 'wgUserGroups' ).indexOf( val ) > -1;
        } )
    ) {
        return;
    }
    mw.loader.using( 'oojs-ui-core', function () {
        var originalLabel;
        mw.hook( 'wikipage.editform' ).add( function ( $editForm ) {
            var saveButton;
            try {
                saveButton = OO.ui.infuse( $editForm.find( '#wpSaveWidget' ) );
            } catch ( e ) {
                return;
            }
            if ( !$( '#wikiPreview, #wikiDiff' ).is( ':visible' ) ) {
                if ( saveButton.isDisabled() ) {
                    return;
                }
                if ( originalLabel === undefined ) {
                    originalLabel = saveButton.getLabel();
                }
                saveButton.setDisabled( true ).setLabel( originalLabel + wgULS( '(请先预览)', '(請先預覽)' ) );
            }
            else if ( originalLabel !== undefined ) {
                saveButton.setLabel( originalLabel ).setDisabled( false );
            }
        } );
    } );
}() );

/**
 * -----------------------------------------------------
 *   Force Preview JavaScript code - End
 * -----------------------------------------------------
 */

--Tranve () 2021年6月30日 (三) 23:34 (UTC)[回覆]

優化強制預覽代碼[編輯]


重寫了一下 Force Preview(強制預覽)的代碼,改進如下:

  1. 支持即時預覽
  2. 使用 OOUI 內建 method 調整和禁用按鈕,有更好的兼容性

代碼如下:

/**
 * -------------------------------------------------------------------------------
 *  Force Preview JavaScript code - Start
 *
 *  For MediaWiki >= 1.23
 *
 *  To allow any group to bypass being forced to preview,
 *  enter the group name in the permittedGroups array.
 *  E.g.
 *    var permittedGroups = [];                        // force everyone
 *    var permittedGroups = [ 'user' ];                // permit logged-in users
 *    var permittedGroups = [ 'sysop', 'bureaucrat' ]; // permit sysop, bureaucrat
 * -------------------------------------------------------------------------------
 */

( function () {
    var permittedGroups = [ 'confirmed', 'autoconfirmed' ];
    if (
        mw.config.get( 'wgAction' ) !== 'edit' ||
        permittedGroups.some( function ( val ) {
            return mw.config.get( 'wgUserGroups' ).indexOf( val ) > -1;
        } )
    ) {
        return;
    }
    mw.loader.using( 'oojs-ui-core', function () {
        var originalLabel;
        mw.hook( 'wikipage.editform' ).add( function ( $editForm ) {
            var saveButton;
            try {
                saveButton = OO.ui.infuse( $editForm.find( '#wpSaveWidget' ) );
            } catch ( e ) {
                return;
            }
            // eslint-disable-next-line no-jquery/no-sizzle
            if ( !$( '#wikiPreview, #wikiDiff' ).is( ':visible' ) ) {
                if ( saveButton.isDisabled() ) {
                    return;
                }
                if ( originalLabel === undefined ) {
                    originalLabel = saveButton.getLabel();
                }
                saveButton.setDisabled( true ).setLabel( originalLabel + wgULS( '(请先预览)', '(請先預覽)' ) );
            }
            else if ( originalLabel !== undefined ) {
                saveButton.setLabel( originalLabel ).setDisabled( false );
            }
        } );
    } );
}() );

/**
 * -----------------------------------------------------
 *   Force Preview JavaScript code - End
 * -----------------------------------------------------
 */

顯示上沒有任何變化。如果無異議將提請更換。

以上。--Tranve () 2021年6月19日 (六) 04:42 (UTC)[回覆]

說實話這種東西不管做成怎樣用一個特殊的url就逃得過去了(((-- Sunny00217  2021年6月19日 (六) 08:09 (UTC)[回覆]
看起來前提是有安裝Twinkle?--Kanashimi留言2021年6月19日 (六) 12:38 (UTC)[回覆]
代碼做了些調整,有問題請留言。--Lt2818留言2021年6月19日 (六) 16:51 (UTC)[回覆]
@Lt2818::我看了一下,好像無論是原有代碼還是上方代碼,點擊「顯示更改」都會啟用提交按鈕,好像不是預期行為,貌似要大改……--Tranve () 2021年6月20日 (日) 07:57 (UTC)[回覆]
那可以加一個只有取消預設行為函式?-- Sunny00217  2021年6月20日 (日) 09:58 (UTC)[回覆]
這是合理的,用戶可以選擇查看更改。比如在大頁面中改了錯別字,預覽要花很多時間,此時查看更改更為合適。--Lt2818留言2021年6月20日 (日) 14:33 (UTC)[回覆]
參考下面Tranve的新版本再次做些調整。根據文檔,事件觸發時editForm可能尚未加進DOM樹,只能用find辦法獲取其中元素。--Lt2818留言2021年6月20日 (日) 18:14 (UTC)[回覆]
做些調整。改動:一、補充注釋;二、根據 MediaWiki 的 ESLint rule 調整代碼風格。--Tranve () 2021年6月23日 (三) 12:32 (UTC)[回覆]
與 Lt2818 討論後,棄用摺疊內容中的版本,改為使用上文提及的版本。--Tranve () 2021年6月21日 (一) 11:45 (UTC)[回覆]

受到 Lt2818 修改的代碼的啟發,設計了一個新版本,代碼位於 Tranve/public/ForcePreview.js

相比以前版本,使用 sessionStorage 判斷是否已經預覽,比之前版本更加精確,同時讓新用戶更加頭疼。[開玩笑的]

以上。--Tranve () 2021年6月20日 (日) 12:48 (UTC)[回覆]

https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.storage.session , this normalises differences across browsers and silences any and all exceptions that may occur.--安憶Talk 2021年6月20日 (日) 13:09 (UTC)[回覆]
見以上留言,我認為現行代碼的行為符合預期。--Lt2818留言2021年6月20日 (日) 14:35 (UTC)[回覆]



以上代碼 公示7日,2021年6月30日 (三) 12:36 (UTC) 結束,到期即提請編輯請求。--Tranve () 2021年6月23日 (三) 12:36 (UTC)[回覆]

已提交請求。--Tranve () 2021年6月30日 (三) 23:36 (UTC)[回覆]
完成。--安憶Talk 2021年7月1日 (四) 00:13 (UTC)[回覆]

編輯請求 2023-12-22[編輯]

Wikipedia:互助客棧/技術/存檔/2023年11月#Edit.js_兩項修改提案,把這個問題給趕緊處理了吧,拖延很久了。輸入一遍又一遍的驗證碼,真的很煩啊!(而且頭一遍輸入的驗證碼是沒用的。)--93.95.230.142留言2023年12月22日 (五) 02:36 (UTC)[回覆]

@SunAfterRain,你修訂的那個js是否可用?--百無一用是書生 () 2024年4月9日 (二) 03:24 (UTC)[回覆]
@Shizhao我自己試Special:PermanentLink/79652411#L-108是有效果的就是--SunAfterRain 2024年4月10日 (三) 11:00 (UTC)[回覆]
話說這部分代碼能否做成單獨的小工具,默認啟用?--百無一用是書生 () 2024年4月10日 (三) 13:06 (UTC)[回覆]