diff --git a/editor/sahliedit.js b/editor/sahliedit.js new file mode 100644 index 0000000..ed3498a --- /dev/null +++ b/editor/sahliedit.js @@ -0,0 +1,348 @@ +// Generated by CoffeeScript 1.7.1 +(function() { + var Sahli, ansiorascii, arraytocolor, booltoint, colortoarray, colortoname, dec2hex, dumpjson, hex2dec, inttobool, loadsahli, newsahli, statustobool; + + $(function() { + return $("h1").hide().slideDown(500); + }); + + $(function() { + return $("#newsahli").button({ + disabled: false + }).click(function() { + return newsahli(); + }); + }); + + $(function() { + return $("#loadsahli").button({ + disabled: false + }).click(function() { + return loadsahli(); + }); + }); + + $(function() { + $(".hidden").hide(); + $("#entryamiga").button({ + icons: { + primary: "ui-icon-gear" + } + }).click(function() { + var stuff; + stuff = $(this).children(); + if (this.value === "1") { + stuff[1].textContent = 'Ansi'; + return this.value = "0"; + } else { + stuff[1].textContent = 'Ascii'; + return this.value = "1"; + } + }); + $(".45box").css({ + width: '45%', + display: 'inline-block' + }); + $(".groupbox p").css({ + margin: "0 0 .25em 0" + }); + $("#entryfilepick").change(function() { + if (this.files[0] != null) { + return $("#entryfile").val(this.files[0].name); + } + }); + return $("#entryfile").click(function() { + return $("#entryfilepick").click(); + }); + }); + + Sahli = (function() { + function Sahli() { + this.emptyfiledef = { + "file": "", + "name": "", + "amiga": true, + "width": "", + "author": "", + "font": "Propaz", + "color": [0, 0, 0, 0], + "bg": [0, 0, 0, 0], + "line1": "", + "line2": "", + "text": "" + }; + this.emptyslidesdef = { + "background": "", + "template": "", + "css": "" + }; + this.empty = { + "slides": this.emptyslidesdef, + "filedata": [] + }; + } + + Sahli.prototype.loader = function() { + return $.ajax({ + url: '../list.sahli', + dataType: "json", + success: (function(_this) { + return function(result) { + _this.data = result; + return _this.edit(); + }; + })(this) + }); + }; + + Sahli.prototype.edit = function() { + $('#buttonbox').hide(); + $('#listsave').button({ + icons: { + primary: "ui-icon-disk" + } + }).click((function(_this) { + return function() { + return console.log(dumpjson(_this.data)); + }; + })(this)); + return this.buildlist(this.data); + }; + + Sahli.prototype.buildlist = function(data) { + var item, x, _i, _len, _ref; + $('#list').show(100); + x = 0; + _ref = this.data.filedata; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + item = _ref[_i]; + $('#sortlist').append(this.additem(item, x++)); + } + return $('#sortlist').sortable({ + start: function(event, ui) { + return ui.item.data({ + startpos: ui.item.index() + }); + }, + stop: (function(_this) { + return function(event, ui) { + var e, name, s, _j, _len1, _ref1; + s = ui.item.data().startpos; + e = ui.item.index(); + _this.data.filedata = _this.rearrangearray(s, e, _this.data.filedata); + _ref1 = _this.data.filedata; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + name = _ref1[_j]; + console.log(name.author); + } + return console.log('---'); + }; + })(this) + }); + }; + + Sahli.prototype.rearrangearray = function(startpos, endpos, a) { + var alen, moving, tarr; + moving = a[startpos]; + alen = a.length; + tarr = a.slice(0, startpos).concat(a.slice(startpos + 1)); + return tarr.slice(0, endpos).concat([moving].concat(tarr.slice(endpos))); + }; + + Sahli.prototype.additem = function(item, pos) { + var entry; + entry = this.genentryline(item, pos); + return entry.dblclick((function(_this) { + return function() { + return _this.editline(item, pos); + }; + })(this)); + }; + + Sahli.prototype.genentryline = function(item, pos) { + var amigastatus, arrows, delbutton, entry; + arrows = ""; + amigastatus = ansiorascii(booltoint(item.amiga)); + delbutton = $("delete").click((function(_this) { + return function(event) { + pos = this.id.replace("del-", ""); + console.log(_this.data.filedata.splice(pos, 1)); + return this.parentNode.remove(); + }; + })(this)); + entry = $("