r90245 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90244‎ | r90245 | r90246 >
Date:23:32, 16 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
small tweaks
Modified paths:
  • /trunk/extensions/LiveTranslate/includes/ext.livetranslate.js (modified) (history)
  • /trunk/extensions/LiveTranslate/includes/ext.lt.google.js (modified) (history)
  • /trunk/extensions/LiveTranslate/includes/ext.lt.ms.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiveTranslate/includes/ext.lt.google.js
@@ -29,7 +29,7 @@
3030 * @param {integer} currentMaxSize
3131 * @param {string} sourceLang
3232 * @param {string} targetLang
33 - * @param {jQuery} element
 33+ * @param {DOM element} element
3434 */
3535 this.translateChunk = function( untranslatedsentences, chunks, currentMaxSize, sourceLang, targetLang, element ) {
3636 ltdebug( 'Google: Translating chunk' );
Index: trunk/extensions/LiveTranslate/includes/ext.livetranslate.js
@@ -20,7 +20,12 @@
2121
2222 window.ltdebug = function( message ) {
2323 if ( window.ltDebugMessages ) {
24 - console.log( 'Live Translate: ' + message );
 24+ if ( typeof console === 'undefined' ) {
 25+ document.title = 'Live Translate: ' + message;
 26+ }
 27+ else {
 28+ console.log( 'Live Translate: ' + message );
 29+ }
2530 }
2631 };
2732
@@ -29,6 +34,8 @@
3035 // For the "show original" feature.
3136 var originalHtml = false;
3237
 38+ window.textAreaElement = document.createElement( 'textarea' );
 39+
3340 // Compatibility with pre-RL code.
3441 // Messages will have been loaded into wgPushMessages.
3542 if ( typeof mediaWiki === 'undefined' ) {
Index: trunk/extensions/LiveTranslate/includes/ext.lt.ms.js
@@ -14,9 +14,6 @@
1515
1616 this.runningJobs = 0;
1717
18 - // This is to enable a hack to decode quotes.
19 - this.textAreaElement = document.createElement( 'textarea' );
20 -
2118 /**
2219 * Determines a chunk to translate of an DOM elements contents and calls the Microsoft Translate API.
2320 * Then calls itself if there is any remaining work to be done.
@@ -26,7 +23,7 @@
2724 * @param {integer} currentMaxSize
2825 * @param {string} sourceLang
2926 * @param {string} targetLang
30 - * @param {jQuery} element
 27+ * @param {DOM element} element
3128 */
3229 this.translateChunk = function( untranslatedsentences, chunks, currentMaxSize, sourceLang, targetLang, element ) {
3330 ltdebug( 'MS: Translating chunk' );
@@ -105,8 +102,9 @@
106103
107104 if ( untranslatedsentences.length == 0 ) {
108105 // If the current chunk was smaller then the max size, node translation is complete, so update text.
109 - self.textAreaElement.innerHTML = chunks.join( '' ); // This is a hack to decode quotes.
110 - element.replaceData( 0, element.length, self.textAreaElement.value );
 106+ window.textAreaElement.innerHTML = chunks.join( '' ); // This is a hack to decode quotes.
 107+ element.replaceData( 0, element.length, window.textAreaElement.value );
 108+
111109 self.handleTranslationCompletion( targetLang );
112110 }
113111 else {

Status & tagging log