|
13 | 13 | <div>
|
14 | 14 | <h2>Taboule</h2>
|
15 | 15 | <div>
|
| 16 | + <div style="display: inline-block"> |
| 17 | + <div id="taboule-show-inputs" style="display: inline"> |
| 18 | + <label>Show Params Inputs</label> |
| 19 | + <input type="checkbox" checked="true" /> |
| 20 | + </div> |
| 21 | + <div id="taboule-show-as-tabs"> |
| 22 | + <label>Show As Tabbed</label> |
| 23 | + <input type="checkbox" /> |
| 24 | + </div> |
| 25 | + </div> |
| 26 | + |
16 | 27 | <select id="taboule-query-value">
|
17 |
| - <option value="YCAIYCAIccRelatedUsers"> |
| 28 | + <option value="YCAIccRelatedUsers"> |
18 | 29 | YCAI Content creator Related Users
|
19 | 30 | </option>
|
20 |
| - <option value="youtubePersonalSearches"> |
21 |
| - Youtube Personal Searches |
22 |
| - </option> |
23 |
| - <option value="youtubePersonalVideos">Youtube Personal Videos</option> |
24 |
| - <option value="youtubePersonalHomes">Youtube Personal Homes</option> |
25 |
| - <option value="youtubePersonalAds">Youtube Personal ADS</option> |
| 31 | + <option value="youtubePersonalSearches">YT Personal Searches</option> |
| 32 | + <option value="youtubePersonalVideos">YT Personal Videos</option> |
| 33 | + <option value="youtubePersonalHomes">YT Personal Homes</option> |
| 34 | + <option value="youtubePersonalAds">YT Personal ADS</option> |
26 | 35 | <option value="youtubeGetExperimentById">
|
27 |
| - Youtube Compare Experiment |
28 |
| - </option> |
29 |
| - <option value="youtubeGetExperimentList"> |
30 |
| - Youtube Experiment list |
| 36 | + YT Compare Experiment |
31 | 37 | </option>
|
| 38 | + <option value="youtubeGetExperimentList">YT Experiment list</option> |
32 | 39 | <option value="tikTokPersonalHTMLSummary">
|
33 |
| - TikTok Personal HTML Summary |
| 40 | + TK Personal HTML Summary |
34 | 41 | </option>
|
35 | 42 | <option value="tikTokPersonalSearch">
|
36 |
| - TikTok Personal Metadata: search |
| 43 | + TK Personal Metadata: search |
37 | 44 | </option>
|
38 | 45 | <option value="tikTokPersonalNative">
|
39 |
| - TikTok Personal Metadata: native |
40 |
| - </option> |
41 |
| - <option value="tikTokSearches" selected> |
42 |
| - TikTok (Collective) Searches |
| 46 | + TK Personal Metadata: native |
43 | 47 | </option>
|
| 48 | + <option value="tikTokPersonalForYou">TK Personal ForYou</option> |
| 49 | + <option value="tikTokPersonalFollowing">TK Personal Following</option> |
44 | 50 | </select>
|
45 |
| - <div id="taboule-show-inputs" style="display: inline"> |
46 |
| - <label>Show Params Inputs</label> |
47 |
| - <input type="checkbox" checked="true" /> |
48 |
| - </div> |
49 | 51 | </div>
|
50 | 52 | <div id="main"></div>
|
51 | 53 | </div>
|
52 | 54 | </body>
|
53 | 55 | <script type="text/javascript" src="./taboule.js"></script>
|
54 | 56 | <script type="text/javascript">
|
55 |
| - // var baseURL = 'http://localhost:9000/api/'; |
56 |
| - var baseURL = 'http://localhost:14000/api/'; |
| 57 | + var baseURL = 'http://localhost:9000/api/'; |
| 58 | + // var baseURL = 'http://localhost:14000/api/'; |
57 | 59 | // var baseURL = 'https://tiktok.tracking.exposed/api/';
|
58 | 60 | // var baseURL = 'https://youtube.tracking.exposed/api/';
|
59 | 61 |
|
60 | 62 | const querySelect = document.querySelector('#taboule-query-value');
|
61 | 63 | const showInputCheckbox = document.querySelector(
|
62 | 64 | '#taboule-show-inputs input'
|
63 | 65 | );
|
| 66 | + const showsAsTabInput = document.querySelector( |
| 67 | + '#taboule-show-as-tabs input' |
| 68 | + ); |
64 | 69 |
|
65 |
| - const runTaboule = (query, showInput = false) => { |
| 70 | + const getSelectedQueries = () => { |
| 71 | + const els = querySelect.querySelectorAll('option:checked'); |
| 72 | + return Array.from(els).map((el) => ({ |
| 73 | + value: el.value, |
| 74 | + label: el.innerHTML, |
| 75 | + })); |
| 76 | + }; |
| 77 | + |
| 78 | + const runTaboule = (queries, showInput = false) => { |
66 | 79 | window.Taboule({
|
67 | 80 | showInput: showInput,
|
68 | 81 | node: document.getElementById('main'),
|
69 | 82 | baseURL: baseURL,
|
70 |
| - query: query, |
71 | 83 | pageSize: 25,
|
72 | 84 | initialParams: {
|
73 | 85 | publicKey: 'H7AsuUszehN4qKTj2GYYwNNzkJVqUQBRo2wgKevzeUwx',
|
74 | 86 | },
|
| 87 | + queries, |
75 | 88 | });
|
76 | 89 | };
|
77 | 90 |
|
| 91 | + querySelect.setAttribute('multiple', 'true'); |
| 92 | + showsAsTabInput.setAttribute('checked', 'true'); |
| 93 | + |
78 | 94 | querySelect.addEventListener('change', (e) => {
|
79 |
| - runTaboule( |
80 |
| - e.target.value, |
81 |
| - showInputCheckbox.getAttribute('checked') === 'true' |
82 |
| - ); |
| 95 | + const values = getSelectedQueries(); |
| 96 | + runTaboule(values, showInputCheckbox.getAttribute('checked') === 'true'); |
83 | 97 | });
|
84 | 98 |
|
85 | 99 | showInputCheckbox.addEventListener('change', (e) => {
|
86 | 100 | const isChecked = e.currentTarget.getAttribute('checked') === 'true';
|
87 | 101 | e.currentTarget.setAttribute('checked', isChecked ? 'false' : 'true');
|
88 |
| - runTaboule(querySelect.value, !isChecked); |
| 102 | + runTaboule(getSelectedQueries(), !isChecked); |
| 103 | + }); |
| 104 | + |
| 105 | + showsAsTabInput.addEventListener('change', (e) => { |
| 106 | + let isChecked = e.currentTarget.getAttribute('checked') === 'true'; |
| 107 | + e.currentTarget.setAttribute('checked', isChecked ? 'false' : 'true'); |
| 108 | + isChecked = e.currentTarget.getAttribute('checked') === 'true'; |
| 109 | + if (isChecked) { |
| 110 | + querySelect.setAttribute('multiple', 'true'); |
| 111 | + } else { |
| 112 | + querySelect.removeAttribute('multiple'); |
| 113 | + } |
89 | 114 | });
|
90 | 115 |
|
91 | 116 | console.log(
|
92 | 117 | 'show input checked?',
|
93 | 118 | showInputCheckbox.getAttribute('checked')
|
94 | 119 | );
|
95 |
| - runTaboule( |
96 |
| - querySelect.value, |
97 |
| - showInputCheckbox.getAttribute('checked') === 'true' |
98 |
| - ); |
| 120 | + |
| 121 | + console.log('show tabs?', showsAsTabInput.getAttribute('checked')); |
| 122 | + |
| 123 | + ['youtubePersonalSearches', 'youtubePersonalVideos'].forEach((v) => { |
| 124 | + const option = querySelect.querySelector(`option[value="${v}"]`); |
| 125 | + option?.setAttribute('checked', 'true'); |
| 126 | + }); |
| 127 | + |
| 128 | + setTimeout(() => { |
| 129 | + runTaboule( |
| 130 | + getSelectedQueries(), |
| 131 | + showInputCheckbox.getAttribute('checked') === 'true' |
| 132 | + ); |
| 133 | + }, 1000); |
99 | 134 | </script>
|
100 | 135 | </html>
|
0 commit comments