「製作流式EPUB(*註1)電子書」,無校對、無潤稿。
價錢: $2500元台幣 ↑↓,依照字數定價
bingzhichen 發表在 痞客邦 留言(0) 人氣(1,324)
'aaasdofjaopfjopaiiisjssfopiasdfffff'.match(/(.)\1+/g) -----> ["aaa", "iii", "ss", "fffff"]
bingzhichen 發表在 痞客邦 留言(0) 人氣(3)
let entry: object = {
a: {
b: {
c: {
dd: 'abcdd',
},
},
d: {
xx: 'adxx',
},
e: 'ae',
},
};
let output: object = {
'a.b.c.dd': 'abcdd',
'a.d.xx': 'adxx',
'a.e': 'ae',
};
bingzhichen 發表在 痞客邦 留言(0) 人氣(4)
// 「>」 子代選擇器:選擇 一個元素 / 裡的第一個直接子元素 / class
// ul 裡面的第一個li
ul {
& > li {
color: blue;
}
}
// 選擇 class .logo 裡面的第一個class .logo-title
.logo {
& > .logo-title {
color: blue;
}
}
// 「+」 同層相鄰組合選擇器:選擇 同層的並緊接在後的元素 / class
// 選擇header 緊接在後的img
header {
& + img {
width: 100px;
}
}
// 選擇 class .logo 緊接在後的class .logo-img
.logo {
& + .logo-img {
width: 100px;
}
}
// 「~」 同層全體組合選擇器:選擇同層指定的元素 / class的後面所有元素 / class,不管它們之間隔了多少個其他元素 / class
// h1 同層後面所有的p
h1 {
& ~ p {
color: gray;
}
}
// 選擇 class logo 同層後面所有的class .logo-title
.logo {
& ~ .logo-title {
color: gray;
}
}
bingzhichen 發表在 痞客邦 留言(0) 人氣(2)
git 2.35.2後,在.gitconfig設定加入
[safe]
directory = *
bingzhichen 發表在 痞客邦 留言(0) 人氣(20)
安裝/解除安裝node.js出現Invalid drive錯誤
win+r
輸入:subst 錯誤硬碟: %TEMP%(建立一個假的錯誤硬碟)
win+r
輸入:subst 錯誤硬碟:/D
bingzhichen 發表在 痞客邦 留言(0) 人氣(8)
let data: Model.IFilterData[] = JSON.parse(JSON.stringify(this.originalFilterData));
let filterKeys: { key: string, value: string }[] = {
{ key: 'name', value: "Name" },
{ key: 'age', value: "Age" },
{ key: 'id', value: "Id" },
{ key: 'email', value: "Email" },
};
// filter
if (!!filterKeys && filterKeys.length > 0) {
// 整理為物件
let filterKeyDirectory = {};
filterKeys.forEach((element) => {
let key: string = element.key;
if (!filterKeyDirectory[key]) {
filterKeyDirectory[key] = [];
}
filterKeyDirectory[key].push(element.selectedKey);
});
// 篩選資料
data = data.filter((item) => {
for (let key in filterKeyDirectory) {
if (item[key] === undefined || filterKeyDirectory[key].indexOf(item[key]) === -1) {
return false;
}
}
return true;
});
}
bingzhichen 發表在 痞客邦 留言(0) 人氣(38)
bingzhichen 發表在 痞客邦 留言(0) 人氣(5)
// way 1
setTimeout(() => {
let convertData = resolveDataString(DataString);
console.log(`convertData => `, convertData);
}, 0);
/**
* use while
*
* @param {object} obj
* @return {*}
*/
function resolveData(obj: object): object {
let result: object = {};
let keyValue = Object.entries(obj);
for (const [key, value] of keyValue) {
// Split key keys array
const keys: string[] = key.split('.');
// Create sub-objects along key as needed
let target: object = result;
while (keys.length > 1) {
const shiftKey = keys.shift();
let targetValue = (target[shiftKey] = target[shiftKey] || {});
target = targetValue;
// target = target[shiftKey] = target[shiftKey] || {};
}
// Set value at end of path
target[keys[0]] = value;
}
return result;
}
function resolveDataString(data: string): any {
let result: object = {};
let dataObj = data.split('\n');
dataObj.forEach((data) => {
let splitData: string[] = data.split('=');
result[splitData[0]] = splitData[1];
});
return resolveData(result);
}
// way 2
setTimeout(async () => {
let strs: string[][] = DataString .split(/(\r)?\n/)
.filter((n) => !!n)
.map((n) => n.split(/\.|=/).filter((n) => !!n));
let obj: object = {};
for (let i: number = 0; i < strs.length; i++) {
Cut(obj, strs[i]);
}
console.log(JSON.stringify(obj, null, 4));
}, 0);
/**
* use recursive
*
* @param {object} obj
* @param {string[]} keys
*/
function Cut(obj: object, keys: string[]) {
if (keys.length > 2) {
if (!obj[keys[0]]) {
obj[keys[0]] = {};
}
Cut(obj[keys[0]], keys.splice(1, keys.length - 1));
} else {
console.log(keys);
if (/[0-9]/.test(keys[1])) obj[keys[0]] = parseInt(keys[1]);
else if (/true|false/.test(keys[1])) obj[keys[0]] = keys[1] === 'true';
else obj[keys[0]] = keys[1];
}
}
const DataString = `scheduleView.today.en-US=Today
scheduleView.today.zh-CN=true
scheduleView.today.zh-TW=当天
scheduleView.today.ko-KR=123
scheduleView.today.ja-JP=오늘
scheduleView.tues.en-US=Tues.
scheduleView.tues.zh-CN=false
scheduleView.tues.zh-TW=周二
scheduleView.tues.ko-KR=456
scheduleView.tues.ja-JP=화요일
scheduleView.week.fri.en-US=fri.
scheduleView.week.fri.zh-CN=true
scheduleView.week.fri.zh-TW=五
scheduleView.week.fri.ko-KR=789
scheduleView.week.fri.ja-JP=ブランド`;
bingzhichen 發表在 痞客邦 留言(3) 人氣(148)
setTimeout(() => {
let convertData = resolveData(Data);
console.log(`convertData => `, convertData);
}, 0);
/**
* use while
* https://stackoverflow.com/questions/7793811/convert-javascript-dot-notation-object-to-nested-object
*
* @param {object} obj
* @return {*}
*/
function resolveData(obj: object): object {
let result: object = {};
let keyValue = Object.entries(obj);
for (const [key, value] of keyValue) {
// Split key keys array
const keys: string[] = key.split('.');
// Create sub-objects along key as needed
let target: object = result;
while (keys.length > 1) {
const shiftKey = keys.shift();
let targetValue = (target[shiftKey] = target[shiftKey] || {});
target = targetValue;
// target = target[shiftKey] = target[shiftKey] || {};
}
// Set value at end of path
target[keys[0]] = value;
}
return result;
}
const Data = {
'scheduleView.today.en-US': 'Today',
'scheduleView.today.zh-CN': '當天',
'scheduleView.today.zh-TW': '当天',
'scheduleView.today.ko-KR': '今日',
'scheduleView.today.ja-JP': '오늘',
'scheduleView.tues.en-US': 'Tues.',
'scheduleView.tues.zh-CN': '週二',
'scheduleView.tues.zh-TW': '周二',
'scheduleView.tues.ko-KR': '水曜日',
'scheduleView.tues.ja-JP': '화요일',
'scheduleView.week.fri.en-US': 'fri.',
'scheduleView.week.fri.zh-CN': '五',
'scheduleView.week.fri.zh-TW': '五',
'scheduleView.week.fri.ko-KR': '브랜드',
'scheduleView.week.fri.ja-JP': 'ブランド',
};
bingzhichen 發表在 痞客邦 留言(0) 人氣(11)