applism118
https://gyazo.com/bba67909e60b87c654e7c87515194889
関西出身のプロダクトマネージャー michiru_daの生活が記録されています。連絡はXのDMまで。
過去の日記 (2023/08~2024/08)
全部をNoitonに集約したかったけど、1年書き溜めたらweb公開版の描画が重い・途中でクラッシュするようになってしまった…
テンプレート
code:style.css
a#Templates.tool-btn:hover { text-decoration: none }
a#Templates.tool-btn::before { position: absolute; content: '\f067'; font: 900 21px/46px 'Font Awesome 5 Free' }
a#Templates.tool-btn img { opacity: 0 }
code:script.js
addTemplateItemsToPageMenu()
function addTemplateItemsToPageMenu() {
// テンプレートメニューの定義ここから ---------- 下の解説を見てね!! ----------
const __templates = [
{ title: '📄 今日の日記', template: '/api/code/applism118/applism118/今日の日記.js' },
{ title: '📄 昨日の日記', template: '/api/code/applism118/applism118/昨日の日記.js' },
{ title: '✍️ 週振り返り', template: '/api/code/applism118/applism118/週振り返り.js' },
{ title: '🎯 週目標', template: '/api/code/applism118/applism118/週目標.js' }
]
// テンプレートメニューの定義ここまで ----------
const __templMenuTitle = 'Templates'
__templates.forEach((i) => {
scrapbox.PageMenu(__templMenuTitle).addItem({
title: i.title,
onClick: () => { __loadTemplate(i.template) }})
})
var __loadTemplate = function (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}))
} catch (ex) {
console.log("だめでした>< \n" + ex)
}
} else {
console.log("だめでした>< \n" + status)
}
})
}
}
}
テンプレート:日記
code:今日の日記.js
(function() {
Date.prototype.setWeek = function(year, week, day) {
var week1 = new Date(year, 0, 1)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.setISOWeek = function(year, week, day) {
var week1 = new Date(year, 0, 4)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.format = function(format) {
// yyyy, MM, dd, ddd だけ
.replace('yyyy', this.getFullYear())
.replace('MM', ('0' + (this.getMonth() + 1)).slice(-2))
.replace('dd', ('0' + this.getDate()).slice(-2))
}
// Returns the ISO week of the date.
Date.prototype.getWeek = function() {
var date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
// Returns the four-digit year corresponding to the ISO week of the date.
Date.prototype.getWeekYear = function() {
var date = new Date(this.getTime());
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
return date.getFullYear();
}
// 処理ここから
const d = new Date()
const yesterday = new Date(d.getFullYear(), d.getMonth(), d.getDate() - 1)
const tomorrow = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1)
const dateFormat = "yyyy-MM-dd"
const dayFormat = "ddd"
// ここで返してるものがページのタイトルと本文になるよ! 1週間分の日付と曜日を並べていきます
return `${d.format(dateFormat)} ${d.format(dayFormat)} : (WIP)
/icons/-.icon
生活
コンテンツ
`
})()
code:昨日の日記.js
(function() {
Date.prototype.setWeek = function(year, week, day) {
var week1 = new Date(year, 0, 1)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.setISOWeek = function(year, week, day) {
var week1 = new Date(year, 0, 4)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.format = function(format) {
// yyyy, MM, dd, ddd だけ
.replace('yyyy', this.getFullYear())
.replace('MM', ('0' + (this.getMonth() + 1)).slice(-2))
.replace('dd', ('0' + this.getDate()).slice(-2))
}
// Returns the ISO week of the date.
Date.prototype.getWeek = function() {
var date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
// Returns the four-digit year corresponding to the ISO week of the date.
Date.prototype.getWeekYear = function() {
var date = new Date(this.getTime());
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
return date.getFullYear();
}
// 処理ここから
const d = new Date()
const y = new Date(d.getFullYear(), d.getMonth(), d.getDate() - 1)
const theday_before_yesterday = new Date(d.getFullYear(), d.getMonth(), d.getDate() - 2)
const tomorrow = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1)
const dateFormat = "yyyy-MM-dd"
const dayFormat = "ddd"
// ここで返してるものがページのタイトルと本文になるよ! 1週間分の日付と曜日を並べていきます
return `${y.format(dateFormat)} ${y.format(dayFormat)} : (WIP)
/icons/-.icon
生活
コンテンツ
`
})()
code:週振り返り.js
(function() {
Date.prototype.setWeek = function(year, week, day) {
var week1 = new Date(year, 0, 1)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.setISOWeek = function(year, week, day) {
var week1 = new Date(year, 0, 4)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.format = function(format) {
// yyyy, MM, dd, ddd だけ
.replace('yyyy', this.getFullYear())
.replace('MM', ('0' + (this.getMonth() + 1)).slice(-2))
.replace('dd', ('0' + this.getDate()).slice(-2))
}
// Returns the ISO week of the date.
Date.prototype.getWeek = function() {
var date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
// Returns the four-digit year corresponding to the ISO week of the date.
Date.prototype.getWeekYear = function() {
var date = new Date(this.getTime());
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
return date.getFullYear();
}
// 処理ここから
const d = new Date()
const yesterday = new Date(d.getFullYear(), d.getMonth(), d.getDate() - 1)
const tomorrow = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1)
const dateFormat = "yyyy-MM-dd"
const dayFormat = "ddd"
// ここで返してるものがページのタイトルと本文になるよ! 1週間分の日付と曜日を並べていきます
return `${d.getWeekYear()}年WN${d.getWeek()}の目標振り返り
/icons/-.icon
テーマの進捗
できたこと
プライベート
仕事
習慣
記事post: / 12回
仕事の振り返り: / 8本
本 : / 2冊
映画: / 1本
ランニング: /4回
できなかったけどやりたいこと
来月トライすること
`
})()
code:週目標.js
(function() {
Date.prototype.setWeek = function(year, week, day) {
var week1 = new Date(year, 0, 1)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.setISOWeek = function(year, week, day) {
var week1 = new Date(year, 0, 4)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.format = function(format) {
// yyyy, MM, dd, ddd だけ
.replace('yyyy', this.getFullYear())
.replace('MM', ('0' + (this.getMonth() + 1)).slice(-2))
.replace('dd', ('0' + this.getDate()).slice(-2))
}
// Returns the ISO week of the date.
Date.prototype.getWeek = function() {
var date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
// Returns the four-digit year corresponding to the ISO week of the date.
Date.prototype.getWeekYear = function() {
var date = new Date(this.getTime());
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
return date.getFullYear();
}
// 処理ここから
const d = new Date()
const yesterday = new Date(d.getFullYear(), d.getMonth(), d.getDate() - 1)
const tomorrow = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1)
const dateFormat = "yyyy-MM-dd"
const dayFormat = "ddd"
const nextWeek = d.getWeek() + 1
// ここで返してるものがページのタイトルと本文になるよ! 1週間分の日付と曜日を並べていきます
return `${d.getWeekYear()}年WN${nextWeek}の目標
/icons/-.icon
Objective 1:hoge
Objective 2: hoge
Objective 3: hoge
それ以外
振り返り
それ以外
まとめ
`
})()
code:style.css
/* 二重括弧による強調をマーカーっぽくする */
.line strong:not(class) { background: linear-gradient(transparent 10%, #ABFF4F 25%, #ABFF4F 70%, transparent 90%) }