diff options
Diffstat (limited to 'sca-cpp/trunk/hosting/server/htdocs/store/index.html')
-rw-r--r-- | sca-cpp/trunk/hosting/server/htdocs/store/index.html | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/sca-cpp/trunk/hosting/server/htdocs/store/index.html b/sca-cpp/trunk/hosting/server/htdocs/store/index.html new file mode 100644 index 0000000000..bcb3ba7c85 --- /dev/null +++ b/sca-cpp/trunk/hosting/server/htdocs/store/index.html @@ -0,0 +1,168 @@ +<!DOCTYPE html> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<div id="bodydiv" class="bodydiv"> + +<table style="width: 100%;"> +<tr> +<td><h2><span id="h1"></span></h2></td> +<td style="vertical-align: middle; text-align: right;"><span id="status" style="font-weight: bold; color: #808080;"></span></td> +</tr> +</table> + +<div id="catmenu"></div> + +<div id="apps"></div> + +<script type="text/javascript"> + +// Set page titles +document.title = ui.windowtitle(location.hostname) + ' - Store'; +$('h1').innerHTML = ui.hometitle(location.hostname); + +// Get the store category +var category = ui.fragmentParams(location)['category']; +if (isNil(category)) + category = 'myapps'; + +/** + * Build store menu bar + */ +function catmenu() { + function catmenuitem(name, cat, idx) { + var c = cat == category? 'smenu' : 'amenu'; + return '<th class="thl thr" style="width: 10px; padding-top: 4px; padding-bottom: 4px; padding-right: 6px;">' + + ui.ahref('/#view=store&category=' + cat + '&idx=' + idx, '_view', '<span class="' + c + '">' + name + '</span>') + '</th>'; + } + + var m = '<table style="width: 100%; margin-bottom: 2px;"><tr>'; + m += catmenuitem('My Apps', 'myapps', '1'); + m += catmenuitem('New', 'new', '2'); + m += catmenuitem('Top', 'top', '3'); + m += catmenuitem('Featured', 'featured', '4'); + m += catmenuitem('All', 'all', '5'); + if (category == 'myapps') { + m += '<th class="thl thr" style="width: 100%; padding-top: 0px; padding-bottom: 0px; padding-right: 0px; text-align: right;">'; + m += '<input type="button" class="graybutton" id="createApp" title="Create a new app" style="font-weight: bold; margin-top: 0px; margin-bottom: 0px; height: 24px;" Value="New App"/>'; + m += '</th></tr></table>'; + return m; + } + m += '<th class="thl thr" style="width: 100%;"></th></tr></table>'; + return m; +} + +// Build store menu bar +$('catmenu').innerHTML = catmenu(); + +/** + * Service references. + */ +var editWidget = sca.component("EditWidget"); +var store = sca.reference(editWidget, "store"); +var dashboards = sca.reference(editWidget, "dashboards"); + +/** + * Edit an app. + */ +function editApp(appname) { + return ui.navigate('/#view=page&app=' + appname, '_view'); +} + +/** + * View an app. + */ +function viewApp(appname) { + return ui.navigate('/#view=stats&app=' + appname, '_view'); +} + +/** + * Create an app. + */ +if (category == 'myapps') { + $('createApp').onclick = function() { + return ui.navigate('/#view=create', '_view'); + } +} + +/** + * Get and display list of apps. + */ +function getapps(category) { + //log('category', category); + showStatus('Loading'); + + function display(doc) { + + // Stop now if we didn't get the apps + if (doc == null) { + showStatus('No data'); + return false; + } + showStatus(defaultStatus()); + + var apps = '<div>'; + var feed = car(elementsToValues(atom.readATOMFeed(mklist(doc)))); + var aentries = assoc("'entry", cdr(feed)); + var entries = isNil(aentries)? mklist() : isList(car(cadr(aentries)))? cadr(aentries) : mklist(cdr(aentries)); + + var appimg = ui.b64img(appcache.get('/public/app.b64')); + + function displayentries(entries) { + if (isNil(entries)) + return apps; + var entry = car(entries); + var title = cadr(assoc("'title", entry)) + var name = cadr(assoc("'id", entry)) + var author = 'joe'; + var clone = isNil(config.clone)? 'Clone' : config.clone; + + apps += '<div class="box" style="width: 150px; display: inline-block; border: 1px; border-style: solid; border-color: #dcdcdc; border-collapse: collapse; margin: 2px; padding: 2px; vertical-align: top;">' + apps += '<table><tr>'; + apps += '<td>'; + apps += '<div>' + ui.ahref('/#view=stats&app=' + name, '_view', '<img src="' + appimg + '" width="50" height="50" style="height: 50px; width: 50px; vertical-align: top; margin: 0px; padding: 0px;"></img>') + '</div>'; + apps += '</td>'; + apps += '<td class="tdw">'; + apps += '<div style="font-weight: bold">' + ui.ahref('/' + name + '/', '_blank', name) + '</div>'; + if (category == 'myapps') + apps += '<div style="color: #808080;">Shared</div>'; + else + apps += '<div>' + 'by ' + '<span style="font-weight: bold;">' + author + '</span></div>'; + apps += '</td>'; + apps += '</tr></table>'; + apps += '</div>'; + return displayentries(cdr(entries)); + } + + displayentries(entries); + + apps += '</div>'; + $('apps').innerHTML = apps; + } + + if (category == 'myapps') + return dashboards.get('', display); + return store.get(category, display); +} + +// Get and display the list of apps +getapps(category); + +</script> + +</div> |