Add ability to generate deeplinks URL for chart
This commit is contained in:
parent
be4678eab1
commit
7df594f22a
@ -41,6 +41,15 @@
|
|||||||
<option value="all">All Available</option>
|
<option value="all">All Available</option>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
|
<div class="tooltip">
|
||||||
|
<button id="copyURLButton">
|
||||||
|
<span class="tooltiptext" id="urlTooltip">Copy to clipboard</span>
|
||||||
|
Copy URL to this Chart
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<details id="advanced">
|
||||||
|
<summary>Advanced Options</summary>
|
||||||
<p>
|
<p>
|
||||||
<label for="aggregate">Aggregate Function:</label>
|
<label for="aggregate">Aggregate Function:</label>
|
||||||
<select name="aggregate" id="aggregate">
|
<select name="aggregate" id="aggregate">
|
||||||
@ -53,7 +62,8 @@
|
|||||||
<option id='agg_wavg' value="weekly_mean" disabled>Weekly Average</option>
|
<option id='agg_wavg' value="weekly_mean" disabled>Weekly Average</option>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
<em>More coming soon™</em>
|
||||||
|
</details>
|
||||||
<details id="about">
|
<details id="about">
|
||||||
<summary>About this Site</summary>
|
<summary>About this Site</summary>
|
||||||
This is a site developed to track the value of the World of Warcraft Token from various
|
This is a site developed to track the value of the World of Warcraft Token from various
|
||||||
|
38
src/index.js
38
src/index.js
@ -203,6 +203,7 @@ function formatToken() {
|
|||||||
function detectRegionQuery(urlSearchParams) {
|
function detectRegionQuery(urlSearchParams) {
|
||||||
const validRegions = ['us', 'eu', 'tw', 'kr'];
|
const validRegions = ['us', 'eu', 'tw', 'kr'];
|
||||||
if (validRegions.includes(urlSearchParams.get('region').toLowerCase())) {
|
if (validRegions.includes(urlSearchParams.get('region').toLowerCase())) {
|
||||||
|
currentRegionSelection = urlSearchParams.get('region').toLowerCase();
|
||||||
let regionDDL = document.getElementById('region');
|
let regionDDL = document.getElementById('region');
|
||||||
for (let i = 0; i < regionDDL.options.length; i++) {
|
for (let i = 0; i < regionDDL.options.length; i++) {
|
||||||
if (regionDDL.options[i].value === currentRegionSelection) {
|
if (regionDDL.options[i].value === currentRegionSelection) {
|
||||||
@ -261,6 +262,37 @@ function detectURLQuery() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildDeepLinksURL() {
|
||||||
|
let url = "https://wowtoken.app/?"
|
||||||
|
if (currentTimeSelection !== '72h'){
|
||||||
|
url += `time=${currentTimeSelection}&`
|
||||||
|
}
|
||||||
|
if (currentRegionSelection !== 'us'){
|
||||||
|
url += `region=${currentRegionSelection}&`
|
||||||
|
}
|
||||||
|
if (currentAggregateSelection !== '' && currentAggregateSelection !== 'none'){
|
||||||
|
url += `aggregate=${currentAggregateSelection}`
|
||||||
|
}
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyURL() {
|
||||||
|
let toolTip = document.getElementById('urlTooltip');
|
||||||
|
navigator.clipboard.writeText(buildDeepLinksURL()).then(
|
||||||
|
() => {
|
||||||
|
toolTip.innerHTML= "Copied the URL";
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
toolTip.innerHTML = "Unable to copy URL to clipboard";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toolTipMouseOut() {
|
||||||
|
let tooltip = document.getElementById("urlTooltip");
|
||||||
|
tooltip.innerHTML = "Copy to clipboard";
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
document.getElementById('region').addEventListener('change', function() {
|
document.getElementById('region').addEventListener('change', function() {
|
||||||
updateRegionPreference(this.value);
|
updateRegionPreference(this.value);
|
||||||
@ -273,6 +305,12 @@ $(document).ready(function() {
|
|||||||
document.getElementById('aggregate').addEventListener('change', function () {
|
document.getElementById('aggregate').addEventListener('change', function () {
|
||||||
updateAggregatePreference(this.value);
|
updateAggregatePreference(this.value);
|
||||||
})
|
})
|
||||||
|
document.getElementById('copyURLButton').addEventListener('click', function (event) {
|
||||||
|
copyURL();
|
||||||
|
})
|
||||||
|
document.getElementById('copyURLButton').addEventListener('mouseout', function (event) {
|
||||||
|
toolTipMouseOut();
|
||||||
|
})
|
||||||
currentAggregateSelection = document.getElementById('aggregate').value;
|
currentAggregateSelection = document.getElementById('aggregate').value;
|
||||||
detectURLQuery();
|
detectURLQuery();
|
||||||
Promise.all([callUpdateURL(), pullChartData()]).then(populateChart)
|
Promise.all([callUpdateURL(), pullChartData()]).then(populateChart)
|
||||||
|
@ -395,6 +395,44 @@ details[open] summary {
|
|||||||
.lds-ripple div:nth-child(2) {
|
.lds-ripple div:nth-child(2) {
|
||||||
animation-delay: -0.5s;
|
animation-delay: -0.5s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tooltip {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip .tooltiptext {
|
||||||
|
visibility: hidden;
|
||||||
|
width: 280px;
|
||||||
|
background-color: #555;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 5px;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
|
bottom: 80%;
|
||||||
|
left: -15%;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip .tooltiptext::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 50%;
|
||||||
|
margin-left: -5px;
|
||||||
|
border-width: 5px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #555 transparent transparent transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip:hover .tooltiptext {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes lds-ripple {
|
@keyframes lds-ripple {
|
||||||
0% {
|
0% {
|
||||||
top: 36px;
|
top: 36px;
|
||||||
|
Loading…
Reference in New Issue
Block a user