1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-21 03:18:23 +00:00
Files
seahub/frontend/src/components/search/constant.js

22 lines
481 B
JavaScript
Raw Normal View History

const SEARCH_DELAY_TIME = 1000;
2023-11-22 17:31:08 +08:00
const getValueLength = (str) => {
let code;
let len = 0;
for (let i = 0; i < str.length; i++) {
code = str.charCodeAt(i);
if (code == 10) { //solve enter problem
len += 2;
} else if (code < 0x007f) {
len += 1;
} else if (code >= 0x0080 && code <= 0x07ff) {
len += 2;
} else if (code >= 0x0800 && code <= 0xffff) {
len += 3;
}
}
return len;
};
export { SEARCH_DELAY_TIME, getValueLength };