Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wixData from 'wix-data';
- import wixFetch from 'wix-fetch';
- $w.onReady(function () {
- //load_hv_table()
- /*var names = {
- 0: "BTC",
- 1: "ETH"
- }*/
- let dropdownIndex = $w("#dropdown1").selectedIndex;
- load_opt_price(dropdownIndex)
- });
- async function load_hv_table() {
- const res = await wixData.query('hv_data').find();
- //var json = JSON.parse(res.items[0]["jsondata"])
- console.log(res.items)
- var json = JSON.parse(res.items[0]["jsondata"])
- console.log(json)
- //console.log(Object.keys(json[0]))
- //await wixData.insert("temp", json[0])
- var cols = []
- Object.keys(json[0]).forEach(key => {
- if (key[0] != "_")
- cols.push({
- "id": key.toString(),
- "label": key.toString(),
- "dataPath": key.toString(),
- // "width": 100,
- // "visible": true,
- // "type": "string"
- })
- })
- console.log(cols)
- $w("#table1").columns = cols;
- //console.log($w("#table1").columns);
- $w('#table1').rows = json;
- }
- async function load_opt_price(id) {
- var t0 = performance.now()
- const res = await wixData.query('opt_data').ascending("title").find();
- var t1 = performance.now()
- console.log("Query took " + (t1 - t0) + " milliseconds.")
- var json = JSON.parse(res.items[id]["call1"])
- //console.log(json)
- //console.log(Object.keys(json[0]))
- //await wixData.insert("temp", json[0])
- let cols = []
- Object.keys(json[id]).forEach(key => {
- if (key[0] != "_")
- cols.push({
- "id": key.toString(),
- "label": key.toString(),
- "dataPath": key.toString(),
- })
- })
- $w("#table1").columns = cols;
- //console.log($w("#table1").columns);
- $w('#table1').rows = json;
- }
- async function loadData() {
- const res = await wixData.query('Data').limit(200).find();
- const data = res.items;
- //$w('#table2').rows = data;
- }
- export function dropdown1_change(event) {
- let newDropdownIndex = event.target.value;
- load_opt_price(newDropdownIndex)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement