Initial commit
This commit is contained in:
8
public/assets/js/bootstrap-datepicker.min.js
vendored
Executable file
8
public/assets/js/bootstrap-datepicker.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
100
public/assets/js/helper.js
vendored
Executable file
100
public/assets/js/helper.js
vendored
Executable file
@ -0,0 +1,100 @@
|
||||
const Helper = {
|
||||
toast: function (title, time, msg, type = 'bg-warning', delay = 2500) {
|
||||
$('#liveToast-type').addClass(type);
|
||||
document.getElementById('liveToast-title').innerText = title;
|
||||
document.getElementById('liveToast-time').innerText = time;
|
||||
document.getElementById('liveToast-msg').innerText = msg;
|
||||
(new bootstrap.Toast(document.getElementById('liveToast'), { delay })).show();
|
||||
},
|
||||
decodeHTMLEntities: function (str) {
|
||||
if (str && typeof str === 'string') {
|
||||
// strip script/html tags
|
||||
str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, '');
|
||||
str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, '');
|
||||
this.element.innerHTML = str;
|
||||
str = this.element.textContent;
|
||||
this.element.textContent = '';
|
||||
}
|
||||
|
||||
return str;
|
||||
},
|
||||
titleCase: function (str) {
|
||||
var splitStr = str.toLowerCase().split(' ');
|
||||
for (var i = 0; i < splitStr.length; i++) {
|
||||
// You do not need to check if i is larger than splitStr length, as your for does that for you
|
||||
// Assign it back to the array
|
||||
splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
|
||||
}
|
||||
// Directly return the joined string
|
||||
return splitStr.join(' ');
|
||||
},
|
||||
rangeToday: function () {
|
||||
return {
|
||||
start: moment().format('DD-MM-YYYY'),
|
||||
end: moment().format('DD-MM-YYYY'),
|
||||
}
|
||||
},
|
||||
rangeWeek: function () {
|
||||
return {
|
||||
start: moment().subtract(7, 'day').format('DD-MM-YYYY'),
|
||||
end: moment().format('DD-MM-YYYY'),
|
||||
}
|
||||
},
|
||||
rangeMonth: function () {
|
||||
return {
|
||||
start: moment().subtract(1, 'month').format('DD-MM-YYYY'),
|
||||
end: moment().format('DD-MM-YYYY'),
|
||||
}
|
||||
},
|
||||
splitEvery4Char: function (str) {
|
||||
if (str) {
|
||||
str = '' + str;
|
||||
let splitEvery4Char = str.match(/.{1,4}/g)
|
||||
return splitEvery4Char.join(' ')
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getCookie: function (name) {
|
||||
var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
|
||||
if (match) {
|
||||
return match[2];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
shortenText: function (text, max) {
|
||||
return text && text.length > max ? text.slice(0, max).split(' ').slice(0, -1).join(' ') : text
|
||||
},
|
||||
initQueryString: function () {
|
||||
// https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
|
||||
const params = new Proxy(new URLSearchParams(window.location.search), {
|
||||
get: (searchParams, prop) => searchParams.get(prop),
|
||||
});
|
||||
return params;
|
||||
},
|
||||
getPercentRange: function (crntVal, min, max) {
|
||||
return (crntVal - min) / (max - min) * 100;
|
||||
},
|
||||
getIndexReversedSequence: function(normalIdx, lastIdx) {
|
||||
return Math.abs(normalIdx - lastIdx);
|
||||
},
|
||||
// https://stackoverflow.com/questions/1184624/convert-form-data-to-javascript-object-with-jquery
|
||||
objectifyForm: function(formArray) {
|
||||
//serialize data function
|
||||
var returnArray = {};
|
||||
for (var i = 0; i < formArray.length; i++){
|
||||
if (formArray[i]['name'].indexOf('[]') > -1) { // dynamic data type
|
||||
let key = formArray[i]['name'].replace('[]', '');
|
||||
if (typeof returnArray[key] === 'undefined') {
|
||||
returnArray[key] = [formArray[i]['value']];
|
||||
} else {
|
||||
returnArray[key].push(formArray[i]['value']);
|
||||
}
|
||||
} else { // primitive data type
|
||||
returnArray[formArray[i]['name']] = formArray[i]['value'];
|
||||
}
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
};
|
||||
3
public/assets/js/load-image.all.min.js
vendored
Executable file
3
public/assets/js/load-image.all.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/assets/js/moment.min.js
vendored
Executable file
1
public/assets/js/moment.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/assets/js/notify.min.js
vendored
Executable file
1
public/assets/js/notify.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
38
public/assets/js/worker/jimp.js
vendored
Executable file
38
public/assets/js/worker/jimp.js
vendored
Executable file
@ -0,0 +1,38 @@
|
||||
importScripts('https://cdn.jsdelivr.net/npm/jimp@0.16.0/browser/lib/jimp.js');
|
||||
|
||||
self.addEventListener('message', function (e) {
|
||||
// e.data => dataURL
|
||||
Jimp.read(e.data)
|
||||
.then(image => {
|
||||
var width = image.bitmap.width
|
||||
if (width > 900) {
|
||||
width = 900
|
||||
}
|
||||
|
||||
image
|
||||
.resize(width, Jimp.AUTO)
|
||||
.quality(60)
|
||||
.getBase64Async(Jimp.MIME_JPEG)
|
||||
.then((dataURL) => {
|
||||
res = {
|
||||
stts: true,
|
||||
data: dataURL // base64
|
||||
}
|
||||
self.postMessage(res)
|
||||
})
|
||||
.catch(err => {
|
||||
res = {
|
||||
stts: false,
|
||||
data: err
|
||||
}
|
||||
self.postMessage(res)
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
res = {
|
||||
stts: false,
|
||||
data: err
|
||||
}
|
||||
self.postMessage(res)
|
||||
})
|
||||
})
|
||||
42
public/assets/js/worker/jimp_multiple.js
vendored
Executable file
42
public/assets/js/worker/jimp_multiple.js
vendored
Executable file
@ -0,0 +1,42 @@
|
||||
importScripts('https://cdn.jsdelivr.net/npm/jimp@0.16.0/browser/lib/jimp.js');
|
||||
|
||||
self.addEventListener('message', function (e) {
|
||||
const { dataURL, importantKey } = e.data;
|
||||
// dataURL => dataURL
|
||||
Jimp.read(dataURL)
|
||||
.then(image => {
|
||||
var width = image.bitmap.width
|
||||
if (width > 900) {
|
||||
width = 900
|
||||
}
|
||||
|
||||
image
|
||||
.resize(width, Jimp.AUTO)
|
||||
.quality(60)
|
||||
.getBase64Async(Jimp.MIME_JPEG)
|
||||
.then((dataURL) => {
|
||||
res = {
|
||||
stts: true,
|
||||
data: dataURL, // base64
|
||||
importantKey
|
||||
}
|
||||
self.postMessage(res)
|
||||
})
|
||||
.catch(err => {
|
||||
res = {
|
||||
stts: false,
|
||||
data: err,
|
||||
importantKey
|
||||
}
|
||||
self.postMessage(res)
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
res = {
|
||||
stts: false,
|
||||
data: err,
|
||||
importantKey
|
||||
}
|
||||
self.postMessage(res)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user