Commit 7e40031b authored by yPhil's avatar yPhil

All: JSHint refactoring

parent 6663b1a1
......@@ -25,8 +25,6 @@ build/Release
# Dependency directories
node_modules
bower_components
tmp
jspm_packages
# Optional npm cache directory
......
var express = require('express')
var path = require('path')
var express = require('express');
var path = require('path');
var index = require('./routes/index')
var index = require('./routes/index');
var app = express()
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'))
app.engine('html', require('ejs').renderFile)
app.set('view engine', 'html')
app.set('views', path.join(__dirname, 'views'));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use('/static', express.static(path.join(__dirname, 'public')))
app.use('/tmp', express.static(path.join(__dirname, 'tmp')))
app.use('/static', express.static(__dirname + '/public'));
app.use('/tmp', express.static(__dirname + '/tmp'));
app.use('/bower', express.static(path.join(__dirname, 'bower_components')))
app.use('/', index)
app.use('/bower', express.static(__dirname + '/bower_components'));
app.use('/', index);
module.exports = app
module.exports = app;
This diff is collapsed.
......@@ -7,7 +7,6 @@
},
"scripts": {
"start": "node ./bin/www",
"test": "standard",
"postinstall": "bower install"
},
"dependencies": {
......@@ -26,26 +25,5 @@
"jquery": "latest",
"jquery-ui": "latest",
"parse-favicon": "1.2.8"
},
"devDependencies": {
"standard": "*"
},
"standard": {
"globals": [
"$",
"Blob",
"localStorage",
"FileReader",
"Dialog",
"Feed",
"Prefs",
"Tab",
"Utilities"
],
"ignore": [
"public/lib/js/jquery.localize.js",
"test.js",
"public/css/**/*.js"
]
}
}
......@@ -72,7 +72,7 @@ fieldset a:link {
}
fieldset a:visited {
color: #e6a400;
color: #6E7A94;
}
p, label {
......@@ -117,24 +117,12 @@ button#donate {
color: #FFDC00 !important;
}
.ui-state-active {
#menu .ui-state-active,
#menu .ui-state-hover {
background-color: #FFD05B !important;
color: #001F3F !important;
}
.ui-button:active {
background-color: #001F3F !important;
color: #FFD05B !important;
}
/* .ui-state-active:hover { */
/* background-color: #FFD05B !important; */
/* } */
.ui-visual-focus {
box-shadow: 0 0 3px 1px #FFD05B !important;
}
.ui-state-success {
background-color: #DFF2BF !important;
}
......
jQuery-ColorPicker @ f4321c79
Subproject commit f4321c79fbfeba2a55b433a0902f7ea5117252c9
This diff is collapsed.
This diff is collapsed.
/**
* A class for finding a website’s favicon URL, if any. Requires a context, like
* a browser extension, that allows cross-origin requests.
* <br />
* <br />
* Copyright 2012, 2013 Disconnect, Inc.
* <br />
* <br />
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at <a
* href="https://mozilla.org/MPL/2.0/">https://mozilla.org/MPL/2.0/</a>.
* <br />
* @constructor
* @param {string} [alt] A default favicon URL, absolute or relative.
* @author <a href="https://github.com/byoogle">Brian Kennish</a>
*/
function Favicon(alt) {
/**
* Fetches the default favicon URL.
* @return {string} An absolute or relative URL.
*/
this.getAlt = function() { return alt; };
/**
* Mungs the default favicon URL.
* @param {string} alt An absolute or relative URL.
* @return {Favicon} The favicon object.
*/
this.setAlt = function(newAlt) {
alt = newAlt;
return this;
};
/**
* Finds a favicon URL.
* @param {string} url A website’s absolute URL or hostname.
* @param {function(string)} callback A continuation, to execute when the
* method completes, that takes a favicon
* URL.
* @return {Favicon} The favicon object.
*/
this.get = function(url, callback) {
var favicon = this.getAlt();
if (typeof favicon != undeclared) callback(favicon);
var id = setInterval(function() {
if (typeof jQuery != undeclared) {
clearInterval(id);
if (url.indexOf('/') + 1) {
anchor.href = url;
url = anchor.hostname;
}
var domain = url.slice(url.indexOf('.') + 1);
var successful;
for (var i = 0; i < protocolCount; i++) {
for (var j = -1; j < subdomainCount; j++) {
for (var k = 0; k < pathCount; k++) {
favicon =
protocols[i] + (j + 1 ? subdomains[j] + domain : url) +
paths[k];
jQuery.get(favicon, function(data, status, xhr) {
var type = xhr.getResponseHeader('Content-Type');
if (!successful && type && type.indexOf('image/') + 1 && data) {
successful = true;
callback(favicon);
}
}).bind(favicon);
}
}
}
}
}, 100);
return this;
};
var version = '1.3.0';
var protocols = ['http://'];
var subdomains = ['', 'www.'];
var paths = ['/favicon.ico'];
var protocolCount = protocols.length;
var subdomainCount = subdomains.length;
var pathCount = paths.length;
var anchor = document.createElement('a');
var undeclared = 'undefined';
if (typeof jQuery == undeclared) {
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', 'vendor/jquery.js');
script.onload = function() { jQuery.noConflict(); };
document.head.appendChild(script);
}
return this;
}
This diff is collapsed.
var globalTest = 'plip';
This diff is collapsed.
<html>
<head>
<title>jscolor demo</title>
</head>
<body>
<script type="text/javascript" src="jscolor.js"></script>
Click here: <input class="color" value="66ff00">
</body>
</html>
This diff is collapsed.
$('<div id="menu">').appendTo($('body')).load('/static/templates/menu.html', function () {
var $slider = $(this)
var $handle = $slider.find('.handle')
var $fileImportButton = $('button#fileImport').button()
var $fileImportInput = $('input#fileImport').button()
var $fileExport = $('#saveTabs').button()
var $donate = $('#donate')
var $profile = $('#profile').button().tooltip()
$donate.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 files = evt.target.files
var f = files[0]
var reader = new FileReader()
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 {
isValid = false
}
return isValid
$('<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
var y = e.target.result
var p = JSON.parse(y)
$fileImportInput.change(function(evt){
var JsonObj = null
var files = evt.target.files
var f = files[0];
var reader = new FileReader();
console.log('p Is array: %s', isOk(p))
var $notifyArea = $slider.find('#mobNotify > p');
if (isOk(p) === true) {
Utilities.notify('success', 'Successful import')
Tab.populateTabs(p, true)
if (f.type.match(/application\/json/)) {
console.log('JSON!')
} else {
Utilities.notify('error', 'Not a Mobylette definition file')
console.log('NOT JSON!')
Utilities.notify('error', 'Not a Mobylette definition file format');
return
}
// console.log('Is Valid: %s', isValid)
}
})(f)
reader.readAsText(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);
});
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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;
This diff is collapsed.
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