Advertisement
Misipuk

home_old7

Jul 20th, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. import wixData from 'wix-data';
  2. import wixFetch from 'wix-fetch';
  3.  
  4. $w.onReady(function () {
  5. //load_hv_table()
  6. /*var names = {
  7. 0: "BTC",
  8. 1: "ETH"
  9. }*/
  10. let dropdownIndex = $w("#dropdown1").selectedIndex;
  11. // load_opt_price(dropdownIndex)
  12. //load_corr_table()
  13. load_tv_table()
  14. });
  15.  
  16.  
  17. async function load_hv_table() {
  18. const res = await wixData.query('hv_data').find();
  19. //var json = JSON.parse(res.items[0]["jsondata"])
  20. console.log(res.items)
  21. var json = JSON.parse(res.items[0]["jsondata"])
  22. console.log(json)
  23. //console.log(Object.keys(json[0]))
  24. //await wixData.insert("temp", json[0])
  25.  
  26. var cols = []
  27. Object.keys(json[0]).forEach(key => {
  28. if (key[0] != "_")
  29. cols.push({
  30. "id": key.toString(),
  31. "label": key.toString(),
  32. "dataPath": key.toString(),
  33. // "width": 100,
  34. // "visible": true,
  35. // "type": "string"
  36. })
  37. })
  38.  
  39.  
  40. console.log(cols)
  41. $w("#table1").columns = cols;
  42. //console.log($w("#table1").columns);
  43. $w('#table1').rows = json;
  44. }
  45.  
  46.  
  47. async function load_corr_table() {
  48. const res = await wixData.query('corr_data').find();
  49. //var json = JSON.parse(res.items[0]["jsondata"])
  50. console.log(res.items)
  51. var json = JSON.parse(res.items[0]["df_hours"])
  52. console.log(json)
  53. //console.log(Object.keys(json[0]))
  54. //await wixData.insert("temp", json[0])
  55.  
  56. var cols = []
  57. Object.keys(json[0]).forEach(key => {
  58. if (key[0] != "_")
  59. cols.push({
  60. "id": key.toString(),
  61. "label": key.toString(),
  62. "dataPath": key.toString(),
  63. // "width": 100,
  64. // "visible": true,
  65. // "type": "string"
  66. })
  67. })
  68.  
  69.  
  70. console.log(cols)
  71. $w("#table1").columns = cols;
  72. //console.log($w("#table1").columns);
  73. $w('#table1').rows = json;
  74. }
  75.  
  76. async function load_tv_table() {
  77. const res = await wixData.query('tv_data').ascending("title").find();
  78. //var json = JSON.parse(res.items[0]["jsondata"])
  79. console.log(res.items)
  80. var json = JSON.parse(res.items[0]["df_tv_10"])
  81. console.log(json)
  82. //console.log(Object.keys(json[0]))
  83. //await wixData.insert("temp", json[0])
  84.  
  85. var cols = []
  86. Object.keys(json[0]).forEach(key => {
  87. if (key[0] != "_")
  88. cols.push({
  89. "id": key.toString(),
  90. "label": key.toString(),
  91. "dataPath": key.toString(),
  92. // "width": 100,
  93. // "visible": true,
  94. // "type": "string"
  95. })
  96. })
  97.  
  98.  
  99. console.log(cols)
  100. $w("#table1").columns = cols;
  101. //console.log($w("#table1").columns);
  102. $w('#table1').rows = json;
  103. }
  104.  
  105. async function load_opt_price(id) {
  106. var t0 = performance.now()
  107. const res = await wixData.query('opt_data').ascending("title").find();
  108. var t1 = performance.now()
  109. console.log("Query took " + (t1 - t0) + " milliseconds.")
  110.  
  111. var json = JSON.parse(res.items[id]["call1"])
  112. //console.log(json)
  113. //console.log(Object.keys(json[0]))
  114. //await wixData.insert("temp", json[0])
  115.  
  116. let cols = []
  117. Object.keys(json[id]).forEach(key => {
  118. if (key[0] != "_")
  119. cols.push({
  120. "id": key.toString(),
  121. "label": key.toString(),
  122. "dataPath": key.toString(),
  123. })
  124. })
  125. $w("#table1").columns = cols;
  126. //console.log($w("#table1").columns);
  127. $w('#table1').rows = json;
  128. }
  129.  
  130.  
  131. async function loadData() {
  132. const res = await wixData.query('Data').limit(200).find();
  133. const data = res.items;
  134. //$w('#table2').rows = data;
  135. }
  136.  
  137. export function dropdown1_change(event) {
  138. let newDropdownIndex = event.target.value;
  139. load_opt_price(newDropdownIndex)
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement