fuga
https://scrapbox.io/files/63b1502e7f7b71002332c4ea.jpg
fuga.iconthis is fuga’s page
ふーが(Fu-ga)
8月5日生まれ
好きな飲食物
蒙古タンメン中本
コカコーラ(350ml缶赤)
トンカツ
餃子
ハンバーグ
グミ
嫌いな飲食物
キノコ類全般
魚介類の大半(まぐろ、サーモン等はいける)
プログラミング
Ruby / Rails
JavaScript / Vue.js
code:script.js
addTemplateItemsToPageMenu()
function addTemplateItemsToPageMenu() {
// テンプレートメニューの定義ここから ----------
const __templates = [
{ title: '🥞today', url: '/api/code/fuga-zakki/template/today.js' },
{ title: '🥞tommorow', url: '/api/code/fuga-zakki/template/tommorow.js' }
]
// テンプレートメニューの定義ここまで ----------
const __templateMenuTitle = 'Templates'
scrapbox.PageMenu.addMenu({ title: __templateMenuTitle, image: '/assets/img/logo.png', onClick: () => { } })
__templates.forEach((template) => {
scrapbox.PageMenu(__templateMenuTitle).addItem({
title: template.title,
onClick: () => { __loadTemplate(template.url) }})
})
const __loadTemplate = templateUrl => {
if (scrapbox.Page.lines && scrapbox.Page.lines.length == 1) {
const line = document.getElementById('L' + scrapbox.Page.lines0.id) const lastChar = line.querySelector('span.char-index:last-of-type')
const textarea = document.getElementById('text-input')
lastChar.dispatchEvent(new MouseEvent('click', {bubbles: true, cancelable: true}))
textarea.dispatchEvent(new KeyboardEvent('keydown', {bubbles: true, cancelable: true, keyCode: 35}))
// テンプレートを読み込む
$('#text-input').load(templateUrl, function (response, status, xhr) {
if (status == "success") {
try {
// 読み込んだテンプレートをテキストエリアにセット
textarea.value = /\.js$/.test(templateUrl) ? eval(response) : response
// テキストエリアのinputイベント
textarea.dispatchEvent(new InputEvent('input', {bubbles: true, cancelable: true}))
console.log("できました")
} catch (ex) {
console.log("だめでした>< \n" + ex)
}
} else {
console.log("だめでした>< \n" + status)
}
})
}
}
}