Changeset 6366

Show
Ignore:
Timestamp:
02/08/08 11:42:22 (5 years ago)
Author:
cho45
Message:

websites/coderepos.org/trac/share/js/TracUtils.js:

似たような処理をまとめた。

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • websites/coderepos.org/trac/share/js/TracUtils.js

    r6365 r6366  
    122122                TracUtils.addCommitterRecentCommits(); 
    123123                TracUtils.addRecentChangesForProject(); 
    124                 TracUtils.avoidGreasemonkeyInstallation(); 
    125                 TracUtils.addGreasemonkeyInstallLink(); 
     124                TracUtils.addUserscriptsUtils(); 
    126125                TracUtils.AuthorIcons.showAuthorIcons(); 
    127126        } 
     
    138137        } 
    139138 
     139        , getSourcePath : function (tracPath) { 
     140                return String(tracPath).replace(TracUtils.TRAC_BASE + "/browser", TracUtils.SVN_REPOS_BASE).replace(/\?.*/, ''); 
     141        } 
     142 
    140143        /** 
    141144         * Browse Source のときに該当する svn web にすぐ翔べるリンクと 
     
    145148                var aboutLink  = $("#metanav li.last a"); 
    146149                if (location.pathname.indexOf("/share/browser") == 0) { 
    147                         var sourcePath = String(location).replace(TracUtils.TRAC_BASE + "/browser", TracUtils.SVN_REPOS_BASE).replace(/\?.*/, ''); 
     150                        var sourcePath = TracUtils.getSourcePath(location); 
    148151                        aboutLink.replaceWith( 
    149152                                $("<a title='Jump to Repository'>SVN Web</a>").attr("href", sourcePath) 
     
    248251 
    249252        /** 
    250          * user.js のページがインストール画面でてうざいのをなんとかする。 
    251          */ 
    252         , avoidGreasemonkeyInstallation : function () { 
    253                 // あんまり広範囲にやりたくないので決め打ち 
    254                 if (($.browser.mozilla || $.browser.safari) && location.pathname == "/share/browser/lang/javascript/userscripts") { 
    255                         $("a").each(function () { 
    256                                 if (this.href.indexOf(".user.js") == this.href.length - 8) this.href += "?"; 
    257                         }); 
    258                 } 
    259         } 
    260  
    261         /** 
    262          * user.js のページにインストールURLを追加する. 
    263          */ 
    264         , addGreasemonkeyInstallLink : function () { 
    265                 if (!(new RegExp("^/share/browser/lang/javascript/userscripts/.*\\.user\\.js")).test(location.pathname) || 
    266                     !$.browser.mozilla && !$.browser.safari) 
    267                         return; 
    268                 var uri = location.protocol + '//svn.coderepos.org' + location.pathname.replace('browser/', ''); 
    269                 $('<a/>') 
    270                 .attr({ 
    271                         href  : uri, 
    272                         title : uri.split('/').slice(-1) + ' をインストールする' 
    273                 }) 
    274                 .text('インストール - ' + uri) 
    275                 .insertAfter($('h1:first')); 
     253         * Userscripts のユーティリティ 
     254         */ 
     255        , addUserscriptsUtils : function () { 
     256                if (($.browser.mozilla || $.browser.safari)) { 
     257                        // user.js のページがインストール画面でてうざいのをなんとかする。 
     258                        // あんまり広範囲にやりたくないので決め打ち 
     259                        if (location.pathname == "/share/browser/lang/javascript/userscripts") { 
     260                                $("a").each(function () { 
     261                                        if (this.href.indexOf(".user.js") == this.href.length - 8) this.href += "?"; 
     262                                }); 
     263                        } 
     264 
     265                        // user.js のページにインストールURLを追加する. 
     266                        if (location.pathname.match(/\.user\.js$/)) { 
     267                                var uri = TracUtils.getSourcePath(location); 
     268                                $('<a/>').attr({ 
     269                                        href  : uri, 
     270                                        title : uri.split('/').slice(-1) + ' をインストールする' 
     271                                }) 
     272                                .text('インストール - ' + uri) 
     273                                .insertAfter($('h1:first')); 
     274                        } 
     275                } 
    276276        } 
    277277