mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 03:36:16 +00:00
parent
a0ec4f5fbf
commit
33a477cf36
@ -45,8 +45,10 @@ var (
|
||||
{{define "numbers"}}Нумер. список{{end}}
|
||||
{{define "mycomarkup help"}}<a href="/help/en/mycomarkup" class="shy-link">Подробнее</a> о Микоразметке{{end}}
|
||||
{{define "actions"}}Действия{{end}}
|
||||
{{define "current date"}}Текущая дата{{end}}
|
||||
{{define "current time"}}Текущее время{{end}}
|
||||
{{define "current date utc"}}Дата UTC{{end}}
|
||||
{{define "current time utc"}}Время UTC{{end}}
|
||||
{{define "current date local"}}Местная дата{{end}}
|
||||
{{define "current time local"}}Местное время{{end}}
|
||||
{{define "selflink"}}Ссылка на вас{{end}}
|
||||
|
||||
{{define "empty heading"}}Эта гифа не существует{{end}}
|
||||
|
@ -32,8 +32,10 @@
|
||||
<aside class="edit-toolbar action-toolbar layout-card">
|
||||
<h2 class="edit-toolbar__title layout-card__title">{{block "actions" .}}Actions{{end}}</h2>
|
||||
<section class="edit-toolbar__buttons">
|
||||
<button class="btn edit-toolbar__btn edit-toolbar__date">{{block "current date" .}}Insert current date{{end}}</button>
|
||||
<button class="btn edit-toolbar__btn edit-toolbar__time">{{block "current time" .}}Insert current time{{end}}</button>
|
||||
<button class="btn edit-toolbar__btn edit-toolbar__date-local">{{block "current date local" .}}Current local date{{end}}</button>
|
||||
<button class="btn edit-toolbar__btn edit-toolbar__time-local">{{block "current time local" .}}Current local time{{end}}</button>
|
||||
<button class="btn edit-toolbar__btn edit-toolbar__date-utc">{{block "current date utc" .}}Current date UTC{{end}}</button>
|
||||
<button class="btn edit-toolbar__btn edit-toolbar__time-utc">{{block "current time utc" .}}Current time UTC{{end}}</button>
|
||||
{{if .Meta.U.Group | ne "anon"}}
|
||||
<button class="btn edit-toolbar__btn edit-toolbar__user-link">{{block "selflink" .}}Link yourself{{end}}</button>
|
||||
{{end}}
|
||||
|
@ -329,7 +329,7 @@ if (document.body.dataset.rrhAddr.startsWith('/edit')) {
|
||||
new Shortcut(isMac ? 'Meta+Shift+x' : 'Ctrl+X', wrapStrikethrough, 'Strikethrough', { force: true }),
|
||||
new Shortcut(isMac ? 'Meta+k' : 'Ctrl+k', wrapLink, 'Inline link', { force: true }),
|
||||
// Apparently, ⌘; conflicts with a Safari's hotkey. Whatever.
|
||||
new Shortcut(isMac ? 'Meta+;' : 'Ctrl+;', insertDate, 'Insert date UTC', { force: true }),
|
||||
new Shortcut(isMac ? 'Meta+;' : 'Ctrl+;', insertDateUTC, 'Insert date UTC', { force: true }),
|
||||
]))
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ const insertHorizontalBar = textInserter('\n----\n'),
|
||||
insertBulletedList = textInserter('\n* '),
|
||||
insertNumberedList = textInserter('\n*. ')
|
||||
|
||||
function insertDate() {
|
||||
function insertDateUTC() {
|
||||
let date = new Date().toISOString().split('T')[0]
|
||||
textInserter(date)()
|
||||
}
|
||||
@ -97,6 +97,20 @@ function insertTimeUTC() {
|
||||
textInserter(time)()
|
||||
}
|
||||
|
||||
function len2(n) {
|
||||
return n < 10 ? `0${n}` : `${n}`
|
||||
}
|
||||
|
||||
function insertDateLocal() {
|
||||
let d = new Date()
|
||||
textInserter(`${d.getFullYear()}-${len2(d.getMonth() + 1)}-${len2(d.getDate())}`)()
|
||||
}
|
||||
|
||||
function insertTimeLocal() {
|
||||
let d = new Date()
|
||||
textInserter(`${len2(d.getHours())}:${len2(d.getMinutes())}:${len2(d.getSeconds())}`)()
|
||||
}
|
||||
|
||||
function insertUserlink() {
|
||||
const userlink = document.querySelector('.auth-links__user-link')
|
||||
const userHypha = userlink.getAttribute('href').substring(7) // no /hypha/
|
||||
@ -124,8 +138,10 @@ const buttonsHandlers = {
|
||||
codeblock: insertCodeblock,
|
||||
bulletedlist: insertBulletedList,
|
||||
numberedlist: insertNumberedList,
|
||||
date: insertDate,
|
||||
time: insertTimeUTC,
|
||||
'date-utc': insertDateUTC,
|
||||
'time-utc': insertTimeUTC,
|
||||
'date-local': insertDateLocal,
|
||||
'time-local': insertTimeLocal,
|
||||
'user-link': insertUserlink,
|
||||
}
|
||||
for (const key of Object.keys(buttonsHandlers)) {
|
||||
|
Loading…
Reference in New Issue
Block a user