mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Error-reporting over mail also
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
var Helper = {
|
||||
|
||||
logs: [],
|
||||
log: function(to_log) {
|
||||
if(localStorage.debug === "true") {
|
||||
console.log("------------");
|
||||
console.log("------------ " + new Date());
|
||||
for(var i = 0; i < to_log.length; i++) {
|
||||
console.log(to_log[i]);
|
||||
}
|
||||
console.log("------------");
|
||||
console.log("------------ " + new Date());
|
||||
}
|
||||
Helper.logs.unshift({log: to_log, date: new Date()});
|
||||
if(Helper.logs.length > 10) {
|
||||
Helper.logs.splice(-1, Helper.logs.length - 10);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -138,10 +138,34 @@ window.zoff = {
|
||||
disable_debug: disable_debug
|
||||
}
|
||||
|
||||
if(!Helper.mobilecheck()) {
|
||||
$(window).error(function(e){
|
||||
e.preventDefault();
|
||||
Helper.logs.unshift({log: e.originalEvent.error.stack.toString().replace(/(\r\n|\n|\r)/gm,""), date: new Date()});
|
||||
$(".contact-form-content").remove();
|
||||
$("#submit-contact-form").remove();
|
||||
$(".contact-modal-header").text("An error occurred");
|
||||
$(".contact-container-info").remove();
|
||||
$(".contact-modal-footer").prepend('<a href="#!" class="waves-effect waves-green btn-flat send-error-modal">Send</a>');
|
||||
$("#contact-form").attr("id", "error-report-form");
|
||||
$("#contact-container").prepend('<p>Do you want to send an error-report?</p> \
|
||||
<p class="error-report-success"></p> \
|
||||
<div class="error-code-container"> \
|
||||
<code id="error-report-code"></code> \
|
||||
</div>');
|
||||
$("#contact").modal();
|
||||
$("#contact").modal("open");
|
||||
/*$("#error-report-modal").modal();*/
|
||||
$("#error-report-code").text(JSON.stringify(Helper.logs, undefined, 4));
|
||||
console.error(e.originalEvent.error);
|
||||
});
|
||||
}
|
||||
|
||||
$().ready(function(){
|
||||
if(!localStorage.getItem("VERSION") || parseInt(localStorage.getItem("VERSION")) != VERSION) {
|
||||
localStorage.setItem("VERSION", VERSION);
|
||||
}
|
||||
|
||||
if(!fromFront && window.location.pathname != "/") Channel.init();
|
||||
else if(!fromChannel && window.location.pathname == "/"){
|
||||
Frontpage.init();
|
||||
@@ -1073,6 +1097,37 @@ $(document).on('submit', '#contact-form', function(e){
|
||||
Helper.send_mail(from, message);
|
||||
});
|
||||
|
||||
$(document).on('click', ".send-error-modal", function(e) {
|
||||
e.preventDefault();
|
||||
$("#error-report-form").submit();
|
||||
})
|
||||
|
||||
$(document).on('submit', "#error-report-form", function(e) {
|
||||
e.preventDefault();
|
||||
var captcha_response = grecaptcha.getResponse();
|
||||
$("#send-loader").removeClass("hide");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: {
|
||||
from: "no-reply@zoff.me",
|
||||
message: $("#error-report-code").text(),
|
||||
"g-recaptcha-response": captcha_response,
|
||||
},
|
||||
url: "/api/mail",
|
||||
success: function(data){
|
||||
if(data == "success"){
|
||||
$(".send-error-modal").remove();
|
||||
$("#error-report-form").remove();
|
||||
$(".error-code-container").remove();
|
||||
$(".error-report-success").text("Error report sent!");
|
||||
$("#contact-container").html("Mail has been sent, we'll be back with you shortly.")
|
||||
}else{
|
||||
$(".error-report-success").text("Mail was not sent, try again");
|
||||
}
|
||||
$("#send-loader").addClass("hide");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on( "click", "#add-many", function(e){
|
||||
var id = $(this).attr("data-video-id");
|
||||
|
||||
Reference in New Issue
Block a user