2018-09-07 23:12:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* First we will load all of this project's JavaScript dependencies which
|
|
|
|
* includes Vue and other libraries. It is a great starting point when
|
|
|
|
* building robust, powerful web applications using Vue and Laravel.
|
|
|
|
*/
|
|
|
|
|
2022-11-14 00:04:45 +00:00
|
|
|
import './bootstrap';
|
2022-11-18 00:30:43 +00:00
|
|
|
import moment from "moment";
|
2018-09-07 23:12:34 +00:00
|
|
|
|
2022-11-12 22:00:35 +00:00
|
|
|
// window.Vue = require('vue');
|
2018-09-07 23:12:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Next, we will create a fresh Vue application instance and attach it to
|
|
|
|
* the page. Then, you may begin adding components to this application
|
|
|
|
* or customize the JavaScript scaffolding to fit your unique needs.
|
|
|
|
*/
|
|
|
|
|
2022-11-12 22:00:35 +00:00
|
|
|
// Vue.component('example-component', require('./components/ExampleComponent.vue'));
|
2018-09-07 23:12:34 +00:00
|
|
|
|
2022-11-12 22:00:35 +00:00
|
|
|
// const app = new Vue({
|
|
|
|
// el: '#app'
|
|
|
|
// });
|
2022-11-16 22:22:31 +00:00
|
|
|
|
2022-11-18 00:30:43 +00:00
|
|
|
function updateTime() {
|
|
|
|
var dates = document.getElementsByClassName("takenItemDate");
|
|
|
|
for (let i = 0; i < dates.length; i++) {
|
|
|
|
let time = dates.item(i).innerText;
|
|
|
|
let fromNow = moment(time).fromNow();
|
|
|
|
let id = "itemPassedTime_" + dates.item(i).id;
|
|
|
|
document.getElementById(id).innerText = fromNow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateTime();
|
|
|
|
setInterval(updateTime, 1 * 60 * 1000);
|
|
|
|
|
2022-11-16 22:22:31 +00:00
|
|
|
|
|
|
|
function setFaviconNumber(number) {
|
|
|
|
var canvas = document.createElement('canvas'),
|
|
|
|
ctx,
|
|
|
|
img = document.createElement('img'),
|
|
|
|
link = document.getElementById('favicon').cloneNode(true);
|
|
|
|
|
|
|
|
if (canvas.getContext) {
|
|
|
|
canvas.height = canvas.width = 48; // set the size
|
|
|
|
ctx = canvas.getContext('2d');
|
|
|
|
img.onload = function () { // once the image has loaded
|
|
|
|
ctx.drawImage(this, 0, 0);
|
|
|
|
ctx.font = 'bold 35px "helvetica", sans-serif';
|
|
|
|
ctx.fillStyle = '#ffff66';
|
|
|
|
ctx.fillText(number, 3, 25);
|
|
|
|
link.href = canvas.toDataURL('image/png');
|
|
|
|
document.body.appendChild(link);
|
|
|
|
};
|
|
|
|
img.src = 'favicon.png';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
usedItems = document.getElementById("usedItems").innerText;
|
|
|
|
setFaviconNumber(usedItems);
|
2022-11-18 00:30:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Source:
|
|
|
|
* https://www.designcise.com/web/tutorial/how-to-detect-if-the-browser-tab-is-active-or-not-using-javascript
|
|
|
|
*/
|
|
|
|
document.addEventListener('visibilitychange', function (event) {
|
|
|
|
if (document.hidden) {
|
|
|
|
console.log('not visible');
|
|
|
|
} else {
|
|
|
|
updateTime();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|