1
0
Fork 0

Switch from jshint to eslint

merge-requests/308/head
Nikos Roussos 2017-02-11 15:59:02 +02:00
parent 50fdc96d4b
commit a0635a4c9c
No known key found for this signature in database
GPG Key ID: BADFF1767BA7C8E1
11 changed files with 126 additions and 68 deletions

35
.eslintrc.json 100644
View File

@ -0,0 +1,35 @@
{
"env": {
"browser": true,
"es6": true,
"jquery": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"curly": [
"error",
"all"
],
"one-var-declaration-per-line": [
"error",
"always"
],
"new-cap": "error"
}
}

View File

@ -4,11 +4,11 @@ python:
- "2.7"
install:
- pip install -r requirements/dev.txt
- npm install -g jshint stylelint
- npm install -g eslint stylelint
script:
- flake8 .
- jshint .
- pytest
- eslint 'network/static/js/*.js'
- stylelint 'network/static/css/*.css'
after_success:
- coveralls

View File

@ -1,9 +1,13 @@
/* This script calculates the grid locator based on the Maidenhead
* Locator System. It references the longitude and latitude fields
* in the Station Add/Edit view, calculating the grid square and adding
* that to the location field iff both lat/lon values exist and are
* valid. -cshields
* that to the location field if both lat/lon values exist and are
* valid.
*/
$(document).ready(function() {
'use strict';
function gridsquare() {
var FIELD_IDENTIFIERS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
@ -43,3 +47,12 @@ function gridsquare() {
lon_subsquare.toLowerCase() + lat_subsquare.toLowerCase());
}
}
$('input#lat').change(function() {
gridsquare();
});
$('input#lng').change(function() {
gridsquare();
});
});

View File

@ -1,3 +1,5 @@
/*global L*/
$(document).ready(function() {
'use strict';
@ -10,7 +12,7 @@ $(document).ready(function() {
var map = L.mapbox.map('map', mapboxid, {
zoomControl: false
}).setView([40, 0], 3);
var LocLayer = L.mapbox.featureLayer().addTo(map);
L.mapbox.featureLayer().addTo(map);
$.ajax({
url: stations

View File

@ -1,3 +1,5 @@
/* global moment, d3 */
$(document).ready( function(){
function select_proper_transmitters(satellite) {
$('#transmitter-selection').prop('disabled', false);
@ -16,7 +18,7 @@ $(document).ready( function(){
if (obs_filter) {
satellite = $('input[name="satellite"]').val();
ground_station = $('input[name="ground_station"]').val();
var ground_station = $('input[name="ground_station"]').val();
}
if (!obs_filter_dates) {
@ -27,7 +29,7 @@ $(document).ready( function(){
$('#datetimepicker-start').data('DateTimePicker').minDate(moment.utc().add(minstart, 'm'));
$('#datetimepicker-end').datetimepicker();
$('#datetimepicker-end').data('DateTimePicker').minDate(moment.utc().add(minend, 'm'));
$("#datetimepicker-start").on('dp.change',function (e) {
$('#datetimepicker-start').on('dp.change',function (e) {
// Setting default, minimum and maximum for end
$('#datetimepicker-end').data('DateTimePicker').defaultDate(moment.utc(e.date).add(60, 'm'));
$('#datetimepicker-end').data('DateTimePicker').minDate(e.date);
@ -63,11 +65,11 @@ $(document).ready( function(){
$('#loading').hide();
if (data.error) {
var error_msg = data.error;
console.log(data.error);
$('#windows-data').html('<span class="text-danger">' + error_msg + '</span>');
} else {
var dc = 0; // Data counter
var suggested_data = [];
var label = '';
$('#windows-data').empty();
$.each(data, function(i, k){
label = k.id + ' - ' + k.name;
@ -120,7 +122,7 @@ $(document).ready( function(){
if (screen.width < 1200) { svg_width = 940; }
if (screen.width < 992) { svg_width = 720; }
if (screen.width < 768) { svg_width = screen.width - 30; }
var svg = d3.select('#timeline').append('svg').attr('width', svg_width)
d3.select('#timeline').append('svg').attr('width', svg_width)
.datum(payload).call(chart);
$('#hoverRes').show();

View File

@ -1,3 +1,5 @@
/* global d3 WaveSurfer URI */
$(document).ready(function() {
'use strict';
@ -14,7 +16,7 @@ $(document).ready(function() {
return String(minute + ':' + second); // combine minute and second in string
};
$('.observation-data').each(function( index ){
$('.observation-data').each(function(){
var $this = $(this);
var data_groundstation = $this.data('groundstation');
var data_time_start = 1000 * $this.data('start');
@ -33,17 +35,17 @@ $(document).ready(function() {
div.find('#name').text(datum.label);
})
.margin({left:140, right:10, top:0, bottom:50})
.tickFormat({format: d3.time.format.utc("%H:%M"), tickTime: d3.time.minutes, tickInterval: 30, tickSize: 6});
.tickFormat({format: d3.time.format.utc('%H:%M'), tickTime: d3.time.minutes, tickInterval: 30, tickSize: 6});
var svg_width = 1140;
if (screen.width < 1200) { svg_width = 940; }
if (screen.width < 992) { svg_width = 720; }
if (screen.width < 768) { svg_width = screen.width - 30; }
var svg = d3.select("#timeline").append("svg").attr("width", svg_width)
d3.select('#timeline').append('svg').attr('width', svg_width)
.datum(observation_data).call(chart);
// Waveform loading
$('.wave').each(function( index ){
$('.wave').each(function(){
var $this = $(this);
var wid = $this.data('id');
var wavesurfer = Object.create(WaveSurfer);
@ -82,16 +84,16 @@ $(document).ready(function() {
});
// Hightlight Data block
var uri = URI(location.href);
var uri = new URI(location.href);
var data_id = uri.hash();
$(data_id).addClass('panel-info');
// Delete confirmation
var message = "Do you really want to delete this Observation?";
var message = 'Do you really want to delete this Observation?';
var actions = $('#obs-delete');
if (actions.length) {
actions[0].addEventListener("click", function(e) {
actions[0].addEventListener('click', function(e) {
if (! confirm(message)) {
e.preventDefault();
}

View File

@ -1,14 +1,14 @@
$(document).ready(function() {
'use strict';
$("#satellite-filter").submit(function () {
$('#satellite-filter').submit(function () {
var the_form = $(this);
the_form.find('input[type="checkbox"]').each( function () {
var the_checkbox = $(this);
if( the_checkbox.is(":checked") === true ) {
if( the_checkbox.is(':checked') === true ) {
the_checkbox.attr('value','1');
} else {
the_checkbox.prop('checked',true);

View File

@ -12,14 +12,14 @@ $(document).ready(function() {
modal.find('.satellite-title').text(data.name);
modal.find('.satellite-names').text(data.names);
modal.find('#SatelliteModalTitle').text(data.name);
modal.find('.satellite-id').text("Norad ID " + satlink.data('id'));
modal.find('#db-link').attr('href', "https://db.satnogs.org/satellite/" + satlink.data('id'));
modal.find('.satellite-id').text('Norad ID ' + satlink.data('id'));
modal.find('#db-link').attr('href', 'https://db.satnogs.org/satellite/' + satlink.data('id'));
modal.find('#new-obs-link').attr('href', '/observations/new/?norad=' + satlink.data('id'));
modal.find('#old-obs-link').attr('href', '/observations/?norad=' + satlink.data('id'));
if (data.image) {
modal.find('.satellite-img-full').attr('src', data.image);
} else {
modal.find('.satellite-img-full').attr('src', "/static/img/sat.png");
modal.find('.satellite-img-full').attr('src', '/static/img/sat.png');
}
});

View File

@ -1,3 +1,5 @@
/* global L */
$(document).ready(function() {
'use strict';

View File

@ -1,7 +1,9 @@
/* global moment */
$(document).ready(function() {
'use strict';
$('#UTCModal').on('show.bs.modal', function (event) {
$('#UTCModal').on('show.bs.modal', function () {
var local = moment().format('HH:mm:ss');
var utc = moment().utc().format('HH:mm:ss');
$('#timezone-utc').text(utc);

View File

@ -39,13 +39,13 @@
<div class="form-group">
<label for="lat" class="col-sm-2 control-label">Latitude</label>
<div class="col-sm-10">
<input value="{{ form.lat.value|default_if_none:"" }}" id="lat" type="text" class="form-control" name="lat" placeholder="Latitude" required onchange="gridsquare()">
<input value="{{ form.lat.value|default_if_none:"" }}" id="lat" type="text" class="form-control" name="lat" placeholder="Latitude" required>
</div>
</div>
<div class="form-group">
<label for="lng" class="col-sm-2 control-label">Longtitude</label>
<div class="col-sm-10">
<input value="{{ form.lng.value|default_if_none:"" }}" id="lng" type="text" class="form-control" name="lng" placeholder="Longtitude" required onchange="gridsquare()">
<input value="{{ form.lng.value|default_if_none:"" }}" id="lng" type="text" class="form-control" name="lng" placeholder="Longtitude" required">
</div>
</div>
<div class="form-group">