HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/hours.komma.pro/wwwroot/js/scripts.js
var pJaxContainer = '#app';
var pageLoaded = false; // used for Dusk tests
var mainFormValid = true;
$.pjax.defaults.timeout = false;

$(document).ready(function () {
    initPage();
});

$(document).on('pjax:success', function () {
    initPage();
});

$(document).on('pjax:send', function() {
    pageLoaded = false;
    $('#loading').css("left", "50%");
});

$(document).on('pjax:complete', function(response) {
    $('#loading').css("left", "-50%");
});

$(document).on('pjax:error', function (response, textStatus, error) {
    var errorList = "";

    if(textStatus.getResponseHeader('pjax-error-test')) {
        var error = textStatus.getResponseHeader('pjax-error-test');
        errorList += '<div class="alert alert-danger" role="alert">' + error + '</div>';
    };

    errorList += '<div class="alert alert-danger" role="alert">' + response.responseText + '</div>';

    $(".error-container").html(errorList);

    return false;
});


function clickWithPjax(url) {
    if( !$(event.target).parent().parent('ul').hasClass("dropdown-menu") ) {
        $(event.target).parent('li').addClass('active').siblings().removeClass('active');
    }
    event.preventDefault();
    goPjax(url);
    return false;
}

function goPjax(url) {
    $.pjax({url: url, container: pJaxContainer});
}

function initPage() {
    $(".active .selectProject").focus();
    $("#datepicker").datepicker();
    $(".datepicker").datepicker();
    $("#datepicker2").datepicker();
    $('.selectpicker').selectpicker('refresh');

    $('#loading').css("left", "-50%");

    $(".spinner").each(function() {
        $(this).spinner({
            step: 0.25,
            numberFormat: "n",
            disabled: this.disabled
        });
    });

    $('[data-toggle="tooltip"]').bstooltip();
    $('[data-toggle="popover"]').popover();

    if ($.support.pjax) {
        $(document).pjax("a:not(.excelExport, .deleteModal, .passwordReset)", pJaxContainer);
    }
    if ($(".modal-backdrop:visible").length > 0 && $(".modal:visible").length == 0) {
        $(".modal-backdrop").hide();
        $('body').removeClass('modal-open');
        document.body.removeAttribute("style")
    }
    if ($(".modal:visible").length > 0 && $(".modal-backdrop:visible").length == 0) {
        $(".modal-backdrop").show();
    }
    setTimeout(function () {
        var $alert = $('#pjaxContainer > .container > .row > .col-md-12 > .alert-info');
        if($alert.html() != "") {
            $alert.slideDown('slow', function() {
                setTimeout(function () {
                    $alert.slideUp('slow', function() {
                        $alert.html('');
                    });
                }, 2500);
            });
        }
    }, 500);

    if($('input#view').length > 0){
        var view = $('input#view').val();
        var url = window.location.href;
        if (url.match(/(day|week|month)/)) {
            if(url.indexOf("day=") > -1 && view !== "day") {
                $('input#view').val("day");
            } else if(url.indexOf("week=") > -1 && view !== "week") {
                $('input#view').val("week");
            } else if(url.indexOf("month=") > -1 && view !== "month") {
                $('input#view').val("month");
            }
        }
    }

    // prevent form submit with enter key (needed for popup dialog forms)
    $(window).keydown(function(event){
        if(event.keyCode == 13 && $(".modal-backdrop:visible").length > 0) {
            event.preventDefault();
            return false;
        }
    });
    pageLoaded = true;
    clearInterval(t);
    swSeconds = 0; swMinutes = 0; swHours = 0; t=null;
}

function fillDeleteModal(id, name) {
    $('#deleteMessage .nameholder').html('').append(name);
    $('#deleteMessage .idholder').val(id);
}

function loadPopup(url, targetElement) {
    $(targetElement).fadeOut("fast", function () {
        $(targetElement).html('');
        $.ajax({
            type: 'get',
            url: url,
            success: function (data) {
                console.log('loadPopup success!');
                $(targetElement).html(data);
                $(targetElement).fadeIn("fast");
                $('.selectpicker').selectpicker('refresh');
                $(".spinner").each(function() {
                    $(this).spinner({
                        step: 0.25,
                        numberFormat: "n",
                        disabled: this.disabled
                    });
                });
            }
        });
    });
}

function isFormValid($form) {
    var errors = [],
        conf = {
            onElementValidate : function(valid, $el, $form, errorMess) {
                if( !valid ) {
                    // gather up the failed validations
                    errors.push({el: $el, error: errorMess});
                }
            }
        };

    errors = [];
    return $form.isValid(conf, false);
}
if(window.location.href.indexOf("instellingen") > -1) {
    $(document).on("submit", "form", function (event) {
        console.log("generic form submit!");
        $.pjax.submit(event, pJaxContainer);
    });
}


//get url params by name
$.urlParam = function (name) {
    var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    return results[1] || 0;
};

/* update url string */
function updateQueryString(key, value, urlString) {
    if (!urlString) urlString = window.location.href;

    if (urlString.indexOf(key + '=') > -1) {
        $current = $.urlParam(key);
        if ($current == 0) {
            $split = urlString.split(key + '=');
            $url = $split[0] + key + "=" + value + $split[1];
        }
        else {
            $url = urlString.replace(key + "=" + $current, key + "=" + value);
        }
    } else {
        if (urlString.indexOf('?') == -1) {
            $split = urlString.split('?');
            $url = $split[0] + '?' + key + '=' + value;
        }
        else {
            $url = urlString + '&' + key + '=' + value;
        }
    }
    return $url;
}

function removeURLParameter(url, key) {
    var urlparts= url.split('?');
    if (urlparts.length>=2) {

        var prefix= encodeURIComponent(key)+'=';
        var pars= urlparts[1].split(/[&;]/g);

        //reverse iteration as may be destructive
        for (var i= pars.length; i-- > 0;) {
            //idiom for string.startsWith
            if (pars[i].lastIndexOf(prefix, 0) !== -1) {
                pars.splice(i, 1);
            }
        }

        url= urlparts[0] + (pars.length > 0 ? '?' + pars.join('&') : "");
        return url;
    } else {
        return url;
    }
}