2014-04-05 16:16:30 +03:00
|
|
|
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
|
2014-04-06 15:08:32 +03:00
|
|
|
- remove item
|
|
|
|
|
- clear whole file
|
2014-04-05 16:16:30 +03:00
|
|
|
- copy/clone
|
|
|
|
|
- move items around
|
2014-04-06 15:08:32 +03:00
|
|
|
- sort items
|
2014-04-05 16:16:30 +03:00
|
|
|
- output to screen (copy into file)
|
|
|
|
|
* run from node - save filename dialog
|
|
|
|
|
|
|
|
|
|
== 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.
|
2014-04-14 20:09:27 +03:00
|
|
|
|
2014-04-05 16:16:30 +03:00
|
|
|
$(-> $("h1").hide().slideDown(500))
|
|
|
|
|
|
2014-04-15 15:49:09 +03:00
|
|
|
Create buttos to choose between the New and Load functionalities
|
2014-04-06 15:08:32 +03:00
|
|
|
(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.)
|
2014-04-15 15:49:09 +03:00
|
|
|
Also hide the editor until needed, and initialize some elements.
|
2014-04-06 15:08:32 +03:00
|
|
|
|
2014-04-14 13:47:01 +03:00
|
|
|
$(->
|
|
|
|
|
$("#newsahli")
|
|
|
|
|
.button { disabled: false}
|
2014-04-15 15:49:09 +03:00
|
|
|
.click -> newsahli()
|
|
|
|
|
)
|
2014-04-14 13:47:01 +03:00
|
|
|
|
|
|
|
|
$(->
|
|
|
|
|
$("#loadsahli")
|
|
|
|
|
.button { disabled: false}
|
2014-04-15 16:23:32 +03:00
|
|
|
.click -> loadsahli()
|
2014-04-14 13:47:01 +03:00
|
|
|
)
|
2014-04-14 20:09:27 +03:00
|
|
|
$(->
|
|
|
|
|
$(".hidden").hide()
|
2014-04-15 14:07:52 +03:00
|
|
|
$("#amiga").button {icons: {primary:"ui-icon-gear"}}
|
|
|
|
|
.click ->
|
|
|
|
|
stuff = $(@).children()
|
|
|
|
|
if @.value == "1"
|
|
|
|
|
stuff[1].textContent = 'Ansi'
|
|
|
|
|
@.value = "0"
|
|
|
|
|
else
|
|
|
|
|
stuff[1].textContent = 'Ascii'
|
|
|
|
|
@.value = "1"
|
2014-04-14 20:09:27 +03:00
|
|
|
$(".45box").css {width:'45%',float:'left'}
|
2014-04-15 14:07:52 +03:00
|
|
|
)
|
2014-04-06 15:08:32 +03:00
|
|
|
|
2014-04-14 13:47:01 +03:00
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
class Sahli
|
2014-04-14 14:25:37 +03:00
|
|
|
constructor: ->
|
2014-04-15 15:49:09 +03:00
|
|
|
@emptyfiledef = {
|
2014-04-14 14:25:37 +03:00
|
|
|
"file": "",
|
|
|
|
|
"name": "",
|
|
|
|
|
"amiga": true,
|
|
|
|
|
"width": "",
|
|
|
|
|
"author": "",
|
|
|
|
|
"font": "Propaz",
|
|
|
|
|
"color": [ 0,0,0,0 ],
|
|
|
|
|
"bg": [ 0,0,0,0 ],
|
|
|
|
|
"line1": "",
|
|
|
|
|
"line2": "",
|
|
|
|
|
"text": ""
|
|
|
|
|
}
|
2014-04-15 15:49:09 +03:00
|
|
|
@emptyslidesdef = {
|
2014-04-14 14:25:37 +03:00
|
|
|
"background": "",
|
|
|
|
|
"template": "",
|
|
|
|
|
"css": ""
|
|
|
|
|
}
|
2014-04-15 15:49:09 +03:00
|
|
|
@empty = {
|
|
|
|
|
"slides": @emptyslidesdef,
|
2014-04-15 16:23:32 +03:00
|
|
|
"filedata": [ ]
|
2014-04-14 14:25:37 +03:00
|
|
|
}
|
2014-04-14 13:47:01 +03:00
|
|
|
|
2014-04-14 20:09:27 +03:00
|
|
|
loader: ->
|
2014-04-15 16:23:32 +03:00
|
|
|
$.ajax {
|
|
|
|
|
url: '../list.sahli',
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: (result) =>
|
|
|
|
|
@data = result
|
|
|
|
|
@.edit()
|
|
|
|
|
}
|
2014-04-14 20:09:27 +03:00
|
|
|
|
2014-04-15 15:49:09 +03:00
|
|
|
Editor functionality:
|
|
|
|
|
Close the new/load buttons - unneeded now.
|
|
|
|
|
list, and allow dragon-droppings for sorting. Doubleclick to edit, or use
|
|
|
|
|
edit button.
|
|
|
|
|
|
|
|
|
|
edit: ->
|
|
|
|
|
$('#buttonbox').hide()
|
|
|
|
|
@buildlist @data
|
|
|
|
|
|
|
|
|
|
buildlist: (data) ->
|
|
|
|
|
$('#list').show 100
|
2014-04-15 16:23:32 +03:00
|
|
|
@.additem item for item in @data.filedata
|
2014-04-15 15:49:09 +03:00
|
|
|
|
|
|
|
|
additem: (item) ->
|
|
|
|
|
alert dumpjson item
|
|
|
|
|
|
|
|
|
|
editline: (data) ->
|
|
|
|
|
$("#formica").dialog {
|
|
|
|
|
width:'800',
|
|
|
|
|
modal: false,
|
|
|
|
|
title:'Line Item', buttons: [{
|
|
|
|
|
text: "OK",
|
|
|
|
|
click: ->
|
|
|
|
|
$(@).dialog "close"
|
|
|
|
|
}]
|
|
|
|
|
}
|
2014-04-14 20:09:27 +03:00
|
|
|
|
|
|
|
|
A Helper function to dump json out of an object as text:
|
|
|
|
|
|
2014-04-14 13:47:01 +03:00
|
|
|
dumpjson = (obj) ->
|
|
|
|
|
JSON.stringify(obj)
|
|
|
|
|
|
2014-04-14 20:09:27 +03:00
|
|
|
When clicking 'New' we want to make a brand new Sahli, and then clear out
|
|
|
|
|
the buttons and create the editor bit as blank.
|
|
|
|
|
|
2014-04-14 13:47:01 +03:00
|
|
|
newsahli = ->
|
|
|
|
|
sahli = new Sahli
|
2014-04-15 15:49:09 +03:00
|
|
|
sahli.data = sahli.empty
|
2014-04-15 16:23:32 +03:00
|
|
|
sahli.data.filedata.push sahli.emptyfiledef
|
2014-04-15 15:49:09 +03:00
|
|
|
sahli.edit()
|
2014-04-14 20:09:27 +03:00
|
|
|
|
2014-04-15 15:49:09 +03:00
|
|
|
And when clicking 'load' we want to load the existing sahli file.
|
2014-04-14 14:25:37 +03:00
|
|
|
|
2014-04-15 15:49:09 +03:00
|
|
|
loadsahli = ->
|
|
|
|
|
sahli = new Sahli
|
2014-04-15 16:23:32 +03:00
|
|
|
sahli.loader 'list.sahli'
|