r105658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105657‎ | r105658 | r105659 >
Date:07:36, 9 December 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Make lqt work without legacy javascript globals
Modified paths:
  • /trunk/extensions/LiquidThreads/js/lqt.toolbar.js (modified) (history)
  • /trunk/extensions/LiquidThreads/lqt.js (modified) (history)
  • /trunk/extensions/LiquidThreads/newmessages.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/newmessages.js
@@ -28,7 +28,7 @@
2929 title = title.replace( ' ', '_' );
3030 title = encodeURIComponent(title);
3131 title = title.replace( '%2F', '/' );
32 - var url = wgArticlePath.replace( '$1', title );
 32+ var url = mw.config.get( 'wgArticlePath' ).replace( '$1', title );
3333 var link = $j('<a/>').attr('href', url).text(subject);
3434 elem.append(link);
3535
@@ -39,7 +39,7 @@
4040 }
4141
4242 // Add the "undo" link.
43 - var undoURL = wgArticlePath.replace( '$1', wgPageName );
 43+ var undoURL = mw.config.get( 'wgArticlePath' ).replace( '$1', mw.config.get( 'wgPageName' ) );
4444 var query = 'lqt_method=mark_as_unread&lqt_operand='+operand;
4545 if ( undoURL.indexOf('?') == -1 ) {
4646 query = '?'+query;
Index: trunk/extensions/LiquidThreads/lqt.js
@@ -259,7 +259,7 @@
260260 if ( typeof doLivePreview == 'function' ) {
261261 doLivePreview(e);
262262 } else {
263 - $j.getScript( stylepath+'/common/preview.js',
 263+ $j.getScript( mw.config.get( 'stylepath' ) +'/common/preview.js',
264264 function() { doLivePreview(e); });
265265 }
266266 },
@@ -538,7 +538,7 @@
539539 var getData = { 'action' : 'query', 'list' : 'threads', 'thid' : threads.join('|'),
540540 'format' : 'json', 'thprop' : 'id|subject|parent|modified' };
541541
542 - $j.get( wgScriptPath+'/api.php', getData,
 542+ $j.get( mw.util.wikiScript( 'api' ), getData,
543543 function(data) {
544544 var threads = data.query.threads;
545545
@@ -596,7 +596,7 @@
597597 var apiReq = { 'action' : 'query', 'list' : 'threads', 'thid' : threadId,
598598 'format' : 'json', 'thrender' : 1 };
599599
600 - $j.get( wgScriptPath+'/api.php', apiReq,
 600+ $j.get( mw.util.wikiScript( 'api' ), apiReq,
601601 function(data) {
602602 // Load data from JSON
603603 var html = data.query.threads[threadId].content;
@@ -716,7 +716,7 @@
717717 var apiParams = { 'action' : 'query', 'list' : 'threads', 'thid' : threadId,
718718 'format' : 'json', 'thrender' : '1', 'thprop' : 'id' };
719719
720 - $j.get( wgScriptPath+'/api'+wgScriptExtension, apiParams,
 720+ $j.get( mw.util.wikiScript( 'api' ), apiParams,
721721 function(data) {
722722 // Interpret
723723 var content = data.query.threads[threadId].content;
@@ -765,7 +765,7 @@
766766 'format' : 'json', 'thrender' : '1', 'thprop' : 'id',
767767 'threnderstartrepliesat' : startAt };
768768
769 - $j.get( wgScriptPath+'/api.php', apiParams,
 769+ $j.get( mw.util.wikiScript( 'api' ), apiParams,
770770 function(data) {
771771 var content = data.query.threads[threadId].content;
772772 content = $j(content).find('.lqt-thread-replies')[0];
@@ -820,7 +820,7 @@
821821 apiParams.unwatch = 'yes';
822822 }
823823
824 - $j.get( wgScriptPath+'/api'+wgScriptExtension, apiParams,
 824+ $j.get( mw.util.wikiScript( 'api' ), apiParams,
825825 function( data ) {
826826 threadLevelCommands.load( window.location.href+' '+
827827 '#'+threadLevelCommands.attr('id')+' > *' );
@@ -833,8 +833,8 @@
834834 e.preventDefault();
835835 var thread = $j(this).closest('.lqt_thread');
836836 var linkTitle = thread.find('.lqt-thread-title-metadata').val();
837 - var linkURL = wgArticlePath.replace( "$1", linkTitle.replace(/ /g, '_' ) );
838 - linkURL = wgServer + linkURL;
 837+ var linkURL = mw.config.get( 'wgArticlePath' ).replace( "$1", linkTitle.replace(/ /g, '_' ) );
 838+ linkURL = mw.config.get( 'wgServer' ) + linkURL;
839839 if ( linkURL.substr( 0, 2 ) == '//' ) {
840840 linkURL = window.location.protocol + linkURL;
841841 }
@@ -884,7 +884,7 @@
885885 'format' : 'json'
886886 };
887887
888 - $j.post( wgScriptPath+'/api'+wgScriptExtension, getTokenParams,
 888+ $j.post( mw.util.wikiScript( 'api' ), getTokenParams,
889889 function( data ) {
890890 var token = data.threadaction.token;
891891
@@ -1072,7 +1072,7 @@
10731073 newTopicParams.signature = signature;
10741074 }
10751075
1076 - $j.post( wgScriptPath+'/api'+wgScriptExtension, newTopicParams,
 1076+ $j.post( mw.util.wikiScript( 'api' ), newTopicParams,
10771077 function(data) {
10781078 if (callback) {
10791079 callback(data);
@@ -1109,7 +1109,7 @@
11101110 replyParams.signature = signature;
11111111 }
11121112
1113 - $j.post( wgScriptPath+'/api'+wgScriptExtension, replyParams,
 1113+ $j.post( mw.util.wikiScript( 'api' ), replyParams,
11141114 function(data) {
11151115 if (callback) {
11161116 callback(data);
@@ -1180,8 +1180,7 @@
11811181
11821182 request.format = 'json';
11831183
1184 - var path = wgScriptPath+'/api'+wgScriptExtension;
1185 - $j.post( path, request,
 1184+ $j.post( mw.util.wikiScript( 'api' ), request,
11861185 function(data) {
11871186 if (callback) {
11881187 callback(data);
Index: trunk/extensions/LiquidThreads/js/lqt.toolbar.js
@@ -857,7 +857,7 @@
858858 {
859859 'description': { htmlMsg: 'wikieditor-toolbar-help-content-file-description' },
860860 'syntax': { htmlMsg: 'wikieditor-toolbar-help-content-file-syntax' },
861 - 'result': { htmlMsg: [ 'wikieditor-toolbar-help-content-file-result', stylepath ] }
 861+ 'result': { htmlMsg: [ 'wikieditor-toolbar-help-content-file-result', mw.config.get( 'stylepath' ) ] }
862862 }
863863 ]
864864 },
@@ -954,7 +954,7 @@
955955 if ( typeof arguments.callee.regex == 'undefined' ) {
956956 // Cache the regex
957957 arguments.callee.regex =
958 - new RegExp( "^(" + wgUrlProtocols + "|www\\.)", 'i');
 958+ new RegExp( "^(" + mw.config.get( 'wgUrlProtocols' ) + "|www\\.)", 'i');
959959 }
960960 return s.match( arguments.callee.regex );
961961 }
@@ -1015,7 +1015,7 @@
10161016 $j( '#wikieditor-toolbar-link-int-target-status' ).data(
10171017 'request',
10181018 $j.ajax( {
1019 - url: wgScriptPath + '/api.php',
 1019+ url: mw.util.wikiScript( 'api' ),
10201020 dataType: 'json',
10211021 data: {
10221022 'action': 'query',
@@ -1212,7 +1212,7 @@
12131213 }
12141214
12151215 var request = $j.ajax( {
1216 - url: wgScriptPath + '/api.php',
 1216+ url: mw.util.wikiScript( 'api' ),
12171217 data: {
12181218 'action': 'opensearch',
12191219 'search': title,
@@ -1344,7 +1344,7 @@
13451345 open: function() {
13461346 // Cache the articlepath regex
13471347 $j(this).data( 'articlePathRegex', new RegExp(
1348 - '^' + $.escapeRE( wgServer + wgArticlePath )
 1348+ '^' + $.escapeRE( mw.config.get( 'wgServer' ) + mw.config.get( 'wgArticlePath' ) )
13491349 .replace( /\\\$1/g, '(.*)' ) + '$'
13501350 ) );
13511351 // Pre-fill the text fields based on the current selection

Status & tagging log