User:PB2008/script-installer.js: Difference between revisions

From Test Wiki
m
no edit summary
mNo edit summary
Tags: Mobile edit Mobile web edit
mNo edit summary
Tags: Mobile edit Mobile web edit
Line 500: Line 500:
         // Namespace 8 is MediaWiki
         // Namespace 8 is MediaWiki
         if( namespaceNumber === 8 ) {
         if( namespaceNumber === 8 ) {
             return $( "<a>" ).text( "Install via preferences" )
             return $( "<a>" ).text( "經偏好設定安裝" )
                     .attr( "href", mw.util.getUrl( "Special:Preferences" ) + "#mw-prefsection-gadgets" );
                     .attr( "href", mw.util.getUrl( "Special:Preferences" ) + "#mw-prefsection-gadgets" );
         }
         }
Line 512: Line 512:
                     $( "<img>" ).attr( "src", "https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Achtung-yellow.svg/20px-Achtung-yellow.svg.png" ).addClass( "warning" ),
                     $( "<img>" ).attr( "src", "https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Achtung-yellow.svg/20px-Achtung-yellow.svg.png" ).addClass( "warning" ),
                     "(insecure)" )
                     "(insecure)" )
                 .attr( "title", "Installation of non-User, non-MediaWiki"+
                 .attr( "title", "不是User空間或MediaWiki空間的安裝"+
                     " protected pages is temporary and may be removed in the future." ) );
                     "受保護的頁面是臨時的,將來可能會被刪除。" ) );
             addingInstallLink = true;
             addingInstallLink = true;
         }
         }
Line 526: Line 526:
         }
         }


         return $( "<abbr>" ).text( "Cannot install (insecure)" )
         return $( "<abbr>" ).text( "不能安裝 (不安全)" )
                 .attr( "title", "Page is not User: or MediaWiki: and is unprotected" );
                 .attr( "title", "頁面不是位於用戶空間或MediaWiki空間,且未被保護" );
     }
     }


Line 538: Line 538:
                 " | ",
                 " | ",
                 $( "<a>" )
                 $( "<a>" )
                     .text( "Manage user scripts" ).click( function () {
                     .text( "管理用戶小工具" ).click( function () {
                         if( !document.getElementById( "script-installer-panel" ) ) {
                         if( !document.getElementById( "script-installer-panel" ) ) {
                             $( "#mw-content-text" ).before( makePanel() );
                             $( "#mw-content-text" ).before( makePanel() );
Line 553: Line 553:
             var scriptName = this.id;
             var scriptName = this.id;
             $( this ).append( " | ", $( "<a>" )
             $( this ).append( " | ", $( "<a>" )
                     .text( localScriptsByName[ scriptName ] ? "Uninstall" : "Install" )
                     .text( localScriptsByName[ scriptName ] ? "解決安裝" : "安裝" )
                     .click( makeLocalInstallClickHandler( scriptName ) ) );
                     .click( makeLocalInstallClickHandler( scriptName ) ) );
         } );
         } );
Line 574: Line 574:
         return function () {
         return function () {
             var $this = $( this );
             var $this = $( this );
             if( $this.text() === "Install" ) {
             if( $this.text() === "安裝" ) {
                 var okay = window.sciNoConfirm || window.confirm( "Warning! All user scripts could contain malicious content capable of compromising your account. Installing a script means it could be changed by others; make sure you trust its author. If you're unsure whether a script is safe, check at the technical village pump. Install this script? (Hide this dialog next time with sciNoConfirm=true; in your common.js.)" );
                 var okay = window.sciNoConfirm || window.confirm( "Warning! All user scripts could contain malicious content capable of compromising your account. Installing a script means it could be changed by others; make sure you trust its author. If you're unsure whether a script is safe, check at the technical village pump. Install this script? (Hide this dialog next time with sciNoConfirm=true; in your common.js.)" );
                 if( okay ) {
                 if( okay ) {
                     $( this ).text( "Installing..." )
                     $( this ).text( "安裝中..." )
                     Import.ofLocal( scriptName, "common" ).install().done( function () {
                     Import.ofLocal( scriptName, "common" ).install().done( function () {
                         $( this ).text( "Uninstall" );
                         $( this ).text( "解除安裝" );
                         conditionalReload( false );
                         conditionalReload( false );
                     }.bind( this ) );
                     }.bind( this ) );
                 }
                 }
             } else {
             } else {
                 $( this ).text( "Uninstalling..." )
                 $( this ).text( "解除安裝中..." )
                 var uninstalls = uniques( localScriptsByName[ scriptName ] )
                 var uninstalls = uniques( localScriptsByName[ scriptName ] )
                         .map( function ( target ) { return Import.ofLocal( scriptName, target ).uninstall(); } )
                         .map( function ( target ) { return Import.ofLocal( scriptName, target ).uninstall(); } )
                 $.when.apply( $, uninstalls ).then( function () {
                 $.when.apply( $, uninstalls ).then( function () {
                     $( this ).text( "Install" );
                     $( this ).text( "安裝" );
                     conditionalReload( false );
                     conditionalReload( false );
                 }.bind( this ) );
                 }.bind( this ) );
Cookies help us deliver our services. By using our services, you agree to our use of cookies.