Guest User

indexxxxx

a guest
Jan 24th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.96 KB | None | 0 0
  1. <script src="/static/scripts/jquery-1.10.2.js"></script>
  2. <head>
  3. <script src="/static/scripts/jquery-1.10.2.js"></script>
  4. <meta charset="utf-8" />
  5. <!--<meta charset="utf-8" /> a name="viewport" content="width=device-width, initial-scale=1.0">-->
  6. <meta name ="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>My Flask Application</title>
  8. <script type="text/javascript" src="request.json"></script>
  9. <script type="text/javascript" src="wishlist.json"></script>
  10. <script type="text/javascript" src="cart.json"></script>
  11. <script type="text/javascript" src="getcategories.json"></script>
  12. <link rel="stylesheet" type="text/css" href="/static/css/style.css" />
  13. <style type="text/css">
  14. .col-md-4{
  15. border: 1px solid #bbb;
  16. border-radius: 5px;
  17. background-color: #fff;
  18. }
  19. .actualheader{
  20. width:70%;
  21. margin-left:100px;
  22. margin-right:auto;
  23. }
  24.  
  25. </style>
  26. <script type="text/javascript">
  27. var resultTag = [];
  28.  
  29. function setDataInResultTag() {
  30. this.resultA = [];
  31. this.set = function (input) {
  32. resultA = input;
  33. }
  34.  
  35. }
  36.  
  37. function categoriesquery(setData) {
  38. var conceptName = $('#categories_drop').find(":selected").text();
  39. if (conceptName != "Tags") {
  40. newresult = $.ajax(
  41. {
  42. data: { tags: conceptName },
  43. type: 'POST',
  44. url: '/getcategoriesproduct',
  45. success: function (data) {
  46. //alert(data);
  47. //console.log(data);
  48. data = JSON.parse(data);
  49.  
  50. //setData.set(data);
  51. //console.log(newdata);
  52. clearPage();
  53. defaultPage(data);
  54. }
  55. });
  56. } else {
  57. clearPage();
  58. defaultPage();
  59. }
  60. }
  61.  
  62. function post(path, params, method) {
  63. method = method || "post";
  64. var form = document.createElement("form");
  65. form.setAttribute("method", method);
  66. form.setAttribute("action", path);
  67.  
  68. for (var key in params) {
  69. if (params.hasOwnProperty(key)) {
  70. var hiddenField = document.createElement("input");
  71. hiddenField.setAttribute("type", "hidden");
  72. hiddenField.setAttribute("name", key);
  73. hiddenField.setAttribute("value", params[key]);
  74.  
  75. form.appendChild(hiddenField);
  76. }
  77. }
  78.  
  79. document.body.appendChild(form);
  80. form.submit();
  81. }
  82. function clearPage() {
  83. document.getElementById("actualcontent").innerHTML = "";
  84.  
  85. }
  86.  
  87.  
  88.  
  89.  
  90. var resultsClass = new setDataInResultTag();
  91. function defaultPage(tagResult) {
  92. 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>";
  93. preludestring += "<button id='sendDataa' type='button' onclick='categoriesquery(resultsClass)'>Send</button></div>";
  94. document.getElementById("actualheader").innerHTML = preludestring;
  95. //document.getElementById("sendDataa").addEventListener("click", categoriesquery(resultsClass), false);
  96.  
  97. var ultrastring = "<div id='item-container'>";
  98. if (typeof (tagResult) != "undefined") {
  99. jsondata.forEach(function (item) {
  100. if (tagResult.length != 0) {
  101. var isIn = false;
  102. tagResult.forEach(function (resultItem) {
  103. if (item.id == resultItem.id) {
  104. isIn = true;
  105. }
  106. });
  107.  
  108. if (isIn) {
  109. var addDescription = "";
  110. if (item.description.substring(0, 80).length < item.description.length) {
  111. addDescription = "..."
  112.  
  113.  
  114. }
  115. ultrastring += "<div id='testdiv'><h2 class='h2-content-inhome'>" + item.name.replace(/;;/g, "'") +
  116. "<p><img src='" + item.site + "' height='104' width='261'>" +
  117. "</h2><p class='p-content-inhome'>" + item.description.substring(0, 80).replace(/;;/g, "'") + addDescription +
  118. "</p><p><button class='btn-default' type='button' onclick='description(" + '"' + item.name + '","' + item.price + '","' + item.description + '","' + item.tags + '","' + item.site + '")' + "'>Read More &raquo;</button>" +
  119. "<button class='btn-default' type='button' onclick='AddToWishlist(" + '"' + item.id + '")' + "'>Add To Wishlist</button> " +
  120. "<button class= 'btn-default' type='button' onclick='buy(" + '"' + item.name + '","' + item.price + '")' + "'>Buy</button></p></div>";
  121. }
  122.  
  123. }
  124. });
  125. } else {
  126. jsondata.forEach(function (item) {
  127. var addDescription = "";
  128. if (item.description.substring(0, 80).length < item.description.length) {
  129. addDescription = "..."
  130.  
  131.  
  132. }
  133. ultrastring += "<div id='testdiv'><h2 class='h2-content-inhome'>" + item.name.replace(/;;/g, "'") +
  134. "<p><img src='" + item.site + "' height='104' width='261'>" +
  135. "</h2><p class='p-content-inhome'>" + item.description.substring(0, 80).replace(/;;/g, "'") + addDescription +
  136. "</p><p><button class='btn-default' type='button' onclick='description(" + '"' + item.name + '","' + item.price + '","' + item.description + '","' + item.tags + '","' + item.site + '")' + "'>Read More &raquo;</button>" +
  137. "<button class='btn-default' type='button' onclick='AddToWishlist(" + '"' + item.id + '")' + "'>Add To Wishlist</button> " +
  138. "<button class= 'btn-default' type='button' onclick='buy(" + '"' + item.name + '","' + item.price + '")' + "'>Buy</button></p></div>";
  139.  
  140. });
  141.  
  142. }
  143. ultrastring += "</div>"
  144. document.getElementById("actualcontent").innerHTML = ultrastring;
  145.  
  146.  
  147.  
  148. var mySelect = $('#categories_drop');
  149. $.each(tagdata, function (val, text) {
  150. mySelect.append(
  151. $('<option></option>').val(val).html(text)
  152. );
  153. });
  154.  
  155.  
  156. }
  157.  
  158. // function tag(itemName, itemPrice, itemDesc, itemTags, itemPicture, itemTagswood)
  159. // {
  160. //var
  161. // }
  162.  
  163.  
  164. function description(itemName, itemPrice, itemDesc, itemTags, itemPicture, itemTag)
  165. { //Description page here
  166. var checkPrice = itemPrice.split(".");
  167. var addedZero = "";
  168. if (checkPrice[1].length == 1)
  169. {
  170. addedZero = "0";
  171. }
  172. var bigstring =
  173. "<div id='descriptiondiv'><div id='innerdiv'><h1>" + itemName.replace(/;;/g, "'") + "</h1>" +
  174. "<p class='p-content'>" + itemDesc.replace(/;;/g, "'") + "</p>";
  175.  
  176. itemTags = itemTags.split(",")
  177. if (itemTags[0] != "")
  178. {
  179. //alert(itemTags[1]);
  180. bigstring += "<p class='p-content'><br>Tags: ";
  181. itemTags.forEach(function (item)
  182. {
  183. bigstring += item + " ";
  184. })
  185. bigstring += "</p>";
  186. }
  187. bigstring += "<hr><p class='p-content'>Price: €" + itemPrice + addedZero +
  188. "</p><p><button type='button' class='btn-default' onclick='defaultPage()'>Go Back</button></p></div>";
  189. if (itemPicture.toString() != "None")
  190. {
  191. bigstring += "<div id='picturediv'><img src='" + itemPicture + "' /></div>";
  192. }
  193. bigstring += "</div>";
  194. //alert(bigstring);
  195. document.getElementById("actualheader").innerHTML = bigstring;
  196. document.getElementById("actualcontent").innerHTML = "";
  197. }
  198. function AddToWishlist(itemID)
  199. {
  200. $.ajax(
  201. {
  202. data: { itemid: itemID }
  203. ,
  204. type: 'POST'
  205. , url: '/wishlistpost'
  206. , success: function (data)
  207. {
  208. data = JSON.parse(data);
  209. alert(data.result);
  210. }
  211. });
  212. }
  213. function buy(itemName,itemPrice) {
  214. sessionStorage.setItem(itemName, itemPrice);
  215. alert("item " + itemName + " saved in your Cart, " + sessionStorage.length + " products saved in cart");
  216. //fillthecart(itemName,false);
  217. }
  218. function getCart() {
  219. items = []
  220. filling = ""
  221. for (x = 0; x < sessionStorage.length; x++) {
  222. items[x] = sessionStorage.key(x);
  223. filling += "<div id='descriptiondiv'><h1>" + sessionStorage.key(x) + "</h1>";
  224. filling += "<p><button type='button' class='btn-default' onclick='deletefromcart(sessionStorage.key(" + x + "))'>Delete from cart</button></p></div><br></br>";
  225. }
  226. if (sessionStorage.length > 0) {
  227. filling += "<p><button type='button' class='btn-default' onclick='checkout()'>Checkout</button></p></div><br></br>";
  228. }
  229. filling += "<p><button type='button' class='btn-default' onclick='defaultPage()'>Close</button></p></div><br></br>";
  230. document.getElementById("actualheader").innerHTML = filling;
  231. }
  232. function deletefromcart(item) {
  233. sessionStorage.removeItem(item);
  234. alert("item removed from cart");
  235. location.reload();
  236. }
  237. function checkout() {
  238. stringy = [];
  239. username = 1;
  240. for (x = 0; x < sessionStorage.length; x++) {
  241. stringy[x] = sessionStorage.key(x);
  242. //post("/testdata", { name: sessionStorage.key(x) });
  243. }
  244. var result = ""
  245. var isFirst = true
  246. stringy.forEach(function (item) {
  247. if (isFirst == false) {
  248. result += ",";
  249. } else {
  250. isFirst = false;
  251. }
  252. result += item;
  253. });
  254. //alert(result);
  255. $.ajax({
  256. type: "POST",
  257. url: "/testdata",
  258. data: { name: result },
  259. success: function (data) {
  260. data = JSON.parse(data);
  261. if (data.status == "OK") {
  262. alert(data.name);
  263. } else {
  264. }
  265. }
  266. });
  267. var objConnection = new ActiveXObject("adodb.connection");
  268. var strConn = "driver={sql server};server=volantis-online.nl;database=iksman_php;uid=iksman_php;password=8s7gVPAs";
  269. objConnection.Open(strConn);
  270. var rs = new ActiveXObject("ADODB.Recordset");
  271. var strQuery = "INSERT INTO invoice VALUES (4,null,1)";
  272. rs.Open(strQuery, objConnection);
  273. rs.MoveFirst();
  274. while (!rs.EOF) {
  275. document.write(rs.fields(0) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  276. document.write(rs.fields(1) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  277. document.write(rs.fields(2) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ");
  278. document.write(rs.fields(3) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ");
  279. document.write(rs.fields(4) + "<br/>");
  280. rs.movenext();
  281. }
  282. }
  283. </script>
  284. </head>
  285. <body>
  286. <div class="toolbar">
  287. <div class="container">
  288. <a href="/" class="toolbutton-head">Instrumental Webshop</a>
  289. <p1>Home</p1>
  290. <a href="/history" class="toolbutton">History</a>
  291. <a href="/wishlist" class="toolbutton">Wishlist</a>
  292. <a href="/login" class="toolbutton">Login</a>
  293. <a href="/register" class="toolbutton">Register</a>
  294. <button class='toolbutton' type='button' onclick='getCart()'>Shopping Cart</button>
  295. <!--
  296. <li><a href="{{ url_for('contact') }}">Contact</a></li>-->
  297. </div>
  298. </div>
  299.  
  300. <div id="toolbar-offset-div"></div>
  301. <div id="content">
  302. <div class="jumbotron" id="actualheader">
  303. <h1 id="ignore">Instrumental Webshop</h1>
  304. <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>
  305. <select id="categories_drop">
  306. <option value="volvo">Volvo</option>
  307. <option value="saab">Saab</option>
  308. <option value="mercedes">Mercedes</option>
  309. <option value="audi">Audi</option>
  310. </select>
  311. <!--<p><a href="http://flask.pocoo.org/" class="btn btn-primary btn-large">Learn more &raquo;</a></p>-->
  312. </div>
  313. <div class="row" id="actualcontent">
  314. <script type="text/javascript">defaultPage();</script>
  315. </div>
  316. </div>
  317. </body>
Add Comment
Please, Sign In to add comment