Skip to content

Instantly share code, notes, and snippets.

@surdaft
Created April 22, 2018 12:47
Show Gist options
  • Save surdaft/9726f127ce8eb414588d5850f6e08d56 to your computer and use it in GitHub Desktop.
Save surdaft/9726f127ce8eb414588d5850f6e08d56 to your computer and use it in GitHub Desktop.
For Above Infinity ECO event
(function() {
let newElement = document.createElement('div');
newElement.innerHTML = `<div><div class="bar-container">
<div class="progress-bar-outer">
<div class="progress-bar-inner">
<span class="progress" id="output" data-goal="0">£0 / £500 (0.00%)</span>
</div>
</div>
</div>
<style>
@import url('https://fonts.googleapis.com/css?family=Oxygen:300,700');
* {
box-sizing: border-box;
}
.bar-container {
padding: 20px;
background: rgb(12, 58, 102);
border-radius: 8px;
box-shadow: inset 0 0 20px 4px rgba(255, 255, 255, 0.15);
}
.bar-container .progress-bar-outer {
box-shadow: 0 0 20px 5px rgba(0, 0, 0, 0.1);
border-radius: 50px;
position: relative;
background: rgba(0, 0, 0, 0.3);
}
.bar-container .progress-bar-inner {
background: rgb(255,215,0);
border-radius: 50px;
box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.7);
display: flex;
flex-direction: row;
width: 0%;
height: 40px;
overflow: hidden;
transition: width .5s ease-out;
}
.bar-container .progress-bar-inner .progress {
flex: 0;
margin: 0 auto;
display: inline-block;
white-space: nowrap;
font-weight: 700;
font-family: 'Oxygen';
font-size: 16px;
color: white;
text-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style></div>`;
let _output = document.getElementById('output');
_output.replaceWith(newElement.firstElementChild);
let output = document.getElementById('output'),
progressBar = document.querySelector('.bar-container .progress-bar-inner'),
completedSoundEffect = new Audio('http://www.noproblo.dayjo.org/ZeldaSounds/BOTW/BOTW_Get_Item.wav');
setInterval(() => {
if (parseInt(progressBar.style.width.replace('px', '')) !== parseInt(output.dataset.goal)) {
progressBar.style.width = output.dataset.goal + '%';
console.log('Updated progress bar:', output.dataset.goal);
if (parseInt(output.dataset.goal) >= 100) {
completedSoundEffect.play();
}
}
}, 500);
} ());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment