Last active
February 27, 2021 06:34
Revisions
-
julio-kim revised this gist
Dec 13, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -110,6 +110,6 @@ if (config.runsInWidget) { Script.setWidget(widget) } else { // for Test widget.presentSmall() } Script.complete() -
julio-kim revised this gist
Dec 13, 2020 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,13 +9,15 @@ let covid = await webView.evaluateJavaScript(` let overseas = document.querySelector(baseSelector + 'div.liveNum_today_new ul li:nth-child(2) span.data').innerText completion({date, count: { domestic: domestic.replace(",", ""), overseas }, wpsData: WPS_data }) `, true) let count = parseInt(covid.count.domestic) + parseInt(covid.count.overseas) let date = covid.date.replace(/\(|\)/g, '').split(',')[0] //console.log(covid.wpsData) const getIconSize = () => Device.isPhone() ? new Size(12, 12) : new Size(16, 16) const getTitleSize = () => Device.isPhone() ? 17 : 20 @@ -56,6 +58,7 @@ const loadImage = async (imageUrl) => { const main = async () => { let widget = new ListWidget() widget.setPadding(0, 0, 0, 0) widget.url = source widget.backgroundColor = new Color(getLevelColor(count)) widget.refreshAfterDate = new Date(Date.now() + 1000 * 30) // 30 Second -
julio-kim revised this gist
Dec 1, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -105,8 +105,8 @@ const main = async () => { let widget = await main() if (config.runsInWidget) { Script.setWidget(widget) } else { // for Test widget.presentMedium() } Script.complete() -
julio-kim revised this gist
Nov 25, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,8 @@ const getCountSize = (count) => { } const getLevelColor = (count) => { if (count >= 500) return '#222831' else if (count < 500 && count >= 300) return '#dc143c' else if (count < 300 && count >= 100) return '#f05454' else return '#0099ff' } -
julio-kim revised this gist
Nov 25, 2020 . 1 changed file with 8 additions and 17 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -40,10 +40,8 @@ const getIcon = async (iconName, color = 'white') => { let path = fm.joinPath(`${dir}`, `${iconName}.png`) if (fm.fileExists(path)) { return fm.readImage(path) } else { let iconImage = await loadImage(`https://iconsdb.com/icons/download/${color}/${iconName}.png`) fm.writeImage(path, iconImage) return iconImage @@ -55,8 +53,7 @@ const loadImage = async (imageUrl) => { return await request.loadImage() } const main = async () => { let widget = new ListWidget() widget.url = source widget.backgroundColor = new Color(getLevelColor(count)) @@ -99,22 +96,16 @@ if (config.runsInWidget) { dateTxt.centerAlignText() dateTxt.textColor = Color.white() dateTxt.font = Font.thinSystemFont(15) return widget } // Main Start let widget = await main() if (config.runsInWidget) { Script.setWidget(widget) Script.complete() } else { // for Test widget.presentMedium() } -
julio-kim revised this gist
Nov 25, 2020 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,10 @@ let covid = await webView.evaluateJavaScript(` let count = parseInt(covid.count.domestic) + parseInt(covid.count.overseas) let date = covid.date.replace(/\(|\)/g, '').split(',')[0] const getIconSize = () => Device.isPhone() ? new Size(12, 12) : new Size(16, 16) const getTitleSize = () => Device.isPhone() ? 17 : 20 const getCountSize = (count) => { if (count >= 1000) { return Device.isPhone() ? 45 : 55 @@ -66,15 +70,15 @@ if (config.runsInWidget) { titleStack.addSpacer() let imageIco = titleStack.addImage(await getIcon('star-11-32')) imageIco.imageSize = getIconSize() imageIco.centerAlignImage() titleStack.addSpacer(2) let titleTxt = titleStack.addText('코로나-19') titleTxt.centerAlignText() titleTxt.textColor = Color.white() titleTxt.font = Font.boldRoundedSystemFont(getTitleSize()) titleStack.addSpacer() -
julio-kim revised this gist
Nov 25, 2020 . 1 changed file with 44 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -30,16 +30,60 @@ const getLevelColor = (count) => { else return '#0099ff' } const getIcon = async (iconName, color = 'white') => { let fm = FileManager.local() let dir = fm.documentsDirectory() let path = fm.joinPath(`${dir}`, `${iconName}.png`) if (fm.fileExists(path)) { console.log(`file is exists: ${path}`) return fm.readImage(path) } else { console.log(`file is not exists: ${path}`) let iconImage = await loadImage(`https://iconsdb.com/icons/download/${color}/${iconName}.png`) fm.writeImage(path, iconImage) return iconImage } } const loadImage = async (imageUrl) => { let request = new Request(imageUrl) return await request.loadImage() } // Main Start if (config.runsInWidget) { let widget = new ListWidget() widget.url = source widget.backgroundColor = new Color(getLevelColor(count)) widget.refreshAfterDate = new Date(Date.now() + 1000 * 30) // 30 Second let titleRow = widget.addStack() let titleStack = titleRow.addStack() titleStack.layoutHorizontally() titleStack.centerAlignContent() titleStack.addSpacer() let imageIco = titleStack.addImage(await getIcon('star-11-32')) imageIco.imageSize = new Size(16, 16) imageIco.centerAlignImage() titleStack.addSpacer(2) let titleTxt = titleStack.addText('코로나-19') titleTxt.centerAlignText() titleTxt.textColor = Color.white() titleTxt.font = Font.boldRoundedSystemFont(20) titleStack.addSpacer() /* let titleTxt = widget.addText('코로나-19') titleTxt.centerAlignText() titleTxt.textColor = Color.white() titleTxt.font = Font.boldRoundedSystemFont(20) */ let countTxt = widget.addText(count.toString()) countTxt.url = source -
julio-kim revised this gist
Nov 25, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -32,6 +32,7 @@ const getLevelColor = (count) => { if (config.runsInWidget) { let widget = new ListWidget() widget.url = source widget.backgroundColor = new Color(getLevelColor(count)) widget.refreshAfterDate = new Date(Date.now() + 1000 * 30) // 30 Second -
julio-kim revised this gist
Nov 24, 2020 . No changes.There are no files selected for viewing
-
julio-kim revised this gist
Nov 24, 2020 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,12 +5,15 @@ await webView.loadURL(source) let covid = await webView.evaluateJavaScript(` const baseSelector = 'div.mainlive_container div.liveboard_layout ' let date = document.querySelector(baseSelector + 'h2 span.livedate').innerText let domestic = document.querySelector(baseSelector + 'div.liveNum_today_new ul li:nth-child(1) span.data').innerText let overseas = document.querySelector(baseSelector + 'div.liveNum_today_new ul li:nth-child(2) span.data').innerText completion({date, count: { domestic, overseas }}) `, true) let count = parseInt(covid.count.domestic) + parseInt(covid.count.overseas) let date = covid.date.replace(/\(|\)/g, '').split(',')[0] const getCountSize = (count) => { -
julio-kim revised this gist
Nov 23, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ const getLevelColor = (count) => { if (config.runsInWidget) { let widget = new ListWidget() widget.backgroundColor = new Color(getLevelColor(count)) widget.refreshAfterDate = new Date(Date.now() + 1000 * 30) // 30 Second let titleTxt = widget.addText('코로나-19') titleTxt.centerAlignText() -
julio-kim revised this gist
Nov 23, 2020 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ if (config.runsInWidget) { titleTxt.textColor = Color.white() titleTxt.font = Font.boldRoundedSystemFont(20) let countTxt = widget.addText(count.toString()) countTxt.url = source countTxt.centerAlignText() countTxt.textColor = Color.white() @@ -51,6 +51,7 @@ if (config.runsInWidget) { Script.setWidget(widget) Script.complete() } else { // for Test let table = new UITable() let row = new UITableRow() @@ -60,7 +61,7 @@ if (config.runsInWidget) { row = new UITableRow() row.addText('확진자수') row.addText(count.toString()).rightAligned() table.addRow(row) table.present() -
julio-kim created this gist
Nov 23, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ const source = 'http://ncov.mohw.go.kr' let webView = new WebView() await webView.loadURL(source) let covid = await webView.evaluateJavaScript(` const baseSelector = 'div.mainlive_container div.liveboard_layout ' let date = document.querySelector(baseSelector + 'h2 span.livedate').innerText let count = document.querySelector(baseSelector + 'div.liveNum_today_new ul li:nth-child(1) span.data').innerText completion({date, count}) `, true) let count = parseInt(covid.count) let date = covid.date.replace(/\(|\)/g, '').split(',')[0] const getCountSize = (count) => { if (count >= 1000) { return Device.isPhone() ? 45 : 55 } else { return Device.isPhone() ? 55 : 70 } } const getLevelColor = (count) => { if (count >= 300) return '#dc143c' else if (count < 300 && count >= 100) return '#f05454' else return '#0099ff' } if (config.runsInWidget) { let widget = new ListWidget() widget.backgroundColor = new Color(getLevelColor(count)) widget.refreshAfterDate = new Date(Date.now() + 1000 * 60 * 60) // 1 Hour let titleTxt = widget.addText('코로나-19') titleTxt.centerAlignText() titleTxt.textColor = Color.white() titleTxt.font = Font.boldRoundedSystemFont(20) let countTxt = widget.addText(covid.count) countTxt.url = source countTxt.centerAlignText() countTxt.textColor = Color.white() countTxt.font = Font.thinSystemFont(getCountSize(count)) let dateTxt = widget.addText(date) dateTxt.centerAlignText() dateTxt.textColor = Color.white() dateTxt.font = Font.thinSystemFont(15) Script.setWidget(widget) Script.complete() } else { let table = new UITable() let row = new UITableRow() row.isHeader = true row.addText(`코로나 확진자 현황 (${date})`) table.addRow(row) row = new UITableRow() row.addText('확진자수') row.addText(covid.count).rightAligned() table.addRow(row) table.present() }