Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.09 KB | None | 0 0
  1. <!-- This is the home page -->
  2. <html>
  3. <head>
  4. <title>The Vegan Repository</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <!-- Load libraries -->
  8. <!-- System.js -->
  9. <script
  10. src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.18.4/system-csp-production.js"></script>
  11. <!-- JQuery -->
  12. <script
  13. src="bower_components/jquery/dist/jquery.min.js"></script>
  14. <!-- Bootstrap CSS -->
  15. <link
  16. rel="stylesheet"
  17. href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
  18. integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
  19. crossorigin="anonymous">
  20. <!-- Bootstrap JS -->
  21. <script
  22. src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
  23. integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"
  24. crossorigin="anonymous"></script>
  25. <!-- Knockout JS -->
  26. <script
  27. src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script>
  28. <!-- Styles -->
  29. <link rel="stylesheet" type="text/css" href="styles/image.css">
  30. <link rel="stylesheet" type="text/css" href="styles/text.css">
  31. <link rel="stylesheet" type="text/css" href="styles/header.css">
  32. <link rel="stylesheet" type="text/css" href="styles/form.css">
  33. <link rel="stylesheet" type="text/css" href="styles/select.css">
  34. <?php
  35. $host = 'localhost';
  36. $port = 8889;
  37. $servername = "$host:$port";
  38. $username = "root";
  39. $password = "root";
  40. $db = "myDB";
  41.  
  42. // Create connection
  43. $conn = new mysqli($servername, $username, $password, $db);
  44. // Check connection
  45. if ($conn->connect_error) {
  46. die("Connection failed: " . $conn->connect_error);
  47. }
  48.  
  49. $sql = "SELECT name, geonameId FROM countryinfo";
  50. $result = $conn->query($sql);
  51. $allCountries = [];
  52. if ($result->num_rows > 0) {
  53. $rows = array ();
  54. while($row = $result->fetch_assoc()) {
  55. $country = array(
  56. "name" => $row['name'],
  57. "geonameId" => $row['geonameId']
  58. );
  59. $allCountries[] = $country;
  60. }
  61. }
  62. $conn->close();
  63. ?>
  64. <script type="text/javascript">
  65. var allCountries = <?php echo json_encode($allCountries, JSON_PRETTY_PRINT) ?>;
  66. </script>
  67. </head>
  68. <body >
  69. <div style="margin-bottom: 100px;" class="full_size dimmed">
  70. <div style="position:fixed; z-index: -1;">
  71. <video
  72. style="position:fixed;"
  73. autoplay loop muted
  74. poster="assets/images/home_page/polina.jpg"
  75. id="bgvid">
  76. <!--<source src="polina.webm" type="video/webm">-->
  77. <source src="assets/videos/polina.mp4" type="video/mp4">
  78. </video>
  79. </div>
  80. <div class="header dim">
  81. <a href="http://www.w3schools.com" >
  82. <h5 id="app-name" class="nav-item clickable white-text medium-text left-text">THE VEGAN REPOSITORY</h5>
  83. </a>
  84. <a href="http://www.w3schools.com" >
  85. <h5 (click)="clicked()" id="sign-in-button" class="nav-item clickable brand-colour-text medium-text right-text with-border">SIGN UP FREE</h5>
  86. </a>
  87. <a href="http://www.w3schools.com" >
  88. <h5 class="nav-item clickable white-text medium-text right-text">LOGIN</h5>
  89. </a>
  90. <a href="#home_page_footer" >
  91. <h5 class="nav-item clickable white-text medium-text right-text" >BLOG</h5>
  92. </a>
  93. <a href="#home_page_footer" >
  94. <h5 class="nav-item clickable white-text medium-text right-text" >ABOUT</h5>
  95. </a>
  96. </div>
  97. <div id="motto-text" class="vertical-center">
  98. <h5 class="white-text medium-text">THE VEGAN REPOSITORY</h5>
  99. <h1 id="main-text" class=" text-center white-text light-text extra-large-text">FIND VEGAN PRODUCTS NEAR YOU</h1>
  100. <a id="try-now-button" class="with-border clickable" href="#find-vegan-products-page" >
  101. <h5 class=" text-center medium-text">TRY NOW</h5>
  102. </a>
  103. </div>
  104. </div>
  105. <!--[if lt IE 9]>
  106. <script>
  107. document.createElement('video');
  108. </script>
  109. <![endif]-->
  110. <div id="find-vegan-products-page" style="height:900px;">
  111. <div class="form-background">
  112. <div class="container-fluid" style="padding: 40px;">
  113. <h1>Filter Your Search!</h1>
  114. <form role="form">
  115. <div class="row">
  116. <div class="form-group col-sm-6">
  117. <div class="select">
  118. <span class="arr"></span>
  119. <select data-bind="options: _countries,
  120. optionsText: 'name',
  121. optionsValue: 'geonameId',
  122. value: selectedCountry,
  123. optionsCaption: 'Country'">
  124. </select>
  125. </div>
  126. </div>
  127. <div class="form-group col-sm-6">
  128. <div class="select">
  129. <span class="arr"></span>
  130. <select data-bind="options: _regions,
  131. optionsText: 'name',
  132. optionsValue: 'name',
  133. value: selectedCity,
  134. optionsCaption: 'Region'">
  135. </select>
  136. </div>
  137. </div>
  138. </div>
  139. </form>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. <div id='container'>
  145. <div>always showing</div>
  146. <div id='loading' data-bind="visible: isLoading">Loading...</div>
  147. </div>
  148. <div>
  149. <button data-bind="click: loadData">Simulate Load
  150. </div>
  151. </div>
  152. <script src="scripts/scroll_to_anchor.js"></script>
  153. <script src="scripts/xml2json.min.js"></script>
  154. <script src="scripts/country.js"></script>
  155. </body>
  156. </html>
  157.  
  158. class HomeViewModel {
  159. _countriesList = [];
  160. _regionsList = [];
  161. _countries = ko.observableArray();
  162. _regions = ko.observableArray();
  163. selectedCountry = ko.observable();
  164.  
  165. constructor(allCountries) {
  166. for (var index = 0; index < allCountries.length; index++) {
  167. this._countriesList.push(allCountries[index]);
  168. }
  169. this._countries(this._countriesList);
  170. this.selectedCountry.subscribe(this.updateCities.bind(this))
  171. }
  172.  
  173. updateCities(geonameId) {
  174. var self = this;
  175. self._regionsList = [];
  176. $.ajax({
  177. url: `http://api.geonames.org/children?geonameId=${geonameId}&username=elion`
  178. }).then(function(allCitiesXML) {
  179. var allCitiesJSON = xml2json(allCitiesXML);
  180. var allCities = JSON.parse(allCitiesJSON);
  181. for (var index = 1; index < allCities.geonames.length - 1; index++) {
  182. self._regionsList.push(allCities.geonames[index].geoname);
  183. }
  184. self._regions(self._regionsList);
  185. });
  186. }
  187. }
  188.  
  189. $(document).ready(function() {
  190. var _homeViewModel: HomeViewModel = new HomeViewModel(allCountries);
  191. ko.applyBindings(_homeViewModel);
  192. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement