scinote-web/app/javascript/vue/mixins/utils.js

22 lines
497 B
JavaScript
Raw Normal View History

/* global ActiveStorage GLOBAL_CONSTANTS Promise i18n */
export default {
methods: {
stripHtml(html) {
let tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText || "";
},
truncate(text, length) {
if (text.length > length) {
return text.substring(0, length) + '...';
}
return text;
2022-08-04 17:06:25 +08:00
},
numberWithSpaces(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
}
};