Advertisement
Guest User

Untitled

a guest
Mar 4th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.31 KB | None | 0 0
  1. // Dom7
  2. var $$ = Dom7;
  3.  
  4. // Framework7 App main instance
  5. var app = new Framework7({
  6. root: "#app", // App root element
  7. id: "io.framework7.testapp", // App bundle ID
  8. name: "Framework7", // App name
  9. theme: "auto", // Automatic theme detection
  10. // App root data
  11. data: function() {
  12. return {
  13. user: {
  14. firstName: "John",
  15. lastName: "Doe"
  16. },
  17. // Demo products for Catalog section
  18. products: [
  19. {
  20. id: "1",
  21. title:
  22. "ੴ ਸਤਿ ਨਾਮੁ ਕਰਤਾ ਪੁਰਖੁ ਨਿਰਭਉ ਨਿਰਵੈਰੁ ਅਕਾਲ ਮੂਰਤਿ ਅਜੂਨੀ ਸੈਭੰ ਗੁਰ ਪ੍ਰਸਾਦਿ ॥",
  23. description:
  24. "One Universal Creator God. The Name Is Truth. Creative Being Personified. No Fear. No Hatred. Image Of The Undying, Beyond Birth, Self-Existent. By Guru's Grace ~"
  25. },
  26. {
  27. id: "2",
  28. title: "॥ ਜਪੁ ॥",
  29. description: 'Name of the Composition, "Jup". Chant And Meditate:'
  30. },
  31. {
  32. id: "3",
  33. title: "ਆਦਿ ਸਚੁ ਜੁਗਾਦਿ ਸਚੁ ॥",
  34. description: "True In The Primal Beginning. True Throughout The Ages."
  35. },
  36. {
  37. id: "4",
  38. title: "ਹੈ ਭੀ ਸਚੁ ਨਾਨਕ ਹੋਸੀ ਭੀ ਸਚੁ ॥੧॥",
  39. description:
  40. "True Here And Now. O Nanak, Forever And Ever True. ||1||"
  41. },
  42. {
  43. id: "5",
  44. title: "ਸੋਚੈ ਸੋਚਿ ਨ ਹੋਵਈ ਜੇ ਸੋਚੀ ਲਖ ਵਾਰ ॥",
  45. description: "Expedita sequi perferendis quod illum pariatur aliquam"
  46. },
  47. {
  48. id: "6",
  49. title: "Apple iPhone 8 Plus",
  50. description: "Velit odit autem modi saepe ratione totam minus"
  51. },
  52. {
  53. id: "7",
  54. title: "Apple iPhone X",
  55. description: "Expedita sequi perferendis quod illum pariatur aliquam"
  56. },
  57. {
  58. id: "8",
  59. title: "Apple iPhone 8 Plus",
  60. description: "Velit odit autem modi saepe ratione totam minus"
  61. },
  62. {
  63. id: "9",
  64. title: "Apple iPhone X",
  65. description: "Expedita sequi perferendis quod illum pariatur aliquam"
  66. },
  67. {
  68. id: "10",
  69. title: "Apple iPhone 8 Plus",
  70. description: "Velit odit autem modi saepe ratione totam minus"
  71. },
  72. {
  73. id: "11",
  74. title: "Apple iPhone X",
  75. description: "Expedita sequi perferendis quod illum pariatur aliquam"
  76. },
  77. {
  78. id: "12",
  79. title: "Apple iPhone 8 Plus",
  80. description: "Velit odit autem modi saepe ratione totam minus"
  81. },
  82. {
  83. id: "13",
  84. title: "Apple iPhone X",
  85. description: "Expedita sequi perferendis quod illum pariatur aliquam"
  86. },
  87. {
  88. id: "14",
  89. title: "Apple iPhone 8 Plus",
  90. description: "Velit odit autem modi saepe ratione totam minus"
  91. },
  92. {
  93. id: "15",
  94. title: "Apple iPhone X",
  95. description: "Expedita sequi perferendis quod illum pariatur aliquam"
  96. },
  97. {
  98. id: "16",
  99. title: "Apple iPhone 8 Plus",
  100. description: "Velit odit autem modi saepe ratione totam minus"
  101. },
  102. {
  103. id: "17",
  104. title: "Apple iPhone X",
  105. description: "Expedita sequi perferendis quod illum pariatur aliquam"
  106. },
  107. {
  108. id: "18",
  109. title: "Apple iPhone 8 Plus",
  110. description: "Velit odit autem modi saepe ratione totam minus"
  111. },
  112. {
  113. id: "19",
  114. title: "Apple iPhone X",
  115. description: "Expedita sequi perferendis quod illum pariatur aliquam"
  116. },
  117. {
  118. id: "20",
  119. title: "Apple iPhone X",
  120. description: "Expedita sequi perferendis quod illum pariatur aliquam"
  121. }
  122. ]
  123. };
  124. },
  125. // App root methods
  126. methods: {
  127. helloWorld: function() {
  128. app.dialog.alert("Hello World!");
  129. }
  130. },
  131. // App routes
  132. routes: routes
  133. });
  134.  
  135. // Init/Create views
  136. var homeView = app.views.create("#view-home", {
  137. url: "/"
  138. });
  139. var catalogView = app.views.create("#view-catalog", {
  140. url: "/catalog/"
  141. });
  142. var settingsView = app.views.create("#view-settings", {
  143. url: "/settings/"
  144. });
  145.  
  146. // Login Screen Demo
  147. $$("#my-login-screen .login-button").on("click", function() {
  148. var username = $$('#my-login-screen [name="username"]').val();
  149. var password = $$('#my-login-screen [name="password"]').val();
  150.  
  151. // Close login screen
  152. app.loginScreen.close("#my-login-screen");
  153.  
  154. // Alert username and password
  155. app.dialog.alert("Username: " + username + "<br>Password: " + password);
  156. });
  157.  
  158. // Virtual list
  159. var test = [];
  160. var items = [];
  161.  
  162. app.request.json("js/shabads.json", function(data) {
  163. console.log(data);
  164.  
  165. for (itm in data) {
  166. // console.log(data[itm].id);
  167. test.push(data[itm]);
  168. }
  169. for (var iD = 0; iD <= 9; iD++) {
  170. // console.log(iD);
  171.  
  172. items.push({
  173. title: data.gurbani[iD].shabad.gurbani.unicode,
  174. subtitle: data.gurbani[iD].shabad.translation.english.ssk
  175. });
  176. console.log(items);
  177. }
  178. virtualList = app.virtualList.create({
  179. // List Element
  180. el: ".virtual-list",
  181. // Pass array with items
  182. items: items,
  183. // Custom search function for searchbar
  184. searchAll: function(query, items) {
  185. var found = [];
  186. for (var i = 0; i < items.length; i++) {
  187. if (
  188. items[i].title.toLowerCase().indexOf(query.toLowerCase()) >= 0 ||
  189. query.trim() === ""
  190. )
  191. found.push(i);
  192. }
  193. return found; //return array with matched indexes
  194. },
  195. // List item Template7 template
  196. itemTemplate:
  197. "<li>" +
  198. '<a href="#" class="item-link item-content">' +
  199. '<div class="item-inner">' +
  200. '<div class="item-title-row">' +
  201. '<div class="item-title">{{gurbani}}</div>' +
  202. "</div>" +
  203. '<div class="item-subtitle">{{translation}}</div>' +
  204. "</div>" +
  205. "</a>" +
  206. "</li>",
  207. // Item height
  208. height: app.theme === "ios" ? 63 : 73
  209. });
  210. });
  211.  
  212. // console.log(items);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement