Skip to content

Instantly share code, notes, and snippets.

@jdlrobson
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdlrobson/a05ddad00175ebceac68 to your computer and use it in GitHub Desktop.
Save jdlrobson/a05ddad00175ebceac68 to your computer and use it in GitHub Desktop.
diff --git a/javascripts/Overlay.js b/javascripts/Overlay.js
index 9ef7f7b..a5e944e 100644
--- a/javascripts/Overlay.js
+++ b/javascripts/Overlay.js
@@ -97,11 +97,11 @@
if ( M.isIos && this.hasFixedHeader ) {
$overlayContent
.on( 'touchstart', function ( ev ) {
- startY = ev.originalEvent.touches[0].pageY;
+ startY = ev.originalEvent.touches[ 0 ].pageY;
} )
.on( 'touchmove', function ( ev ) {
var
- y = ev.originalEvent.touches[0].pageY,
+ y = ev.originalEvent.touches[ 0 ].pageY,
contentLenght = $overlayContent.prop( 'scrollHeight' ) - $overlayContent.outerHeight();
ev.stopPropagation();
diff --git a/javascripts/OverlayManager.js b/javascripts/OverlayManager.js
index 97b7fda..eddfce9 100644
--- a/javascripts/OverlayManager.js
+++ b/javascripts/OverlayManager.js
@@ -92,7 +92,7 @@
_checkRoute: function ( ev ) {
var
self = this,
- current = this.stack[0],
+ current = this.stack[ 0 ],
match;
$.each( this.entries, function ( id, entry ) {
@@ -130,7 +130,7 @@
_matchRoute: function ( path, entry ) {
var
match = path.match( entry.route ),
- previous = this.stack[1],
+ previous = this.stack[ 1 ],
next;
if ( match ) {
@@ -181,7 +181,7 @@
factory: factory
};
- this.entries[route] = entry;
+ this.entries[ route ] = entry;
// check if overlay should be shown for the current path
this._processMatch( this._matchRoute( this.router.getPath(), entry ) );
},
@@ -198,8 +198,8 @@
if ( this.stack.length === 0 ) {
throw new Error( 'Trying to replace OverlayManager\'s current overlay, but stack is empty' );
}
- this._hideOverlay( this.stack[0].overlay );
- this.stack[0].overlay = overlay;
+ this._hideOverlay( this.stack[ 0 ].overlay );
+ this.stack[ 0 ].overlay = overlay;
this._showOverlay( overlay );
}
} );
diff --git a/javascripts/Page.js b/javascripts/Page.js
index 4899ec1..e413910 100644
--- a/javascripts/Page.js
+++ b/javascripts/Page.js
@@ -119,8 +119,8 @@
var nsId,
args = this.options.title.split( ':' );
- if ( args[1] ) {
- nsId = mw.config.get( 'wgNamespaceIds' )[ args[0].toLowerCase().replace( ' ', '_' ) ] || 0;
+ if ( args[ 1 ] ) {
+ nsId = mw.config.get( 'wgNamespaceIds' )[ args[ 0 ].toLowerCase().replace( ' ', '_' ) ] || 0;
} else {
nsId = 0;
}
@@ -151,7 +151,7 @@
$.each( options.sections, function () {
var section = new Section( this );
self.sections.push( section );
- self._sectionLookup[section.id] = section;
+ self._sectionLookup[ section.id ] = section;
} );
},
diff --git a/javascripts/PageApi.js b/javascripts/PageApi.js
index 784f097..9aba412 100644
--- a/javascripts/PageApi.js
+++ b/javascripts/PageApi.js
@@ -18,7 +18,7 @@
listOfSections.push( child );
} else {
// take a look at the last child
- section = listOfSections[listOfSections.length - 1];
+ section = listOfSections[ listOfSections.length - 1 ];
// If the level is the same as another section in this list it is a sibling
if ( parseInt( section.level, 10 ) === parseInt( child.level, 10 ) ) {
listOfSections.push( child );
@@ -52,16 +52,14 @@
}
section.children = [];
- if (
- !lastSection ||
- (
- !section.level ||
+ if ( !lastSection ||
+ ( !section.level ||
section.level === collapseLevel
) ||
// make sure lastSections first child's level is bigger than section.level
(
lastSection.children.length &&
- lastSection.children[0].level > section.level
+ lastSection.children[ 0 ].level > section.level
) ||
// also make sure section.level is not bigger than the lastSection.level
(
@@ -110,8 +108,8 @@
edit: [ '*' ]
};
- if ( !this.cache[title] ) {
- page = this.cache[title] = $.Deferred();
+ if ( !this.cache[ title ] ) {
+ page = this.cache[ title ] = $.Deferred();
this.get( {
action: 'mobileview',
page: title,
@@ -127,7 +125,7 @@
if ( resp.error || !resp.mobileview.sections ) {
page.reject( resp );
- // FIXME: [LQT] remove when liquid threads is dead (see Bug 51586)
+ // FIXME: [LQT] remove when liquid threads is dead (see Bug 51586)
} else if ( resp.mobileview.hasOwnProperty( 'liquidthreads' ) ) {
page.reject( {
error: {
@@ -154,7 +152,7 @@
id: mv.id,
revId: mv.revId,
protection: protection,
- lead: sections[0].text,
+ lead: sections[ 0 ].text,
sections: sections.slice( 1 ),
isMainPage: mv.hasOwnProperty( 'mainpage' ) ? true : false,
historyUrl: mw.util.getUrl( title, {
@@ -177,7 +175,7 @@
} ).fail( $.proxy( page, 'reject' ) );
}
- return this.cache[title];
+ return this.cache[ title ];
},
/**
@@ -187,7 +185,7 @@
* @param {string} title the title of the page who's cache you want to invalidate
*/
invalidatePage: function ( title ) {
- delete this.cache[title];
+ delete this.cache[ title ];
},
/**
@@ -209,11 +207,11 @@
return v;
} );
// FIXME: "|| []" wouldn't be needed if API was more consistent
- langlinks = pages[0] ? pages[0].langlinks || [] : [];
+ langlinks = pages[ 0 ] ? pages[ 0 ].langlinks || [] : [];
$.each( langlinks, function ( index, item ) {
item.langname = allAvailableLanguages[ item.lang ];
- item.title = item['*'] || false;
+ item.title = item[ '*' ] || false;
} );
return langlinks;
@@ -269,19 +267,19 @@
result = $.Deferred();
self.get( {
- action: 'query',
- meta: 'siteinfo',
- siprop: 'general|languages',
- prop: 'langlinks',
- llurl: true,
- lllimit: 'max',
- titles: title
- } ).done( function ( resp ) {
- result.resolve( {
- languages: self._getLanguagesFromApiResponse( resp ),
- variants: self._getLanguageVariantsFromApiResponse( title, resp )
- } );
- } ).fail( $.proxy( result, 'reject' ) );
+ action: 'query',
+ meta: 'siteinfo',
+ siprop: 'general|languages',
+ prop: 'langlinks',
+ llurl: true,
+ lllimit: 'max',
+ titles: title
+ } ).done( function ( resp ) {
+ result.resolve( {
+ languages: self._getLanguagesFromApiResponse( resp ),
+ variants: self._getLanguageVariantsFromApiResponse( title, resp )
+ } );
+ } ).fail( $.proxy( result, 'reject' ) );
return result;
},
@@ -292,7 +290,7 @@
sections = [];
$headings.each( function () {
- var level = $( this )[0].tagName.substr( 1 ),
+ var level = $( this )[ 0 ].tagName.substr( 1 ),
$span = $( this ).find( 'span' );
sections.push( {
diff --git a/javascripts/Router.js b/javascripts/Router.js
index 6b18a7a..6c63fcd 100644
--- a/javascripts/Router.js
+++ b/javascripts/Router.js
@@ -91,7 +91,7 @@
path: typeof path === 'string' ? new RegExp( '^' + path + '$' ) : path,
callback: callback
};
- this.routes[entry.path] = entry;
+ this.routes[ entry.path ] = entry;
matchRoute( this.getPath(), entry );
};
diff --git a/javascripts/api.js b/javascripts/api.js
index ba9aa2a..6c7f3d1 100644
--- a/javascripts/api.js
+++ b/javascripts/api.js
@@ -60,10 +60,10 @@
if ( typeof data !== 'string' ) {
for ( key in data ) {
- if ( data[key] === false ) {
- delete data[key];
- } else if ( $.isArray( data[key] ) ) {
- data[key] = data[key].join( '|' );
+ if ( data[ key ] === false ) {
+ delete data[ key ];
+ } else if ( $.isArray( data[ key ] ) ) {
+ data[ key ] = data[ key ].join( '|' );
}
}
}
@@ -142,10 +142,10 @@
// We'll need to check upstream usage though before removing this.
if ( user.isAnon() && !mw.config.get( 'wgMFAnonymousEditing' ) ) {
return d.reject( 'Token requested when not logged in.' );
- // If the token is cached, return it from cache.
+ // If the token is cached, return it from cache.
} else if ( isCacheable && this.tokenCache[ endpoint ].hasOwnProperty( tokenType ) ) {
return this.tokenCache[ endpoint ][ tokenType ];
- // If the token is available from mw.user.tokens, get it from there.
+ // If the token is available from mw.user.tokens, get it from there.
} else if ( $.inArray( tokenType, easyTokens ) > -1 && !endpoint && !caToken ) {
token = user.tokens.get( tokenType + 'Token' );
if ( token && ( token !== '+\\' || mw.config.get( 'wgMFAnonymousEditing' ) ) ) {
@@ -153,7 +153,7 @@
} else {
d.reject( 'Anonymous token.' );
}
- // Otherwise, make an API request for the token.
+ // Otherwise, make an API request for the token.
} else {
data = {
action: 'tokens',
diff --git a/javascripts/application.js b/javascripts/application.js
index dd52b84..2028b40 100644
--- a/javascripts/application.js
+++ b/javascripts/application.js
@@ -12,7 +12,7 @@
watchIcon = new Icon( {
name: 'watched'
} ),
- qs = window.location.search.split( '?' )[1],
+ qs = window.location.search.split( '?' )[ 1 ],
PageApi = M.require( 'PageApi' ),
pageApi = new PageApi(),
Page = M.require( 'Page' ),
@@ -182,7 +182,7 @@
// allow disabling of transitions in android ics 4.0.2
function fixBrowserBugs() {
// see http://adactio.com/journal/4470/ (fixed in ios 6)
- if ( $viewportMeta[0] && ( isIPhone4 || isIPhone5 ) ) {
+ if ( $viewportMeta[ 0 ] && ( isIPhone4 || isIPhone5 ) ) {
lockViewport();
document.addEventListener( 'gesturestart', function () {
lockViewport();
@@ -209,8 +209,8 @@
* @returns {boolean}
*/
function supportsAnimations() {
- var has3d, t,
- el = $( '<p>' )[0],
+ var has3d, t,
+ el = $( '<p>' )[ 0 ],
$iframe = $( '<iframe>' ),
transforms = {
webkitTransform: '-webkit-transform',
@@ -229,9 +229,9 @@
$iframe.appendTo( $body ).contents().find( 'body' ).append( el );
for ( t in transforms ) {
- if ( el.style[t] !== undefined ) {
- el.style[t] = 'translate3d(1px,1px,1px)';
- has3d = window.getComputedStyle( el ).getPropertyValue( transforms[t] );
+ if ( el.style[ t ] !== undefined ) {
+ el.style[ t ] = 'translate3d(1px,1px,1px)';
+ has3d = window.getComputedStyle( el ).getPropertyValue( transforms[ t ] );
}
}
@@ -308,7 +308,7 @@
if ( qs ) {
$.each( qs.split( '&' ), function ( index, p ) {
p = p.split( '=' );
- params[ p[0] ] = p[1];
+ params[ p[ 0 ] ] = p[ 1 ];
} );
}
return params;
@@ -332,7 +332,7 @@
* @return {Boolean}
*/
function inNamespace( namespace ) {
- return mw.config.get( 'wgNamespaceNumber' ) === mw.config.get( 'wgNamespaceIds' )[namespace];
+ return mw.config.get( 'wgNamespaceNumber' ) === mw.config.get( 'wgNamespaceIds' )[ namespace ];
}
/**
diff --git a/javascripts/loggingSchemas/init.js b/javascripts/loggingSchemas/init.js
index e69de29..8b13789 100644
--- a/javascripts/loggingSchemas/init.js
+++ b/javascripts/loggingSchemas/init.js
@@ -0,0 +1 @@
+
diff --git a/javascripts/modules/PageList.js b/javascripts/modules/PageList.js
index 09c9274..95ad6fc 100644
--- a/javascripts/modules/PageList.js
+++ b/javascripts/modules/PageList.js
@@ -43,14 +43,14 @@
} else {
page.pageimageClass = 'list-thumb-none list-thumb-x';
}
- pages[page.title] = page;
+ pages[ page.title ] = page;
} );
// Render page images
$ul.find( 'li' ).each( function () {
var $li = $( this ),
title = $li.attr( 'title' ),
- page = pages[title];
+ page = pages[ title ];
if ( page ) {
$li.find( '.list-thumb' ).addClass( page.pageimageClass )
diff --git a/javascripts/modules/editor/EditorApi.js b/javascripts/modules/editor/EditorApi.js
index 6924a4d..c7f7c0b 100644
--- a/javascripts/modules/editor/EditorApi.js
+++ b/javascripts/modules/editor/EditorApi.js
@@ -52,9 +52,9 @@
// FIXME: MediaWiki API, seriously?
revision = $.map( resp.query.pages, function ( page ) {
return page;
- } )[0].revisions[0];
+ } )[ 0 ].revisions[ 0 ];
- self.content = revision['*'];
+ self.content = revision[ '*' ];
self.timestamp = revision.timestamp;
result.resolve( self.content );
@@ -225,12 +225,12 @@
// section 0 haven't a section name so skip
if ( self.sectionId !== 0 &&
resp.parse.sections !== undefined &&
- resp.parse.sections[0] !== undefined &&
- resp.parse.sections[0].line !== undefined
+ resp.parse.sections[ 0 ] !== undefined &&
+ resp.parse.sections[ 0 ].line !== undefined
) {
- sectionLine = resp.parse.sections[0].line;
+ sectionLine = resp.parse.sections[ 0 ].line;
}
- result.resolve( resp.parse.text['*'], sectionLine );
+ result.resolve( resp.parse.text[ '*' ], sectionLine );
} else {
result.reject();
}
diff --git a/javascripts/modules/editor/EditorOverlay.js b/javascripts/modules/editor/EditorOverlay.js
index eb37c4c..969520e 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -111,12 +111,12 @@
_showAnonWarning: function ( options ) {
var params = $.extend( {
- // use wgPageName as this includes the namespace if outside Main
- returnto: options.returnTo || mw.config.get( 'wgPageName' )
- }, options.queryParams ),
- signupParams = $.extend( {
- type: 'signup'
- }, options.signupQueryParams );
+ // use wgPageName as this includes the namespace if outside Main
+ returnto: options.returnTo || mw.config.get( 'wgPageName' )
+ }, options.queryParams ),
+ signupParams = $.extend( {
+ type: 'signup'
+ }, options.signupQueryParams );
this.$content.hide();
this.showSpinner();
@@ -159,7 +159,7 @@
new Section( {
el: self.$preview,
text: parsedText
- // bug 49218: stop links from being clickable (note user can still hold down to navigate to them)
+ // bug 49218: stop links from being clickable (note user can still hold down to navigate to them)
} ).$( 'a' ).on( 'click', false );
// Emit event so we can perform enhancements to page
M.emit( 'edit-preview', self );
diff --git a/javascripts/modules/editor/init.js b/javascripts/modules/editor/init.js
index 5fe5b7e..5ee02e5 100644
--- a/javascripts/modules/editor/init.js
+++ b/javascripts/modules/editor/init.js
@@ -59,7 +59,7 @@
if ( allowAnonymous ) {
options.links = [ {
label: mw.msg( 'mobile-frontend-editor-anon' ),
- href: $el[0].href,
+ href: $el[ 0 ].href,
selector: 'edit-anon mw-ui-progressive'
} ];
}
diff --git a/javascripts/modules/infobox/Infobox.js b/javascripts/modules/infobox/Infobox.js
index 17a3b85..c908722 100644
--- a/javascripts/modules/infobox/Infobox.js
+++ b/javascripts/modules/infobox/Infobox.js
@@ -25,40 +25,31 @@
typeDefaults: {
// FIXME: In future this should be configurable by Wikipedia admins
taxon: {
- rows: [
- {
- // image
- id: 'P18'
- },
- {
- label: 'Conservation status',
- id: 'P141'
- },
- {
- label: 'Genus',
- id: 'P171'
- },
- {
- label: 'Species',
- id: 'P225'
- },
- {
- label: 'Geographic distribution',
- id: 'P181'
- }
- ]
+ rows: [ {
+ // image
+ id: 'P18'
+ }, {
+ label: 'Conservation status',
+ id: 'P141'
+ }, {
+ label: 'Genus',
+ id: 'P171'
+ }, {
+ label: 'Species',
+ id: 'P225'
+ }, {
+ label: 'Geographic distribution',
+ id: 'P181'
+ } ]
},
country: {
- rows: [
- {
+ rows: [ {
// image
id: 'P18'
- },
- {
+ }, {
label: 'Flag',
id: 'P41'
- },
- {
+ }, {
label: 'Coat of arms',
id: 'P94'
},
@@ -66,16 +57,13 @@
{
label: 'Anthem',
id: 'P85'
- },
- {
+ }, {
label: 'Location',
id: 'P242'
- },
- {
+ }, {
label: 'Languages',
id: 'P37'
- },
- {
+ }, {
label: 'Capital',
id: 'P36'
},
@@ -83,8 +71,7 @@
{
label: 'Basic form of government',
id: 'P122'
- },
- {
+ }, {
label: 'Legislature',
id: 'P194'
},
@@ -97,8 +84,7 @@
{
label: 'Currency',
id: 'P38'
- },
- {
+ }, {
label: 'Timezone',
id: 'P421'
},
@@ -107,83 +93,64 @@
{
label: 'Country calling code',
id: 'P474'
- },
- {
+ }, {
label: 'ISO 3166 code',
id: 'P297'
- },
- {
+ }, {
label: 'Internet TLD',
id: 'P78'
}
]
},
city: {
- rows: [
- {
- // image
- id: 'P18'
- },
- {
- label: 'Flag',
- id: 'P41'
- },
- {
- label: 'Coat of arms',
- id: 'P94'
- },
- {
- label: 'Coordinates',
- id: 'P625'
- },
- {
- label: 'State',
- id: 'P131'
- },
- {
- label: 'Country',
- id: 'P17'
- },
- {
- label: 'Founded',
- id: 'P571'
- },
- {
- label: 'Population',
- id: 'P1082'
- },
- {
- label: 'Timezone',
- id: 'P421'
- },
- {
- id: 'P856',
- label: 'Official website'
- }
- ]
+ rows: [ {
+ // image
+ id: 'P18'
+ }, {
+ label: 'Flag',
+ id: 'P41'
+ }, {
+ label: 'Coat of arms',
+ id: 'P94'
+ }, {
+ label: 'Coordinates',
+ id: 'P625'
+ }, {
+ label: 'State',
+ id: 'P131'
+ }, {
+ label: 'Country',
+ id: 'P17'
+ }, {
+ label: 'Founded',
+ id: 'P571'
+ }, {
+ label: 'Population',
+ id: 'P1082'
+ }, {
+ label: 'Timezone',
+ id: 'P421'
+ }, {
+ id: 'P856',
+ label: 'Official website'
+ } ]
},
human: {
- rows: [
- {
+ rows: [ {
id: 'P18'
- },
- {
+ }, {
id: 'P569',
label: 'Born'
- },
- {
+ }, {
id: 'P19',
label: 'Birthplace'
- },
- {
+ }, {
id: 'P570',
label: 'Died'
- },
- {
+ }, {
id: 'P20',
label: 'Place of death'
- },
- {
+ }, {
id: 'P27',
label: 'Country of citizenship'
},
@@ -202,12 +169,10 @@
{
id: 'P9',
label: 'Sister(s)'
- },
- {
+ }, {
id: 'P7',
label: 'Brother(s)'
- },
- {
+ }, {
id: 'P40',
label: 'Child(ren)'
},
@@ -215,16 +180,13 @@
{
id: 'P69',
label: 'Alma mater'
- },
- {
+ }, {
id: 'P106',
label: 'Occupation'
- },
- {
+ }, {
id: 'P108',
label: 'Employer(s)'
- },
- {
+ }, {
id: 'P140',
label: 'Religion'
},
@@ -232,8 +194,7 @@
{
id: 'P109',
label: 'Signature'
- },
- {
+ }, {
id: 'P856',
label: 'Official website'
}
@@ -241,12 +202,10 @@
},
default: {
description: undefined,
- rows: [
- {
- id: 'P856',
- label: 'Official website'
- }
- ]
+ rows: [ {
+ id: 'P856',
+ label: 'Official website'
+ } ]
}
},
/**
diff --git a/javascripts/modules/issues/init.js b/javascripts/modules/issues/init.js
index 2a905c4..36d54f0 100644
--- a/javascripts/modules/issues/init.js
+++ b/javascripts/modules/issues/init.js
@@ -78,7 +78,7 @@
if ( ns === 0 ) {
createBanner( $container, mw.msg( 'mobile-frontend-meta-data-issues' ),
mw.msg( 'mobile-frontend-meta-data-issues-header' ) );
- // Create a banner for talk pages (namespace 1) in beta mode to make them more readable.
+ // Create a banner for talk pages (namespace 1) in beta mode to make them more readable.
} else if ( ns === 1 && inBeta ) {
createBanner( $container, mw.msg( 'mobile-frontend-meta-data-issues-talk' ),
mw.msg( 'mobile-frontend-meta-data-issues-header-talk' ) );
diff --git a/javascripts/modules/lastEdited/time.js b/javascripts/modules/lastEdited/time.js
index 8de7002..41a568a 100644
--- a/javascripts/modules/lastEdited/time.js
+++ b/javascripts/modules/lastEdited/time.js
@@ -4,12 +4,12 @@
function timeAgo( timestampDelta ) {
var i = 0;
- while ( i < limits.length && timestampDelta > limits[i + 1] ) {
+ while ( i < limits.length && timestampDelta > limits[ i + 1 ] ) {
++i;
}
return {
- value: Math.round( timestampDelta / limits[i] ),
- unit: units[i]
+ value: Math.round( timestampDelta / limits[ i ] ),
+ unit: units[ i ]
};
}
diff --git a/javascripts/modules/mediaViewer/ImageApi.js b/javascripts/modules/mediaViewer/ImageApi.js
index fee9ad3..f7a368b 100644
--- a/javascripts/modules/mediaViewer/ImageApi.js
+++ b/javascripts/modules/mediaViewer/ImageApi.js
@@ -8,10 +8,10 @@
*/
function findSizeBucket( size ) {
var i = 0;
- while ( size > sizeBuckets[i] && i < sizeBuckets.length - 1 ) {
+ while ( size > sizeBuckets[ i ] && i < sizeBuckets.length - 1 ) {
++i;
}
- return sizeBuckets[i];
+ return sizeBuckets[ i ];
}
/**
@@ -26,11 +26,11 @@
},
getThumb: function ( title ) {
- var result = this._cache[title],
+ var result = this._cache[ title ],
imageSizeMultiplier = ( window.devicePixelRatio && window.devicePixelRatio > 1 ) ? window.devicePixelRatio : 1;
if ( !result ) {
- this._cache[title] = result = $.Deferred();
+ this._cache[ title ] = result = $.Deferred();
this.get( {
action: 'query',
@@ -46,7 +46,7 @@
// FIXME: API
var data = $.map( resp.query.pages, function ( v ) {
return v;
- } )[0].imageinfo[0];
+ } )[ 0 ].imageinfo[ 0 ];
result.resolve( data );
}
} );
diff --git a/javascripts/modules/mediaViewer/init.js b/javascripts/modules/mediaViewer/init.js
index 061952f..81357ea 100644
--- a/javascripts/modules/mediaViewer/init.js
+++ b/javascripts/modules/mediaViewer/init.js
@@ -9,7 +9,7 @@
$a.off();
$a.on( 'click', function ( ev ) {
ev.preventDefault();
- M.router.navigate( '#/image/' + match[0] );
+ M.router.navigate( '#/image/' + match[ 0 ] );
} );
}
} );
diff --git a/javascripts/modules/nearby/Nearby.js b/javascripts/modules/nearby/Nearby.js
index 0f3b973..add8efe 100644
--- a/javascripts/modules/nearby/Nearby.js
+++ b/javascripts/modules/nearby/Nearby.js
@@ -61,8 +61,7 @@
err = 'location';
}
result.reject( err );
- },
- {
+ }, {
timeout: 10000,
enableHighAccuracy: true
} );
diff --git a/javascripts/modules/nearby/NearbyApi.js b/javascripts/modules/nearby/NearbyApi.js
index 6a66deb..37c9858 100644
--- a/javascripts/modules/nearby/NearbyApi.js
+++ b/javascripts/modules/nearby/NearbyApi.js
@@ -140,8 +140,8 @@
// distance
if ( params.ggscoord ) {
loc = {
- latitude: params.ggscoord[0],
- longitude: params.ggscoord[1]
+ latitude: params.ggscoord[ 0 ],
+ longitude: params.ggscoord[ 1 ]
};
}
// If we have no coords (searching for a page's nearby), find the
@@ -150,8 +150,8 @@
$.each( pages, function ( i, page ) {
if ( params.ggspage === page.title ) {
loc = {
- latitude: page.coordinates[0].lat,
- longitude: page.coordinates[0].lon
+ latitude: page.coordinates[ 0 ].lat,
+ longitude: page.coordinates[ 0 ].lon
};
}
} );
@@ -171,7 +171,7 @@
page.anchor = 'item_' + i;
page.url = mw.util.getUrl( page.title );
if ( page.coordinates && loc ) { // FIXME: protect against bug 47133 (remove when resolved)
- coords = page.coordinates[0];
+ coords = page.coordinates[ 0 ];
lngLat = {
latitude: coords.lat,
longitude: coords.lon
diff --git a/javascripts/modules/notifications/NotificationsOverlay.js b/javascripts/modules/notifications/NotificationsOverlay.js
index 7222edf..5ecf805 100644
--- a/javascripts/modules/notifications/NotificationsOverlay.js
+++ b/javascripts/modules/notifications/NotificationsOverlay.js
@@ -48,7 +48,7 @@
if ( result.query && result.query.notifications ) {
notifications = $.map( result.query.notifications.list, function ( a ) {
return {
- message: a['*'],
+ message: a[ '*' ],
timestamp: a.timestamp.mw
};
} ).sort( function ( a, b ) {
diff --git a/javascripts/modules/search/SearchApi.js b/javascripts/modules/search/SearchApi.js
index 55b7b8b..5560241 100644
--- a/javascripts/modules/search/SearchApi.js
+++ b/javascripts/modules/search/SearchApi.js
@@ -44,8 +44,8 @@
},
search: function ( query ) {
- if ( !this.searchCache[query] ) {
- this.searchCache[query] = this.get( {
+ if ( !this.searchCache[ query ] ) {
+ this.searchCache[ query ] = this.get( {
action: 'query',
generator: 'prefixsearch',
gpssearch: query,
@@ -67,8 +67,8 @@
// results) here in order to maintain the correct order.
$.each( data.query.prefixsearch, function ( i, page ) {
var title = page.title;
- if ( page.pageid && data.query.pages[page.pageid] ) {
- info = data.query.pages[page.pageid];
+ if ( page.pageid && data.query.pages[ page.pageid ] ) {
+ info = data.query.pages[ page.pageid ];
}
results.push( {
id: page.pageid,
@@ -86,11 +86,11 @@
} );
}
- return this.searchCache[query];
+ return this.searchCache[ query ];
},
isCached: function ( query ) {
- return !!this.searchCache[query];
+ return !!this.searchCache[ query ];
}
} );
diff --git a/javascripts/modules/search/SearchOverlay.js b/javascripts/modules/search/SearchOverlay.js
index 89f57cf..c0c05b3 100644
--- a/javascripts/modules/search/SearchOverlay.js
+++ b/javascripts/modules/search/SearchOverlay.js
@@ -119,8 +119,8 @@
Overlay.prototype.show.apply( this, arguments );
this.$input.focus();
// Cursor to the end of the input
- if ( this.$input[0].setSelectionRange ) {
- this.$input[0].setSelectionRange( len, len );
+ if ( this.$input[ 0 ].setSelectionRange ) {
+ this.$input[ 0 ].setSelectionRange( len, len );
}
},
diff --git a/javascripts/modules/toc/init.js b/javascripts/modules/toc/init.js
index 66a2d90..687b21d 100644
--- a/javascripts/modules/toc/init.js
+++ b/javascripts/modules/toc/init.js
@@ -9,8 +9,7 @@
if ( enableToc ||
// Fallback for old cached HTML, added 26 June, 2014
- ( enableToc === null && sections.length > 0 && !page.isMainPage() ) )
- {
+ ( enableToc === null && sections.length > 0 && !page.isMainPage() ) ) {
toc = new TableOfContents( {
sections: sections
} );
diff --git a/javascripts/modules/toggling/init.js b/javascripts/modules/toggling/init.js
index dc3bf54..8b0072a 100644
--- a/javascripts/modules/toggling/init.js
+++ b/javascripts/modules/toggling/init.js
@@ -1,5 +1,5 @@
( function ( M, $ ) {
- var currentPageTitle = M.getCurrentPage().title,
+ var currentPageTitle = M.getCurrentPage().title,
settings = M.require( 'settings' ),
Icon = M.require( 'Icon' ),
iconUp = new Icon( {
@@ -18,7 +18,7 @@
var expandedSections = $.parseJSON(
settings.get( 'expandedSections', false ) || '{}'
);
- expandedSections[currentPageTitle] = expandedSections[currentPageTitle] || {};
+ expandedSections[ currentPageTitle ] = expandedSections[ currentPageTitle ] || {};
return expandedSections;
}
@@ -44,9 +44,9 @@
if ( headline ) {
if ( isSectionOpen ) {
- expandedSections[currentPageTitle][headline] = ( new Date() ).getTime();
+ expandedSections[ currentPageTitle ][ headline ] = ( new Date() ).getTime();
} else {
- delete expandedSections[currentPageTitle][headline];
+ delete expandedSections[ currentPageTitle ][ headline ];
}
saveExpandedSections( expandedSections );
@@ -66,7 +66,7 @@
$sectionHeading = $headline.parents( '.section-heading' );
// toggle only if the section is not already expanded
if (
- expandedSections[currentPageTitle][$headline.attr( 'id' )] &&
+ expandedSections[ currentPageTitle ][ $headline.attr( 'id' ) ] &&
!$sectionHeading.hasClass( 'open-block' )
) {
toggle( $sectionHeading );
@@ -88,7 +88,7 @@
$.each( sections, function ( section, timestamp ) {
daysDifference = Math.floor( ( now - timestamp ) / 1000 / 60 / 60 / 24 );
if ( daysDifference >= 1 ) {
- delete expandedSections[page][section];
+ delete expandedSections[ page ][ section ];
}
} );
} );
@@ -223,7 +223,7 @@
function checkHash() {
var internalRedirect = mw.config.get( 'wgInternalRedirectTargetUrl' ),
- internalRedirectHash = internalRedirect ? internalRedirect.split( '#' )[1] : false,
+ internalRedirectHash = internalRedirect ? internalRedirect.split( '#' )[ 1 ] : false,
hash = window.location.hash;
if ( hash.indexOf( '#' ) === 0 ) {
@@ -249,8 +249,7 @@
}
// avoid this running on Watchlist
- if (
- !M.inNamespace( 'special' ) &&
+ if ( !M.inNamespace( 'special' ) &&
!mw.config.get( 'wgIsMainPage' ) &&
mw.config.get( 'wgAction' ) === 'view'
) {
diff --git a/javascripts/modules/uploads/PhotoApi.js b/javascripts/modules/uploads/PhotoApi.js
index 5bb6896..1e37e52 100644
--- a/javascripts/modules/uploads/PhotoApi.js
+++ b/javascripts/modules/uploads/PhotoApi.js
@@ -115,7 +115,7 @@
warnings = $.map( warnings, function ( value, code ) {
return code + '/' + value;
} );
- err.details = warnings[0] || 'unknown';
+ err.details = warnings[ 0 ] || 'unknown';
if ( warnings.exists ) {
humanErrorMsg = mw.msg( 'mobile-frontend-photo-upload-error-filename' );
@@ -204,8 +204,8 @@
if ( data.error ) {
if ( data.error.code ) {
err.details = data.error.code;
- if ( data.error.details && data.error.details[0] ) {
- err.details += '/' + data.error.details[0];
+ if ( data.error.details && data.error.details[ 0 ] ) {
+ err.details += '/' + data.error.details[ 0 ];
}
}
}
@@ -238,7 +238,7 @@
self.editorApi.setPrependText( '[[File:' + options.fileName + '|thumbnail|' + options.description + ']]\n\n' );
self.editorApi.save( {
summary: mw.msg( 'mobile-frontend-photo-upload-comment' )
- } )
+ } )
.done( function () {
result.resolve( options.fileName, descriptionUrl );
} )
diff --git a/javascripts/modules/uploads/PhotoUploaderButton.js b/javascripts/modules/uploads/PhotoUploaderButton.js
index 57c09ba..2be694d 100644
--- a/javascripts/modules/uploads/PhotoUploaderButton.js
+++ b/javascripts/modules/uploads/PhotoUploaderButton.js
@@ -65,7 +65,7 @@
$input
.on( 'change', function () {
- handleFile( $input[0].files[0] );
+ handleFile( $input[ 0 ].files[ 0 ] );
// clear so that change event is fired again when user selects the same file
$input.val( '' );
} );
diff --git a/javascripts/modules/uploads/UploadTutorial.js b/javascripts/modules/uploads/UploadTutorial.js
index 70fbf3e..e3d4dfa 100644
--- a/javascripts/modules/uploads/UploadTutorial.js
+++ b/javascripts/modules/uploads/UploadTutorial.js
@@ -26,20 +26,16 @@
additionalClassNames: 'slider-button next'
} ).toHtmlString(),
inBeta: M.isBetaGroupMember(),
- pages: [
- {
- caption: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-1-header' ),
- text: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-1' )
- },
- {
- caption: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-2-header' ),
- text: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-2' )
- },
- {
- caption: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-3-header' ),
- button: buttonMsg
- }
- ]
+ pages: [ {
+ caption: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-1-header' ),
+ text: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-1' )
+ }, {
+ caption: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-2-header' ),
+ text: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-2' )
+ }, {
+ caption: mw.msg( 'mobile-frontend-first-upload-wizard-new-page-3-header' ),
+ button: buttonMsg
+ } ]
},
postRender: function ( options ) {
diff --git a/javascripts/modules/uploads/init.js b/javascripts/modules/uploads/init.js
index e3e05bf..5e14675 100644
--- a/javascripts/modules/uploads/init.js
+++ b/javascripts/modules/uploads/init.js
@@ -19,7 +19,7 @@
function initialize() {
// FIXME: make some general function for that (or a page object with a method)
var
- // FIXME: not updated on dynamic page loads
+ // FIXME: not updated on dynamic page loads
isEditable = mw.config.get( 'wgIsPageEditable' ),
validNamespace = ( M.inNamespace( '' ) || M.inNamespace( 'user' ) || M.inNamespace( 'file' ) );
@@ -30,10 +30,10 @@
}
} else {
if ( !isEditable || !validNamespace ||
- // FIXME: Anonymous users cannot upload but really this should also check rights of user via getRights
- // (without triggering an additional HTTP request)
- user.isAnon() ||
- mw.util.getParamValue( 'action' ) || !needsPhoto( M.getLeadSection() ) || mw.config.get( 'wgIsMainPage' ) ) {
+ // FIXME: Anonymous users cannot upload but really this should also check rights of user via getRights
+ // (without triggering an additional HTTP request)
+ user.isAnon() ||
+ mw.util.getParamValue( 'action' ) || !needsPhoto( M.getLeadSection() ) || mw.config.get( 'wgIsMainPage' ) ) {
$( '#ca-upload' ).remove();
}
}
diff --git a/javascripts/modules/watchstar/WatchstarApi.js b/javascripts/modules/watchstar/WatchstarApi.js
index 630049e..4ccce19 100644
--- a/javascripts/modules/watchstar/WatchstarApi.js
+++ b/javascripts/modules/watchstar/WatchstarApi.js
@@ -70,7 +70,7 @@
isWatchedPage: function ( page ) {
var id = page.getId();
if ( this._cache.hasOwnProperty( id ) ) {
- return this._cache[id];
+ return this._cache[ id ];
} else {
throw new Error( 'WatchstarApi unable to check watch status: Did you call load first?' );
}
diff --git a/javascripts/modules/wikigrok/WikiDataApi.js b/javascripts/modules/wikigrok/WikiDataApi.js
index 2964a76..9dfd433 100644
--- a/javascripts/modules/wikigrok/WikiDataApi.js
+++ b/javascripts/modules/wikigrok/WikiDataApi.js
@@ -31,15 +31,15 @@
// See if the page has any 'instance of' claims.
if (
data.entities !== undefined &&
- data.entities[id].claims !== undefined &&
- data.entities[id].claims.P31 !== undefined
+ data.entities[ id ].claims !== undefined &&
+ data.entities[ id ].claims.P31 !== undefined
) {
- entityClaims = data.entities[id].claims;
+ entityClaims = data.entities[ id ].claims;
instanceClaims = entityClaims.P31;
// Examine claims closely
$.each( instanceClaims, function ( i, claim ) {
- instanceOf = claim.mainsnak.datavalue.value['numeric-id'];
+ instanceOf = claim.mainsnak.datavalue.value[ 'numeric-id' ];
if ( instanceOf === 5 ) {
claims.isHuman = true;
} else if ( instanceOf === 515 ) {
diff --git a/javascripts/modules/wikigrok/WikiGrokDialog.js b/javascripts/modules/wikigrok/WikiGrokDialog.js
index c12a29b..c18cf30 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialog.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialog.js
@@ -1,454 +1,446 @@
( function ( M, $ ) {
- M.assertMode( [ 'beta', 'alpha' ] );
+ M.assertMode( [ 'beta', 'alpha' ] );
- var Panel = M.require( 'Panel' ),
- WikiGrokSuggestionApi = M.require( 'modules/wikigrok/WikiGrokSuggestionApi' ),
- WikiGrokResponseApi = M.require( 'modules/wikigrok/WikiGrokResponseApi' ),
- WikiDataApi = M.require( 'modules/wikigrok/WikiDataApi' ),
- schema = M.require( 'loggingSchemas/mobileWebWikiGrok' ),
- errorSchema = M.require( 'loggingSchemas/mobileWebWikiGrokError' ),
- WikiGrokDialog,
- timer = null,
- $window = $( window );
+ var Panel = M.require( 'Panel' ),
+ WikiGrokSuggestionApi = M.require( 'modules/wikigrok/WikiGrokSuggestionApi' ),
+ WikiGrokResponseApi = M.require( 'modules/wikigrok/WikiGrokResponseApi' ),
+ WikiDataApi = M.require( 'modules/wikigrok/WikiDataApi' ),
+ schema = M.require( 'loggingSchemas/mobileWebWikiGrok' ),
+ errorSchema = M.require( 'loggingSchemas/mobileWebWikiGrokError' ),
+ WikiGrokDialog,
+ timer = null,
+ $window = $( window );
- /**
- * @class WikiGrokDialog
- * @extends Panel
- * THIS IS AN EXPERIMENTAL FEATURE THAT MAY BE MOVED TO A SEPARATE EXTENSION.
- * This creates the dialog at the bottom of the lead section that appears when a user
- * scrolls past the lead. It asks the user to confirm metadata information for use
- * in Wikidata (https://www.wikidata.org).
- */
- WikiGrokDialog = Panel.extend( {
- version: 'a',
- className: 'wikigrok',
- defaults: {
- beginQuestions: false,
- taskToken: mw.user.generateRandomSessionId(),
- thankUser: false,
- closeMsg: mw.msg( 'mobile-frontend-overlay-close' ),
- headerMsg: 'Help Wikipedia',
- contentMsg: 'Improve Wikipedia by tagging information on this page',
- // Other ideas:
- // Can you help improve Wikipedia?
- // Play a game to help Wikipedia!
- // Help add tags to this page!
- buttons: [
- {
- classes: 'cancel inline mw-ui-button',
- label: 'No, thanks'
- },
- {
- classes: 'proceed inline mw-ui-button mw-ui-progressive',
- label: 'Okay!'
- }
- ],
- noticeMsg: '<a class="wg-notice-link" href="#/wikigrok/about">Tell me more</a>'
- },
- template: mw.template.get( 'mobile.wikigrok.dialog', 'Dialog.hogan' ),
+ /**
+ * @class WikiGrokDialog
+ * @extends Panel
+ * THIS IS AN EXPERIMENTAL FEATURE THAT MAY BE MOVED TO A SEPARATE EXTENSION.
+ * This creates the dialog at the bottom of the lead section that appears when a user
+ * scrolls past the lead. It asks the user to confirm metadata information for use
+ * in Wikidata (https://www.wikidata.org).
+ */
+ WikiGrokDialog = Panel.extend( {
+ version: 'a',
+ className: 'wikigrok',
+ defaults: {
+ beginQuestions: false,
+ taskToken: mw.user.generateRandomSessionId(),
+ thankUser: false,
+ closeMsg: mw.msg( 'mobile-frontend-overlay-close' ),
+ headerMsg: 'Help Wikipedia',
+ contentMsg: 'Improve Wikipedia by tagging information on this page',
+ // Other ideas:
+ // Can you help improve Wikipedia?
+ // Play a game to help Wikipedia!
+ // Help add tags to this page!
+ buttons: [ {
+ classes: 'cancel inline mw-ui-button',
+ label: 'No, thanks'
+ }, {
+ classes: 'proceed inline mw-ui-button mw-ui-progressive',
+ label: 'Okay!'
+ } ],
+ noticeMsg: '<a class="wg-notice-link" href="#/wikigrok/about">Tell me more</a>'
+ },
+ template: mw.template.get( 'mobile.wikigrok.dialog', 'Dialog.hogan' ),
- initialize: function ( options ) {
- var self = this;
+ initialize: function ( options ) {
+ var self = this;
- // Remove any disambiguation parentheticals from the title.
- options.name = options.title.replace( / \(.+\)$/, '' );
- this.apiWikiGrokSuggestion = new WikiGrokSuggestionApi( {
- itemId: options.itemId,
- subject: options.name,
- version: this.version
- } );
- this.apiWikiGrokResponse = new WikiGrokResponseApi( {
- itemId: options.itemId,
- subject: options.name,
- version: this.version,
- userToken: options.userToken,
- taskToken: this.defaults.taskToken
- } );
- this.apiWikiData = new WikiDataApi( {
- itemId: options.itemId
- } );
- Panel.prototype.initialize.apply( this, arguments );
+ // Remove any disambiguation parentheticals from the title.
+ options.name = options.title.replace( / \(.+\)$/, '' );
+ this.apiWikiGrokSuggestion = new WikiGrokSuggestionApi( {
+ itemId: options.itemId,
+ subject: options.name,
+ version: this.version
+ } );
+ this.apiWikiGrokResponse = new WikiGrokResponseApi( {
+ itemId: options.itemId,
+ subject: options.name,
+ version: this.version,
+ userToken: options.userToken,
+ taskToken: this.defaults.taskToken
+ } );
+ this.apiWikiData = new WikiDataApi( {
+ itemId: options.itemId
+ } );
+ Panel.prototype.initialize.apply( this, arguments );
- // log page impression and widget impression when the widget is shown
- this.once( 'show', function () {
- self.logPageImpression();
- self.initializeWidgetImpressionLogging();
+ // log page impression and widget impression when the widget is shown
+ this.once( 'show', function () {
+ self.logPageImpression();
+ self.initializeWidgetImpressionLogging();
- } );
- },
+ } );
+ },
- /**
- * Log data to the schema
- * @method
- * @param {string} action to log as described in schema
- * See [Schema][1] for details on valid values.
- *
- * [1]: https://meta.wikimedia.org/wiki/Schema:MobileWebWikiGrok}
- */
- log: function ( action ) {
- var data = {
- action: action,
- taskType: 'version ' + this.version,
- taskToken: this.defaults.taskToken,
- userToken: this.options.userToken,
- // the position of the top of the widget in viewports (as a unit)
- widgetOffset: parseFloat( ( this.$el.offset().top / $window.height() ).toFixed( 2 ) ),
- // top of the document - top of the viewport in viewports (as a unit)
- scrollOffset: parseFloat( ( $window.scrollTop() / $window.height() ).toFixed( 2 ) )
- };
- if ( this.options.testing ) {
- data.testing = true;
- }
- schema.log( data );
- },
+ /**
+ * Log data to the schema
+ * @method
+ * @param {string} action to log as described in schema
+ * See [Schema][1] for details on valid values.
+ *
+ * [1]: https://meta.wikimedia.org/wiki/Schema:MobileWebWikiGrok}
+ */
+ log: function ( action ) {
+ var data = {
+ action: action,
+ taskType: 'version ' + this.version,
+ taskToken: this.defaults.taskToken,
+ userToken: this.options.userToken,
+ // the position of the top of the widget in viewports (as a unit)
+ widgetOffset: parseFloat( ( this.$el.offset().top / $window.height() ).toFixed( 2 ) ),
+ // top of the document - top of the viewport in viewports (as a unit)
+ scrollOffset: parseFloat( ( $window.scrollTop() / $window.height() ).toFixed( 2 ) )
+ };
+ if ( this.options.testing ) {
+ data.testing = true;
+ }
+ schema.log( data );
+ },
- /**
- * Log data to the error schema
- * @method
- * @param {string} error to log as described in schema
- * See [Schema][1] for details on valid values.
- *
- * [1]: https://meta.wikimedia.org/wiki/Schema:MobileWebWikiGrok}
- */
- logError: function ( error ) {
- var data = {
- error: error,
- taskType: 'version ' + this.version,
- taskToken: this.defaults.taskToken,
- userToken: this.options.userToken,
- isLoggedIn: !mw.user.isAnon()
- };
- if ( this.options.testing ) {
- data.testing = true;
- }
- errorSchema.log( data );
- },
+ /**
+ * Log data to the error schema
+ * @method
+ * @param {string} error to log as described in schema
+ * See [Schema][1] for details on valid values.
+ *
+ * [1]: https://meta.wikimedia.org/wiki/Schema:MobileWebWikiGrok}
+ */
+ logError: function ( error ) {
+ var data = {
+ error: error,
+ taskType: 'version ' + this.version,
+ taskToken: this.defaults.taskToken,
+ userToken: this.options.userToken,
+ isLoggedIn: !mw.user.isAnon()
+ };
+ if ( this.options.testing ) {
+ data.testing = true;
+ }
+ errorSchema.log( data );
+ },
- /**
- * Return a new array from 'array' with 'count' randomly selected elements.
- * @param {Array} array Array from which random elements are selected
- * @param {number} count - Positive number of random elements to select
- * @returns {Array}
- */
- chooseRandomItemsFromArray: function ( array, count ) {
- var arrayCopy, i, randomIndex,
- result = [],
- arrayLength = array.length;
+ /**
+ * Return a new array from 'array' with 'count' randomly selected elements.
+ * @param {Array} array Array from which random elements are selected
+ * @param {number} count - Positive number of random elements to select
+ * @returns {Array}
+ */
+ chooseRandomItemsFromArray: function ( array, count ) {
+ var arrayCopy, i, randomIndex,
+ result = [],
+ arrayLength = array.length;
- if ( arrayLength >= 1 ) {
- count = ( count > arrayLength ) ? arrayLength : count;
+ if ( arrayLength >= 1 ) {
+ count = ( count > arrayLength ) ? arrayLength : count;
- // only clone the array if we need to return more than one element
- if ( count > 1 ) {
- arrayCopy = array.slice();
- // with each iteration the arrayCopy size decreases by 1.
- for ( i = 1; i <= count; i++ ) {
- randomIndex = Math.round( Math.random() * ( arrayLength - i ) );
- result = result.concat( arrayCopy.splice( randomIndex, 1 ) );
- }
- } else {
- randomIndex = Math.round( Math.random() * ( arrayLength - 1 ) );
- result.push( array[ randomIndex ] );
- }
- }
- return result;
- },
+ // only clone the array if we need to return more than one element
+ if ( count > 1 ) {
+ arrayCopy = array.slice();
+ // with each iteration the arrayCopy size decreases by 1.
+ for ( i = 1; i <= count; i++ ) {
+ randomIndex = Math.round( Math.random() * ( arrayLength - i ) );
+ result = result.concat( arrayCopy.splice( randomIndex, 1 ) );
+ }
+ } else {
+ randomIndex = Math.round( Math.random() * ( arrayLength - 1 ) );
+ result.push( array[ randomIndex ] );
+ }
+ }
+ return result;
+ },
- /**
- * Creates a question with a yes, no and not sure answer
- * Makes API request to Wikidata to retrieve labels.
- * FIXME: No i18n
- * @method
- * @param {Object} options needed to render.
- */
- askWikidataQuestion: function ( options ) {
- var self = this,
- vowels = [ 'a', 'e', 'i', 'o', 'u' ],
- theCountries = [ 'United States', 'United Kingdom', 'Philippines',
- 'Marshall Islands', 'Central African Republic' ];
+ /**
+ * Creates a question with a yes, no and not sure answer
+ * Makes API request to Wikidata to retrieve labels.
+ * FIXME: No i18n
+ * @method
+ * @param {Object} options needed to render.
+ */
+ askWikidataQuestion: function ( options ) {
+ var self = this,
+ vowels = [ 'a', 'e', 'i', 'o', 'u' ],
+ theCountries = [ 'United States', 'United Kingdom', 'Philippines',
+ 'Marshall Islands', 'Central African Republic'
+ ];
- if ( options.suggestions.length ) {
- // choose a suggestion category (dob, dod, occupation, or nationality) randomly
- options.suggestion = this.chooseRandomItemsFromArray( options.suggestions, 1 )[0];
- // pick a claim randomly
- options.claimId = this.chooseRandomItemsFromArray( options.suggestion.list, 1 )[0];
+ if ( options.suggestions.length ) {
+ // choose a suggestion category (dob, dod, occupation, or nationality) randomly
+ options.suggestion = this.chooseRandomItemsFromArray( options.suggestions, 1 )[ 0 ];
+ // pick a claim randomly
+ options.claimId = this.chooseRandomItemsFromArray( options.suggestion.list, 1 )[ 0 ];
- // Get the name of the claim from Wikidata.
- self.apiWikiData.getLabels( [ options.claimId ] ).done( function ( labels ) {
- options.claimLabel = labels[ options.claimId ];
- if ( options.claimLabel ) {
- // ask if it is a correct occupation for the person.
- // FIXME: add support for DOB and DOD
- if ( options.suggestion.name === 'occupations' ) {
- // Hack for English prototype
- if ( $.inArray( options.claimLabel.charAt( 0 ), vowels ) === -1 ) {
- options.contentMsg = 'Was ' + options.name + ' a ' + options.claimLabel + '?';
- } else {
- options.contentMsg = 'Was ' + options.name + ' an ' + options.claimLabel + '?';
- }
- } else if ( options.suggestion.name === 'nationality' ) {
- if ( $.inArray( options.claimLabel, theCountries ) === -1 ) {
- options.contentMsg = 'Was ' + options.name + ' a citizen of ' + options.claimLabel + '?';
- } else {
- options.contentMsg = 'Was ' + options.name + ' a citizen of the ' + options.claimLabel + '?';
- }
- } else if ( options.suggestion.name === 'schools' ) {
- options.contentMsg = 'Did ' + options.name + ' attend ' + options.claimLabel + '?';
- }
+ // Get the name of the claim from Wikidata.
+ self.apiWikiData.getLabels( [ options.claimId ] ).done( function ( labels ) {
+ options.claimLabel = labels[ options.claimId ];
+ if ( options.claimLabel ) {
+ // ask if it is a correct occupation for the person.
+ // FIXME: add support for DOB and DOD
+ if ( options.suggestion.name === 'occupations' ) {
+ // Hack for English prototype
+ if ( $.inArray( options.claimLabel.charAt( 0 ), vowels ) === -1 ) {
+ options.contentMsg = 'Was ' + options.name + ' a ' + options.claimLabel + '?';
+ } else {
+ options.contentMsg = 'Was ' + options.name + ' an ' + options.claimLabel + '?';
+ }
+ } else if ( options.suggestion.name === 'nationality' ) {
+ if ( $.inArray( options.claimLabel, theCountries ) === -1 ) {
+ options.contentMsg = 'Was ' + options.name + ' a citizen of ' + options.claimLabel + '?';
+ } else {
+ options.contentMsg = 'Was ' + options.name + ' a citizen of the ' + options.claimLabel + '?';
+ }
+ } else if ( options.suggestion.name === 'schools' ) {
+ options.contentMsg = 'Did ' + options.name + ' attend ' + options.claimLabel + '?';
+ }
- // Re-render with new content for 'Question' step
- options.beginQuestions = true;
- options.buttons = [
- {
- classes: 'yes inline mw-ui-button mw-ui-progressive',
- label: 'Yes'
- },
- {
- classes: 'not-sure inline mw-ui-button',
- label: 'Not Sure'
- },
- {
- classes: 'no inline mw-ui-button mw-ui-progressive',
- label: 'No'
- }
- ];
- options.noticeMsg = 'All submissions are <a class="wg-notice-link" href="#/wikigrok/about">released freely</a>';
- self.render( options );
- } else {
- self.showError( options, 'There was an error retrieving tag labels.' );
- }
- } ).fail( function () {
- self.logError( 'no-impression-cannot-fetch-labels' );
- } );
- }
- },
+ // Re-render with new content for 'Question' step
+ options.beginQuestions = true;
+ options.buttons = [ {
+ classes: 'yes inline mw-ui-button mw-ui-progressive',
+ label: 'Yes'
+ }, {
+ classes: 'not-sure inline mw-ui-button',
+ label: 'Not Sure'
+ }, {
+ classes: 'no inline mw-ui-button mw-ui-progressive',
+ label: 'No'
+ } ];
+ options.noticeMsg = 'All submissions are <a class="wg-notice-link" href="#/wikigrok/about">released freely</a>';
+ self.render( options );
+ } else {
+ self.showError( options, 'There was an error retrieving tag labels.' );
+ }
+ } ).fail( function () {
+ self.logError( 'no-impression-cannot-fetch-labels' );
+ } );
+ }
+ },
- showError: function ( options, errorMsg ) {
- options.contentMsg = errorMsg;
- options.buttons = [
- {
- classes: 'cancel inline mw-ui-button mw-ui-progressive',
- label: 'OK'
- }
- ];
- this.render( options );
- },
+ showError: function ( options, errorMsg ) {
+ options.contentMsg = errorMsg;
+ options.buttons = [ {
+ classes: 'cancel inline mw-ui-button mw-ui-progressive',
+ label: 'OK'
+ } ];
+ this.render( options );
+ },
- // Record answer in temporary database for analysis.
- // Eventually answers will be recorded directly to Wikidata.
- recordClaim: function ( options ) {
- var self = this,
- claim = {
- valueid: options.claimId,
- value: options.claimLabel,
- correct: options.claimIsCorrect,
- propid: options.suggestion.id
- };
+ // Record answer in temporary database for analysis.
+ // Eventually answers will be recorded directly to Wikidata.
+ recordClaim: function ( options ) {
+ var self = this,
+ claim = {
+ valueid: options.claimId,
+ value: options.claimLabel,
+ correct: options.claimIsCorrect,
+ propid: options.suggestion.id
+ };
- // FIXME: add support for DOB and DOD
- if ( options.suggestion.name === 'occupations' ) {
- claim.prop = 'occupation';
- } else if ( options.suggestion.name === 'nationality' ) {
- claim.prop = 'nationality';
- } else if ( options.suggestion.name === 'schools' ) {
- claim.prop = 'alma mater';
- }
+ // FIXME: add support for DOB and DOD
+ if ( options.suggestion.name === 'occupations' ) {
+ claim.prop = 'occupation';
+ } else if ( options.suggestion.name === 'nationality' ) {
+ claim.prop = 'nationality';
+ } else if ( options.suggestion.name === 'schools' ) {
+ claim.prop = 'alma mater';
+ }
- this.apiWikiGrokResponse.recordClaims( [ claim ] ).always( function () {
- self.thankUser( options, true );
- } ).fail( function () {
- self.logError( 'no-response-cannot-record-user-input' );
- } );
- },
+ this.apiWikiGrokResponse.recordClaims( [ claim ] ).always( function () {
+ self.thankUser( options, true );
+ } ).fail( function () {
+ self.logError( 'no-response-cannot-record-user-input' );
+ } );
+ },
- thankUser: function ( options, claimAttempted ) {
- options.thankUser = true;
- if ( claimAttempted ) {
- options.contentMsg = 'You just made Wikipedia a little better, thanks!';
- } else {
- options.contentMsg = 'That\'s OK, thanks for taking the time.';
- }
- // Re-render with new content for 'Thanks' step
- this.render( options );
- this.$( '.wg-notice' ).hide();
- this.log( 'widget-impression-success' );
- },
+ thankUser: function ( options, claimAttempted ) {
+ options.thankUser = true;
+ if ( claimAttempted ) {
+ options.contentMsg = 'You just made Wikipedia a little better, thanks!';
+ } else {
+ options.contentMsg = 'That\'s OK, thanks for taking the time.';
+ }
+ // Re-render with new content for 'Thanks' step
+ this.render( options );
+ this.$( '.wg-notice' ).hide();
+ this.log( 'widget-impression-success' );
+ },
- /**
- * Check if at least half of the element's height and half of its width are in viewport
- * @method
- * @param {jQuery.Object} $el - element that's being tested
- * @return {boolean}
- */
- isElementInViewport: function ( $el ) {
- var windowHeight = $window.height(),
- windowWidth = $window.width(),
- windowScrollLeft = $window.scrollLeft(),
- windowScrollTop = $window.scrollTop(),
- elHeight = $el.height(),
- elWidth = $el.width(),
- elOffset = $el.offset();
- return (
- ( elHeight > 0 && elWidth > 0 ) &&
- ( windowScrollTop + windowHeight >= elOffset.top + elHeight / 2 ) &&
- ( windowScrollLeft + windowWidth >= elOffset.left + elWidth / 2 ) &&
- ( windowScrollTop <= elOffset.top + elHeight / 2 )
- );
- },
- /**
- * Log widget-impression if the widget is in viewport.
- * Stop listening to events that are namespaced with the taskToken.
- * @param {jQuery.Object} $el WikiGrokDialog element
- */
- logWidgetImpression: function ( $el ) {
- // detect whether the dialog is in viewport, and
- // record it if yes
- if ( !this.isWidgetImpressionLogged ) {
- if ( this.isElementInViewport( $el ) ) {
- this.isWidgetImpressionLogged = true;
- $window.off( '.' + this.defaults.taskToken );
- this.log( 'widget-impression' );
- }
- }
- },
+ /**
+ * Check if at least half of the element's height and half of its width are in viewport
+ * @method
+ * @param {jQuery.Object} $el - element that's being tested
+ * @return {boolean}
+ */
+ isElementInViewport: function ( $el ) {
+ var windowHeight = $window.height(),
+ windowWidth = $window.width(),
+ windowScrollLeft = $window.scrollLeft(),
+ windowScrollTop = $window.scrollTop(),
+ elHeight = $el.height(),
+ elWidth = $el.width(),
+ elOffset = $el.offset();
+ return (
+ ( elHeight > 0 && elWidth > 0 ) &&
+ ( windowScrollTop + windowHeight >= elOffset.top + elHeight / 2 ) &&
+ ( windowScrollLeft + windowWidth >= elOffset.left + elWidth / 2 ) &&
+ ( windowScrollTop <= elOffset.top + elHeight / 2 )
+ );
+ },
+ /**
+ * Log widget-impression if the widget is in viewport.
+ * Stop listening to events that are namespaced with the taskToken.
+ * @param {jQuery.Object} $el WikiGrokDialog element
+ */
+ logWidgetImpression: function ( $el ) {
+ // detect whether the dialog is in viewport, and
+ // record it if yes
+ if ( !this.isWidgetImpressionLogged ) {
+ if ( this.isElementInViewport( $el ) ) {
+ this.isWidgetImpressionLogged = true;
+ $window.off( '.' + this.defaults.taskToken );
+ this.log( 'widget-impression' );
+ }
+ }
+ },
- /**
- * Create namespaced window.resize and window.scroll events.
- * The namespace is a unique taskToken. Log widget-impression once and
- * stop listening to events that are namespaced with the taskToken.
- * This method is intended to be run only once because we don't want
- * to create and listen to the same events more than once.
- * @method
- */
- initializeWidgetImpressionLogging: function () {
- var self = this;
- if ( !this.isLogWidgetImpressionInitialized && !this.isWidgetImpressionLogged ) {
- // widget specific event listener because there may be more than
- // one widget on the page
- // FIXME: listen to page zoom/pinch too?
- $window.on(
- 'resize.' + self.defaults.taskToken +
- ' scroll.' + self.defaults.taskToken,
- // debounce
- function () {
- clearTimeout( timer );
- timer = setTimeout( function () {
- self.logWidgetImpression( self.$el );
- }, 250 );
- }
- );
- this.isLogWidgetImpressionInitialized = true;
- }
- // widget may be in the viewport already
- this.logWidgetImpression( self.$el );
- },
+ /**
+ * Create namespaced window.resize and window.scroll events.
+ * The namespace is a unique taskToken. Log widget-impression once and
+ * stop listening to events that are namespaced with the taskToken.
+ * This method is intended to be run only once because we don't want
+ * to create and listen to the same events more than once.
+ * @method
+ */
+ initializeWidgetImpressionLogging: function () {
+ var self = this;
+ if ( !this.isLogWidgetImpressionInitialized && !this.isWidgetImpressionLogged ) {
+ // widget specific event listener because there may be more than
+ // one widget on the page
+ // FIXME: listen to page zoom/pinch too?
+ $window.on(
+ 'resize.' + self.defaults.taskToken +
+ ' scroll.' + self.defaults.taskToken,
+ // debounce
+ function () {
+ clearTimeout( timer );
+ timer = setTimeout( function () {
+ self.logWidgetImpression( self.$el );
+ }, 250 );
+ }
+ );
+ this.isLogWidgetImpressionInitialized = true;
+ }
+ // widget may be in the viewport already
+ this.logWidgetImpression( self.$el );
+ },
- /**
- * Log page-impression once
- * @method
- */
- logPageImpression: function () {
- // record page impression
- if ( !this.isPageImpressionLogged ) {
- this.isPageImpressionLogged = true;
- this.log( 'page-impression' );
- }
- },
- /**
- * @inheritdoc
- */
- postRender: function ( options ) {
- var self = this;
+ /**
+ * Log page-impression once
+ * @method
+ */
+ logPageImpression: function () {
+ // record page impression
+ if ( !this.isPageImpressionLogged ) {
+ this.isPageImpressionLogged = true;
+ this.log( 'page-impression' );
+ }
+ },
+ /**
+ * @inheritdoc
+ */
+ postRender: function ( options ) {
+ var self = this;
- self.$( '.wg-link' ).hide();
+ self.$( '.wg-link' ).hide();
- // If you're wondering where the DOM insertion happens, look in wikigrokeval.js.
+ // If you're wondering where the DOM insertion happens, look in wikigrokeval.js.
- // Initialize all the buttons and links
- // ...for final 'Thanks' step
- if ( options.thankUser ) {
- self.$( '.wg-buttons' ).hide();
- self.$( '.wg-link' ).show();
- this.$( '.wg-link .tell-more' ).on( 'click', function () {
- self.hide();
- self.log( 'widget-click-moreinfo' );
- } );
- // ...for intermediate 'Question' step
- } else if ( options.beginQuestions ) {
- this.$( '.wg-buttons .yes' ).on( 'click', function () {
- self.log( 'widget-click-submit' );
- options.claimIsCorrect = true;
- self.recordClaim( options );
- } );
- this.$( '.wg-buttons .not-sure' ).on( 'click', function () {
- self.log( 'widget-click-submit' );
- self.thankUser( options, false );
- } );
- this.$( '.wg-buttons .no' ).on( 'click', function () {
- self.log( 'widget-click-submit' );
- options.claimIsCorrect = false;
- self.recordClaim( options );
- } );
- // ...for initial 'Intro' step
- } else {
- this.$( '.wg-buttons .cancel' ).on( 'click', function () {
- self.hide();
- self.log( 'widget-click-nothanks' );
- } );
- this.$( '.wg-buttons .proceed' ).on( 'click', function () {
- self.log( 'widget-click-accept' );
- // Proceed with asking the user a metadata question.
- self.askWikidataQuestion( options );
- } );
- // Log more info clicks
- this.$( '.wg-notice-link' ).on( 'click', function () {
- self.log( 'widget-click-moreinfo' );
- } );
- }
+ // Initialize all the buttons and links
+ // ...for final 'Thanks' step
+ if ( options.thankUser ) {
+ self.$( '.wg-buttons' ).hide();
+ self.$( '.wg-link' ).show();
+ this.$( '.wg-link .tell-more' ).on( 'click', function () {
+ self.hide();
+ self.log( 'widget-click-moreinfo' );
+ } );
+ // ...for intermediate 'Question' step
+ } else if ( options.beginQuestions ) {
+ this.$( '.wg-buttons .yes' ).on( 'click', function () {
+ self.log( 'widget-click-submit' );
+ options.claimIsCorrect = true;
+ self.recordClaim( options );
+ } );
+ this.$( '.wg-buttons .not-sure' ).on( 'click', function () {
+ self.log( 'widget-click-submit' );
+ self.thankUser( options, false );
+ } );
+ this.$( '.wg-buttons .no' ).on( 'click', function () {
+ self.log( 'widget-click-submit' );
+ options.claimIsCorrect = false;
+ self.recordClaim( options );
+ } );
+ // ...for initial 'Intro' step
+ } else {
+ this.$( '.wg-buttons .cancel' ).on( 'click', function () {
+ self.hide();
+ self.log( 'widget-click-nothanks' );
+ } );
+ this.$( '.wg-buttons .proceed' ).on( 'click', function () {
+ self.log( 'widget-click-accept' );
+ // Proceed with asking the user a metadata question.
+ self.askWikidataQuestion( options );
+ } );
+ // Log more info clicks
+ this.$( '.wg-notice-link' ).on( 'click', function () {
+ self.log( 'widget-click-moreinfo' );
+ } );
+ }
- // render() does a "deep copy" $.extend() on the template data, so we need
- // to reset the buttons after each step (since some steps have fewer
- // buttons than the initial default).
- self.options.buttons = [];
+ // render() does a "deep copy" $.extend() on the template data, so we need
+ // to reset the buttons after each step (since some steps have fewer
+ // buttons than the initial default).
+ self.options.buttons = [];
- this.reveal( options );
- },
+ this.reveal( options );
+ },
- reveal: function ( options ) {
- var self = this;
+ reveal: function ( options ) {
+ var self = this;
- // fetch suggestions only if we didn't try loading suggestions before
- if ( options.suggestions ) {
- self.show();
- } else {
- options.suggestions = [];
- self.apiWikiData.getClaims().done( function ( claims ) {
- if ( claims.isHuman ) {
- self.apiWikiGrokSuggestion.getSuggestions().fail( function () {
- self.logError( 'no-impression-cannot-fetch-suggestions' );
- } ).done( function ( suggestions ) {
- // FIXME: add support for DOB and DOD
- if ( suggestions.occupations && suggestions.occupations.list.length ) {
- options.suggestions.push( suggestions.occupations );
- }
- if ( suggestions.nationalities && suggestions.nationalities.list.length ) {
- options.suggestions.push( suggestions.nationalities );
- }
- if ( suggestions.schools && suggestions.schools.list.length ) {
- options.suggestions.push( suggestions.schools );
- }
- if ( options.suggestions.length ) {
- self.show();
- } else {
- // FIXME: remove this before deploying to stable
- self.logError( 'no-impression-not-enough-suggestions' );
- }
- } );
- }
- } );
- }
- }
- } );
+ // fetch suggestions only if we didn't try loading suggestions before
+ if ( options.suggestions ) {
+ self.show();
+ } else {
+ options.suggestions = [];
+ self.apiWikiData.getClaims().done( function ( claims ) {
+ if ( claims.isHuman ) {
+ self.apiWikiGrokSuggestion.getSuggestions().fail( function () {
+ self.logError( 'no-impression-cannot-fetch-suggestions' );
+ } ).done( function ( suggestions ) {
+ // FIXME: add support for DOB and DOD
+ if ( suggestions.occupations && suggestions.occupations.list.length ) {
+ options.suggestions.push( suggestions.occupations );
+ }
+ if ( suggestions.nationalities && suggestions.nationalities.list.length ) {
+ options.suggestions.push( suggestions.nationalities );
+ }
+ if ( suggestions.schools && suggestions.schools.list.length ) {
+ options.suggestions.push( suggestions.schools );
+ }
+ if ( options.suggestions.length ) {
+ self.show();
+ } else {
+ // FIXME: remove this before deploying to stable
+ self.logError( 'no-impression-not-enough-suggestions' );
+ }
+ } );
+ }
+ } );
+ }
+ }
+ } );
- M.define( 'modules/wikigrok/WikiGrokDialog', WikiGrokDialog );
-}( mw.mobileFrontend, jQuery ) );
+ M.define( 'modules/wikigrok/WikiGrokDialog', WikiGrokDialog );
+ }( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/wikigrok/WikiGrokDialogB.js b/javascripts/modules/wikigrok/WikiGrokDialogB.js
index 862800c..1a065b9 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialogB.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialogB.js
@@ -58,7 +58,7 @@
allSuggestions = allSuggestions.concat( data.list );
// Make sure it's easy to look up the property later.
$.each( data.list, function ( i, itemId ) {
- lookupProp[itemId] = prop;
+ lookupProp[ itemId ] = prop;
} );
} );
@@ -71,7 +71,7 @@
self.$( '.tags' ).show();
$.each( labels, function ( itemId, label ) {
var btnLabel, $tag,
- prop = lookupProp[itemId],
+ prop = lookupProp[ itemId ],
id = 'tag-' + itemId;
$tag = $( '<div class="ui-tag-button mw-ui-button">' )
@@ -87,7 +87,7 @@
.data( 'readable', label );
$( '<label>' )
- .text( i18n[prop.type] ).appendTo( $tag );
+ .text( i18n[ prop.type ] ).appendTo( $tag );
$( '<label>' )
.text( label )
diff --git a/javascripts/modules/wikigrok/WikiGrokResponseApi.js b/javascripts/modules/wikigrok/WikiGrokResponseApi.js
index 41ad513..dcfdd4e 100644
--- a/javascripts/modules/wikigrok/WikiGrokResponseApi.js
+++ b/javascripts/modules/wikigrok/WikiGrokResponseApi.js
@@ -15,7 +15,7 @@
this.userToken = options.userToken;
this.taskToken = options.taskToken;
this.taskType = 'mobile ' + options.version;
- this.testing = false; // FIXME: TBD on what qualifies as a test
+ this.testing = false; // FIXME: TBD on what qualifies as a test
Api.prototype.initialize.apply( this, arguments );
},
/**
diff --git a/javascripts/modules/wikigrok/WikiGrokSuggestionApi.js b/javascripts/modules/wikigrok/WikiGrokSuggestionApi.js
index d76b99a..1beb0ee 100644
--- a/javascripts/modules/wikigrok/WikiGrokSuggestionApi.js
+++ b/javascripts/modules/wikigrok/WikiGrokSuggestionApi.js
@@ -37,17 +37,17 @@
*/
action: function ( action, key ) {
return this.ajax( {
- action: action,
- item: this.subjectId.replace( 'Q', '' )
- } ).then( function ( data ) {
- if ( key ) {
- if ( data[key] !== undefined ) {
- return data[key];
- } else {
- return [];
- }
+ action: action,
+ item: this.subjectId.replace( 'Q', '' )
+ } ).then( function ( data ) {
+ if ( key ) {
+ if ( data[ key ] !== undefined ) {
+ return data[ key ];
+ } else {
+ return [];
}
- } );
+ }
+ } );
}
} );
diff --git a/javascripts/modules/wikigrok/init.js b/javascripts/modules/wikigrok/init.js
index a69dae6..9639692 100644
--- a/javascripts/modules/wikigrok/init.js
+++ b/javascripts/modules/wikigrok/init.js
@@ -45,11 +45,11 @@
versionOverride = M.query.wikigrokversion.toUpperCase();
if ( versionConfigs.hasOwnProperty( versionOverride ) ) {
- versionConfig = versionConfigs[versionOverride];
+ versionConfig = versionConfigs[ versionOverride ];
}
- // Otherwise, see if A/B test is running, and if so, choose a version.
+ // Otherwise, see if A/B test is running, and if so, choose a version.
} else if ( wikiGrokAbTest.isEnabled ) {
- versionConfig = versionConfigs[wikiGrokAbTest.getVersion( wikiGrokUser )];
+ versionConfig = versionConfigs[ wikiGrokAbTest.getVersion( wikiGrokUser ) ];
}
return versionConfig;
diff --git a/javascripts/modules/wikigrok/wikigrokuser.js b/javascripts/modules/wikigrok/wikigrokuser.js
index 900ae68..566c3f2 100644
--- a/javascripts/modules/wikigrok/wikigrokuser.js
+++ b/javascripts/modules/wikigrok/wikigrokuser.js
@@ -42,4 +42,4 @@
M.define( 'wikiGrokUser', wikiGrokUser );
-} ( mw.mobileFrontend, jQuery, mw ) );
+}( mw.mobileFrontend, jQuery, mw ) );
diff --git a/javascripts/settings.js b/javascripts/settings.js
index 87a4881..2043d06 100644
--- a/javascripts/settings.js
+++ b/javascripts/settings.js
@@ -12,7 +12,7 @@
// If session cookie already set, return true
if ( $.cookie( 'mf_testcookie' ) === 'test_value' ) {
return true;
- // Otherwise try to set mf_testcookie and return true if it was set
+ // Otherwise try to set mf_testcookie and return true if it was set
} else {
$.cookie( 'mf_testcookie', 'test_value', {
path: '/'
@@ -35,7 +35,7 @@
};
return M.supportsLocalStorage ?
localStorage.setItem( name, value ) :
- ( useCookieFallback ? $.cookie( name, value, cookieOptions ) : false );
+ ( useCookieFallback ? $.cookie( name, value, cookieOptions ) : false );
}
/**
diff --git a/javascripts/specials/notifications.js b/javascripts/specials/notifications.js
index 1db551e..8c4defd 100644
--- a/javascripts/specials/notifications.js
+++ b/javascripts/specials/notifications.js
@@ -45,7 +45,7 @@
unread = [];
$.each( notifications.index, function ( index, id ) {
- data = notifications.list[id];
+ data = notifications.list[ id ];
if ( header !== data.timestamp.date ) {
header = data.timestamp.date;
@@ -60,7 +60,7 @@
// To facilitate debugging / bug reports
'data-notification-event': data.id
} )
- .append( data['*'] )
+ .append( data[ '*' ] )
.appendTo( container );
if ( !data.read ) {
@@ -72,7 +72,7 @@
} );
} );
- notContinue = notifications['continue'];
+ notContinue = notifications[ 'continue' ];
if ( unread.length > 0 ) {
markAsRead( unread );
} else {
diff --git a/javascripts/specials/uploads.js b/javascripts/specials/uploads.js
index ae82b39..5c687af 100644
--- a/javascripts/specials/uploads.js
+++ b/javascripts/specials/uploads.js
@@ -8,7 +8,7 @@
corsUrl = mw.config.get( 'wgMFPhotoUploadEndpoint' ),
pageParams = mw.config.get( 'wgPageName' ).split( '/' ),
currentUserName = user.getName(),
- userName = pageParams[1] ? pageParams[1] : currentUserName,
+ userName = pageParams[ 1 ] ? pageParams[ 1 ] : currentUserName,
IMAGE_WIDTH = mw.config.get( 'wgMFThumbnailSizes' ).medium,
UserGalleryApi, PhotoItem, PhotoList,
icons = M.require( 'icons' );
@@ -54,8 +54,8 @@
var photos = $.map( resp.query.pages, getImageDataFromPage ).sort( function ( a, b ) {
return a.timestamp < b.timestamp ? 1 : -1;
} );
- if ( resp['query-continue'] ) {
- self.endTimestamp = resp['query-continue'].allimages.gaicontinue;
+ if ( resp[ 'query-continue' ] ) {
+ self.endTimestamp = resp[ 'query-continue' ].allimages.gaicontinue;
} else {
self.endTimestamp = false;
}
@@ -179,7 +179,7 @@
}
function getImageDataFromPage( page ) {
- var img = page.imageinfo[0];
+ var img = page.imageinfo[ 0 ];
return {
url: img.thumburl,
title: page.title,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment