This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if device is mobile | |
function isMobileDevice() { | |
return /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent); | |
} | |
// Check if device is touchable | |
function isTouchDevice() { | |
return 'ontouchstart' in document.documentElement; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isFunction(obj) { | |
return obj && {}.toString.call(obj) === '[object Function]'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let orientation = 'portrait'; | |
if(window?.screen?.orientation?.angle && [270, 90].includes(window.screen.orientation.angle)) { | |
orientation = 'landscape'; | |
} else if(window.orientation && [90, -90].includes(window.orientation)) { | |
orientation = 'landscape'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertViToEn(str) { | |
str = str.toLowerCase(); | |
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a"); | |
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e"); | |
str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i"); | |
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o"); | |
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u"); | |
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y"); | |
str = str.replace(/đ/g, "d"); | |
str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // Huyền sắc hỏi ngã nặng |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
buildModules: [ | |
'@nuxtjs/style-resources' | |
], | |
styleResources: { | |
scss: [ | |
'./assets/scss/_responsive.scss', // use underscore "_" & also file extension ".scss" | |
'./assets/scss/_variables.scss' // use underscore "_" & also file extension ".scss" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//data: file data | |
// fileName: file's name to download | |
// typeFile: type file download. eg: text/html | |
function downloadFile(data, fileName, typeFile) { | |
const aEl = document.createElement('a') | |
const file = new Blob([data], { type: typeFile}) | |
aEl.href = URL.createObjectURL(file) | |
aEl.download = fileName | |
aEl.click() |
OlderNewer