// Generated by CoffeeScript 1.7.1 (function() { var Sahli, ansiorascii, arraytocolor, booltoint, colorindex, colortoarray, colortoname, dec2hex, dumpjson, hex2dec, inttobool, loadsahli, newsahli, resolvefiletype, 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, "filetype": 'plain', "width": "", "author": "", "font": "Propaz", "color": [0, 0, 0, 0], "bg": [0, 0, 0, 0], "line1": "", "line2": "", "text": "" }; this.emptyslidesdef = { "background": "", "template": "", "css": "" }; this.empty = { "location": "", "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(); $('#dirlocation').change((function(_this) { return function(event) { return _this.data.location = event.target.value; }; })(this)); $('#listsave').button({ icons: { primary: "ui-icon-disk" } }).click((function(_this) { return function() { $('#sahlioutput').text(dumpjson(_this.data)); $('#dumparea').show(100); return console.log(dumpjson(_this.data)); }; })(this)); $('#listlist').button({ icons: { primary: "ui-icon-folder-open" } }).click((function(_this) { return function() { return alert('clicked'); }; })(this)); $('#listinsert').button({ icons: { primary: "ui-icon-1-n" } }).click((function(_this) { return function() { return alert('clicked'); }; })(this)); $('#listdisplay').button({ icons: { primary: "ui-icon-refresh" } }).click((function(_this) { return function() { return _this.buildlist(_this.data); }; })(this)); $('#closespan').click(function() { $(this.parentElement.parentElement).hide(); return $('#sahlioutput').text(''); }); return this.buildlist(this.data); }; Sahli.prototype.buildlist = function(data) { var i, item, x, _i, _j, _len, _len1, _ref, _ref1; $('#list').show(100); $('#list ol li').remove(); _ref = this.data.filedata; for (_i = 0, _len = _ref.length; _i < _len; _i++) { i = _ref[_i]; console.log(i.author); } x = 0; $('#dirlocation').val(this.data.location); _ref1 = this.data.filedata; for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { item = _ref1[_j]; $('#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, _k, _len2, _ref2; s = ui.item.data().startpos; e = ui.item.index(); _this.data.filedata = _this.rearrangearray(s, e, _this.data.filedata); _ref2 = _this.data.filedata; for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { name = _ref2[_k]; 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 = event.currentTarget.id.replace("del-", ""); _this.data.filedata.splice(pos, 1); return _this.buildlist(_this.data); }; })(this)); entry = $("