generated from jric11/baseProject
Chat's updates for security, db and workflow
Security and workflow regressions / regression (push) Has been cancelled
Security and workflow regressions / regression (push) Has been cancelled
This commit is contained in:
+44
-96
@@ -109,48 +109,16 @@ function isURL(object) {
|
||||
// AJAX Call to Get Zip Code Detail.
|
||||
// ---------------------------------
|
||||
|
||||
function getZipCodeDetail(zipcode) {
|
||||
|
||||
var zipCodeDetail = null;
|
||||
|
||||
$.ajax({
|
||||
url: "./",
|
||||
type: "POST",
|
||||
async: false,
|
||||
data: {action: "get_zipcode_detail",
|
||||
zip_code: zipcode},
|
||||
dataType: "json",
|
||||
success: function (info) {
|
||||
zipCodeDetail = info;
|
||||
}
|
||||
});
|
||||
|
||||
return zipCodeDetail;
|
||||
|
||||
async function getZipCodeDetail(zipcode) {
|
||||
return await formPost({action:'getZipcode',zip_code:zipcode});
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// AJAX Call to Validate a Date.
|
||||
// -----------------------------
|
||||
|
||||
function isDate(date) {
|
||||
|
||||
var valid = false;
|
||||
|
||||
$.ajax({
|
||||
url: "./",
|
||||
type: "POST",
|
||||
async: false,
|
||||
data: {action: "validateDate",
|
||||
date: date.val()},
|
||||
dataType: "json",
|
||||
success: function (result) {
|
||||
valid = result;
|
||||
}
|
||||
});
|
||||
|
||||
return valid;
|
||||
|
||||
async function isDate(date) {
|
||||
return await formPost({action:'validateDate',date:date.val()});
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
@@ -208,71 +176,44 @@ function trimString(string) {
|
||||
// -------------------
|
||||
|
||||
function formPost(inputs) {
|
||||
|
||||
var response = "";
|
||||
|
||||
$.ajax({
|
||||
url: "./",
|
||||
type: "POST",
|
||||
async: false,
|
||||
dataType: "json",
|
||||
data: inputs,
|
||||
success: function (results) {
|
||||
response = results;
|
||||
}, error: function (errorcode) {
|
||||
console.log(errorcode);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return response;
|
||||
|
||||
return $.ajax({url:'./',type:'POST',dataType:'json',data:inputs});
|
||||
}
|
||||
|
||||
// --------------
|
||||
// Submit a Form.
|
||||
// --------------
|
||||
|
||||
//function formSubmit(inputs, target) {
|
||||
//
|
||||
// $('<form action="./" method="post" id="formSubmit"/>').appendTo("body");
|
||||
//
|
||||
// var form = $("#formSubmit");
|
||||
//
|
||||
// if (target === "_blank") {
|
||||
// form.prop("target", target);
|
||||
// }
|
||||
//
|
||||
// for (var name in inputs) {
|
||||
// form.append('<input type="hidden" name="' + name + '" value="' + inputs[name] + '"/>');
|
||||
// }
|
||||
//
|
||||
// console.log($('#formSubmit').html());
|
||||
//
|
||||
//// form.submit();
|
||||
//
|
||||
//}
|
||||
|
||||
// --------------
|
||||
// Submit a Form.
|
||||
// --------------
|
||||
|
||||
function formSubmit(inputs, target = "") {
|
||||
const form=$("#formSubmit");
|
||||
form.prop('target',target);
|
||||
form.find('input').not('[name="csrf_token"]').remove();
|
||||
Object.entries(inputs).forEach(([name,value])=>{
|
||||
if(name!=='csrf_token' && value!==undefined && value!==null)$('<input>',{type:'hidden',name:name,value:String(value)}).appendTo(form);
|
||||
});
|
||||
form.get(0).submit();
|
||||
}
|
||||
|
||||
var form = $("#formSubmit");
|
||||
|
||||
if (target === "_blank") {
|
||||
form.prop("target", target);
|
||||
} else {
|
||||
form.prop("target", "");
|
||||
}
|
||||
|
||||
for (var name in inputs) {
|
||||
form.append('<input type="hidden" name="' + name + '" value="' + inputs[name] + '"/>');
|
||||
}
|
||||
|
||||
form.submit();
|
||||
|
||||
$(document).ajaxError(function(event,xhr){
|
||||
const message=(xhr.responseJSON && xhr.responseJSON.error) || (xhr.status===401?'Your session has expired. Reload the page to sign in.':'The request failed. Please try again.');
|
||||
showRequestMessage(message,'danger');
|
||||
});
|
||||
$(document).ajaxStart(function(){
|
||||
$('.btnSave,.btnConfirmDialogConfirm').filter(':enabled').addClass('request-busy').prop('disabled',true).attr('aria-busy','true');
|
||||
}).ajaxStop(function(){
|
||||
$('.request-busy').prop('disabled',false).removeClass('request-busy').removeAttr('aria-busy');
|
||||
});
|
||||
// jQuery reports these failures through ajaxError above. Stop the rejected event
|
||||
// handler without also producing an unhandled promise error in the browser.
|
||||
window.addEventListener('unhandledrejection',function(event){
|
||||
if(event.reason && typeof event.reason.status==='number')event.preventDefault();
|
||||
});
|
||||
function showRequestMessage(message,kind='info'){
|
||||
let box=$('#request-message');
|
||||
let target=$('.modal.show .modal-body').first();
|
||||
if(!target.length)target=$('.hr-workspace,main,body').first();
|
||||
if(!box.length)box=$('<div>',{id:'request-message',role:'alert',tabindex:'-1'});
|
||||
box.prependTo(target);
|
||||
box.attr('class','alert alert-'+kind).text(message).trigger('focus');
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
@@ -283,8 +224,15 @@ $(document).ready(function () {
|
||||
// Enable Tooltips and Popovers
|
||||
// ----------------------------
|
||||
|
||||
$("[data-bs-toggle=tooltip]").tooltip({trigger: "hover", container: "body"});
|
||||
$("[data-bs-toggle=popover]").popover({trigger: "focus", container: "body"});
|
||||
document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(element=>{
|
||||
const title=element.getAttribute('data-bs-title')||element.getAttribute('title')||'';
|
||||
if(title)bootstrap.Tooltip.getOrCreateInstance(element,{title:title,trigger:'hover',container:'body'});
|
||||
});
|
||||
document.querySelectorAll('[data-bs-toggle="popover"]').forEach(element=>{
|
||||
const title=element.getAttribute('data-bs-title')||element.getAttribute('title')||'';
|
||||
const content=element.getAttribute('data-bs-content')||'';
|
||||
if(title||content)bootstrap.Popover.getOrCreateInstance(element,{title:title,content:content,trigger:'focus',container:'body'});
|
||||
});
|
||||
|
||||
// -------------
|
||||
// Display Toast
|
||||
@@ -294,7 +242,7 @@ $(document).ready(function () {
|
||||
|
||||
if (toast !== "") {
|
||||
|
||||
$(".toast-body").html(toast);
|
||||
$(".toast-body").text(toast);
|
||||
|
||||
$("#toast-message").toast("show");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user