js
This commit is contained in:
@@ -25,52 +25,6 @@
|
||||
|
||||
})
|
||||
|
||||
|
||||
function debounce(func, wait, immediate) {
|
||||
var timeout;
|
||||
return function () {
|
||||
var context = this, args = arguments;
|
||||
var later = function () {
|
||||
timeout = null;
|
||||
if (!immediate) func.apply(context, args);
|
||||
};
|
||||
var callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) func.apply(context, args);
|
||||
};
|
||||
};
|
||||
|
||||
function getTextAreaSelection(textarea) {
|
||||
var start = textarea.selectionStart, end = textarea.selectionEnd;
|
||||
return {
|
||||
start: start,
|
||||
end: end,
|
||||
length: end - start,
|
||||
text: textarea.value.slice(start, end)
|
||||
};
|
||||
}
|
||||
|
||||
function detectPaste(textarea, callback) {
|
||||
textarea.onpaste = function () {
|
||||
var sel = getTextAreaSelection(textarea);
|
||||
var initialLength = textarea.value.length;
|
||||
window.setTimeout(function () {
|
||||
var val = textarea.value;
|
||||
var pastedTextLength = val.length - (initialLength - sel.length);
|
||||
var end = sel.start + pastedTextLength;
|
||||
callback({
|
||||
start: sel.start,
|
||||
end: end,
|
||||
length: pastedTextLength,
|
||||
text: val.slice(sel.start, end)
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
}
|
||||
// end search
|
||||
|
||||
|
||||
function formatCurrency(a) {
|
||||
var b = parseFloat(a).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1.").toString();
|
||||
var len = b.length;
|
||||
|
||||
Reference in New Issue
Block a user