diff options
Diffstat (limited to '')
-rw-r--r-- | sca-cpp/trunk/modules/edit/htdocs/edit/edit.html | 57 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/edit/htdocs/edit/index.html | 32 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/edit/htdocs/index.html | 6 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html | 100 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/edit/htdocs/main/index.html | 1 |
5 files changed, 139 insertions, 57 deletions
diff --git a/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html b/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html index 5e1e41bf5c..91910ab292 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html +++ b/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html @@ -35,34 +35,41 @@ var editWidget = sca.component("EditWidget"); var dashboard = sca.reference(editWidget, "dashboard"); var apps = sca.reference(editWidget, "apps"); -if (false) { -dashboard.get('', function(doc) { - var entries = cddr(atom.readATOMFeedDocument(doc)); - var entry = car(entries); - var item = caddr(entry); - var composite = cddr(item); - var comps = scdl.components(composite); - - var g = graph.mkgraph(); - var shapes = graph.composite(composite); - log(shapes); - for (var s in shapes) - g.appendChild(shapes[s]); -}); +/** + * Return the current app name. + */ +function appname() { + var qs = window.location.toString().split('?'); + if (isNil(cdr(qs))) + return null; + var p = cadr(qs).split('='); + if (isNil(p) || isNil(cdr(p))) + return null; + return cadr(p); } -apps.get('store', function(doc) { - var entry = atom.readATOMEntryDocument(doc); - var item = caddr(entry); - var composite = cddr(item); - var comps = scdl.components(composite); +/** + * Get an app and display it. + */ +function getapp(name) { + if (name == null) + return; + apps.get(name, function(doc) { + var entry = atom.readATOMEntryDocument(doc); + var item = caddr(entry); + var composite = cddr(item); + var comps = scdl.components(composite); + + var g = graph.mkgraph(); + var shapes = graph.composite(composite); + log(shapes); + for (var s in shapes) + g.appendChild(shapes[s]); + }); +} - var g = graph.mkgraph(); - var shapes = graph.composite(composite); - log(shapes); - for (var s in shapes) - g.appendChild(shapes[s]); -}); +// Display the current app +getapp(appname()); </script> </body> diff --git a/sca-cpp/trunk/modules/edit/htdocs/edit/index.html b/sca-cpp/trunk/modules/edit/htdocs/edit/index.html index 7cdfcd81a4..d5df8bc678 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/edit/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/edit/index.html @@ -24,9 +24,39 @@ <script type="text/javascript" src="/ui.js"></script> </head> <body> -<iframe id="editFrame" src="edit.html" style="visibility: visible; height: 100%; width: 100%; border: 0px;" scrolling="no" frameborder="0"></iframe> +<h1><span id="titleDiv"></span></h1> +<div id="editDiv"></div> <script type="text/javascript"> +/** + * Return the current app name. + */ +function appname() { + var qs = window.location.toString().split('?'); + if (isNil(cdr(qs))) + return null; + var p = cadr(qs).split('='); + if (isNil(p) || isNil(cdr(p))) + return null; + return cadr(p); +} + +/** + * Display the editor for an app. + */ +function editapp(name) { + if (name == null) + return; + $('titleDiv').innerHTML = 'Editing: ' + name; + $('editDiv').innerHTML = + '<iframe id="editFrame" style="visibility: visible; height: 100%; width: 100%; border: 0px;" scrolling="no" frameborder="0" src="edit.html?' + + 'app=' + name + + '"></iframe>'; +} + +// Display the editor for the current app +editapp(appname()); + </script> </body> </html> diff --git a/sca-cpp/trunk/modules/edit/htdocs/index.html b/sca-cpp/trunk/modules/edit/htdocs/index.html index 3c18fdbd47..dffcf2d416 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/index.html @@ -27,11 +27,11 @@ <h1>App Edit Tools</h1> <p>This module implements simple tools to help you create Tuscany apps.</p> -<h2>App Dashboard</h1> +<h2>App Dashboard</h2> <p>Try the <a href="main">App Dashboard</a> to manage your collection of apps.</p> -<h2>App Editor</h1> -<p>Try the <a href="edit">App Editor</a> to edit an app.</p> +<h2>App Editor</h2> +<p>Try the <a href="edit/?app=store">App Editor</a> to edit an app.</p> </body> </html> diff --git a/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html b/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html index a5e5b12aef..b69c760c99 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html +++ b/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html @@ -45,8 +45,8 @@ <br> <table> -<tr><td>App name:</td><td><input type="text" name="appName" size="50"/></td></td><td>e.g. mycoolapp</td></tr> -<tr><td>Title:</td><td><input type="text" name="appTitle" size="50"/></td></td><td>e.g. My really cool app</td></tr> +<tr><td>App name:</td><td><input type="text" id="appName" size="50"/></td></td><td>e.g. mycoolapp</td></tr> +<tr><td>Title:</td><td><input type="text" id="appTitle" size="50"/></td></td><td>e.g. My really cool app</td></tr> </table> <input id="addAppButton" type="button" value="Add"/> </form> @@ -55,50 +55,94 @@ </div> <script type="text/javascript"> +// Install the widget ui.installwidget(); +// Init service references var editWidget = sca.component("EditWidget"); var dashboard = sca.reference(editWidget, "dashboard"); -// Get and display list of apps -dashboard.get('', function(doc) { - var apps = ''; - apps += '<table width="100%">'; - apps += '<tr><th>App</th><th>Title</th></tr>'; - - var entries = cddr(atom.readATOMFeedDocument(doc)); - for (var i = 0; i < length(entries); i++) { - var entry = entries[i]; - var item = caddr(entry); - var composite = cddr(item); - var comps = scdl.components(composite); - - name = cadr(entry); - title = car(entry); - - apps += '<tr>'; - apps += '<td><input name="apps" type="checkbox" value="' + name + '">' + '<a href=\"' + '/edit/?app=' + name + '\">' + name + '</a></td>'; - apps += '<td class="tdw">' + title + '</td>'; - apps += '</tr>'; +/** + * Get and display list of apps. + */ +function getapps(sync) { + function display(doc) { + var apps = ''; + apps += '<table width="100%">'; + apps += '<tr><th>App</th><th>Title</th></tr>'; + + var entries = cddr(atom.readATOMFeedDocument(doc)); + for (var i = 0; i < length(entries); i++) { + var entry = entries[i]; + var item = caddr(entry); + var composite = cddr(item); + var comps = scdl.components(composite); + + name = cadr(entry); + title = car(entry); + + apps += '<tr>'; + apps += '<td><input name="apps" type="checkbox" value="' + name + '">' + '<a href=\"' + '/edit/?app=' + name + '\">' + name + '</a></td>'; + apps += '<td class="tdw">' + title + '</td>'; + apps += '</tr>'; + } + apps += '</table>'; + $('apps').innerHTML = apps; } - apps += '</table>'; - $('apps').innerHTML = apps; -}); + if (sync) { + display(dashboard.get('')); + } else { + dashboard.get('', function(doc) { + display(doc); + }); + } +} -// Toggle new app form +/** + * Toggle new app form link event. + */ $('addAppLink').onclick = function() { var div = $('newApp'); div.style.visibility = div.style.visibility == 'hidden'? 'visible' : 'hidden'; return false; }; -// Add a new app +/** + * Add a new app button event. + */ $('addAppButton').onclick = function() { - alert('Add new app'); + var name = $('appName').value; + var title = $('appTitle').value; + var app = mklist(title, name, mklist()); + var entry = atom.writeATOMEntry(app); + dashboard.put(name, car(entry)); + getapps(); return false; }; +/** + * Delete apps event. + */ +$('deleteAppLink').onclick = function() { + var apps = $('appsForm').apps; + if (isNil(apps)) + return false; + if (isNil(apps.length)) + apps = mklist(apps); + for (var i = 0; i < length(apps); i++) { + if (apps[i].checked) { + var name = apps[i].value; + dashboard.del(name); + } + } + getapps(); + return false; +}; + +// Get and display the list of apps +getapps(true); + </script> </body> </html> diff --git a/sca-cpp/trunk/modules/edit/htdocs/main/index.html b/sca-cpp/trunk/modules/edit/htdocs/main/index.html index 13b2662645..6242309ab9 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/main/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/main/index.html @@ -29,6 +29,7 @@ <iframe id="dashboardFrame" src="dashboard.html"></iframe> <script type="text/javascript"> +// Display the dashboard widget ui.bindwidget('dashboardFrame', 'dashboard'); </script> </body> |