Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
More eslint fixes
Browse files Browse the repository at this point in the history
It's passing now
  • Loading branch information
Ladsgroup committed Jul 5, 2017
1 parent becebf4 commit 23094ad
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 41 deletions.
14 changes: 11 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"extends": "eslint:recommended",
"env": {},
"globals": {},
"env": {
"browser": true,
"jquery": true
},
"globals": {
"mediaWiki": false,
"OO": false,
"require": false,
"util": false
},
"rules": {
"array-bracket-spacing": [ "error", "always" ],
"block-spacing": "error",
Expand Down Expand Up @@ -36,7 +44,7 @@
"no-extra-label": "error",
"no-floating-decimal": "error",
"no-implicit-coercion": [ "error", { "string": true, "boolean": false, "number": false } ],
"no-implicit-globals": "error",
"no-implicit-globals": "off",
"no-implied-eval": "error",
"no-label-var": "error",
"no-loop-func": "error",
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ before_install:
- export PATH=/home/travis/miniconda3/bin:$PATH
- ls -l /home/travis/miniconda3/bin
- conda update --yes conda
- npm install -g eslint
# Install packages
install:
- conda install --yes python=$TRAVIS_PYTHON_VERSION numpy scipy=0.16.1
Expand All @@ -34,6 +35,7 @@ install:
script:
- nosetests -v --with-coverage --cover-package=revscoring
- flake8 .
- eslint .
after_success:
codecov
group: stable
Expand Down
84 changes: 46 additions & 38 deletions ores/wsgi/static/js/scorer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
var urlModels = [];

function getParameterByName( name ) {
name = name.replace( /[\[]/, '\\[' ).replace( /[\]]/, '\\]' );
var regex = new RegExp( '[\\?&]' + name + '=([^&#]*)' ),
results = regex.exec( location.search );
var regex = null, results = null;

name = name.replace( /[[]/, '\\[' ).replace( /[\]]/, '\\]' );
regex = new RegExp( '[\\?&]' + name + '=([^&#]*)' );
results = regex.exec( location.search );
return results === null ? '' : decodeURIComponent( results[ 1 ].replace( /\+/g, ' ' ) );
}

Expand All @@ -10,15 +14,37 @@ function error( msg ) {
return htm;
}

function loadModels( wiki ) {
$.get( '/scores/' + wiki + '/', function ( data ) {
var htm = '', models = [], i = 0;

htm = '<ul style="padding-top: 15px; padding-left: 0px" id="modelSelection"><h5>Select models</h5>';
models = Object.keys( data.models );

for ( i = 0; i < models.length; i++ ) {
htm += '<li class="checkbox"><label><input type="checkbox" value="' + models[ i ] + '">' + models[ i ] + '</label></li>\n\n';
}
htm += '</ul>';
if ( $( '#modelSelection' ).length ) {
$( '#modelSelection' ).replaceWith( htm );
} else {
$( '#wikisList' ).after( htm );
}
$( '#revIds' ).removeAttr( 'disabled' );
}, 'json' );
$( '#wikiDropDownInput' ).html( wiki + '<wiki-icon icon="caret-down"></wiki-icon>' );
$( '#wikiDropDownInput' ).attr( 'value', wiki );
}

function wikis() {
$.get( '/scores/', function ( data ) {
var wikis = data.contexts;
var wikis = data.contexts, i = 0;
for ( i = 0; i < wikis.length; i++ ) {
$( '#wikis' ).append( '<li><a>' + wikis[ i ] + '</a></li>' );
}
$( '#wikiDropDownInput' ).removeAttr( 'disabled' );
$( '#wikisList li > a' ).click( function ( e ) {
loadModels( this.innerHTML );
$( '#wikisList li > a' ).click( function () {
loadModels( this.innerHTML );
} );
} );
}
Expand All @@ -27,22 +53,23 @@ function enableResult() {
$( '#resultButton' ).removeAttr( 'disabled' );
}
function createTable( data ) {
var htm = '<table class="celled table sortable"><thead><tr><th>Wiki</th><th>Model</th><th>Revision ID</th>';
htm += '<th>Value</th><th>Score</th></tr></thead>';
var htm = '', i = 0, j = 0, k = 0, revids = [], outcomes = [], models = [];

htm = '<table class="celled table sortable"><thead><tr><th>Wiki</th><th>Model</th><th>Revision ID</th><th>Value</th><th>Score</th></tr></thead>';
revids = Object.keys( data );
if ( data.responseJSON && data.responseJSON.error ) {
return error( data.responseJSON.error.message );
}
var revids = Object.keys( data );
for ( i = 0; i < revids.length; i++ ) {
if ( data[ revids[ i ] ].error ) {
return error( data[ revids[ i ] ].error.message );
}
var models = Object.keys( data[ revids[ i ] ] );
models = Object.keys( data[ revids[ i ] ] );
for ( j = 0; j < models.length; j++ ) {
if ( data[ revids[ i ] ][ models[ j ] ].error ) {
return error( data[ revids[ i ] ][ models[ j ] ].error.message );
}
var outcomes = Object.keys( data[ revids[ i ] ][ models[ j ] ].probability );
outcomes = Object.keys( data[ revids[ i ] ][ models[ j ] ].probability );
for ( k = 0; k < outcomes.length; k++ ) {
htm += '<tr><td>' + $( '#wikiDropDownInput' ).attr( 'value' ) + '</td><td>' + models[ j ] + '</td><td>' + revids[ i ] + '</td><td>' + outcomes[ k ] + '</td><td>' + data[ revids[ i ] ][ models[ j ] ].probability[ outcomes[ k ] ] + '</td></tr>';
}
Expand All @@ -51,34 +78,14 @@ function createTable( data ) {
htm += '</tbody></table>';
return htm;
}
function loadModels( wiki ) {
$.get( '/scores/' + wiki + '/', function ( data ) {
var htm = '<ul style="padding-top: 15px; padding-left: 0px" id="modelSelection"><h5>Select models</h5>';
var models = Object.keys( data.models );
for ( i = 0; i < models.length; i++ ) {
htm += '<li class="checkbox"><label><input type="checkbox" value="' + models[ i ] + '">' + models[ i ] + '</label></li>\n\n';
}
htm += '</ul>';
if ( $( '#modelSelection' ).length ) {
$( '#modelSelection' ).replaceWith( htm );
} else {
$( '#wikisList' ).after( htm );
}
$( '#revIds' ).removeAttr( 'disabled' );
}, 'json' );
$( '#wikiDropDownInput' ).html( wiki + '<wiki-icon icon="caret-down"></wiki-icon>' );
$( '#wikiDropDownInput' ).attr( 'value', wiki );
}

function getResults() {
var revs = $( '#revIds' ).val().replace( ',', '|' );
var models_url = '';
var revs = $( '#revIds' ).val().replace( ',', '|' ), modelsUrl = '', url = '', container = '<div id="tableContainer" class="col-md-6 col-md-offset-3" style="margin-top: 3em; margin-bottom: 3em;">';
$( 'input:checked' ).each( function () {
models_url += $( this ).val() + '|';
modelsUrl += $( this ).val() + '|';
} );
models_url = models_url.slice( 0, -1 );
var container = '<div id="tableContainer" class="col-md-6 col-md-offset-3" style="margin-top: 3em; margin-bottom: 3em;">';
var url = '/scores/' + $( '#wikiDropDownInput' ).attr( 'value' ) + '/?models=' + models_url + '&revids=' + revs;
modelsUrl = modelsUrl.slice( 0, -1 );
url = '/scores/' + $( '#wikiDropDownInput' ).attr( 'value' ) + '/?models=' + modelsUrl + '&revids=' + revs;
$.get( { url: url, datatype: 'jsonp' } ).always( function ( data ) {
$( '#tableContainer' ).remove();
$( '#afterThis' ).after( container + createTable( data ) + '</div>' );
Expand Down Expand Up @@ -108,11 +115,12 @@ if ( getParameterByName( 'revids' ) ) {
}

if ( getParameterByName( 'models' ) ) {
var url_models = getParameterByName( 'models' ).split( '|' );
urlModels = getParameterByName( 'models' ).split( '|' );
$( function () {
setTimeout( function () {
for ( i = 0; i < url_models.length; i++ ) {
$( ':input[value="' + url_models[ i ] + '"]' ).prop( 'checked', true );
var i = 0;
for ( i = 0; i < urlModels.length; i++ ) {
$( ':input[value="' + urlModels[ i ] + '"]' ).prop( 'checked', true );
}
}, 3000 );
} );
Expand Down

0 comments on commit 23094ad

Please sign in to comment.