Advertisement
Misipuk

home_old5

Jul 20th, 2021
1,165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. });
  13.  
  14.  
  15. async function load_hv_table() {
  16.     const res = await wixData.query('hv_data').find();
  17.     //var json = JSON.parse(res.items[0]["jsondata"])
  18.     console.log(res.items)
  19.     var json = JSON.parse(res.items[0]["jsondata"])
  20.     console.log(json)
  21.     //console.log(Object.keys(json[0]))
  22.     //await wixData.insert("temp", json[0])
  23.  
  24.     var cols = []
  25.     Object.keys(json[0]).forEach(key => {
  26.         if (key[0] != "_")
  27.             cols.push({
  28.                 "id": key.toString(),
  29.                 "label": key.toString(),
  30.                 "dataPath": key.toString(),
  31.                 // "width": 100,
  32.                 // "visible": true,
  33.                 // "type": "string"
  34.             })
  35.     })
  36.  
  37.    
  38.     console.log(cols)
  39.     $w("#table1").columns = cols;
  40.     //console.log($w("#table1").columns);
  41.     $w('#table1').rows = json;
  42. }
  43.  
  44. async function load_opt_price(id) {
  45.     var t0 = performance.now()
  46.     const res = await wixData.query('opt_data').ascending("title").find();
  47.     var t1 = performance.now()
  48.     console.log("Query took " + (t1 - t0) + " milliseconds.")
  49.  
  50.     var json = JSON.parse(res.items[id]["call1"])
  51.     //console.log(json)
  52.     //console.log(Object.keys(json[0]))
  53.     //await wixData.insert("temp", json[0])
  54.  
  55.     let cols = []
  56.     Object.keys(json[id]).forEach(key => {
  57.         if (key[0] != "_")
  58.             cols.push({
  59.                 "id": key.toString(),
  60.                 "label": key.toString(),
  61.                 "dataPath": key.toString(),
  62.             })
  63.     })
  64.     $w("#table1").columns = cols;
  65.     //console.log($w("#table1").columns);
  66.     $w('#table1').rows = json;
  67. }
  68.  
  69.  
  70. async function loadData() {
  71.     const res = await wixData.query('Data').limit(200).find();
  72.     const data = res.items;
  73.     //$w('#table2').rows = data;
  74. }
  75.  
  76. export function dropdown1_change(event) {
  77.     let newDropdownIndex = event.target.value;
  78.     load_opt_price(newDropdownIndex)
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement