mirror of
https://github.com/KevinMidboe/zoff.git
synced 2026-03-02 21:29:32 +00:00
Added url for applying for api-tokens
This commit is contained in:
@@ -30,17 +30,21 @@ $(document).on("click", "#refresh_all", function(e){
|
||||
}
|
||||
$(".header-api-fields").removeClass("hide");
|
||||
for(var i = 0; i < response.length; i++) {
|
||||
var to_add = api_token_list;
|
||||
var to_add = api_token_list.clone();
|
||||
to_add.find(".api_token_limit").val(response[i].limit);
|
||||
to_add.attr("id", response[i]._id);
|
||||
to_add.find(".api_token_name").text(response[i].name);
|
||||
to_add.find(".api_token_usage").text(response[i].usage);
|
||||
to_add.find(".api_token_limit").attr("id", response[i]._id + "-limit");
|
||||
to_add.find("#delete_api_token").attr("data-id", response[i]._id);
|
||||
to_add.find("#update_api_token").attr("data-id", response[i]._id);
|
||||
$(".channel_things").append(to_add);
|
||||
}
|
||||
},
|
||||
error: function(err) {
|
||||
}
|
||||
});
|
||||
|
||||
if(!$(".channel_things").hasClass("hide")) {
|
||||
$(".channel_things").addClass("hide")
|
||||
}
|
||||
@@ -116,11 +120,39 @@ if(!$(".channel_things").hasClass("hide")) {
|
||||
}
|
||||
$(".preloader-wrapper").removeClass("hide");
|
||||
|
||||
$(document).on("click", "#update_api_token", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var id = $(this).attr("data-id");
|
||||
var limit = $("#" + id + "-limit").val();
|
||||
var that = this;
|
||||
$(that).toggleClass("disabled");
|
||||
$("#delete_api_token").toggleClass("disabled");
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: "api/api_token",
|
||||
data: {
|
||||
id: id,
|
||||
limit: limit,
|
||||
},
|
||||
success: function(response) {
|
||||
if(response == "OK") {
|
||||
Materialize.toast("Updated limit!", 2000, "green lighten");
|
||||
} else {
|
||||
Materialize.toast("Something went wrong...", 2000, "red lighten");
|
||||
}
|
||||
$(that).toggleClass("disabled");
|
||||
$("#delete_api_token").toggleClass("disabled");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#delete_api_token", function(e) {
|
||||
e.preventDefault();
|
||||
var id = $(this).attr("data-id");
|
||||
var that = this;
|
||||
$(that).toggleClass("disabled");
|
||||
$("#update_api_token").toggleClass("disabled");
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "api/api_token",
|
||||
@@ -134,6 +166,7 @@ $(document).on("click", "#delete_api_token", function(e) {
|
||||
} else {
|
||||
Materialize.toast("Something went wrong...", 2000, "red lighten");
|
||||
$(that).toggleClass("disabled");
|
||||
$("#update_api_token").toggleClass("disabled");
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -153,10 +186,13 @@ function loaded() {
|
||||
$(".header-api-fields").removeClass("hide");
|
||||
for(var i = 0; i < response.length; i++) {
|
||||
var to_add = api_token_list.clone();
|
||||
to_add.find(".api_token_limit").val(response[i].limit);
|
||||
to_add.attr("id", response[i]._id);
|
||||
to_add.find(".api_token_name").text(response[i].name);
|
||||
to_add.find(".api_token_usage").text(response[i].usage);
|
||||
to_add.find(".api_token_limit").attr("id", response[i]._id + "-limit");
|
||||
to_add.find("#delete_api_token").attr("data-id", response[i]._id);
|
||||
to_add.find("#update_api_token").attr("data-id", response[i]._id);
|
||||
$(".channel_things").append(to_add);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -91,6 +91,27 @@ body {
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.token-container {
|
||||
padding-top: 64px;
|
||||
}
|
||||
|
||||
.token-form {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.full-form-token {
|
||||
background: rgba(0,0,0,.5);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.center-loader-token {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#send-loader {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
@@ -405,6 +426,10 @@ li.disabled span {
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
.auto-pointer {
|
||||
cursor: auto !important;
|
||||
}
|
||||
|
||||
#chatchannel li:nth-child(even), #chatall li:nth-child(even) {
|
||||
background: rgba(0,0,0,.1);
|
||||
}
|
||||
|
||||
1
server/public/assets/dist/token.min.js
vendored
Normal file
1
server/public/assets/dist/token.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(){$(document).ready(function(){$("#about").modal(),$(".help-button-footer").hide(),$("#contact").modal(),$("#contact-container").empty(),$("#contact-container").html("Send a mail to us: <a title='Open in client' href='mailto:contact@zoff.me?Subject=Contact%20Zoff'>contact@zoff.me</a>"),$("#submit-contact-form").hide(),$(".token-form").on("submit",function(e){e.preventDefault();var t=$("#email_address").val();$("#email_address").attr("readonly",!0),$(".submit").toggleClass("disabled"),$(".full-form-token").removeClass("hide");var a=grecaptcha.getResponse();$.ajax({type:"POST",url:"/api/apply",data:{email:t,"g-recaptcha-response":a},success:function(e){$(".full-form-token").addClass("hide"),"OK"!=e?($("#email_address").attr("readonly",!0),$(".submit").toggleClass("disabled"),Materialize.toast("Couldn't send email.",3e3,"red lighten")):(Materialize.toast("Email sent!",3e3,"green lighten"),grecaptcha.reset())},error:function(e){$(".full-form-token").addClass("hide"),$("#email_address").attr("readonly",!1),$(".submit").toggleClass("disabled")}})}),$("#submit-contact-form").on("click",function(e){e.preventDefault(),$("#contact-form").submit()})});Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var e=0,t=this.length;e<t;e++)this[e]&&this[e].parentElement&&this[e].parentElement.removeChild(this[e])},String.prototype.startsWith=function(e,t){return t=t||0,this.indexOf(e,t)===t}}();
|
||||
@@ -213,7 +213,7 @@ var Player = {
|
||||
"New state\nState: ",
|
||||
newState
|
||||
]);
|
||||
if(player.getCurrentTime() > startTime + Player.np.start && !fix_too_far) {
|
||||
if(player.getCurrentTime() > startTime + Player.np.start && !fix_too_far && autoplay) {
|
||||
Player.seekTo(seekTo);
|
||||
Player.playVideo();
|
||||
fix_too_far = true;
|
||||
|
||||
47
server/public/assets/js/token_apply.js
Normal file
47
server/public/assets/js/token_apply.js
Normal file
@@ -0,0 +1,47 @@
|
||||
$(document).ready(function() {
|
||||
$("#about").modal();
|
||||
$(".help-button-footer").hide();
|
||||
$("#contact").modal();
|
||||
|
||||
$("#contact-container").empty();
|
||||
$("#contact-container").html("Send a mail to us: <a title='Open in client' href='mailto:contact@zoff.me?Subject=Contact%20Zoff'>contact@zoff.me</a>");
|
||||
$("#submit-contact-form").hide();
|
||||
|
||||
$(".token-form").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
var email = $("#email_address").val();
|
||||
$("#email_address").attr("readonly", true);
|
||||
$(".submit").toggleClass("disabled");
|
||||
$(".full-form-token").removeClass("hide");
|
||||
var captcha_response = grecaptcha.getResponse();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/api/apply",
|
||||
data: {
|
||||
email: email,
|
||||
"g-recaptcha-response": captcha_response,
|
||||
},
|
||||
success: function(response) {
|
||||
$(".full-form-token").addClass("hide");
|
||||
if(response != "OK") {
|
||||
$("#email_address").attr("readonly", true);
|
||||
$(".submit").toggleClass("disabled");
|
||||
Materialize.toast("Couldn't send email.", 3000, "red lighten");
|
||||
} else {
|
||||
Materialize.toast("Email sent!", 3000, "green lighten");
|
||||
grecaptcha.reset();
|
||||
}
|
||||
},
|
||||
error: function(response) {
|
||||
$(".full-form-token").addClass("hide");
|
||||
$("#email_address").attr("readonly", false);
|
||||
$(".submit").toggleClass("disabled");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#submit-contact-form').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#contact-form").submit();
|
||||
});
|
||||
});
|
||||
@@ -111,21 +111,24 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row header-api-fields">
|
||||
<div class="col s4">
|
||||
<div class="col s3">
|
||||
Name
|
||||
</div>
|
||||
<div class="col s4">
|
||||
<div class="col s3">
|
||||
Usage
|
||||
</div>
|
||||
<div class="col s1">
|
||||
Limit
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" id="api_token_list">
|
||||
<div class="col s4 api_token_name">
|
||||
<div class="col s3 api_token_name truncate">
|
||||
</div>
|
||||
<div class="col s4 api_token_usage">
|
||||
</div>
|
||||
<div class="col s2">
|
||||
<a href="#" id="delete_api_token" class="btn waves-effect red">REMOVE</a>
|
||||
<div class="col s3 api_token_usage">
|
||||
</div>
|
||||
<input class="api_token_limit col s1" type="number" />
|
||||
<a href="#" id="update_api_token" class="btn waves-effect green col s2">UPDATE</a>
|
||||
<a href="#" id="delete_api_token" class="btn waves-effect red col s1">X</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
72
server/public/layouts/client/token.handlebars
Normal file
72
server/public/layouts/client/token.handlebars
Normal file
@@ -0,0 +1,72 @@
|
||||
<header>
|
||||
<nav id="fp-nav">
|
||||
<div class="nav-wrapper">
|
||||
<a href="#" class="brand-logo">
|
||||
<img class="zicon" src="/assets/images/z.svg" alt="zoff" title="Zoff" />
|
||||
</a>
|
||||
<div id="frontpage-viewer-counter" class="noselect" title="Divided among all channels. Hidden or not"></div>
|
||||
<ul class="right hide-on-med-and-down">
|
||||
<li><a class="header-buttons waves-effect waves-green" title="Remote control a Zoff player" href="https://remote.zoff.me">Remote</a></li>
|
||||
<li><a class="header-buttons modal-trigger waves-effect waves-orange" data-target="about">About</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
{{> modal/about}}
|
||||
<div id="donation" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Thanks!</h4>
|
||||
<p>Thanks for your donation, we love you <3
|
||||
<br><br>
|
||||
We will use the money for something awesome, just you wait and see!
|
||||
<br><br>
|
||||
We might also add your name somewhere in the code as a sign of gratitude, see if you can find it! (Might take a day or two for us to see the donation and implement it..)
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="modal-action modal-close waves-effect waves-green btn-flat">I'm awesome! (Close)</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div id="main-container" class="token-container">
|
||||
<main class="center-align container">
|
||||
<div class="token-info left-align">
|
||||
{{#if activated}}
|
||||
<h1 class="center-align">API-token</h1>
|
||||
<p>Here is your api token</p>
|
||||
<h4 class="select auto-pointer">{{token}}</h3>
|
||||
<p>Use it wisely, and don't lose it!</p>
|
||||
<p>As of now, the tokens have no limit for how many requests you can do is 100 requests a second. If you need a higher limit, just contact the team and we'll set you up for as much as you need.</p>
|
||||
{{else}}
|
||||
<h2 class="center-align">API-token</h2>
|
||||
<p>Apply for a API-token with your email here! You'll get an email on the specified address, with a link. Follow that link, and the token will be shown to you! Take good care of it, and don't lose it. It won't be shown to you again.</p>
|
||||
<p>If you're wondering anything about how the api works, there is a guide on our GitHub. You can also click <a href="https://zoff.me/api/help">HERE</a> to be taken to the detailed README.</p>
|
||||
<p>As of now, the tokens have no limit for how many requests you can do is 100 requests a second. If you need a higher limit, just contact the team and we'll set you up for as much as you need.</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{#if activated}}
|
||||
<iframe id="iframe" src="https://zoff.me/_embed#celebrate&808080" width="600px" height="300px"></iframe>
|
||||
{{else}}
|
||||
<form class="token-form row" type="post">
|
||||
<div class="row center">
|
||||
<div class="input-field col s6 offset-s3">
|
||||
<label for="email_address" class="noselect">Email</label>
|
||||
<input type="email" class="validate" id="email_address" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col offset-s3">
|
||||
{{{captcha}}}
|
||||
</div>
|
||||
<div class="input-field col s12 m2">
|
||||
<input type="submit" class="btn submit" />
|
||||
</div>
|
||||
<div class="full-form-token valign-wrapper hide">
|
||||
<div class="preloader-wrapper medium active center-loader-token">
|
||||
{{> spinner}}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{{/if}}
|
||||
<p>Any lost tokens can easily be deleted by our admins, so just send us an email if something goes awry. Just click the CONTACT button in the footer, and we will be with you as fast as we can!</p>
|
||||
<br>
|
||||
</main>
|
||||
</div>
|
||||
@@ -15,7 +15,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{{{captcha}}}
|
||||
<div class="valign hide" id="send-loader">
|
||||
<div class="valign-wrapper hide" id="send-loader">
|
||||
<div class="preloader-wrapper small active">
|
||||
{{> spinner}}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user