Commit 214f4af0 authored by yPhil's avatar yPhil

Lib: JS files cleanup: npm standard

parent 896e2940
......@@ -2,7 +2,9 @@
"globals": {
"Dialog": false,
"Feed": false,
"Tab": false
"Prefs": false,
"Tab": false,
"Utilities": false
},
"env": {
"browser": true,
......@@ -13,18 +15,10 @@
},
"extends": "eslint:recommended",
"rules": {
"one-var": ["error", "initializations"],
"indent": [2, 2, {"MemberExpression": 1}],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
]
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single"],
"semi": ["error", "never"]
}
}
......@@ -25,6 +25,8 @@ build/Release
# Dependency directories
node_modules
bower_components
tmp
jspm_packages
# Optional npm cache directory
......
This diff is collapsed.
......@@ -7,6 +7,7 @@
},
"scripts": {
"start": "node ./bin/www",
"test": "standard",
"postinstall": "bower install"
},
"dependencies": {
......@@ -27,11 +28,13 @@
"parse-favicon": "1.2.8"
},
"devDependencies": {
"eslint": "4.11.0",
"eslint-config-standard": "10.2.1",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-node": "5.2.1",
"eslint-plugin-promise": "3.6.0",
"eslint-plugin-standard": "3.0.1"
}
"standard": "*"
},
"standard": {
"ignore": [
"public/lib/js/jquery.localize.js",
"test.js",
"public/css"
]
}
}
jQuery-ColorPicker @ f4321c79
Subproject commit f4321c79fbfeba2a55b433a0902f7ea5117252c9
$('<div id="menu">').appendTo($('body')).load('/static/templates/menu.html', function() {
var $slider = $(this)
, $handle = $slider.find('.handle')
, $fileImportButton = $("button#fileImport").button()
, $fileImportInput = $("input#fileImport").button()
, $fileExport = $('#saveTabs').button()
, $donate = $('#donate').button().tooltip()
, $profile = $('#profile').button().tooltip();
$handle.click(function () {
$slider.toggleClass('expanded');
$(this).children('i').toggleClass('close')
});
$profile.click(function (event) {
event.preventDefault();
console.log('Click!');
$handle.click();
Dialog.question(0);
});
$fileImportButton.click(function () {
$("input#fileImport").click();
return false;
});
$fileExport.click(function () {
Prefs.exportConfig(Tab.getTabs(), 'mobylette.json');
return false;
});
$(".checkboxradio").checkboxradio();
$(this).find('input#' + Prefs.readConfig('theme')).prop("checked", true)
.checkboxradio('refresh');
$('.themeSwitcher').change(function() {
console.log('Theme: ' + '/static/css/themes/' + $(this).attr('value') + '.css')
$("#mobStyle").attr({href : '/static/css/themes/' + $(this).attr('value') + '.css'});
Prefs.writeConfig('theme', $(this).attr('value'));
});
var gallerySlideshowSpeed = Prefs.readConfig('gallerySlideshowSpeed');
var gallerySlideTransition = Prefs.readConfig('gallerySlideTransition');
$.fancybox.defaults.thumbs.autoStart = true;
$.fancybox.defaults.transitionEffect = gallerySlideTransition;
$.fancybox.defaults.slideShow.speed = gallerySlideshowSpeed;
$slider.find('select#gallerySlideTransition').change(function() {
console.log('New FX: %s', $(this).val());
$.fancybox.defaults.transitionEffect = $(this).val();
Prefs.writeConfig('gallerySlideTransition', $(this).val());
});
$slider.find('select#gallerySlideTransition').val(gallerySlideTransition);
if (Prefs.readConfig('tabDropActivate') === 'true')
$('#tabDropActivate').prop('checked', true).checkboxradio('refresh')
else
$('#tabDropActivate').prop('checked', false).checkboxradio('refresh')
$('#tabDropActivate').change(function() {
Prefs.writeConfig('tabDropActivate', $(this).prop('checked'));
});
$slider.find('#gallerySlideshowSpeed').slider({
value: gallerySlideshowSpeed,
min: 1,
max: 10000,
step: 1,
slide: function(event, ui) {
$('#amount').val(ui.value + 'ms');
// $('#gallerySlideshowSpeedValue').text(ui.value + 'ms');
$('#gallerySlideshowSpeedValue').text(Utilities.milliToSecs(ui.value) + 's');
},
change: function(event, ui) {
Prefs.writeConfig('gallerySlideshowSpeed', ui.value);
$('#tabs').find("[data-fancybox]").fancybox({
slideShow: {
speed: ui.value
}
});
$('<div id="menu">').appendTo($('body')).load('/static/templates/menu.html', function () {
var $slider = $(this),
$handle = $slider.find('.handle'),
$fileImportButton = $('button#fileImport').button(),
$fileImportInput = $('input#fileImport').button(),
$fileExport = $('#saveTabs').button(),
$donate = $('#donate').button().tooltip(),
$profile = $('#profile').button().tooltip()
$handle.click(function () {
$slider.toggleClass('expanded')
$(this).children('i').toggleClass('close')
})
$profile.click(function (event) {
event.preventDefault()
console.log('Click!')
$handle.click()
Dialog.question(0)
})
$fileImportButton.click(function () {
$('input#fileImport').click()
return false
})
$fileExport.click(function () {
Prefs.exportConfig(Tab.getTabs(), 'mobylette.json')
return false
})
$('.checkboxradio').checkboxradio()
$(this).find('input#' + Prefs.readConfig('theme')).prop('checked', true)
.checkboxradio('refresh')
$('.themeSwitcher').change(function () {
console.log('Theme: ' + '/static/css/themes/' + $(this).attr('value') + '.css')
$('#mobStyle').attr({href: '/static/css/themes/' + $(this).attr('value') + '.css'})
Prefs.writeConfig('theme', $(this).attr('value'))
})
var gallerySlideshowSpeed = Prefs.readConfig('gallerySlideshowSpeed')
var gallerySlideTransition = Prefs.readConfig('gallerySlideTransition')
$.fancybox.defaults.thumbs.autoStart = true
$.fancybox.defaults.transitionEffect = gallerySlideTransition
$.fancybox.defaults.slideShow.speed = gallerySlideshowSpeed
$slider.find('select#gallerySlideTransition').change(function () {
console.log('New FX: %s', $(this).val())
$.fancybox.defaults.transitionEffect = $(this).val()
Prefs.writeConfig('gallerySlideTransition', $(this).val())
})
$slider.find('select#gallerySlideTransition').val(gallerySlideTransition)
if (Prefs.readConfig('tabDropActivate') === 'true') { $('#tabDropActivate').prop('checked', true).checkboxradio('refresh') } else { $('#tabDropActivate').prop('checked', false).checkboxradio('refresh') }
$('#tabDropActivate').change(function () {
Prefs.writeConfig('tabDropActivate', $(this).prop('checked'))
})
$slider.find('#gallerySlideshowSpeed').slider({
value: gallerySlideshowSpeed,
min: 1,
max: 10000,
step: 1,
slide: function (event, ui) {
$('#amount').val(ui.value + 'ms')
// $('#gallerySlideshowSpeedValue').text(ui.value + 'ms');
$('#gallerySlideshowSpeedValue').text(Utilities.milliToSecs(ui.value) + 's')
},
change: function (event, ui) {
Prefs.writeConfig('gallerySlideshowSpeed', ui.value)
$('#tabs').find('[data-fancybox]').fancybox({
slideShow: {
speed: ui.value
}
})
}
})
$('#amount').val($('#gallerySlideshowSpeed').slider('value') + 'ms')
$('#gallerySlideshowSpeedValue').text(Utilities.milliToSecs($('#gallerySlideshowSpeed').slider('value')) + 's')
// File select
$fileImportInput.change(function (evt) {
var JsonObj = null
var files = evt.target.files
var f = files[0]
var reader = new FileReader()
var $notifyArea = $slider.find('#mobNotify > p')
if (f.type.match(/application\/json/)) {
console.log('JSON!')
} else {
console.log('NOT JSON!')
Utilities.notify('error', 'Not a Mobylette definition file format')
return
}
reader.onload = (function (theFile) {
return function (e) {
function isOk (o) {
if (Object.prototype.toString.call(o) === '[object Array]') {
var isValid = o.some(obj =>
Array.isArray(obj.feeds) && obj.feeds.some(feed =>
Object.prototype.hasOwnProperty.call(feed, 'url')
)
)
} else {
var isValid = false
}
return isValid
}
});
$('#amount').val($('#gallerySlideshowSpeed').slider('value') + 'ms');
$('#gallerySlideshowSpeedValue').text(Utilities.milliToSecs($('#gallerySlideshowSpeed').slider('value')) + 's');
// File select
$fileImportInput.change(function(evt){
var JsonObj = null
var files = evt.target.files
var f = files[0];
var reader = new FileReader();
var y = e.target.result
var p = JSON.parse(y)
var $notifyArea = $slider.find('#mobNotify > p');
console.log('p Is array: %s', isOk(p))
if (f.type.match(/application\/json/)) {
console.log('JSON!')
if (isOk(p) === true) {
Utilities.notify('success', 'Successful import')
Tab.populateTabs(p, true)
} else {
console.log('NOT JSON!')
Utilities.notify('error', 'Not a Mobylette definition file format');
return
Utilities.notify('error', 'Not a Mobylette definition file')
}
// console.log('Is Valid: %s', isValid)
}
})(f)
reader.onload = (function(theFile) {
return function(e) {
function isOk(o) {
if (Object.prototype.toString.call(o) === '[object Array]') {
var isValid = o.some(obj =>
Array.isArray(obj.feeds) && obj.feeds.some(feed =>
Object.prototype.hasOwnProperty.call(feed, 'url')
)
)
} else {
var isValid = false;
}
return isValid
}
var y = e.target.result
var p = JSON.parse(y);
console.log('p Is array: %s', isOk(p))
if (isOk(p) === true){
Utilities.notify('success', 'Successful import');
Tab.populateTabs(p, true);
} else {
Utilities.notify('error', 'Not a Mobylette definition file');
}
// console.log('Is Valid: %s', isValid)
};
})(f);
reader.readAsText(f);
});
});
reader.readAsText(f)
})
})
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res, next) {
res.send('respond with a resource');
});
module.exports = router;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment