Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #82 from BrainBuzzer/master
Browse files Browse the repository at this point in the history
[ci] Add JSLint
  • Loading branch information
nemesifier authored Jan 15, 2018
2 parents b343af6 + 90d2b66 commit 385a949
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 48 deletions.
15 changes: 6 additions & 9 deletions .jslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
"document",
"navigator",
"console",
"window",
"alert",
"django",
"gettext",
"windowname_to_id",
"jQuery",
"WebSocket",
"$",
"alert"
"window",
"closeOverlay",
"setTimeout"
],

"adsafe": false,
Expand Down Expand Up @@ -39,11 +36,11 @@
"vars": true,
"white": false,
"validthis": true,
"strict_mode":true,
"strict_mode":false,

"browser": false,
"devel": false,
"node": false,
"node": true,
"rhino": false,
"widget": false,
"windows": false,
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ before_install:
- pip install --no-cache-dir -U -r requirements-test.txt
- ./runflake8
- ./runisort
- npm install --save jslint -g
- jslint --config ./.jslintrc ./django_netjsongraph/static/netjsongraph/js/*.js
- npm install jslint -g
- jslint django_netjsongraph/static/netjsongraph/js/*.js

install:
- pip install $DJANGO
Expand Down
11 changes: 6 additions & 5 deletions django_netjsongraph/static/netjsongraph/js/receive-url.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
(function($) {
$(document).ready(function() {
(function ($) {
'use strict';
$(document).ready(function () {
var p = $('.field-receive_url p, .field-receive_url > div > div'),
value = window.location.origin + p.text();
p.html('<input readonly id="id_receive_url" type="text" class="vTextField readonly" value="'+ value +'">');
p.html('<input readonly id="id_receive_url" type="text" class="vTextField readonly" value="' + value + '">');
var field = $('#id_receive_url');
field.click(function(){
field.click(function () {
$(this).select();
});
});
})(django.jQuery);
}(django.jQuery));
14 changes: 7 additions & 7 deletions django_netjsongraph/static/netjsongraph/js/strategy-switcher.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
(function($) {
$(document).ready(function() {
(function ($) {
'use strict';
$(document).ready(function () {
var strategy = $('#id_strategy'),
fetchRows = $('#id_url').parents('.form-row'),
receiveRows = $('#id_key, #id_expiration_time, #id_receive_url').parents('.form-row');
strategy.change(function(e){
if (strategy.val() == 'fetch'){
strategy.change(function (e) {
if (strategy.val() === 'fetch') {
fetchRows.show();
receiveRows.hide();
}
else{
} else {
fetchRows.hide();
receiveRows.show();
}
});
strategy.trigger('change');
});
})(django.jQuery);
}(django.jQuery));
11 changes: 6 additions & 5 deletions django_netjsongraph/static/netjsongraph/js/topology-history.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
window.initTopologyHistory = function($){
window.initTopologyHistory = function ($) {
'use strict';
var datepicker = $('#njg-datepicker'),
today = new Date(),
apiUrl = datepicker.attr('data-history-api');
today.setHours(0, 0, 0, 0);
datepicker.datepicker({dateFormat: 'dd/mm/yy'});
datepicker.datepicker('setDate', today);
datepicker.change(function() {;
datepicker.change(function () {
var date = datepicker.val().split('/').reverse().join('-'),
url = apiUrl + '?date=' + date;
// load latest data when looking currentDate
if(datepicker.datepicker('getDate').getTime() == today.getTime()){
if (datepicker.datepicker('getDate').getTime() === today.getTime()) {
url = window.__njg_default_url__;
}
$.getJSON(url).done(function(data){
$.getJSON(url).done(function (data) {
window.graph = window.loadNetJsonGraph(data);
}).error(function(xhr){
}).error(function (xhr) {
alert(xhr.responseJSON.detail);
});
});
Expand Down
40 changes: 20 additions & 20 deletions django_netjsongraph/static/netjsongraph/js/visualize.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
django.jQuery(function($) {
django.jQuery(function ($) {
'use strict';
var overlay = $('.djnjg-overlay'),
body = $('body'),
inner = overlay.find('.inner'),
visualizeUrl = $('.visualizelink').attr('data-url');

var openOverlay = function() {
var disableArrowKeys = function (e) {
var ar = [37, 38, 39, 40];
if ($.inArray(e.keyCode, ar) >= 0) {
e.preventDefault();
}
};

var openOverlay = function () {
// show overlay
window.__njg_el__ = '.djnjg-overlay .inner';
$.get(visualizeUrl, function(html) {
$.get(visualizeUrl, function (html) {
overlay.show();
inner.html(html);
body.css('overflow', 'hidden');
inner.css('overflow', 'hidden');
overlay.find('.close').click(function(e){
overlay.find('.close').click(function (e) {
e.preventDefault();
closeOverlay();
})
})
});
});
$(document).keydown(disableArrowKeys);
};

var closeOverlay = function () {
$(document).unbind('keydown', disableArrowKeys);
inner.html('');
overlay.hide()
overlay.hide();
body.attr('style', '');
};

$('.visualizelink').click(function(e){
$('.visualizelink').click(function (e) {
openOverlay();
});

$(document).keyup(function(e) {
$(document).keyup(function (e) {
// ALT+P
if (e.altKey && e.which == 80) {
if (e.altKey && e.which === 80) {
// unfocus any active input before proceeding
$(document.activeElement).trigger('blur');
// corresonding raw value before proceding
setTimeout(openOverlay, 15);
}
// ESC
else if (!e.ctrlKey && e.which == 27) {
} else if (!e.ctrlKey && e.which === 27) {
// ESC
closeOverlay();
}
});

var disableArrowKeys = function(e) {
var ar = new Array(37, 38, 39, 40);
if ($.inArray(e.keyCode, ar)>=0){
e.preventDefault();
}
}
});

0 comments on commit 385a949

Please sign in to comment.