Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div data-role="header" class="header">
- </div>
- <div role="main" class="ui-content padding">
- <div id="addpage">
- <h1>Login Page</h1>
- <form novalidate>
- <label for="custName">UserName:</label>
- <input type="text" id="custName" name="custName" placeholder="eg. Lim Siew Ming" required />
- <label for="custMobile">Password:</label>
- <input type="text" id="custMobile" name="custMobile" placeholder="eg. 1600000X"
- required />
- <button id="search" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-plus">
- Add
- </button>
- <button id="register" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-plus">
- Register
- </button>
- </form>
- </div>
- <div id="searchpage" hidden>
- <form novalidate>
- <h1>Register Page</h1>
- <label for="custName">Username:</label>
- <input type="text" id="custName" name="custName" placeholder="eg. Lim Siew Ming" />
- <label for="custMobile">Password:</label>
- <input type="text" id="custMobile" name="custMobile" placeholder="eg. 1600000X"
- required />
- <label for="custEmail">Email:</label>
- <input type="text" id="custEmail" name="custEmail" placeholder="eg.limsiewming@customer.tp.edu.sg" />
- <label for="custEmail">
- Date of Birth
- </label>
- <input type="date" data-role="date" />
- <button id="add" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-plus">
- Register
- </button>
- <button id="return" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-plus">
- Return
- </button>
- </form>
- </div>
- <div id="mainpage" hidden>
- <form>
- <h1>Main Page</h1>
- <input type="image" src="images/txnxcokskgxdwhbjlayk.png" name="order" class="btTxt submit" id="order" width="150" height="60" />
- <label for="order1">Order Food</label>
- <input type="image" src="images/download1.png" name="takeorder" class="btTxt1 submit" id="order1" width="150" height="60" />
- <label for="order2" style="float:right">Check My Order</label>
- <button class="ui-btn" id="signout">Sign Out</button>
- </form>
- </div>
- <div id="selectcanteen" hidden>
- <form>
- <h1>Select Canteen</h1>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" name="itas" id="itas">
- <img src="images/download.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Itas</h3>
- </button>
- <button type="submit" style="background-color:transparent; border-color:transparent;" name="businesspark" id="businesspark">
- <img src="images/businesspark.jpg" height="100" id="image2" class="myImage1" />
- <h3 class="heading1">Business Park</h3>
- </button>
- <button type="button" id="back" class="ui-btn ui-shadow ui-btn-icon-left uicorner-all">Back</button>
- </form>
- </div>
- <div id="verifycanteen" hidden>
- <h1>Verify Canteen</h1>
- <div role="main" class="ui-content padding">
- <div id="mainpage" class="btn-toolbar">
- <form>
- <button type="button" id="getPosition" class="ui-btn ui-shadow ui-btn-icon-left uicorner-all">
- CURRENT POSITION
- </button>
- </form>
- </div>
- </div>
- <div id="displayresults">Current Postion:</div>
- <button type="button" id="watchPosition" class="ui-btn ui-shadow ui-btn-icon-left uicorner-all">
- PROCEED
- </button>
- <button type="button" id="backposition" class="ui-btn ui-shadow ui-btn-icon-left uicorner-all">
- Back
- </button>
- </div>
- <div id="selectstore">
- <h1>Select the Stall</h1>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" name="malaystall" id="malaystall">
- <img src="images/3fbd8-javamalay1.jpg" height="100" id="image3" class="myImage" />
- <h3 class="heading">Malay Stall</h3>
- </button>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" name="westernfood" id="westernfood">
- <img src="images/images.jpg" height="100" id="image4" class="myImage" />
- <h3 class="heading">Western Food</h3>
- </button>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" name="miniwok" id="miniwok">
- <img src="images/mw2.jpg" height="100" id="image5" class="myImage" />
- <h3 class="heading">Mini Wok</h3>
- </button>
- <button type="button" id="selectback" class="ui-btn ui-shadow ui-btn-icon-left uicorner-all">
- Back
- </button>
- </div>
- <div id="selectfood">
- <h1>Select Food</h1>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" value="nasilemak" id="nasilemak">
- <img src="images/1200px-Nasi_Lemak,_Mamak,_Sydney.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Nasi Lemak</h3>
- </button>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" value="nasigoreng" id="nasigoreng">
- <img src="images/Nasi-Goreng_1_landscape-680x486.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Nasi Goreng</h3>
- </button>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" value="nasipadang" id="nasipadang">
- <img src="images/nasi-padang-plate-delicious-bali-indonesia.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Nasi Padang</h3>
- </button>
- <button type="button" id="selectfoodback" class="ui-btn ui-shadow ui-btn-icon-left uicorner-all">
- Back
- </button>
- </div>
- <div id="selectdrink">
- <h1>Select Drinks</h1>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" value="lemontea" id="lemontea">
- <img src="images/Thai-Lemon-Iced-Tea.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Ice Lemon Tea</h3>
- </button>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" value="hotcoffee" id="hotcoffee">
- <img src="images/images1.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Hot Coffee</h3>
- </button>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" value="icemilo" id="icemilo">
- <img src="images/download2.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Ice Milo</h3>
- </button>
- <button type="button" id="selectdrinkback" class="ui-btn ui-shadow ui-btn-icon-left uicorner-all">
- Back
- </button>
- </div>
- </div>
- <div id="selectfood1">
- <h1>Select Food</h1>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" name="chickenrice" id="chickenrice">
- <img src="images/chickenrice_566x424_fillbg_1b71b0de73.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Chicken Rice</h3>
- </button>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" name="westernfood1" id="westernfood1">
- <img src="images/5. Shi Xin Western Food 时新西餐 (Tekka Food Centre) - Pork Chop.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Western Food</h3>
- </button>
- <button class="btn" type="submit" style="background-color:transparent; border-color:transparent;" name="banmian" id="banmian">
- <img src="images/T&T-banmian-lanxiang.jpg" height="100" id="image1" class="myImage" />
- <h3 class="heading">Ban Mian</h3>
- </button>
- <button type="button" id="selectfood2" class="ui-btn ui-shadow ui-btn-icon-left uicorner-all">
- Back
- </button>
- </div>
- <div id="PaymentPage">
- <h1>Confirm Order</h1>
- <div id="searchResults">
- <table id="allresults">
- <tbody></tbody>
- </table>
- <button id="delete1" class="ui-btn ui-shadow ui-btn-icon-left ui-corner-all ui-icondelete">Get Order</button>
- <button id="delete" class="ui-btn ui-shadow ui-btn-icon-left ui-corner-all ui-icondelete">Confirm Order</button>
- </div>
- </div>
- (function () {
- "use strict";
- document.addEventListener('deviceready', onDeviceReady.bind(this), false);
- var username = [10];
- var password = [10];
- var apikey = "AIzaSyDjY3kWvaRawcehjhYVx-v-T-1daTrzNfE";
- var watchID = null;
- var foodname = [5];
- var foodprice = [5];
- function onDeviceReady() {
- $("#getPosition").click(getPosition);
- $("#add").click(addCustomer);
- $("#search").click(searchCustomer);
- $("#itas").click(selectcanteen);
- $("#businesspark").click(selectcanteen);
- $("#delete1").click(retrievetotal);
- $("#addpage").show();
- $("#selectstore").hide();
- $("#selectfood").hide();
- $("#selectfood1").hide();
- $("#PaymentPage").hide();
- $("#selectdrink").hide();
- $("#watchPosition").hide();
- $('#order').click(function () {
- $("#searchpage").hide();
- $("#addpage").hide();
- $("#mainpage").hide();
- $("#selectcanteen").show();
- $("#selectstore").hide();
- $("#selectfood").hide();
- $("#selectdrink").hide();
- $("#selectfood1").hide();
- $("#PaymentPage").hide();
- });
- $('#register').click(function () {
- $("#searchpage").show();
- $("#addpage").hide();
- $("#mainpage").hide();
- $("#selectcanteen").hide();
- $("#selectstore").hide();
- $("#selectfood").hide();
- $("#selectdrink").hide();
- $("#selectfood1").hide();
- $("#PaymentPage").hide();
- });
- $('#return').click(function () {
- $("#addpage").show();
- $("#mainpage").hide();
- $("#searchpage").hide();
- $("#selectcanteen").hide();
- $("#selectstore").hide();
- $("#selectfood").hide();
- $("#selectdrink").hide();
- $("#selectfood1").hide();
- $("#PaymentPage").hide();
- });
- $('#watchPosition').click(function () {
- $("#selectstore").show();
- $("#verifycanteen").hide();
- });
- $('#malaystall').click(function () {
- $("#selectstore").hide();
- $("#selectfood").show();
- });
- $('#nasilemak').click(function () {
- for (var i = 0; i < foodname.length; i++) {
- foodname[i] = $(this).val();
- foodprice[i] = 3;
- }
- $("#selectfood").hide();
- $("#selectdrink").show();
- });
- $('#nasilgoreng').click(function () {
- $("#selectfood").hide();
- $("#selectdrink").show();
- });
- $('#nasilpadang').click(function () {
- $("#selectfood").hide();
- $("#selectdrink").show();
- });
- $('#lemontea').click(function () {
- for (var i = 0; i < foodprice.length; i++)
- {
- foodname[i] = $(this).val();
- foodprice[i] = 4;
- calculatetotal(foodname, foodprice);
- }
- $("#selectdrink").hide();
- $("#PaymentPage").show();
- });
- $('#hotcoffee').click(function () {
- calculatetotal(foodprice,foodname);
- $("#selectdrink").hide();
- $("#PaymentPage").show();
- });
- $('#icemilo').click(function () {
- $("#selectdrink").hide();
- $("#PaymentPage").show();
- });
- $('#chickenrice').click(function () {
- $("#selectfood").hide();
- $("#selectdrink").hide();
- });
- $('#westernfood1').click(function () {
- $("#selectfood").hide();
- $("#selectdrink").hide();
- });
- $('#banmian').click(function () {
- $("#selectfood").hide();
- $("#selectdrink").hide();
- });
- $('#signout').click(function () {
- $("#addpage").show();
- $("#mainpage").hide();
- });
- $('#back').click(function () {
- $("#mainpage").show();
- $("#selectcanteen").hide();
- });
- $('#backposition').click(function () {
- $("#selectcanteen").show();
- $("#verifycanteen").hide();
- });
- $('#selectback').click(function () {
- $("#selectstore").hide();
- $("#verifycanteen").show();
- });
- $('#selectfoodback').click(function () {
- $("#selectstore").show();
- $("#selectfood").hide();
- });
- $('#selectdrinkback').click(function () {
- $("#selectfood").show();
- $("#selectdrink").hide();
- });
- $('#selectfood2').click(function () {
- $("#selectstore").show();
- $("#selectfood1").hide();
- });
- }
- function calculatetotal(foodname,foodprice) {
- var total;
- for (var i = 0; i < foodprice.length; i++)
- {
- total += foodprice[i];
- }
- var db = window.sqlitePlugin.openDatabase({
- name: "total1.db",
- location: 1
- });
- db.transaction(function (tx) {
- //tx.executeSql('DROP TABLE IF EXISTS total1');
- tx.executeSql('CREATE TABLE IF NOT EXISTS total1 (id integer primary key, foodname varchar(255), foodprice integer)');
- tx.executeSql("INSERT INTO total1 (foodName,foodprice) VALUES (?,?)", [foodname, total], function
- (tx, res) {
- console.log("insertId: " + res.insertId);
- console.log("rowsAffected: " + res.rowsAffected);
- });
- }, function (e) {
- console.log("ERROR: " + e.message);
- });
- return false;
- }
- function retrievetotal(foodname) {
- var db = window.sqlitePlugin.openDatabase({
- name: "total1.db",
- location: 1
- });
- var tBody = $('#allresults tbody');
- var theRow = "";
- db.transaction(function (tx) {
- tx.executeSql("select foodname,foodprice from total1 where foodname LIKE ?", ['%' + foodname + '%'], function (tx, res) {
- if (res.rows.length < 1) {
- $("#searchResults").hide();
- }
- else {
- $("#searchResults").show();
- }
- tBody.empty();
- theRow = "<tr><td>Name:</td><td>Mobile:</td><td>Email:</td></tr>";
- for (var i = 0; i < res.rows.length; i++) {
- theRow += "<tr><td>" + res.rows.item(i).foodname + "</td>";
- theRow += "<td>" + res.rows.item(i).foodprice + "</td>";
- exactName = res.rows.item(i).foodName;
- }
- tBody.append(theRow);
- $("#allresults").table("refresh");
- }, function (e) {
- console.log("ERROR: " + e.message);
- });
- });
- return false;
- }
- function showLocation(datareturned) {
- if (datareturned.results.length) {
- $('#displayresults').show();
- $('#displayresults').text(datareturned.results[0].formatted_address);
- } else {
- $('#displayresults').show();
- $('#displayresults').text("Something is wrong");
- }
- }
- function getPosition() {
- navigator.geolocation.clearWatch(watchID);
- var options = {
- enableHighAccuracy: true,
- maximumAge: 3600000
- };
- watchID = navigator.geolocation.watchPosition(onSuccess, onError, options);
- function onSuccess(position) {
- var message = 'Latitude: ' + position.coords.latitude + 'n' +
- 'Longitude: ' + position.coords.longitude + 'n' +
- 'Altitude: ' + position.coords.altitude + 'n' +
- 'Accuracy: ' + position.coords.accuracy + 'n' +
- 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + 'n' +
- 'Heading: ' + position.coords.heading + 'n' +
- 'Speed: ' + position.coords.speed + 'n' +
- 'Timestamp: ' + position.timestamp + 'n';
- var title = 'Current Location';
- var buttonName = 'Ok';
- //navigator.notification.alert(message, alertCallback, title, buttonName);
- //getlocation from googlemaps
- var queryString = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='
- + position.coords.latitude + ',' + position.coords.longitude + '&key=' + apikey + '';
- $.getJSON(queryString, function (datareturned) {
- showLocation(datareturned);
- $("#getPosition").hide();
- $("#watchPosition").show();
- }).fail(function (jqXHR) {
- $('#error-msg').show();
- $('#error-msg').text("Error retrieving data. " + jqXHR.statusText);
- });
- }
- function alertCallback() {
- }
- function onError(error) {
- navigator.notification.alert('code: ' + error.code + 'n' + 'message: ' + error.message + 'n', alertCallback, 'Error', 'Ok');
- }
- }
- function addCustomer() {
- var custNameVal = $("#custName").val();
- var custEmailVal = $("#custEmail").val();
- var custMobileVal = parseInt($("#custMobile").val());
- var db = window.sqlitePlugin.openDatabase({
- name: "customer.db",
- location: 1
- });
- db.transaction(function (tx) {
- //tx.executeSql('DROP TABLE IF EXISTS customer');
- tx.executeSql('CREATE TABLE IF NOT EXISTS customer (id integer primary key, custName varchar(255), custMobile integer, custEmail)');
- tx.executeSql("INSERT INTO customer (custName, custMobile,custEmail) VALUES (?,?,?)", [custNameVal, custMobileVal, custEmailVal], function
- (tx, res) {
- for (var i = 0; i < username.length; i++) {
- for (var o = 0; o < password.length; o++) {
- username[i] = custNameVal;
- password[o] = custEmailVal;
- }
- }
- });
- }, function (e) {
- console.log("ERROR: " + e.message);
- });
- return false;
- }
- function searchCustomer() {
- var custname = $("#custName").val();
- var custpassword = $("#custMobile").val();
- for (var i = 0; i < username.length; i++) {
- for (var o = 0; o < password.length; o++) {
- if (username[i] === custname && password[o] === custpassword) {
- $("#addpage").hide();
- $("#mainpage").show();
- $("#searchpage").hide();
- }
- }
- }
- return false;
- }
- function selectcanteen() {
- var message = "Are you sure you are in the right canteen";
- var title = "Confirmation";
- var buttonLabels = "YES, NO";
- navigator.notification.confirm(message, confirmCallback, title, buttonLabels);
- function confirmCallback(buttonIndex) {
- if (buttonIndex === 1) {
- $("#verifycanteen").show();
- $("#mainpage").hide();
- $("#selectcanteen").hide();
- $("#searchpage").hide();
- $("#addpage").hide();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement