Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="/static/scripts/jquery-1.10.2.js"></script>
- <head>
- <script src="/static/scripts/jquery-1.10.2.js"></script>
- <meta charset="utf-8" />
- <!--<meta charset="utf-8" /> a name="viewport" content="width=device-width, initial-scale=1.0">-->
- <meta name ="viewport" content="width=device-width, initial-scale=1.0">
- <title>My Flask Application</title>
- <script type="text/javascript" src="request.json"></script>
- <script type="text/javascript" src="wishlist.json"></script>
- <script type="text/javascript" src="cart.json"></script>
- <script type="text/javascript" src="getcategories.json"></script>
- <link rel="stylesheet" type="text/css" href="/static/css/style.css" />
- <style type="text/css">
- .col-md-4{
- border: 1px solid #bbb;
- border-radius: 5px;
- background-color: #fff;
- }
- .actualheader{
- width:70%;
- margin-left:100px;
- margin-right:auto;
- }
- </style>
- <script type="text/javascript">
- var resultTag = [];
- function setDataInResultTag() {
- this.resultA = [];
- this.set = function (input) {
- resultA = input;
- }
- }
- function categoriesquery(setData) {
- var conceptName = $('#categories_drop').find(":selected").text();
- if (conceptName != "Tags") {
- newresult = $.ajax(
- {
- data: { tags: conceptName },
- type: 'POST',
- url: '/getcategoriesproduct',
- success: function (data) {
- //alert(data);
- //console.log(data);
- data = JSON.parse(data);
- //setData.set(data);
- //console.log(newdata);
- clearPage();
- defaultPage(data);
- }
- });
- } else {
- clearPage();
- defaultPage();
- }
- }
- function post(path, params, method) {
- method = method || "post";
- var form = document.createElement("form");
- form.setAttribute("method", method);
- form.setAttribute("action", path);
- for (var key in params) {
- if (params.hasOwnProperty(key)) {
- var hiddenField = document.createElement("input");
- hiddenField.setAttribute("type", "hidden");
- hiddenField.setAttribute("name", key);
- hiddenField.setAttribute("value", params[key]);
- form.appendChild(hiddenField);
- }
- }
- document.body.appendChild(form);
- form.submit();
- }
- function clearPage() {
- document.getElementById("actualcontent").innerHTML = "";
- }
- var resultsClass = new setDataInResultTag();
- function defaultPage(tagResult) {
- var preludestring = "<div id='item-container'><h1>Instrumental Webshop</h1><p class='p-content'>Welcome to Instrumental Webshop, a place for young and old to bask in the glory of instruments of string and blow</p><select id='categories_drop'><option>Tags</option> </select>";
- preludestring += "<button id='sendDataa' type='button' onclick='categoriesquery(resultsClass)'>Send</button></div>";
- document.getElementById("actualheader").innerHTML = preludestring;
- //document.getElementById("sendDataa").addEventListener("click", categoriesquery(resultsClass), false);
- var ultrastring = "<div id='item-container'>";
- if (typeof (tagResult) != "undefined") {
- jsondata.forEach(function (item) {
- if (tagResult.length != 0) {
- var isIn = false;
- tagResult.forEach(function (resultItem) {
- if (item.id == resultItem.id) {
- isIn = true;
- }
- });
- if (isIn) {
- var addDescription = "";
- if (item.description.substring(0, 80).length < item.description.length) {
- addDescription = "..."
- }
- ultrastring += "<div id='testdiv'><h2 class='h2-content-inhome'>" + item.name.replace(/;;/g, "'") +
- "<p><img src='" + item.site + "' height='104' width='261'>" +
- "</h2><p class='p-content-inhome'>" + item.description.substring(0, 80).replace(/;;/g, "'") + addDescription +
- "</p><p><button class='btn-default' type='button' onclick='description(" + '"' + item.name + '","' + item.price + '","' + item.description + '","' + item.tags + '","' + item.site + '")' + "'>Read More »</button>" +
- "<button class='btn-default' type='button' onclick='AddToWishlist(" + '"' + item.id + '")' + "'>Add To Wishlist</button> " +
- "<button class= 'btn-default' type='button' onclick='buy(" + '"' + item.name + '","' + item.price + '")' + "'>Buy</button></p></div>";
- }
- }
- });
- } else {
- jsondata.forEach(function (item) {
- var addDescription = "";
- if (item.description.substring(0, 80).length < item.description.length) {
- addDescription = "..."
- }
- ultrastring += "<div id='testdiv'><h2 class='h2-content-inhome'>" + item.name.replace(/;;/g, "'") +
- "<p><img src='" + item.site + "' height='104' width='261'>" +
- "</h2><p class='p-content-inhome'>" + item.description.substring(0, 80).replace(/;;/g, "'") + addDescription +
- "</p><p><button class='btn-default' type='button' onclick='description(" + '"' + item.name + '","' + item.price + '","' + item.description + '","' + item.tags + '","' + item.site + '")' + "'>Read More »</button>" +
- "<button class='btn-default' type='button' onclick='AddToWishlist(" + '"' + item.id + '")' + "'>Add To Wishlist</button> " +
- "<button class= 'btn-default' type='button' onclick='buy(" + '"' + item.name + '","' + item.price + '")' + "'>Buy</button></p></div>";
- });
- }
- ultrastring += "</div>"
- document.getElementById("actualcontent").innerHTML = ultrastring;
- var mySelect = $('#categories_drop');
- $.each(tagdata, function (val, text) {
- mySelect.append(
- $('<option></option>').val(val).html(text)
- );
- });
- }
- // function tag(itemName, itemPrice, itemDesc, itemTags, itemPicture, itemTagswood)
- // {
- //var
- // }
- function description(itemName, itemPrice, itemDesc, itemTags, itemPicture, itemTag)
- { //Description page here
- var checkPrice = itemPrice.split(".");
- var addedZero = "";
- if (checkPrice[1].length == 1)
- {
- addedZero = "0";
- }
- var bigstring =
- "<div id='descriptiondiv'><div id='innerdiv'><h1>" + itemName.replace(/;;/g, "'") + "</h1>" +
- "<p class='p-content'>" + itemDesc.replace(/;;/g, "'") + "</p>";
- itemTags = itemTags.split(",")
- if (itemTags[0] != "")
- {
- //alert(itemTags[1]);
- bigstring += "<p class='p-content'><br>Tags: ";
- itemTags.forEach(function (item)
- {
- bigstring += item + " ";
- })
- bigstring += "</p>";
- }
- bigstring += "<hr><p class='p-content'>Price: €" + itemPrice + addedZero +
- "</p><p><button type='button' class='btn-default' onclick='defaultPage()'>Go Back</button></p></div>";
- if (itemPicture.toString() != "None")
- {
- bigstring += "<div id='picturediv'><img src='" + itemPicture + "' /></div>";
- }
- bigstring += "</div>";
- //alert(bigstring);
- document.getElementById("actualheader").innerHTML = bigstring;
- document.getElementById("actualcontent").innerHTML = "";
- }
- function AddToWishlist(itemID)
- {
- $.ajax(
- {
- data: { itemid: itemID }
- ,
- type: 'POST'
- , url: '/wishlistpost'
- , success: function (data)
- {
- data = JSON.parse(data);
- alert(data.result);
- }
- });
- }
- function buy(itemName,itemPrice) {
- sessionStorage.setItem(itemName, itemPrice);
- alert("item " + itemName + " saved in your Cart, " + sessionStorage.length + " products saved in cart");
- //fillthecart(itemName,false);
- }
- function getCart() {
- items = []
- filling = ""
- for (x = 0; x < sessionStorage.length; x++) {
- items[x] = sessionStorage.key(x);
- filling += "<div id='descriptiondiv'><h1>" + sessionStorage.key(x) + "</h1>";
- filling += "<p><button type='button' class='btn-default' onclick='deletefromcart(sessionStorage.key(" + x + "))'>Delete from cart</button></p></div><br></br>";
- }
- if (sessionStorage.length > 0) {
- filling += "<p><button type='button' class='btn-default' onclick='checkout()'>Checkout</button></p></div><br></br>";
- }
- filling += "<p><button type='button' class='btn-default' onclick='defaultPage()'>Close</button></p></div><br></br>";
- document.getElementById("actualheader").innerHTML = filling;
- }
- function deletefromcart(item) {
- sessionStorage.removeItem(item);
- alert("item removed from cart");
- location.reload();
- }
- function checkout() {
- stringy = [];
- username = 1;
- for (x = 0; x < sessionStorage.length; x++) {
- stringy[x] = sessionStorage.key(x);
- //post("/testdata", { name: sessionStorage.key(x) });
- }
- var result = ""
- var isFirst = true
- stringy.forEach(function (item) {
- if (isFirst == false) {
- result += ",";
- } else {
- isFirst = false;
- }
- result += item;
- });
- //alert(result);
- $.ajax({
- type: "POST",
- url: "/testdata",
- data: { name: result },
- success: function (data) {
- data = JSON.parse(data);
- if (data.status == "OK") {
- alert(data.name);
- } else {
- }
- }
- });
- var objConnection = new ActiveXObject("adodb.connection");
- var strConn = "driver={sql server};server=volantis-online.nl;database=iksman_php;uid=iksman_php;password=8s7gVPAs";
- objConnection.Open(strConn);
- var rs = new ActiveXObject("ADODB.Recordset");
- var strQuery = "INSERT INTO invoice VALUES (4,null,1)";
- rs.Open(strQuery, objConnection);
- rs.MoveFirst();
- while (!rs.EOF) {
- document.write(rs.fields(0) + " ");
- document.write(rs.fields(1) + " ");
- document.write(rs.fields(2) + " ");
- document.write(rs.fields(3) + " ");
- document.write(rs.fields(4) + "<br/>");
- rs.movenext();
- }
- }
- </script>
- </head>
- <body>
- <div class="toolbar">
- <div class="container">
- <a href="/" class="toolbutton-head">Instrumental Webshop</a>
- <p1>Home</p1>
- <a href="/history" class="toolbutton">History</a>
- <a href="/wishlist" class="toolbutton">Wishlist</a>
- <a href="/login" class="toolbutton">Login</a>
- <a href="/register" class="toolbutton">Register</a>
- <button class='toolbutton' type='button' onclick='getCart()'>Shopping Cart</button>
- <!--
- <li><a href="{{ url_for('contact') }}">Contact</a></li>-->
- </div>
- </div>
- <div id="toolbar-offset-div"></div>
- <div id="content">
- <div class="jumbotron" id="actualheader">
- <h1 id="ignore">Instrumental Webshop</h1>
- <p class="lead">Welcome to Instrumental Webshop, a place for young and old to bask in the glory of instruments of string and blow</p>
- <select id="categories_drop">
- <option value="volvo">Volvo</option>
- <option value="saab">Saab</option>
- <option value="mercedes">Mercedes</option>
- <option value="audi">Audi</option>
- </select>
- <!--<p><a href="http://flask.pocoo.org/" class="btn btn-primary btn-large">Learn more »</a></p>-->
- </div>
- <div class="row" id="actualcontent">
- <script type="text/javascript">defaultPage();</script>
- </div>
- </div>
- </body>
Add Comment
Please, Sign In to add comment