mirror of
https://github.com/SunRed/haste-server.git
synced 2024-11-23 17:50:19 +01:00
fixed eslint formatting
This commit is contained in:
parent
9255094ec4
commit
d303416dba
5 changed files with 36 additions and 35 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
||||||
node_modules
|
node_modules
|
||||||
.vscode
|
.vscode
|
||||||
data
|
data
|
||||||
|
data-test
|
||||||
|
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
|
10
server.js
10
server.js
|
@ -10,6 +10,11 @@ const HasteUtils = require('./lib/util');
|
||||||
|
|
||||||
const utils = new HasteUtils();
|
const utils = new HasteUtils();
|
||||||
|
|
||||||
|
//load config and set some defaults
|
||||||
|
const config = require('./config');
|
||||||
|
config.port = config.port || 7777;
|
||||||
|
config.host = config.host || '127.0.0.1';
|
||||||
|
|
||||||
//set up logger
|
//set up logger
|
||||||
winston.add(new winston.transports.Console({
|
winston.add(new winston.transports.Console({
|
||||||
level: config.logging.level,
|
level: config.logging.level,
|
||||||
|
@ -19,11 +24,6 @@ winston.add(new winston.transports.Console({
|
||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//load config and set some defaults
|
|
||||||
const config = require('./config');
|
|
||||||
config.port = config.port || 7777;
|
|
||||||
config.host = config.host || '127.0.0.1';
|
|
||||||
|
|
||||||
//defaulting storage type to file
|
//defaulting storage type to file
|
||||||
if (!config.storage){
|
if (!config.storage){
|
||||||
config.storage = {
|
config.storage = {
|
||||||
|
|
|
@ -28,13 +28,13 @@ haste_document.prototype.load = function(key, callback, lang){
|
||||||
let high;
|
let high;
|
||||||
try {
|
try {
|
||||||
if (lang == 'txt'){
|
if (lang == 'txt'){
|
||||||
high = { value: _this.htmlEscape(res.data) };
|
high = { value: _this.htmlEscape(res.data) };
|
||||||
}
|
}
|
||||||
else if (lang){
|
else if (lang){
|
||||||
high = hljs.highlight(lang, res.data);
|
high = hljs.highlight(lang, res.data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
high = hljs.highlightAuto(res.data);
|
high = hljs.highlightAuto(res.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(err){
|
catch(err){
|
||||||
|
@ -68,7 +68,7 @@ haste_document.prototype.save = function(data, callback){
|
||||||
_this.locked = true;
|
_this.locked = true;
|
||||||
_this.key = res.key;
|
_this.key = res.key;
|
||||||
let high = hljs.highlightAuto(data);
|
let high = hljs.highlightAuto(data);
|
||||||
callback(null, {
|
callback(null, {
|
||||||
value: high.value,
|
value: high.value,
|
||||||
key: res.key,
|
key: res.key,
|
||||||
language: high.language,
|
language: high.language,
|
||||||
|
@ -130,7 +130,7 @@ haste.prototype.configureKey = enable => {
|
||||||
let $this;
|
let $this;
|
||||||
$('#box2 .function').each(function(){
|
$('#box2 .function').each(function(){
|
||||||
$this = $(this);
|
$this = $(this);
|
||||||
for (el of enable){
|
for (const el of enable){
|
||||||
if ($this.hasClass(el)){
|
if ($this.hasClass(el)){
|
||||||
$this.addClass('enabled');
|
$this.addClass('enabled');
|
||||||
return true;
|
return true;
|
||||||
|
@ -315,7 +315,7 @@ haste.prototype.configureButtons = function(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
for (button of this.buttons){
|
for (const button of this.buttons){
|
||||||
this.configureButton(button);
|
this.configureButton(button);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -346,7 +346,7 @@ haste.prototype.configureButton = function(options){
|
||||||
haste.prototype.configureShortcuts = function(){
|
haste.prototype.configureShortcuts = function(){
|
||||||
let _this = this;
|
let _this = this;
|
||||||
$(document.body).keydown(function(evt){
|
$(document.body).keydown(function(evt){
|
||||||
for (button of _this.buttons){
|
for (const button of _this.buttons){
|
||||||
if (button.shortcut && button.shortcut(evt)){
|
if (button.shortcut && button.shortcut(evt)){
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
button.action();
|
button.action();
|
||||||
|
|
|
@ -8,20 +8,20 @@ const vowels = 'aeiou';
|
||||||
const consonants = 'bcdfghjklmnpqrstvwxyz';
|
const consonants = 'bcdfghjklmnpqrstvwxyz';
|
||||||
|
|
||||||
describe('RandomKeyGenerator', () => {
|
describe('RandomKeyGenerator', () => {
|
||||||
describe('randomKey', () => {
|
describe('randomKey', () => {
|
||||||
it('should return a key of the proper length', () => {
|
it('should return a key of the proper length', () => {
|
||||||
const gen = new Generator();
|
const gen = new Generator();
|
||||||
assert.equal(6, gen.createKey(6).length);
|
assert.equal(6, gen.createKey(6).length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should alternate consonants and vowels', () => {
|
it('should alternate consonants and vowels', () => {
|
||||||
const gen = new Generator();
|
const gen = new Generator();
|
||||||
|
|
||||||
const key = gen.createKey(3);
|
const key = gen.createKey(3);
|
||||||
|
|
||||||
assert.ok(consonants.includes(key[0]));
|
assert.ok(consonants.includes(key[0]));
|
||||||
assert.ok(consonants.includes(key[2]));
|
assert.ok(consonants.includes(key[2]));
|
||||||
assert.ok(vowels.includes(key[1]));
|
assert.ok(vowels.includes(key[1]));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,15 +5,15 @@ const assert = require('assert');
|
||||||
const Generator = require('../../lib/key_generators/random');
|
const Generator = require('../../lib/key_generators/random');
|
||||||
|
|
||||||
describe('RandomKeyGenerator', () => {
|
describe('RandomKeyGenerator', () => {
|
||||||
describe('randomKey', () => {
|
describe('randomKey', () => {
|
||||||
it('should return a key of the proper length', () => {
|
it('should return a key of the proper length', () => {
|
||||||
const gen = new Generator();
|
const gen = new Generator();
|
||||||
assert.equal(6, gen.createKey(6).length);
|
assert.equal(6, gen.createKey(6).length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use a key from the given keyset if given', () => {
|
it('should use a key from the given keyset if given', () => {
|
||||||
const gen = new Generator({keyspace: 'A'});
|
const gen = new Generator({keyspace: 'A'});
|
||||||
assert.equal('AAAAAA', gen.createKey(6));
|
assert.equal('AAAAAA', gen.createKey(6));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue