added superexpert mode

This commit is contained in:
Frank Schubert
2024-03-07 15:33:59 +01:00
parent 39478b9fb9
commit 2df2ca22a1
6 changed files with 269 additions and 8 deletions

View File

@@ -7,7 +7,7 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-6 <?=(MFAPPNAME == "devthetool") ? "text-danger" : ""?>">
<span title="<?=MFAPPNAME?>">the tool &copy; <?=date('Y')?></span> <a href="https://www.xinon.at">Xinon GmbH</a>
<span title="<?=MFAPPNAME?>">the to<span class="secondO">o</span>l &copy; <?=date('Y')?></span> <a href="https://www.xinon.at">Xinon GmbH</a>
</div>
</div>
@@ -36,6 +36,111 @@
$(this).parent('li').toggleClass('open').find('.submenu:first').toggleClass('open');
}
});
<?php if($me->can("Superexpert")): ?>
$(".secondO").addClass("pointer");
var se_to = 0;
var se_intv;
var se_notf;
$(".footer .secondO").click(function() {
if(!se_to) {
$.post("<?=self::getUrl("User", "api")?>",{
do: "sse"
},
function(success) {
if(!("status" in success)) return;
if(success.status == "OK") {
if(!("result" in success)) return;
if(!("valid_to" in success.result) || !success.result.valid_to) return;
se_to = success.result.valid_to;
addSeMark();
se_intv = setInterval(checkSe, 1000);
location.reload();
}
},
"json");
}
});
function checkSe() {
var now = Math.floor(Date.now() / 1000);
if(!se_to || se_to < 0) {
clearInterval(se_intv);
se_to = null;
$("#se_notf").remove();
removeSeMark();
return;
}
var rest_duration = se_to - now;
if(rest_duration <= 0) {
clearInterval(se_intv);
se_to = null;
$("#se_notf").remove();
removeSeMark();
return;
}
if(rest_duration < 60*5) {
// show notification
if($("#se_notf").length) {
$("#se_notf .time").text(rest_duration);
} else {
var notf_html = $('<div class="fixed-top alert alert-warning mx-4 mt-3" id="se_notf" style="width: 50vh;">Achtung: Noch <span class="time">' + rest_duration +'</span> Sekunden. <a href="#" onclick="extSe()">Jetzt verlängern!</a></div>');
$("body").prepend(notf_html);
}
}
}
function extSe() {
console.log("in ese");
$.post("<?=self::getUrl("User", "api")?>", {
do: "ese"
},
function(success) {
if(!("result" in success)) return;
if(!("valid_to" in success.result) || !success.result.valid_to) return;
se_to = success.result.valid_to;
},
"json"
);
}
function endSe() {
$.post("<?=self::getUrl("User", "api")?>", {
do: "endse"
},
function(success) {
if(!("result" in success)) return;
if(!("valid_to" in success.result)) return;
se_to = success.result.valid_to;
location.reload();
},
"json"
);
}
function addSeMark() {
if(!$("#se-mark").length) {
$("#topbar").append('<li id="SeMark"><a class="nav-link dropdown-toggle text-danger" href="#" role="button" aria-haspopup="false" aria-expanded="false" onclick="endSe(); return false;" title="Beenden"><i class="fas fa-crown"></i></a></li>');
}
}
function removeSeMark() {
$("#SeMark").remove();
}
<?php if($me->superexpertEnabled()): ?>
addSeMark();
if(!se_intv) {
se_to = <?=$me->flags["superexpert_lock_date"]?>;
setInterval(checkSe, 1000);
}
<?php endif; ?>
<?php endif; ?>
</script>
</body>
</html>

View File

@@ -1,7 +1,7 @@
<!-- Topbar Start -->
<div class="navbar-custom">
<div class="container-fluid">
<ul class="list-unstyled topnav-menu float-right mb-0">
<ul class="list-unstyled topnav-menu float-right mb-0" id="topbar">
<li class="dropdown notification-list">
<!-- Mobile menu toggle-->
@@ -14,7 +14,7 @@
</a>
<!-- End mobile menu toggle-->
</li>
<li class="dropdown notification-list">
<a class="nav-link dropdown-toggle" data-toggle="adropdown" href="#" role="button" aria-haspopup="false" aria-expanded="false">
<i class="fe-bell noti-icon"></i>