Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link href="StyleSheet.css" rel="stylesheet" />
  5. <title>Deise's Dice</title>
  6. <meta charset="utf-8" />
  7. <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  8. <script src="myScript.js"></script>
  9.  
  10. </head>
  11. <body>
  12.  
  13. <h1>
  14. <font face="Impact"> Deise's Dice </font>
  15. </h1>
  16.  
  17. <hr />
  18.  
  19. <navigate>
  20. <a href="Home.html">Return To Our Homepage</a>
  21. <a href="ViewByMaterial.html">View Inventory by Material</a>
  22. <a href="ViewByBrand.html">View Inventory by Brand</a>
  23. <a href="Checkout.html">Continue to Checkout</a>
  24. <a href="Feedback.html">Leave us Some Feedback</a>
  25. </navigate>
  26.  
  27. <hr />
  28.  
  29.  
  30. <h2>
  31. We Appreciate Your Comments and Feedback!
  32. </h2>
  33.  
  34.  
  35. <button class="navbutton" onClick="clearComment()">Clear Comment</button>
  36. <button class="navbutton" onClick="saveComment()">Save Comment </button>
  37.  
  38. <div id="dtext">
  39. <h4>Your comment</h4>
  40. <input id="username" type="text" maxlength="32" size="20" placeholder="Name" />
  41. <br />
  42. <textarea id="feedback" class="textbox" rows="6" placeholder="Your comment"></textarea>
  43. </div>
  44.  
  45. <h1>Comments</h1>
  46. <div id="commentlist"></div>
  47.  
  48.  
  49.  
  50. <Script>
  51.  
  52.  
  53.  
  54. function setObject(key, value) {
  55. window.localStorage.setItem(key, JSON.stringify(value));
  56. }
  57. function getObject(key) {
  58. var storage = window.localStorage,
  59. value = storage.getItem(key);
  60. return value && JSON.parse(value);
  61. }
  62. function clearStorage() {
  63. window.localStorage.clear();
  64. }
  65.  
  66. // Clear inputfields and localstorage
  67. function clearComment(){
  68. $('#feedback').val('');
  69. $('#username').val('');
  70. clearStorage();
  71. }
  72.  
  73. function saveComment(){
  74. var cText = $('#feedback').val(),
  75. cName = $('#username').val(),
  76. commentList = getObject('commentlist');
  77.  
  78. if (commentList){
  79. commentList.push({name: cName, text: cText});
  80. setObject('commentlist', commentList);
  81. }else{ //Add a comment
  82. setObject('commentlist', [{name: cName, text: cText}]);
  83. }
  84.  
  85. bindComment();
  86. }
  87.  
  88. function bindComment(){
  89. var commentListElement = $('#commentlist'),
  90. commentList = getObject('commentlist');
  91.  
  92. //Out with the old
  93. commentListElement.empty();
  94. //And in with the new
  95. $.each(commentList, function(i, k){
  96. commentListElement.append( $('<p><span>'+ k.name +'</span>'+ k.text +'</p>') );
  97. });
  98. }
  99.  
  100.  
  101. $(function(){
  102. bindComment();
  103. });
  104.  
  105.  
  106.  
  107.  
  108. </Script>
  109.  
  110.  
  111.  
  112.  
  113.  
  114. </body>
  115. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement