Remove tofu detection logging

Change-Id: I2b808bae2ee19062c16d8aaff2bdf0b2986e8ad0
This commit is contained in:
Amir E. Aharoni
2014-06-26 14:52:15 +03:00
parent 28dcc1e284
commit 6de6bdf8f2
5 changed files with 0 additions and 106 deletions

View File

@@ -42,11 +42,6 @@
interfaceLanguage: mw.config.get( 'wgUserLanguage' )
} );
mw.eventLog.setDefaults( 'UniversalLanguageSelector-tofu', {
version: 1,
token: mw.user.id()
} );
eventLogger.logEventQueue.fire();
},
@@ -92,7 +87,6 @@
mw.hook( 'mw.uls.font.change' ).add( $.proxy( this.fontChange, this ) );
mw.hook( 'mw.uls.webfonts.enable' ).add( $.proxy( this.enableWebfonts, this ) );
mw.hook( 'mw.uls.webfonts.disable' ).add( $.proxy( this.disableWebfonts, this ) );
mw.hook( 'mw.uls.webfonts.tofudetected' ).add( $.proxy( this.tofuDetected, this ) );
$( 'body' ).on( 'noresults.uls', '.uls-menu .languagefilter',
$.proxy( this.noSearchResults, this )
@@ -235,17 +229,6 @@
this.log( { action: 'webfonts-enable', context: context } );
},
/**
* Log tofu detection
* @param {string} language Code of the element in which tofu was detected
*/
tofuDetected: function ( language ) {
this.log( {
tofuElementLanguage: language,
webfontsEnabled: mw.webfonts.preferences.isEnabled()
}, 'UniversalLanguageSelector-tofu' );
},
/**
* Log search strings which produce no search results.
* @param {jQuery.event} event The orignal event

View File

@@ -224,70 +224,11 @@
$( document ).ready( function () {
mw.uls.init( function () {
var tofuStartTime, tofuEndTime, tofuTime;
mw.webfonts.preferences.load();
if ( mw.webfonts.preferences.isEnabled() ) {
mw.loader.using( 'ext.uls.webfonts.fonts', mw.webfonts.setup );
}
// If event logging is enabled and this page "wins" the tofu logging lottery
// try to detect tofu
if ( !mw.config.get( 'wgULSEventLogging' ) ||
mw.config.get( 'wgULSTofuLoggingChance' ) < mw.config.get( 'wgArticleId' ) % 100
) {
return;
}
setTimeout( function () {
var i, lang, text,
$langElements, $element,
maxTime = mw.config.get( 'wgULSTofuLoggingMaxTime' );
tofuStartTime = ( new Date() ).getTime();
// Check all elements that have the lang attribute,
// except the root <html> - it has lang,
// but its text is not useful for testing.
// mw-content-text also always has lang,
// and its text is more relevant.
$langElements = $( 'body [lang]' );
for ( i = 0; i < $langElements.length; i++ ) {
$element = $( $langElements[ i ] );
lang = $element.prop( 'lang' );
// Skip if this languages was already tested
if ( tofuLanguages[lang] !== undefined ) {
continue;
}
text = $.trim( $element.text() ).substr( 0, 4 );
// Skip if the text only has basic ASCII and Latin
if ( !text.match( /[^\u0009-\u0200]/ ) ) {
continue;
}
tofuLanguages[lang] = detectTofu( text );
if ( tofuLanguages[lang] ) {
mw.log( 'tofu detected for ' + lang );
mw.hook( 'mw.uls.webfonts.tofudetected' ).fire( lang );
}
// Force to break the detection loop if it's taking too long
if ( maxTime && ( new Date() ).getTime() - tofuStartTime > maxTime ) {
mw.log( 'tofu detection max time reached. last lang: ' + lang );
break;
}
}
tofuEndTime = ( new Date() ).getTime();
tofuTime = ( tofuEndTime - tofuStartTime ) / 1000;
mw.log( 'tofu detection took ' + tofuTime + ' seconds' );
}, 1000 );
} );
} );
}( jQuery, mediaWiki ) );