4 <title>MaePadWeb
</title>
5 <script type=
"text/javascript" src=
"/jquery.js"></script>
6 <script type=
"text/javascript">
8 var selectedChecklistItem
= null;
9 var selectedChecklistIndex
= null;
10 var activeChecklistNodeId
= null;
12 function switchTo(selector
) {
13 var items
= Array("#nodelist", "#checklist", "#sketch", "#richtext");
14 for (i
=0; i
<items
.length
; i
++) {
15 if (items
[i
] != selector
) {
21 if (selector
!= "#nodelist") {
22 $("#backlink").css('visibility', 'visible');
24 $("#backlink").css('visibility', 'hidden');
25 $('#checklistToolbar').hide();
29 var nodeTypes
= new Array("UNKNOWN", "Text", "Sketch", "Checklist");
30 $(document
).ready(function() {
31 switchTo('#nodelist');
32 $.getJSON('/nodelist.json', function(data
) {
33 var current
= $('#nodelist_ul');
35 $.each(data
, function() {
36 current
.append('<li><a onclick="setNodeTitle(\''+this[1]+'\');open'+nodeTypes
[this[2]]+'('+this[0]+')"><span style="font-weight: bold;">'+this[1]+'</span><small style="color: #aaa;"><br>'+nodeTypes
[this[2]]+'</small></a></li>');
41 function openText(nodeid
) {
42 switchTo('#richtext');
43 $.get('/richtext.html?id='+nodeid
, function(data
) {
44 $('#richtext').html(data
);
48 function openSketch(nodeid
) {
50 $('#sketch_img').attr('src', '/sketch.png?id='+nodeid
);
53 function trueComesBack(data
) {
55 alert('A request to the web server failed.');
59 function setNodeTitle(title
) {
60 $('#nodetitle').html(title
);
63 function editChecklistItem(index
, item
) {
64 if (selectedChecklistItem
!= null) {
65 $(selectedChecklistItem
).removeClass('selectedChecklistItem');
67 selectedChecklistItem
= item
;
68 selectedChecklistIndex
= index
;
69 if (index
!= null && item
!= null) {
70 updateChecklistToolbar();
71 $(item
).addClass('selectedChecklistItem');
75 function checklistAddNew() {
76 var newItemText
= prompt('Enter text for new item:', '');
77 if (newItemText
!= null && newItemText
!= '') {
78 $.getJSON('/checklist.addItem?id='+activeChecklistNodeId
+'&text='+escape(newItemText
), function(data
) {
80 /* Reload checklist */
81 openChecklist(activeChecklistNodeId
);
83 alert('Could not save checklist item');
89 function checklistDelete() {
90 if (!confirm('Really delete this item?')) {
93 $.getJSON('/checklist.deleteItem?id='+selectedChecklistIndex
, function(data
) {
95 /* Reload checklist */
96 openChecklist(activeChecklistNodeId
);
98 alert('Could not save checklist item');
103 function checklistToggleBold() {
104 var item
= $(selectedChecklistItem
);
105 var span
= item
.find('span').first();
106 var isBold
= (span
.css('font-weight') == 'bold');
108 span
.css('font-weight', 'normal');
110 span
.css('font-weight', 'bold');
112 $.getJSON('/checklist.setBold?id='+selectedChecklistIndex
+'&bold='+(!isBold
), trueComesBack
);
113 updateChecklistToolbar();
116 function checklistToggleStrike() {
117 var item
= $(selectedChecklistItem
);
118 var span
= item
.find('span').first();
119 var isStrike
= (span
.css('text-decoration') == 'line-through');
121 span
.css('text-decoration', 'none');
123 span
.css('text-decoration', 'line-through');
125 $.getJSON('/checklist.setStrike?id='+selectedChecklistIndex
+'&strike='+(!isStrike
), trueComesBack
);
126 updateChecklistToolbar();
129 function checklistToggleCheck() {
130 var item
= $(selectedChecklistItem
);
131 var checkbox
= item
.find('img').first();
132 checkbox
.toggleClass('checked');
133 if (checkbox
.hasClass('checked')) {
134 checkbox
.attr('src', '/icons/widgets_tickmark_list');
136 checkbox
.attr('src', '/nix.gif');
138 $.getJSON('/checklist.setCheck?id='+selectedChecklistIndex
+'&check='+checkbox
.hasClass('checked'), trueComesBack
);
139 updateChecklistToolbar();
142 function checklistEditText() {
143 var item
= $(selectedChecklistItem
);
144 var span
= item
.find('span').first();
145 newValue
= prompt('Edit this node:', span
.html());
146 if (newValue
== null) {
148 } else if (newValue
== '') {
153 $.getJSON('/checklist.setText?id='+selectedChecklistIndex
+'&text='+escape(newValue
), trueComesBack
);
157 function updateChecklistToolbar()
159 var item
= $(selectedChecklistItem
);
160 var span
= item
.find('span').first();
161 var checkbox
= item
.find('img').first();
162 var isBold
= (span
.css('font-weight') == 'bold');
163 var isStrike
= (span
.css('text-decoration') == 'line-through');
164 var isChecked
= checkbox
.hasClass('checked');
166 $('#checklistToolbar #boldButton').addClass('selected');
168 $('#checklistToolbar #boldButton').removeClass('selected');
171 $('#checklistToolbar #strikeButton').addClass('selected');
173 $('#checklistToolbar #strikeButton').removeClass('selected');
176 $('#checklistToolbar #checkButton').addClass('selected');
178 $('#checklistToolbar #checkButton').removeClass('selected');
182 function openChecklist(nodeid
) {
183 activeChecklistNodeId
= nodeid
;
184 $('#checklistToolbar').fadeIn();
186 switchTo('#checklist');
187 $('#checklist_ul').html('');
188 $.getJSON('/checklist.json?id='+nodeid
, function(data
) {
189 var current
= $('#checklist_ul');
190 $.each(data
, function() {
196 if (color
!= '000000') {
197 spanStyle
+= 'color: #'+color
+';';
200 spanStyle
+= 'text-decoration:line-through;';
203 spanStyle
+= 'font-weight:bold;';
205 current
.append('<li><a ondblclick="checklistEditText();" onclick="editChecklistItem('+index
+', this)"><img class="checklistBox '+((style
&(1<<0))?"checked":"")+'" src="'+((style
&(1<<0))?"/icons/widgets_tickmark_list":"/nix.gif")+'" onclick="editChecklistItem('+index
+', $(this).parent());checklistToggleCheck();"><span style="'+spanStyle
+'">'+name
+'</span></a></li>');
211 <style type=
"text/css">
214 background-color: black
;
216 font-family: sans-serif
;
225 vertical-align: middle
;
227 background-image: url
(/theme/title_bg);
230 border-bottom: 1px solid black
;
235 #nodelist ul
, #checklist ul
{
240 #nodelist li
, #checklist li
{
241 background-color: #000;
245 #nodelist li:nth-child
(2n+1), #checklist
li:nth-child
(2n+1) {
246 background-color: #080808;
252 text-decoration: none
;
253 text-shadow: 0px 0px 3px black
;
259 text-decoration: none
;
260 text-shadow: 0px 0px 3px black
;
262 #checklist li a
.selectedChecklistItem
{
263 background-image: url
(/theme/toolbar_hi);
264 background-color: #666; /* FIXME: take from theme */
269 text-decoration: none
;
274 padding-bottom: 40px;
278 vertical-align: middle
;
285 #checklistToolbar img
{
296 background-image: url
(/theme/toolbar_bg);
297 background-color: black
;
300 #checklistToolbar .selected
{
301 background-image: url
(/theme/toolbar_hi);
302 background-color: #666; /* FIXME: take from theme */
305 #checklistToolbar a
{
315 <h1 id=
"x"><img src=
"/logo.png" style=
"vertical-align: middle; border-right: 1px solid black; padding: 14px;" alt=
"MaePadWeb"> <span style=
"font-weight: normal; padding: 4px; font-size: 20px;" id=
"nodetitle"></span>
316 <span id=
"backlink" style=
"float: right;">
317 <a onclick=
"setNodeTitle('');switchTo('#nodelist')"><img src=
"/theme/title_btn" alt=
"back" style=
"border-left: 1px solid black;"></a>
319 </h1><div style=
"padding-top: 56px; padding-bottom: 30px;">
321 <ul id=
"nodelist_ul"></ul>
324 <ul id=
"checklist_ul"></ul>
327 <img id=
"sketch_img" style=
"border: 1px solid black;">
329 <p id=
"richtext" style=
"border: 1px solid black; background-color: white;"></p>
331 <div id=
"checklistToolbar">
332 <a id=
"checkButton" onclick=
"checklistToggleCheck();"><img src=
"/icons/widgets_tickmark_list" alt=
"CHECK" title=
""></a>
333 <a id=
"boldButton" onclick=
"checklistToggleBold();"><img src=
"/icons/general_bold" alt=
"BOLD" title=
""></a>
334 <a id=
"strikeButton" onclick=
"checklistToggleStrike();"><img src=
"/icons/strike" alt=
"STRIKE" title=
""></a>
335 <a id=
"colorButton" onclick=
"alert('Not yet implemented.');"><img src=
"/icons/palette" alt=
"COLOR" title=
""></a>
336 <a style=
"border-left: 1px solid white; margin: 10px; padding: 0px; height: 32px;"></a>
337 <a id=
"addButton" onclick=
"checklistAddNew();"><img src=
"/icons/general_add" alt=
"ADD" title=
""></a>
338 <a id=
"editButton" onclick=
"checklistEditText();"><img src=
"/icons/sketch" alt=
"EDIT" title=
""></a>
339 <a id=
"deleteButton" onclick=
"checklistDelete();"><img src=
"/icons/general_delete" alt=
"DEL" title=
""></a>