diff options
Diffstat (limited to 'sca-cpp/trunk/modules/edit/htdocs')
-rw-r--r-- | sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html | 43 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/edit/htdocs/graph/graph.html | 4 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/edit/htdocs/page/page.html | 62 |
3 files changed, 84 insertions, 25 deletions
diff --git a/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html b/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html index b45c0ffe24..71f9c61c41 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html +++ b/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html @@ -33,22 +33,25 @@ <form id="appsForm"> <div id="apps"></div> <br/> -><a href="" id="addAppLink">Add</a> <a href="" id="deleteAppLink">Delete</a> +<input type="button" id="createAppButton" value="Create App"/> </form> <div id="newApp" style="visibility: hidden;"> <form id="newAppForm"> <table width="100%"> -<tr><th>Add a New App</th></tr> -<tr><td>Add a new App to your dashboard.</td></tr> +<tr><th>Create an App</th></tr> +<tr><td></td></tr> </table> <br> <table width="100%"> -<tr><td>App name:</td><td><input type="text" id="appName" size="10"/></td></tr> -<tr><td>Title:</td><td><input type="text" id="appTitle" size="20"/></td></tr> +<tr><td><b>App Name:</b></td></tr> +<tr><td><input type="text" id="appName" size="10"/></td></tr> +<tr><tr><td><b>App Title:</b></td></tr> +<tr><td><input type="text" id="appTitle" size="20"/></td></tr> </table> -<input id="addAppButton" type="button" value="Add"/> +<input id="createAppOKButton" type="button" style="font-weight: bold;" value="Create"/> +<input id="createAppCancelButton" type="button" value="Cancel"/> </form> </div> @@ -100,31 +103,46 @@ function getapps(sync) { } /** - * Toggle new app form link event. + * Display create app form. */ -$('addAppLink').onclick = function() { +$('createAppButton').onclick = function() { var div = $('newApp'); - div.style.visibility = div.style.visibility == 'hidden'? 'visible' : 'hidden'; + div.style.visibility = 'visible'; $('appName').focus(); return false; }; /** - * Add a new app button event. + * Create an app. */ -$('addAppButton').onclick = function() { +$('createAppOKButton').onclick = function() { var name = $('appName').value; var title = $('appTitle').value; var app = mklist(title, name, mklist()); var entry = atom.writeATOMEntry(app); dashboard.put(name, car(entry)); + $('appName').value = ''; + $('appTitle').title = ''; getapps(); + div.style.visibility = 'visible'; return false; }; /** - * Delete apps event. + * Cancel creating an app. */ +$('createAppCancelButton').onclick = function() { + var div = $('newApp'); + div.style.visibility = 'hidden'; + $('appName').value = ''; + $('appTitle').title = ''; + return false; +}; + +/** + * Delete an app. + */ +/* $('deleteAppLink').onclick = function() { var apps = $('appsForm').apps; if (isNil(apps)) @@ -140,6 +158,7 @@ $('deleteAppLink').onclick = function() { getapps(); return false; }; +*/ // Get and display the list of apps getapps(true); diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html index fd9ae694a7..5eb8c6cc1e 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html +++ b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html @@ -31,7 +31,7 @@ <body> <table style="position: absolute; top: 0px; left: 0px;" width="100%"> -<tr><th style="width: 338px;">Palette</th><th>App</th></tr> +<tr><th style="width: 338px;">Palette</th><th style="padding-top: 0px; padding-bottom: 0px;"><span>App</span><span style="position: absolute; top: 2px; right: 8px;"><input type="button" id="saveButton" style="font-weight: bold;" Value="Save"/></span></th></tr> </table> <script type="text/javascript"> @@ -40,7 +40,7 @@ var palettes = sca.reference(editWidget, "palettes"); var apps = sca.reference(editWidget, "apps"); // Setup remote log -rconsole = sca.defun(sca.reference(editWidget, "log"), "log"); +//rconsole = sca.defun(sca.reference(editWidget, "log"), "log"); /** * Return the current app name. diff --git a/sca-cpp/trunk/modules/edit/htdocs/page/page.html b/sca-cpp/trunk/modules/edit/htdocs/page/page.html index 0e0441b4c0..e2cd50088e 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/page/page.html +++ b/sca-cpp/trunk/modules/edit/htdocs/page/page.html @@ -31,7 +31,7 @@ <body> <table style="position: absolute; top: 0px; left: 0px;" width="100%"> -<tr><th style="width: 338px;">Palette</th><th>Page</th></tr> +<tr><th style="width: 338px;">Palette</th><th style="padding-top: 0px; padding-bottom: 0px;"><span>Page</span><span style="position: absolute; top: 2px; right: 8px;"><input type="button" id="saveButton" style="font-weight: bold;" Value="Save"/></span></th></tr> </table> <div id="page" style="position: absolute; top: 60px; left: 0px; width: 5000px; height: 5000px;"> @@ -41,9 +41,9 @@ <span id="palette:button" style="position: absolute; left: 0px; top: 80px;"><input type="button" value="button"/></span> <span id="palette:entry" style="position: absolute; left: 0px; top: 120px;"><input type="text" value="field" size="5"/></span> <span id="palette:password" style="position: absolute; left: 0px; top: 160px;"><input type="password" value="password" size="5"/></span> -<span id="palette:checkbox" style="position: absolute; left: 0px; top: 200px;"><input type="checkbox" value="checkbox"/>checkbox</span> +<span id="palette:checkbox" style="position: absolute; left: 0px; top: 200px;"><input type="checkbox" value="checkbox"></input><span>checkbox</span></span> <span id="palette:select" style="position: absolute; left: 0px; top: 240px;"><select><option value="list">list</option></select></span> -<span id="palette:link" style="position: absolute; left: 0px; top: 280px;"><a href="">link</a></span> +<span id="palette:link" style="position: absolute; left: 0px; top: 280px;"><a href="/"><span>link</span></a></span> <span id="palette:text" style="position: absolute; left: 0px; top: 320px;"><span>text</span></span> <span id="palette:img" style="position: absolute; left: 0px; top: 360px;"><img/></span> @@ -75,32 +75,72 @@ function atompage(doc) { /** * Get and display an app page. */ -function getpage(name, e) { +function getpage(name, edit) { if (isNil(name)) return; pages.get(name, function(doc) { - // Convert the page to XML - var x = writeStrings(writeXML(atompage(doc), false)); + // Convert the page to XHTML + var xhtml = writeStrings(writeXML(atompage(doc), false)); // Prepare page DOM in hidden buffer var buffer = $('buffer'); - buffer.innerHTML = x; + buffer.innerHTML = xhtml; // Append page nodes to editor map(function(e) { e.style.left = ui.posn(e.style.left) + 350; - pageedit.appendChild(e); + edit.appendChild(e); return page.cover(e); }, nodeList(buffer.childNodes[0].childNodes)); }); } +/** + * Save the current edited page. + */ +$('saveButton').onclick = function(e) { + // Copy page DOM to hidden buffer + var edit = $('page'); + var buffer = $('buffer'); + buffer.innerHTML = '<div id="page"></div>' + var div = buffer.childNodes[0]; + div.innerHTML = edit.innerHTML; + + // Remove nodes from palette and editor artifacts, which are + // not part of the page, as well as nodes positioned out of + // the editing area + map(function(e) { + if (isNil(e.id) || e.id == '' || e.id.substr(0, 8) == 'palette:') { + div.removeChild(e); + return e; + } + var x = ui.posn(e.style.left) - 350; + if (x < 0 || ui.posn(e.style.top) < 0) { + div.removeChild(e); + return e; + } + e.style.left = x; + return e; + }, nodeList(div.childNodes)); + + // Convert the page to XHTML + var lxhtml = readXHTMLElement(div); + var xhtml = writeStrings(writeXML(lxhtml, false)); + + // Update the page ATOM entry + var name = appname(); + var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">' + name + '</title><id>' + name + '</id><content type="application/xml"><item>' + + xhtml + '</item></content></entry>'; + + pages.put(name, entry, function(e) {}); +}; + // Initialize the page editor -var pageedit = $('page'); -page.initpage(pageedit); +var edit = $('page'); +page.initpage(edit); // Get and display the current app page -getpage(appname(), pageedit); +getpage(appname(), edit); </script> </body> |