diff options
Diffstat (limited to 'sca-cpp/branches/lightweight-sca/hosting/server/htdocs/store')
-rw-r--r-- | sca-cpp/branches/lightweight-sca/hosting/server/htdocs/store/index.html | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/sca-cpp/branches/lightweight-sca/hosting/server/htdocs/store/index.html b/sca-cpp/branches/lightweight-sca/hosting/server/htdocs/store/index.html new file mode 100644 index 0000000000..1264007fe3 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/hosting/server/htdocs/store/index.html @@ -0,0 +1,170 @@ +<!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="body"> + +<div id="apps" class="viewcontent"></div> + +<script type="text/javascript"> +(function() { + +/** + * Set page titles. + */ +document.title = config.windowtitle() + ' - Store'; + +/** + * The store categories + */ +var categories = [ + //['Featured', 'featured', 1], + ['Top', 'top', 2], + ['New', 'new', 3], + ['Search', 'all', 4], + ['My Apps', 'myapps', 5] +]; + +/** + * Find a store category. + */ +function findcategory(name) { + if (isNil(name)) + return findcategory('top'); + var f = filter(function(c) { return cadr(c) == name }, categories); + if (isNil(f)) + return findcategory('top'); + return car(f); +} + +/** + * Get the current store category. + */ +var catname = cadr(findcategory(ui.fragmentParams(location)['category'])); + +/** + * Build the store menu bar + */ +function catmenu() { + function catmenuitem(name, cat, idx) { + var c = cat == catname? 'smenu' : 'amenu'; + return '<span>' + ui.href('storecat_' + cat, '/#view=store&category=' + cat + '&idx=' + idx, '_view', '<span class="' + c + '">' + name + '</span>') + '</span>'; + } + + var m = ''; + map(function(c) { m += catmenuitem(car(c), cadr(c), caddr(c)); }, categories); + m += '<span class="rmenu"><input type="button" class="graybutton bluebutton" id="createApp" title="Create a new app" Value="Create"/></span>'; + return m; +} + +/** + * Build the store menu bar. + */ +$('viewhead').innerHTML = catmenu(); + +/** + * Init service references. + */ +var editorComp = sca.component("Editor"); +var store = sca.reference(editorComp, "store"); +var dashboards = sca.reference(editorComp, "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. + */ +$('createApp').onclick = function() { + return ui.navigate('/#view=create', '_view'); +} + +/** + * Get and display list of apps. + */ +function getapps(catname) { + //debug('catname', catname); + showStatus('Loading'); + + function display(doc) { + + // Stop now if we didn't get the apps + if (doc == null) { + showError('App not available'); + return false; + } + showOnlineStatus(); + + 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 = cadr(assoc("'author", entry)); + var updated = cadr(assoc("'updated", entry)); + + apps += '<div class="box">' + apps += '<span class="appicon">' + ui.href('appicon_' + name, '/#view=stats&app=' + name, '_view', '<img src="' + appimg + '" width="50" height="50"></img>') + '</span>'; + apps += '<span>' + apps += '<span class="apptitle">' + ui.href('apptitle_' + name, '/#view=stats&app=' + name, '_view', name) + '</span>'; + if (catname != 'myapps') + apps += '<br/><span>' + 'by ' + author.split('@')[0] + '</span>'; + apps += '</span>'; + apps += '</div>'; + return displayentries(cdr(entries)); + } + + displayentries(entries); + + apps += '</div>'; + $('apps').innerHTML = apps; + } + + if (catname == 'myapps') + return dashboards.get('', display); + return store.get(catname, display); +} + +/** + * Get and display the list of apps. + */ +getapps(catname); + +})(); +</script> + +</div> |