change from literate to straight coffeescript

- was getting lots of linting errors due to tabulation
 - probably better this way, though I still like literate's concept
 - all seems to work but need to triple check everything
This commit is contained in:
Iam Naughton Phier 2015-03-27 14:40:28 +02:00
parent 4bcfeb755c
commit aeb76cefc0
2 changed files with 572 additions and 19 deletions

View file

@ -1,11 +1,57 @@
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.9.0
/*
Sahli Editor
============
Editor for Sahli files.
- open existing file
- create new item
* get filename from dir
* insert SAUCE data if available
* use SAUCE data to find font
* allow Amiga choices
* colorpicker
- edit existing item
- remove item
- clear whole file
- copy/clone
- move items around
- sort items
- output to screen (copy into file)
* run from node - save filename dialog
***
It should be noted that this does not do bounds checking, and it would be very
possible to overflow this by using a debugger and such. As the purpose of this
is limited, and this should NOT be put on a live website, I feel that is ok for
now. Perhaps I will fix it after Revision.
***
== Create Initial crappage
We need to make a screen that has a few things in it for starters
Title, load existing, and new file options.
Silliness for checking that this works.
*/
(function() {
var Sahli, ansiorascii, arraytocolor, booltoint, colorindex, colortoarray, colortoname, dec2hex, dumpjson, emptyfiledef, getfilelist, hex2dec, inttobool, loadsahli, newsahli, resolvefiletype, sahlicolor, statustobool;
var Emptyfiledef, Sahli, ansiorascii, arraytocolor, booltoint, colorindex, colortoarray, colortoname, dec2hex, dumpjson, getfilelist, hex2dec, inttobool, loadsahli, newsahli, resolvefiletype, sahlicolor, statustobool;
$(function() {
return $("h1").hide().slideDown(500);
});
/*
Create buttons to choose between the New and Load functionalities
(As we aren't going to ever load a file _and_ do a new file.)
(If someone wants to do that, they can restart with F5 or something.)
Also hide the editor until needed, and initialize some elements.
*/
$(function() {
return $("#newsahli").button({
disabled: false
@ -46,11 +92,9 @@
$(".groupbox p").css({
margin: "0 0 .25em 0"
});
$(".colorbox").change((function(_this) {
return function() {
return sahlicolor();
};
})(this));
$(".colorbox").change(function() {
return sahlicolor();
});
$("#entryfilepick").change(function() {
if (this.files[0] != null) {
return $("#entryfile").val(this.files[0].name);
@ -61,8 +105,22 @@
});
});
emptyfiledef = (function() {
function emptyfiledef() {
/*
The sahli file definition format is as follows:
"file" - the actual filename on disk, "name" - the title of the piece,
the boolean 'amiga' indicates if it is ansi or ascii (True = ascii),
width is the width (widest point of the file), author the author of the piece,
the color and bg items define the color for amiga ascii, and the font
defines the font similarly. For PC ansi, this should be 'ansifont.'
The three remaining lines are informational and optional.
The slide format is currently unused, but consists of a background picture,
a html template, and a css file.
*/
Emptyfiledef = (function() {
function Emptyfiledef() {
this.file = "";
this.name = "";
this.amiga = true;
@ -77,13 +135,13 @@
this.text = "";
}
return emptyfiledef;
return Emptyfiledef;
})();
Sahli = (function() {
function Sahli() {
this.emptyfiledef = new emptyfiledef;
this.emptyfiledef = new Emptyfiledef;
this.emptyslidesdef = {
"background": "",
"template": "",
@ -141,7 +199,7 @@
}).click((function(_this) {
return function(event) {
var newentry;
newentry = new emptyfiledef;
newentry = new Emptyfiledef;
_this.data.filedata.push(newentry);
return _this.buildlist(_this.data);
};
@ -186,22 +244,27 @@
},
stop: (function(_this) {
return function(event, ui) {
var e, name, s, _k, _len2, _ref2;
var a, e, name, s, _k, _len2, _ref2;
a = 2;
s = ui.item.data().startpos;
e = ui.item.index();
_this.data.filedata = _this.rearrangearray(s, e, _this.data.filedata);
_this.buildlist(_this.data);
_ref2 = _this.data.filedata;
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
name = _ref2[_k];
console.log(name.author, name.name, name.file);
}
console.log('---');
return _this.buildlist(_this.data);
return console.log('---');
};
})(this)
});
};
Sahli.prototype.harry = function(potter) {
return console.log("yer a lizzard, harry");
};
Sahli.prototype.rearrangearray = function(startpos, endpos, a) {
var alen, moving, tarr;
moving = a[startpos];
@ -221,7 +284,7 @@
};
Sahli.prototype.genentryline = function(item, pos) {
var amigastatus, arrows, delbutton, entry;
var amigastatus, arrows, delbutton, entry, whichone;
arrows = "<span class='ui-icon ui-icon-arrowthick-2-n-s'></span>";
amigastatus = ansiorascii(booltoint(item.amiga));
delbutton = $("<span class='righty' id=del-" + pos + ">delete</span>").click((function(_this) {
@ -231,7 +294,9 @@
return _this.buildlist(_this.data);
};
})(this));
entry = $("<li class='entry' id='" + item.file + "'>" + arrows + amigastatus + " | " + item.author + " : " + item.name + " : " + item.file + "</li>");
whichone = "<li class='entry' id='" + item.file + "'>" + arrows + amigastatus + " |";
whichone += " " + item.author + " : " + item.name + " : " + item.file + "</li>";
entry = $(whichone);
return entry.append(delbutton);
};
@ -242,7 +307,8 @@
entry.name = $("#entryname").val();
entry.author = $("#entryauthor").val();
entry.amiga = statustobool($("#entryamiga").children()[1].textContent);
console.log($("#entryamiga").children()[1].textContent, entry.amiga, entry.author);
console.log($("#entryamiga").children()[1].textContent);
console.log(entry.amiga, entry.author);
entry.color = colortoarray($("#entrycolor").val());
entry.bg = colortoarray($("#entrybg").val());
entry.width = $("#entrywidth").val();
@ -311,10 +377,20 @@
})();
/*
A Helper function to dump json out of an object as text:
*/
dumpjson = function(obj) {
return JSON.stringify(obj, null, "\t");
};
/*
Boolean / integer Helpers
*/
booltoint = function(bool) {
return bool + 1 - 1;
};
@ -331,6 +407,11 @@
}
};
/*
Resolve filetype offset in array:
*/
resolvefiletype = function(filetype) {
var options;
options = {
@ -348,6 +429,11 @@
return options[filetype];
};
/*
Resolve ansi or ascii status
*/
ansiorascii = function(status) {
if (status === 0) {
return "Ansi";
@ -356,6 +442,14 @@
}
};
/*
Color conversion from array to color item:
This decimal to hex conversion only handles 00-FF but it's fine for this
purpose; we actually _want_ that limitation in the output.
*/
dec2hex = function(num) {
return "" + (('000' + num.toString(16)).slice(-2));
};
@ -395,6 +489,11 @@
return x;
};
/*
Need a way to convert the array back to the color name.
*/
colortoname = function(color) {
var bw, colorname, names, ret;
names = {
@ -421,6 +520,11 @@
return ret = colorname != null ? colorname : bw;
};
/*
Similarly, need to be able to get the color index.
*/
colorindex = function(colorname) {
var names;
names = {
@ -444,6 +548,12 @@
return names[colorname];
};
/*
A function for changing the fore and background colors of the sahli ascii
example
*/
sahlicolor = function() {
var bg, fg;
fg = $('#entrycolor').val();
@ -455,6 +565,12 @@
});
};
/*
Function for loading the filelist from the specified directory on the
server/filesystem.
*/
getfilelist = function() {
var location;
location = $("#dirlocation").val();
@ -463,15 +579,26 @@
});
};
/*
When clicking 'New' we want to make a brand new Sahli, and then clear out
the buttons and create the editor bit as blank.
*/
newsahli = function() {
var newentry, sahli;
sahli = new Sahli;
sahli.data = sahli.empty;
newentry = new emptyfiledef;
newentry = new Emptyfiledef;
sahli.data.filedata.push(newentry);
return sahli.edit();
};
/*
And when clicking 'load' we want to load the existing sahli file.
*/
loadsahli = function() {
var sahli;
sahli = new Sahli;