//Personal Functions Library for the site //jQuery(function ($) { // 'use strict'; // tool tips activation // Function for the data-toggle baloon $(function () { $('[data-toggle="tooltip"]').tooltip() }) // Function to check the strength of the given password function checkPasswordStrength() { //alert("ff"); var number = /([0-9])/; var alphabets = /([a-zA-Z])/; var special_characters = /([~,!,@,#,$,%,^,&,*,-,_,+,=,?,>,<])/; if (!$('#TXT_Pass1').val()) { $('#password-strength-status').html(""); $('#password-strength-status').removeClass(); } else if ($('#TXT_Pass1').val().length < 6) { $('#password-strength-status').removeClass(); $('#password-strength-status').addClass('weak-password small'); $('#password-strength-status').html("Weak (should be atleast 6 characters.)"); } else { if ($('#TXT_Pass1').val().match(number) && $('#TXT_Pass1').val().match(alphabets) && $('#TXT_Pass1').val().match(special_characters)) { $('#password-strength-status').removeClass(); $('#password-strength-status').addClass('strong-password small'); $('#password-strength-status').html("Strong password"); } else { $('#password-strength-status').removeClass(); $('#password-strength-status').addClass('medium-password small'); $('#password-strength-status').html("Medium (should include alphabets, numbers and special characters.)"); } } }; // Function to check the strength of the given password function checkPasswordStrengthN() { //alert("ff"); var number = /([0-9])/; var alphabets = /([a-zA-Z])/; var special_characters = /([~,!,@,#,$,%,^,&,*,-,_,+,=,?,>,<])/; if (!$('#TXT_NPass1').val()) { $('#password-strength-statusN').html(""); $('#password-strength-statusN').removeClass(); } else if ($('#TXT_NPass1').val().length < 6) { $('#password-strength-statusN').removeClass(); $('#password-strength-statusN').addClass('weak-password small'); $('#password-strength-statusN').html("Weak (should be atleast 6 characters.)"); } else { if ($('#TXT_NPass1').val().match(number) && $('#TXT_NPass1').val().match(alphabets) && $('#TXT_NPass1').val().match(special_characters)) { $('#password-strength-statusN').removeClass(); $('#password-strength-statusN').addClass('strong-password small'); $('#password-strength-statusN').html("Strong password"); } else { $('#password-strength-statusN').removeClass(); $('#password-strength-statusN').addClass('medium-password small'); $('#password-strength-statusN').html("Medium (should include alphabets, numbers and special characters.)"); } } }; //This function will show hide a password, //Requirement: need the font-awesome 4.7 font icon library //usage, on the text control add this class: G-form-control-pass //and add this line below the text control which will produce the icon // $('.G-form-control-pass-show').click(function () { var id = $(this).siblings('.G-form-control-pass').attr('id'); var fullID = '#' + id //alert(id); if ($(fullID).attr("type") === "text") { $(fullID).attr('type', 'password'); $(this).addClass("ri-eye-off-line"); $(this).removeClass("ri-eye-line"); //alert("text"); } else if ($(fullID).attr("type") === "password") { $(fullID).attr('type', 'text'); $(this).addClass("ri-eye-line"); $(this).removeClass("ri-eye-off-line"); //alert("password"); } }); $('.G-form-control-pass').on('input propertychange', function () { // var mystyle = $(this).G_getInputTypeIconMargin() //alert(mystyle); var $this = $(this); var visible = Boolean($this.val()); $this.siblings('.G-form-control-pass-show').toggleClass('invisible', !visible); }).trigger('propertychange'); $(".G-textarea").each(function () { this.setAttribute("style", "height:" + (this.scrollHeight) + "px;overflow-y:hidden;width:100%"); }).on("input", function () { this.style.height = "auto"; this.style.height = (this.scrollHeight) + "px"; }); // Setup Line for Print of the User Application + Profile ############### var ColLeft = $('#leftCol').height(); var ColRight = $('#RightCol').height(); var lines = (ColLeft - ColRight) / 36; //$('#LBL1').text("the height on left is " + ColLeft + " and on right is " + ColRight + " lines is " + lines); var Slines = "
"; for (i = 0; i < Math.floor(lines); i++) { $('#Slines').append(Slines); } //// Hide the alert boxes //window.setTimeout(function () { // $('.alert').delay(4000).slideUp(500, function () { // $(this).remove(); // //$(this).alert('close'); // }); //}, 0); //Hide the alert boxes window.setTimeout(function () { $('.G-alert').delay(4000).slideUp(500, function () { $(this).remove(); //$(this).alert('close'); }); }, 0); //######################################################################### //function SearchText() { // $("#JobCityTextBox").autocomplete({ // source: function (request, response) { // $.ajax({ // type: "POST", // contentType: "application/json; charset=utf-8", // url: "bNewJobAdvert.aspx/GetCities", // data: "{'cityName':'" + document.getElementById('JobCityTextBox').value + "','countryName':'" + document.getElementById('DD_Countries').value + "'}", // dataType: "json", // success: function (data) { // response(data.d); // }, // error: function (result) { // alert("No Match"); // } // }); // } // }); //} //}(jQuery)); function gAppHistoryBack1(msg) { if (confirm(msg)) window.history.back(1); } //Delete a cookie by name function eraseCookie(name) { document.cookie = name + '=; Max-Age=0; path=/; domain=;' + location.host; } // Block any clicks after the button clicked takes (the name of the validation group of the form, and the button object) function BTN_BlockClick(ValidationName, BTN_Clciked, BTN_SubmitForm) { if (Page_ClientValidate(ValidationName)) { //'ContactGR' //BTN_Clciked.form.submit(); BTN_Clciked.value = 'Please wait…'; //BTN_Clciked._BTN_BlockClick_Disable = true; //$("#cBodyContact").addClass("DissableForm") _BTN_BlockClick_Disable(BTN_Clciked); //return false; //if (BTN_SubmitForm === undefined) { // BTN_SubmitForm = 'na'; //} //var BTN_SF = document.getElementById(BTN_SubmitForm); //BTN_SF.click(); document.forms[0].submit(); } } function _BTN_BlockClick_Disable(BTN_Clicked) { $('.BTN_BlockClick').prop('disabled', true); } function disableBtn(btnID, newText) { Page_IsValid = null; if (typeof (Page_ClientValidate) == 'function') { Page_ClientValidate(); } var btn = document.getElementById(btnID); var isValidationOk = Page_IsValid; if (isValidationOk !== null) { if (isValidationOk) { btn.disabled = true; btn.value = newText; return false; } else { btn.disabled = false; } } else { //setTimeout("setImage('" + btnID + "')", 10); btn.disabled = true; btn.value = newText; } } //If substr will be dropped in the future, then you can use this replacement, instead of rewriting all your JavaScript codes. String.prototype.gAppsubstr = function (start, length) { const S = this.toString(); // step 1 and 2 const size = S.length; // step 3 let intStart = Number.isNaN(Number(start)) ? 0 : Number.parseInt(start); // step 4 if (intStart === -Infinity) intStart = 0; // step 5 else if (intStart < 0) intStart = Math.max(size + intStart, 0); // step 6 else intStart = Math.min(intStart, size); // step 7 let intLength = length === undefined ? size : (Number.isNaN(Number(length)) ? 0 : Number.parseInt(length)); // step 8 intLength = Math.max(Math.min(intLength, size), 0); // step 9 let intEnd = Math.min(intStart + intLength, size); // step 10 return S.substring(intStart, intEnd); // step 11 }; /* Bell Notification Functions */ function sound(src) { this.sound = document.createElement("audio"); this.sound.src = src; this.sound.setAttribute("preload", "auto"); this.sound.setAttribute("controls", "none"); this.sound.style.display = "none"; document.body.appendChild(this.sound); this.play = function () { this.sound.play(); } this.stop = function () { this.sound.pause(); } } function playSound() { var mySound; var soundfile = 'https://secure.hostelry.gr/gAppAssets/Themes/Bell1.mp3'; mySound = new sound(soundfile); mySound.play(); } /* Script to give efect on bootstrap alerts */ // Get all elements with class "auto-close" const autoCloseElements = document.querySelectorAll(".auto-close"); // Define a function to handle the fading and sliding animation function fadeAndSlide(element) { const fadeDuration = 2500; const slideDuration = 2500; // Step 1: Fade out the element let opacity = 1; const fadeInterval = setInterval(function () { if (opacity > 0) { opacity -= 0.1; element.style.opacity = opacity; } else { clearInterval(fadeInterval); // Step 2: Slide up the element let height = element.offsetHeight; const slideInterval = setInterval(function () { if (height > 0) { height -= 10; element.style.height = height + "px"; } else { clearInterval(slideInterval); // Step 3: Remove the element from the DOM element.parentNode.removeChild(element); } }, slideDuration / 10); } }, fadeDuration / 10); } // Set a timeout to execute the animation after 5000 milliseconds (5 seconds) setTimeout(function () { autoCloseElements.forEach(function (element) { fadeAndSlide(element); }); }, 10000); //10sec // =============== Photo upload User view ============================ var $croppie = $('#croppie-container').croppie({ //enableExif: true, //enableResize: true, enforceBoundary: false, viewport: { width: 300, height: 300, type: 'square' }, boundary: { width: 450, height: 450 } }); //Get image from user $('#upload-image').on('change', function () { var reader = new FileReader(); $('#cropped-image').attr('src', ''); $('#Panel_NewPhoto').css('display', 'block'); reader.onload = function (e) { $croppie.croppie('bind', { url: e.target.result }); } reader.readAsDataURL(this.files[0]); }); //$('#crop-button').on('click', function () { // $croppie.croppie('result', { // type: 'base64', // size: { width: 450, height: 450 }, // format: 'jpeg', // quality: 1 // }).then(function (img) { // $('#cropped-image').attr('src', img); // $('#cropped-result').show(); // }); //}); //Photo Preview Open Modal $('#cropModalPreview').on('click', function () { var myIMG = $('.cr-image').attr('src'); var myIMGtype; if (myIMG.indexOf("jpeg") != -1) { myIMGtype = "jpeg" console.log("jpeg found"); } if (myIMG.indexOf("png") != -1) { myIMGtype = "png" console.log("png found"); } $croppie.croppie('result', { type: 'base64', size: { width: 450, height: 450 }, format: myIMGtype, //'jpeg', quality: 1 }).then(function (img) { $('#cropped-image').attr('src', img); $('#cropped-result').show(); $('#imageModalPreview').modal('show') }); }); //Photo Crop and save without preview $('#cropSave-btn').on('click', function () { var myIMG = $('.cr-image').attr('src'); var myIMGtype; if (myIMG.indexOf("jpeg") != -1) { myIMGtype = "jpeg" console.log("jpeg found"); } if (myIMG.indexOf("png") != -1) { myIMGtype = "png" console.log("png found"); } $croppie.croppie('result', { type: 'base64', size: { width: 450, height: 450 }, format: myIMGtype, //'jpeg', quality: 1 }).then(function (img) { UploadPhoto(img); }); }); //Photo Modal Cancel button //$('#closePreviewModal').on('click', function () { // $('#imageModalPreview').modal('hide') //}); //Photo Preview Save button $('#savePhotoModal').on('click', function () { var myIMG = $('#cropped-image').attr('src'); UploadPhoto(myIMG); }); function UploadPhoto(myIMG) { var myIMGtype; if (myIMG.indexOf("jpeg") != -1) { myIMGtype = "image/jpeg" console.log("jpeg found"); } if (myIMG.indexOf("png") != -1) { myIMGtype = "image/png" console.log("png found"); } var myURL = "https://secure.hostelry.gr/Downloads/gAppUploadUserImgV1.ashx" var uid = document.getElementById("HF_UID").value; $.ajax({ type: "POST", url: myURL, //"../../Downloads/gAppUploadUserImgV1.ashx", //"ImageHandler.ashx", data: { image: myIMG, format: myIMGtype, uID: uid }, success: function (response) { alert('Image uploaded successfully!'); // + response window.location.href = "uRefreshProfile.aspx"; }, error: function (response) { alert('Upload failed!'); } }); } // =============== Photo upload Bus view ============================ var $croppieBus = $('#croppie-containerBus').croppie({ //enableExif: true, //enableResize: true, enforceBoundary: false, viewport: { width: 300, height: 300, type: 'square' }, boundary: { width: 450, height: 450 } }); //Get image from user $('#upload-imageBus').on('change', function () { var reader = new FileReader(); $('#cropped-imageBus').attr('src', ''); $('#Panel_NewPhotoBus').css('display', 'block'); reader.onload = function (e) { $croppieBus.croppie('bind', { url: e.target.result }); } reader.readAsDataURL(this.files[0]); }); //$('#crop-button').on('click', function () { // $croppie.croppie('result', { // type: 'base64', // size: { width: 450, height: 450 }, // format: 'jpeg', // quality: 1 // }).then(function (img) { // $('#cropped-image').attr('src', img); // $('#cropped-result').show(); // }); //}); //Photo Preview Open Modal $('#cropModalPreviewBus').on('click', function () { var myIMG = $('.cr-image').attr('src'); var myIMGtype; if (myIMG.indexOf("jpeg") != -1) { myIMGtype = "jpeg" console.log("jpeg found"); } if (myIMG.indexOf("png") != -1) { myIMGtype = "png" console.log("png found"); } $croppieBus.croppie('result', { type: 'base64', size: { width: 450, height: 450 }, format: myIMGtype, //'jpeg', quality: 1 }).then(function (img) { $('#cropped-imageBus').attr('src', img); $('#cropped-resultBus').show(); $('#imageModalPreviewBus').modal('show') }); }); //Photo Crop and save without preview $('#cropSave-btnBus').on('click', function () { var myIMG = $('.cr-image').attr('src'); var myIMGtype; if (myIMG.indexOf("jpeg") != -1) { myIMGtype = "jpeg" console.log("jpeg found"); } if (myIMG.indexOf("png") != -1) { myIMGtype = "png" console.log("png found"); } $croppieBus.croppie('result', { type: 'base64', size: { width: 450, height: 450 }, format: myIMGtype, //'jpeg', quality: 1 }).then(function (img) { UploadPhotoBus(img); }); }); //Photo Modal Cancel button //$('#closePreviewModalBus').on('click', function () { // $('#imageModalPreviewBus').modal('hide') //}); //Photo Preview Save button $('#savePhotoModalBus').on('click', function () { var myIMG = $('#cropped-imageBus').attr('src'); UploadPhotoBus(myIMG); }); function UploadPhotoBus(myIMG) { var myIMGtype; if (myIMG.indexOf("jpeg") != -1) { myIMGtype = "image/jpeg" console.log("jpeg found"); } if (myIMG.indexOf("png") != -1) { myIMGtype = "image/png" console.log("png found"); } //https://localhost:44397/ var myURL = "https://secure.hostelry.gr/Downloads/gAppUploadBusImgV1.ashx" var bid = document.getElementById("HF_bID").value; $.ajax({ type: "POST", url: myURL, //"../../Downloads/gAppUploadUserImgV1.ashx", //"ImageHandler.ashx", data: { image: myIMG, format: myIMGtype, bID: bid }, success: function (response) { alert('Image uploaded successfully!'); // + response window.location.href = "bRefreshProfile.aspx"; }, error: function (response) { alert('Upload failed!'); } }); } //// Validate input file type //function validateFileType() { // var rtn // var fileName = document.getElementById("uploadImage").value; // var idxDot = fileName.lastIndexOf(".") + 1; // var extFile = fileName.substr(idxDot, fileName.length).toLowerCase(); // if (extFile == "jpg" || extFile == "jpeg" || extFile == "png") { // rtn = "ok"; // } else { // rtn = "error" // } // return rtn //} //$('#uploadImage').on('change', function (e) { // if (validateFileType() == "error") { // alert("Only jpg, jpeg and png files are allowed!"); // this.value = ''; //reset file input // return false; // } // var files = e.target.files; // var done = function (url) { $('#srcImage').attr('src', url).show(); }; // if (files && files.length > 0) { // var reader = new FileReader(); // reader.onload = function (event) { done(event.target.result); }; // reader.readAsDataURL(files[0]); // } // // Update GUI // $("#Panel_UploadSelect").hide(); // $("#PanelCrop").show(); //}); ///* info for file upload */ //let cropper; //$('#srcImage').on('load', function () { // cropper = new Cropper(this, { // aspectRatio: 1, //450 / 450, // viewMode: 1, // dragMode: 'move', // Allow the image to be dragged within the crop box // autoCropArea: 1, // Make sure the crop area covers the entire container // cropBoxResizable: false, // Fix crop box size // cropBoxMovable: false, // Disable crop box movement // movable: true, // Allow the image to be moved // zoomable: true, // Disable zoom to keep actual image size // scalable: true, // Disable scaling // toggleDragModeOnDblclick: false, // Enable to toggle drag mode between "crop" and "move" // responsive: true, //Re-render the cropper when resizing the window. // ready() { // // Set crop box size to 450x450 pixels // cropper.setCropBoxData({ // width: 450, // height: 450, // left: (cropper.getContainerData().width - 450) / 2, // Center the crop box horizontally // top: (cropper.getContainerData().height - 450) / 2 // Center the crop box vertically // }); // }, // crop: function (event) { // // var canvas = cropper.getCroppedCanvas(); // const canvas = document.getElementById("canvas"); // const ctx = canvas.getContext("2d"); // const cropData = cropper.getCroppedCanvas({ // width: 450, // Set preview canvas width // height: 450 // Set preview canvas height // }); // ctx.clearRect(0, 0, canvas.width, canvas.height); // ctx.drawImage(cropData, 0, 0, 450, 450); // //context.drawImage(canvas, 0, 0); // } // }); //}); //$('#cropButton').on('click', function () { // // Get source image info // const img = document.getElementById("srcImage"); // // Detect image format from file extension // const src = img.src.toLowerCase(); // let imageFormat = 'image/jpeg'; // Default to JPEG // if (src.startsWith("data:image/png")) { // imageFormat = 'image/png'; // } else if (src.startsWith("data:image/jpeg")) { // imageFormat = 'image/jpeg'; // } // // Get cropped image as a 450x450px base64 data URL // const croppedImageDataUrl = cropper.getCroppedCanvas({ // width: 450, // height: 450 // }).toDataURL(imageFormat); //"image/png" // var uid = document.getElementById("HF_UID").value; // $.ajax({ // type: "POST", // url: "../../Downloads/gAppUploadUserImgV1.ashx", //"ImageHandler.ashx", // data: { // image: croppedImageDataUrl, // format: imageFormat, // uID: uid // }, // success: function (response) { // alert('Image uploaded successfully!' + response); // window.location.href = "uRefreshProfile.aspx"; // }, // error: function (response) { // alert('Upload failed!'); // } // }); //}); //$('#ResetButton').on('click', function () { // // Destroy existing cropper instance // if (cropper) { // cropper.destroy(); // } // // Reload the image to reset it // const img = document.getElementById("srcImage"); // img.src = ''; // img.src; // Reload the image by resetting the src // $('#uploadImage').show(); // $('#srcImage').hide(); // // Reinitialize the cropper after the image reloads // img.onload = function () { // initializeCropper(); // }; //}); /* * Pass requirement function * originaly create on this url https://github.com/09arnold/PassRequirements * * Extended for PerkPlaza by Geo Oct 2020 * */ if (typeof jQuery === 'undefined') { throw new Error('PassRequirements requires jQuery') } +(function ($) { $.fn.PassRequirements = function (options) { /* * TODO * ==== * * store regexes in variables so they can be used by users through string * specifications,ex 'number', 'special', etc * / /* * How to use it >>> * popoverPlacement: 'top', >> where the Popover baloon to be placed * defaults: false, >> the default options for the validation * container: '#regPASS', >> where to be placed * buttonSubmit: '.pass1' >> the button to disable until is valid pass * * added by Geo * option [buttonSubmit] to disable the button before password is verified * */ var defaults = { // defaults: true }; if ( !options || //if no options are passed /* options.defaults == true || //if default option is passed with defaults set to true * Extend options with default ones options.defaults == undefined //if options are passed but defaults is not passed */ ) { if (!options) { //if no options are passed, options = {}; //create an options object } defaults.rules = $.extend({ minlength: { text: "be at least minLength characters long", minLength: 8, }, containSpecialChars: { text: "Your input should contain at least minLength special character", minLength: 1, regex: new RegExp('([^!,%,&,@,#,$,^,*,?,_,~])', 'g') }, containLowercase: { text: "Your input should contain at least minLength lower case character", minLength: 1, regex: new RegExp('[^a-z]', 'g') }, containUppercase: { text: "Your input should contain at least minLength upper case character", minLength: 1, regex: new RegExp('[^A-Z]', 'g') }, containNumbers: { text: "Your input should contain at least minLength number", minLength: 1, regex: new RegExp('[^0-9]', 'g') } }, options.rules); } else { defaults = options; //if options are passed with defaults === false } var i = 0; return this.each(function () { if (!defaults.defaults && !defaults.rules) { console.error('You must pass in your rules if defaults is set to false. Skipping this input with id:[' + this.id + '] with class:[' + this.classList + ']'); return false; } var requirementList = ""; $(this).data('pass-req-id', i++); $(this).keyup(function () { var isLocked = false; var this_ = $(this); Object.getOwnPropertyNames(defaults.rules).forEach(function (val, idx, array) { if (this_.val().replace(defaults.rules[val].regex, "").length > defaults.rules[val].minLength - 1) { this_.next('.popover').find('#' + val).css('text-decoration', 'line-through'); //.removeClass('text-primary').addClass('text-success'); } else { this_.next('.popover').find('#' + val).css('text-decoration', 'none'); //.removeClass('text-success').addClass('text-primary') isLocked = true; } if (isLocked) { $(options.buttonSubmit).attr('disabled', 'disabled'); // $('.pass1').attr('disabled', 'disabled'); } else { $(options.buttonSubmit).removeAttr('disabled'); // $('.pass1').removeAttr('disabled'); } }) }); Object.getOwnPropertyNames(defaults.rules).forEach(function (val, idx, array) { requirementList += (("
  • " + defaults.rules[val].text).replace("minLength", defaults.rules[val].minLength)); }) try { $(this).popover({ title: 'Password Requirements', trigger: options.trigger ? options.trigger : 'focus', html: true, placement: options.popoverPlacement ? options.popoverPlacement : 'bottom', content: 'Your password should:' // '

    The confirm field is actived only if all criteria are met

    ' }); } catch (e) { throw new Error('PassRequirements requires Bootstraps Popover plugin'); } $(this).focus(function () { $(this).keyup(); }); }); }; }(jQuery));