From 364fefaa4a8fb6ded2d9d4bcae06e95a78d4b6bb Mon Sep 17 00:00:00 2001 From: WEBXOSS Date: Mon, 7 Nov 2016 23:15:34 +0800 Subject: [PATCH] handle CardInfo for translation --- test.html | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test.html b/test.html index 74f438e..05773b0 100644 --- a/test.html +++ b/test.html @@ -62,7 +62,7 @@ function handleCardInfo () { // document.body.appendChild(textarea); // textarea.select(); } -function handleCardInfo_ru () { +function handleCardInfo_ko (min, max) { var props = [ "name", "actionEffectTexts", @@ -81,7 +81,8 @@ function handleCardInfo_ru () { ] var arr = []; for (var x in CardInfo) { - if (x <= 1762) continue; + // if (x <= 1762) continue; + if (x < min || x > max) continue; var info = CardInfo[x]; var obj = { pid: info.pid, @@ -93,11 +94,11 @@ function handleCardInfo_ru () { // if (!info[prop]) return; // obj[prop] = info[prop]; // }); - obj[rawprop+"_ru"] = info[rawprop+"_en"]; + obj[rawprop+"_ko"] = info[rawprop+"_en"]; }); arr.push(obj); } - window.arr = arr; + down(arr, `${min}-${max}.json`) } function fetchAndHandleRuJson (url) { let CardInfo_ru = {}; @@ -156,6 +157,17 @@ function getNewCardNames () { } return names; } +function down (content, filename = 'down.txt') { + if (typeof content === 'object') { + content = JSON.stringify(content, null, ' ') + } + let blob = new Blob([content], { type: 'application/octet-stream' }) + let url = URL.createObjectURL(blob) + let link = document.createElement('a') + link.href = url + link.download = filename + link.click() +}