summaryrefslogtreecommitdiffstats
path: root/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html194
1 files changed, 0 insertions, 194 deletions
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
deleted file mode 100644
index aadb4ebd4f..0000000000
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
+++ /dev/null
@@ -1,194 +0,0 @@
-<!--
- * 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.
--->
-<html>
-<head>
-<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-<title>Online Store - Powered by Apache Tuscany</title>
-
-<link href="store.css" rel="stylesheet" type="text/css">
-
-<script type="text/javascript" src="dojo/dojo/dojo.js"></script>
-
-<script type="text/javascript">
- dojo.require("dojo.rpc.JsonService");
-</script>
-
-<script language="JavaScript">
-
- var userServices = new dojo.rpc.JsonService("/User?smd");
-
- var catalog = new dojo.rpc.JsonService("/Catalog?smd");
-
- var shoppingCart = new dojo.rpc.JsonService("/ShoppingCart?smd");
-
- var userContext;
-
- var catalogItems;
-
- function showHeader() {
- var userContextCallback = function(context) {
- userContext = context;
- //alert(userContext.userId + " --> " + userContext.loginUrl);
-
- var html='';
- if(! userContext.userId) {
- html = "<a href='" + userContext.loginUrl +"'>Login</a>";
- } else {
- html = userContext.email + " | <a href='" + userContext.logoutUrl +"'> Logout</a>";
- }
-
- document.getElementById('appHeader').innerHTML = html;
- }
-
- userServices.getUserContext(document.URL, "").addCallback(userContextCallback);
- }
-
- function showCatalogs() {
- var catalogCallback = function(items) {
- var catalog = "";
- for (var i=0; i<items.length; i++) {
- var item = items[i].name + ' - ' + items[i].currencySymbol + items[i].price;
- catalog += '<input name="items" type="checkbox" value="' +
- item + '">' + item + ' <br>';
- }
- document.getElementById('catalog').innerHTML=catalog;
- catalogItems = items;
- }
-
- catalog.get().addCallback(catalogCallback);
- }
-
-
- // This handles the response from shoppingCart.getAll
- // which is a collection of Entry<K,D>
- function shoppingCart_getResponse(items) {
- var list='';
- for (var i=0; i<items.length; i++) {
- //get the actual item, that is Entry.data
- var item = items[i].data;
- // process its attributes
- var name = item.name;
- var symbol = item.currencySymbol;
- var price = item.price
- list += name + ' - ' + symbol + price + ' <br>';
- }
- document.getElementById("shoppingCart").innerHTML = list;
-
- if (items.length != 0) {
- try {
- shoppingCart.getTotal().addCallback(shoppingCart_getTotalResponse);
- }
- catch(e){
- alert(e);
- }
- }
- }
-
- function shoppingCart_getTotalResponse(total,exception) {
- if(exception) {
- alert(exception.message);
- return;
- }
- document.getElementById('total').innerHTML = total;
- }
-
- function shoppingCart_postResponse(entry) {
- shoppingCart.getAll().addCallback(shoppingCart_getResponse);
- }
-
- function addToCart() {
- var items = document.catalogForm.items;
- var j = 0;
- for (var i=0; i<items.length; i++)
- if (items[i].checked) {
- shoppingCart.post("", catalogItems[i]).addCallback(shoppingCart_postResponse);
- items[i].checked = false;
- }
- }
- function checkoutCart() {
- document.getElementById('store').innerHTML='<h2>' +
- 'Thanks for Shopping With Us!</h2>'+
- '<h2>Your Order</h2>'+
- '<form name="orderForm">'+
- document.getElementById('shoppingCart').innerHTML+
- '<br>'+
- document.getElementById('total').innerHTML+
- '<br>'+
- '<br>'+
- '<input type="submit" value="Continue Shopping">'+
- '</form>';
- shoppingCart.delete("");
- }
- function deleteCart() {
- shoppingCart.delete("");
- document.getElementById('shoppingCart').innerHTML = "";
- document.getElementById('total').innerHTML = "";
- }
-
-
-
- function init() {
- try {
- showHeader();
-
- showCatalogs();
-
- shoppingCart.getAll().addCallback(shoppingCart_getResponse);
- } catch (e) {
- alert(e);
- }
- }
-
-
-</script>
-
-</head>
-
-<body onload="init()">
- <div id="appHeader" class="header">
- </div>
-
- <h1>Store</h1>
-
-
-
- <div id="store">
- <h2>Catalog</h2>
- <form name="catalogForm">
- <div id="catalog" ></div>
- <br>
- <input type="button" onClick="addToCart()" value="Add to Cart">
- </form>
-
-
- <br>
-
- <h2>Your Shopping Cart</h2>
- <form name="shoppingCartForm">
- <div id="shoppingCart"></div>
- <br>
- <div id="total"></div>
- <br>
- <input type="button" onClick="checkoutCart()" value="Checkout">
- <input type="button" onClick="deleteCart()" value="Empty">
- </form>
- </div>
-</body>
-
-</html> \ No newline at end of file