Skip to content

Commit

Permalink
Refactor pen.js, add JSHint rules
Browse files Browse the repository at this point in the history
Closes #17
  • Loading branch information
Ethan T. Jorgensen authored and Ethan T. Jorgensen committed Mar 7, 2019
1 parent 8ed6f73 commit 8655916
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions script/pen.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
var yearmod = 288
/* jshint browser: true, jquery: true */
/* global ClipboardJS */
'use strict';
var yearmod = 288;

$(document).ready(function() {
$(document).ready(function () {
$('#year').html(getYear());

$('#input').bind('input change', run);
$('#save').click(function() { download('pencode.txt', $('#input').val()) });
$('#load').click(function() { loadFile($('#template').val()) });
$('#save').click(function () { download('pencode.txt', $('#input').val()); });
$('#load').click(function () { loadFile($('#template').val()); });

$('.controlgroup').controlgroup();

// get clipboard.js set up
var clip = new ClipboardJS('#copy');
clip.on('success', function() {
alert('Copied to clipboard.')
clip.on('success', function () {
alert('Copied to clipboard.');
});
clip.on('failure', function() {
alert('Failed to copy.')
clip.on('failure', function () {
alert('Failed to copy.');
});

// keep #copy loaded with the path currently on #template
$('#template').on('selectmenuchange', function() {
var temp = $('#template').val()
$('#copy').attr('data-clipboard-text','http://ps.ss13.net#' + temp.substring(0, temp.indexOf('.txt')))
$('#template').on('selectmenuchange', function () {
var temp = $('#template').val();
$('#copy').attr('data-clipboard-text','http://ps.ss13.net#' + temp.substring(0, temp.indexOf('.txt')));
});

setTimeout(function() {
setTimeout(function () {
var hash = $(location).attr('hash');
loadFile(hash ? hash.substring(1) + '.txt' : 'instructions.txt')
}, 100);
loadFile(hash ? hash.substring(1) + '.txt' : 'instructions.txt');
}, 100);

});

Expand Down Expand Up @@ -102,7 +105,7 @@ function processText(str) {
.replaceAll('[xynlogo]', '<img src = ./img/xynlogo.png>')

.replaceAll('[editorbr]', '')
)
);

return str;
}
Expand Down Expand Up @@ -140,7 +143,7 @@ function download(filename, text) {

document.body.removeChild(element);

alert('Document saved as ' + filename)
alert('Document saved as ' + filename);
}

function loadFile(filename) {
Expand Down

0 comments on commit 8655916

Please sign in to comment.