Comparing version 1.1.3 to 1.1.4
{ | ||
"name": "corsica", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Ephemeral screens for the masses.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -27,6 +27,6 @@ /* Description: | ||
}); | ||
var insecureScrub = function(str) { | ||
return str.replace(/</g, "<").replace(/>/g, ">"); | ||
} | ||
}; | ||
@@ -33,0 +33,0 @@ corsica.serveRoute('tags', function(req, res) { |
@@ -48,3 +48,3 @@ /* Description: | ||
if (name === undefined) { | ||
console.log('[timer] Error: No name.') | ||
console.log('[timer] Error: No name.'); | ||
return Promise.reject(); | ||
@@ -62,4 +62,10 @@ } | ||
.then(function(settings) { | ||
var resetTime = +settings.resetTime; | ||
var jitter = +settings.jitter; | ||
var resetTime, jitter; | ||
if ('screens' in settings && name in settings.screens) { | ||
resetTime = parseInt(settings.screens[name].resetTime || settings.resetTime); | ||
jitter = parseInt(settings.screens[name].jitter || settings.jitter); | ||
} else { | ||
resetTime = +settings.resetTime; | ||
jitter = +settings.jitter; | ||
} | ||
var offset = jitter * (Math.random() * 2 - 1); | ||
@@ -66,0 +72,0 @@ var timeout = resetTime + offset; |
@@ -1,2 +0,1 @@ | ||
console.log( | ||
@@ -13,21 +12,21 @@ 'Welcome to Corsica.\n'+ | ||
config = localStorage.getItem('config'); | ||
if (config) { | ||
config = JSON.parse(config); | ||
if (config) { | ||
console.log('Welcome back, old friend.'); | ||
} else { | ||
config = undefined; | ||
} | ||
} | ||
config = JSON.parse(config); | ||
console.log('Welcome back, old friend.'); | ||
} catch (e) { | ||
console.warn('Config could not be parsed: ' + e); | ||
} | ||
if (!config) { | ||
console.log('You\'re new here, aren\'t you.'); | ||
config = {}; | ||
writeConfig(); | ||
} | ||
if (!config.tags) { | ||
config.tags = []; | ||
writeConfig(); | ||
} | ||
// name will come on socket connect | ||
function writeConfig() { | ||
@@ -48,10 +47,8 @@ try { | ||
// names | ||
if (names instanceof Array) { | ||
for (i = 0; i < names.length; i++) { | ||
if (names[i] === config.name) { | ||
return true; | ||
} | ||
} | ||
} else { | ||
if (names === config.name) { | ||
if (!(names instanceof Array)) { | ||
names = [names]; | ||
} | ||
for (i = 0; i < names.length; i++) { | ||
if (names[i] === config.name) { | ||
return true; | ||
@@ -62,10 +59,13 @@ } | ||
// tags | ||
if (tags instanceof Array) { | ||
for (i = 0; i < tags.length; i++) { | ||
if (config.tags.indexOf(tags[i]) >= 0) { | ||
return true; | ||
} | ||
if (!(tags instanceof Array)) { | ||
tags = [tags]; | ||
} | ||
for (i = 0; i < tags.length; i++) { | ||
if (config.tags.indexOf(tags[i]) >= 0) { | ||
return true; | ||
} | ||
} | ||
// this message is boring | ||
return false; | ||
@@ -83,3 +83,5 @@ } | ||
toastEl.classList.add('show'); | ||
toastTimeout = setTimeout(untoast, timeout || 5000); | ||
if (timeout > -1) { | ||
toastTimeout = setTimeout(untoast, timeout); | ||
} | ||
} | ||
@@ -168,5 +170,5 @@ | ||
}); | ||
} else { | ||
init(); | ||
return; | ||
} | ||
init(); | ||
}); | ||
@@ -173,0 +175,0 @@ |
Sorry, the diff of this file is not supported yet
117345
50
1658