Compare commits

...

7 Commits

12 changed files with 898 additions and 876 deletions

465
composer.lock generated

File diff suppressed because it is too large Load Diff

1151
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -19,5 +19,8 @@
"sass": "^1.56.1", "sass": "^1.56.1",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"vite": "^3.2.3" "vite": "^3.2.3"
},
"dependencies": {
"moment": "^2.29.4"
} }
} }

File diff suppressed because one or more lines are too long

44
public/build/assets/app.f51a693a.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"resources/js/app.js": { "resources/js/app.js": {
"file": "assets/app.0299f74e.js", "file": "assets/app.f51a693a.js",
"src": "resources/js/app.js", "src": "resources/js/app.js",
"isEntry": true "isEntry": true
}, },

View File

BIN
public/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

52
resources/js/app.js vendored
View File

@ -6,6 +6,7 @@
*/ */
import './bootstrap'; import './bootstrap';
import moment from "moment";
// window.Vue = require('vue'); // window.Vue = require('vue');
@ -20,3 +21,54 @@ import './bootstrap';
// const app = new Vue({ // const app = new Vue({
// el: '#app' // el: '#app'
// }); // });
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);
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);
/**
* 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();
}
});

View File

@ -1,6 +1,7 @@
@if ($item->used_by == \Auth::id()) @if ($item->used_by == \Auth::id())
<form action="/take" method="POST" class="form-inline"> <form action="/take" method="POST" class="form-inline">
<em class="pr-sm-2 ml-auto">{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}}</em> <em id="itemPassedTime_{{$item->id}}" class="pr-sm-2 ml-auto">{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}}</em>
<div hidden class="takenItemDate" id="{{$item->id}}">{{\Carbon\Carbon::parse($item->updated_at)->format('Y-m-d\TH:i:s.uP')}}</div>
<div class="w-100 d-xm-block d-sm-none"></div> <div class="w-100 d-xm-block d-sm-none"></div>
{{ csrf_field() }} {{ csrf_field() }}
@method('DELETE') @method('DELETE')
@ -16,8 +17,9 @@
@if ($item->waiting_user_id && $item->waiting_user_id != \Auth::id()) @if ($item->waiting_user_id && $item->waiting_user_id != \Auth::id())
<strong>> {{str_limit($users[$item->waiting_user_id], 15, '...')}}</strong> <strong>> {{str_limit($users[$item->waiting_user_id], 15, '...')}}</strong>
@endif @endif
<small>({{$item->updated_at->diffForHumans()}})</small> <small id="itemPassedTime_{{$item->id}}">({{$item->updated_at->diffForHumans()}})</small>
</em> </em>
<div hidden class="takenItemDate" id="{{$item->id}}">{{$item->updated_at->format('Y-m-d\TH:i:s.uP')}}</div>
<div class="w-100 d-xm-block d-sm-none"></div> <div class="w-100 d-xm-block d-sm-none"></div>
{{ csrf_field() }} {{ csrf_field() }}
<input type="hidden" name="item" value="{{$item->id}}"> <input type="hidden" name="item" value="{{$item->id}}">

View File

@ -19,9 +19,12 @@
<!-- Styles --> <!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet"> <link href="{{ asset('css/app.css') }}" rel="stylesheet">
<link id="favicon" rel="icon" type="image/png" href="favicon.png" />
</head> </head>
<body> <body>
<div hidden id="usedItems">{{ isset($usedItems) && $usedItems > 0 ? $usedItems : '' }}</div>
<div id="app"> <div id="app">
<nav class="navbar navbar-expand-md navbar-light navbar-laravel"> <nav class="navbar navbar-expand-md navbar-light navbar-laravel">
<div class="container"> <div class="container">

View File

@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Share It</title> <title>Share It</title>
<link id="favicon" rel="icon" type="image/png" href="favicon.png" />
<!-- Fonts --> <!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet" type="text/css">