mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-15 06:27:34 -07:00
wip
This commit is contained in:
parent
2eb93567e4
commit
87429d7881
64 changed files with 332 additions and 332 deletions
|
@ -314,11 +314,11 @@
|
|||
query: q
|
||||
max: 5
|
||||
.then (users) =>
|
||||
users.for-each (user) =>
|
||||
users.forEach (user) =>
|
||||
user._click = =>
|
||||
this.trigger 'navigate-user' user
|
||||
this.search-result = []
|
||||
this.search-result = users
|
||||
this.searchResult = []
|
||||
this.searchResult = users
|
||||
this.update();
|
||||
.catch (err) =>
|
||||
console.error err
|
||||
|
@ -330,16 +330,16 @@
|
|||
| 9, 40 => // Key[TAB] or Key[↓]
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.refs.search-result.childNodes[0].focus();
|
||||
this.refs.searchResult.childNodes[0].focus();
|
||||
};
|
||||
|
||||
this.on-search-result-keydown = (i, e) => {
|
||||
this.on-searchResult-keydown = (i, e) => {
|
||||
key = e.which
|
||||
switch (key)
|
||||
| 10, 13 => // Key[ENTER]
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@search-result[i]._click!
|
||||
this.searchResult[i]._click();
|
||||
| 27 => // Key[ESC]
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
@ -347,11 +347,11 @@
|
|||
| 38 => // Key[↑]
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
(this.refs.search-result.childNodes[i].previous-element-sibling || this.refs.search-result.childNodes[@search-result.length - 1]).focus();
|
||||
(this.refs.searchResult.childNodes[i].previousElementSibling || this.refs.searchResult.childNodes[this.searchResult.length - 1]).focus();
|
||||
| 9, 40 => // Key[TAB] or Key[↓]
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
(this.refs.search-result.childNodes[i].next-element-sibling || this.refs.search-result.childNodes[0]).focus();
|
||||
(this.refs.searchResult.childNodes[i].nextElementSibling || this.refs.searchResult.childNodes[0]).focus();
|
||||
};
|
||||
|
||||
</script>
|
||||
|
|
|
@ -159,9 +159,9 @@
|
|||
document.removeEventListener 'visibilitychange' this.on-visibilitychange
|
||||
|
||||
this.on('update', () => {
|
||||
@messages.for-each (message) =>
|
||||
date = (new Date message.created_at).get-date!
|
||||
month = (new Date message.created_at).get-month! + 1
|
||||
@messages.forEach (message) =>
|
||||
date = (new Date message.created_at).getDate()
|
||||
month = (new Date message.created_at).getMonth() + 1
|
||||
message._date = date
|
||||
message._datetext = month + '月 ' + date + '日'
|
||||
|
||||
|
@ -184,7 +184,7 @@
|
|||
|
||||
this.on-read = (ids) => {
|
||||
if not Array.isArray ids then ids = [ids]
|
||||
ids.for-each (id) =>
|
||||
ids.forEach (id) =>
|
||||
if (@messages.some (x) => x.id == id)
|
||||
exist = (@messages.map (x) -> x.id).index-of id
|
||||
@messages[exist].is_read = true
|
||||
|
@ -215,7 +215,7 @@
|
|||
|
||||
this.on-visibilitychange = () => {
|
||||
if document.hidden then return
|
||||
@messages.for-each (message) =>
|
||||
@messages.forEach (message) =>
|
||||
if message.user_id != this.I.id and not message.is_read
|
||||
@connection.socket.send JSON.stringify do
|
||||
type: 'read'
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
this.on('mount', () => {
|
||||
text = this.root.innerHTML
|
||||
this.root.innerHTML = ''
|
||||
(text.split '').for-each (c, i) =>
|
||||
(text.split '').forEach (c, i) =>
|
||||
ce = document.createElement 'span'
|
||||
ce.innerHTML = c
|
||||
ce.style.animationDelay = (i / 10) + 's'
|
||||
|
|
|
@ -63,10 +63,10 @@
|
|||
.catch (err) =>
|
||||
console.error err
|
||||
|
||||
@stream.on 'signin' this.on-signin
|
||||
this.stream.on 'signin' this.on-signin
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'signin' this.on-signin
|
||||
this.stream.off 'signin' this.on-signin
|
||||
|
||||
this.on-signin = (signin) => {
|
||||
@history.unshift signin
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
username: this.refs.username.value
|
||||
password: this.refs.password.value
|
||||
.then =>
|
||||
location.reload!
|
||||
location.reload();
|
||||
.catch =>
|
||||
alert 'something happened'
|
||||
this.signing = false
|
||||
|
|
|
@ -268,15 +268,15 @@
|
|||
this.onsubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
username = this.refs.username.value
|
||||
password = this.refs.password.value
|
||||
const username = this.refs.username.value;
|
||||
const password = this.refs.password.value;
|
||||
|
||||
locker = document.body.appendChild document.createElement 'mk-locker'
|
||||
|
||||
this.api 'signup' do
|
||||
username: username
|
||||
password: password
|
||||
'g-recaptcha-response': grecaptcha.get-response!
|
||||
username: username,
|
||||
password: password,
|
||||
'g-recaptcha-response': grecaptcha.getResponse()
|
||||
.then =>
|
||||
this.api 'signin' do
|
||||
username: username
|
||||
|
|
|
@ -6,25 +6,25 @@
|
|||
this.tickid = null
|
||||
|
||||
this.absolute =
|
||||
@time.get-full-year! + '年' +
|
||||
@time.get-month! + 1 + '月' +
|
||||
@time.get-date! + '日' +
|
||||
this.time.getFullYear() + '年' +
|
||||
this.time.getMonth() + 1 + '月' +
|
||||
this.time.getDate() + '日' +
|
||||
' ' +
|
||||
@time.get-hours! + '時' +
|
||||
@time.get-minutes! + '分'
|
||||
this.time.getHours() + '時' +
|
||||
this.time.getMinutes() + '分'
|
||||
|
||||
this.on('mount', () => {
|
||||
if @mode == 'relative' or @mode == 'detail'
|
||||
@tick!
|
||||
this.tickid = set-interval @tick, 1000ms
|
||||
if this.mode == 'relative' or this.mode == 'detail'
|
||||
this.tick!
|
||||
this.tickid = setInterval this.tick, 1000ms
|
||||
|
||||
this.on('unmount', () => {
|
||||
if @mode == 'relative' or @mode == 'detail'
|
||||
clear-interval @tickid
|
||||
if this.mode == 'relative' or this.mode == 'detail'
|
||||
clearInterval this.tickid
|
||||
|
||||
this.tick = () => {
|
||||
now = new Date!
|
||||
ago = (now - @time) / 1000ms
|
||||
const now = new Date();
|
||||
ago = (now - this.time) / 1000ms
|
||||
this.relative = switch
|
||||
| ago >= 31536000s => ~~(ago / 31536000s) + '年前'
|
||||
| ago >= 2592000s => ~~(ago / 2592000s) + 'ヶ月前'
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
<script>
|
||||
this.on('mount', () => {
|
||||
@draw!
|
||||
this.clock = set-interval @draw, 1000ms
|
||||
this.clock = setInterval @draw, 1000ms
|
||||
|
||||
this.on('unmount', () => {
|
||||
clear-interval @clock
|
||||
clearInterval @clock
|
||||
|
||||
this.draw = () => {
|
||||
now = new Date!
|
||||
const now = new Date();
|
||||
s = now.get-seconds!
|
||||
m = now.get-minutes!
|
||||
h = now.get-hours!
|
||||
m = now.getMinutes()
|
||||
h = now.getHours()
|
||||
|
||||
vec2 = (x, y) ->
|
||||
this.x = x
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
@textarea.addEventListener 'keydown' this.on-keydown
|
||||
|
||||
all = document.query-selector-all 'body *'
|
||||
Array.prototype.for-each.call all, (el) =>
|
||||
Array.prototype.forEach.call all, (el) =>
|
||||
el.addEventListener 'mousedown' @mousedown
|
||||
|
||||
this.api 'users/search_by_username' do
|
||||
|
@ -109,7 +109,7 @@
|
|||
@textarea.removeEventListener 'keydown' this.on-keydown
|
||||
|
||||
all = document.query-selector-all 'body *'
|
||||
Array.prototype.for-each.call all, (el) =>
|
||||
Array.prototype.forEach.call all, (el) =>
|
||||
el.removeEventListener 'mousedown' @mousedown
|
||||
|
||||
this.mousedown = (e) => {
|
||||
|
@ -164,7 +164,7 @@
|
|||
@apply-select!
|
||||
|
||||
this.apply-select = () => {
|
||||
this.refs.users.children.for-each (el) =>
|
||||
this.refs.users.children.forEach (el) =>
|
||||
el.remove-attribute 'data-selected'
|
||||
|
||||
this.refs.users.children[@select].setAttribute 'data-selected' \true
|
||||
|
|
|
@ -84,12 +84,12 @@
|
|||
this.user = user
|
||||
this.init = false
|
||||
this.update();
|
||||
@stream.on 'follow' this.on-stream-follow
|
||||
@stream.on 'unfollow' this.on-stream-unfollow
|
||||
this.stream.on 'follow' this.on-stream-follow
|
||||
this.stream.on 'unfollow' this.on-stream-unfollow
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'follow' this.on-stream-follow
|
||||
@stream.off 'unfollow' this.on-stream-unfollow
|
||||
this.stream.off 'follow' this.on-stream-follow
|
||||
this.stream.off 'unfollow' this.on-stream-unfollow
|
||||
|
||||
this.on-stream-follow = (user) => {
|
||||
if user.id == @user.id
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
|
||||
this.open = (pos) => {
|
||||
all = document.query-selector-all 'body *'
|
||||
Array.prototype.for-each.call all, (el) =>
|
||||
Array.prototype.forEach.call all, (el) =>
|
||||
el.addEventListener 'mousedown' @mousedown
|
||||
this.root.style.display = 'block'
|
||||
this.root.style.left = pos.x + 'px'
|
||||
|
@ -123,7 +123,7 @@
|
|||
|
||||
this.close = () => {
|
||||
all = document.query-selector-all 'body *'
|
||||
Array.prototype.for-each.call all, (el) =>
|
||||
Array.prototype.forEach.call all, (el) =>
|
||||
el.removeEventListener 'mousedown' @mousedown
|
||||
this.trigger('closed');
|
||||
this.unmount();
|
||||
|
|
|
@ -80,10 +80,10 @@
|
|||
</style>
|
||||
<script>
|
||||
this.can-through = if opts.can-through? then opts.can-through else true
|
||||
this.opts.buttons.for-each (button) =>
|
||||
this.opts.buttons.forEach (button) =>
|
||||
button._onclick = =>
|
||||
if button.onclick?
|
||||
button.onclick!
|
||||
button.onclick();
|
||||
@close!
|
||||
|
||||
this.on('mount', () => {
|
||||
|
|
|
@ -243,24 +243,24 @@
|
|||
this.mixin('input-dialog');
|
||||
this.mixin('stream');
|
||||
|
||||
this.files = []
|
||||
this.folders = []
|
||||
this.hierarchy-folders = []
|
||||
this.files = [];
|
||||
this.folders = [];
|
||||
this.hierarchyFolders = [];
|
||||
|
||||
this.uploads = []
|
||||
this.uploads = [];
|
||||
|
||||
// 現在の階層(フォルダ)
|
||||
// * null でルートを表す
|
||||
this.folder = null
|
||||
this.folder = null;
|
||||
|
||||
this.multiple = if this.opts.multiple? then this.opts.multiple else false
|
||||
|
||||
// ドロップされようとしているか
|
||||
this.draghover = false
|
||||
this.draghover = false;
|
||||
|
||||
// 自信の所有するアイテムがドラッグをスタートさせたか
|
||||
// (自分自身の階層にドロップできないようにするためのフラグ)
|
||||
this.is-drag-source = false
|
||||
this.is-drag-source = false;
|
||||
|
||||
this.on('mount', () => {
|
||||
this.refs.uploader.on('uploaded', (file) => {
|
||||
|
@ -270,10 +270,10 @@
|
|||
this.uploads = uploads
|
||||
this.update();
|
||||
|
||||
@stream.on 'drive_file_created' this.on-stream-drive-file-created
|
||||
@stream.on 'drive_file_updated' this.on-stream-drive-file-updated
|
||||
@stream.on 'drive_folder_created' this.on-stream-drive-folder-created
|
||||
@stream.on 'drive_folder_updated' this.on-stream-drive-folder-updated
|
||||
this.stream.on 'drive_file_created' this.on-stream-drive-file-created
|
||||
this.stream.on 'drive_file_updated' this.on-stream-drive-file-updated
|
||||
this.stream.on 'drive_folder_created' this.on-stream-drive-folder-created
|
||||
this.stream.on 'drive_folder_updated' this.on-stream-drive-folder-updated
|
||||
|
||||
// Riotのバグでnullを渡しても""になる
|
||||
// https://github.com/riot/riot/issues/2080
|
||||
|
@ -284,10 +284,10 @@
|
|||
@load!
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'drive_file_created' this.on-stream-drive-file-created
|
||||
@stream.off 'drive_file_updated' this.on-stream-drive-file-updated
|
||||
@stream.off 'drive_folder_created' this.on-stream-drive-folder-created
|
||||
@stream.off 'drive_folder_updated' this.on-stream-drive-folder-updated
|
||||
this.stream.off 'drive_file_created' this.on-stream-drive-file-created
|
||||
this.stream.off 'drive_file_updated' this.on-stream-drive-file-updated
|
||||
this.stream.off 'drive_folder_created' this.on-stream-drive-folder-created
|
||||
this.stream.off 'drive_folder_updated' this.on-stream-drive-folder-updated
|
||||
|
||||
this.on-stream-drive-file-created = (file) => {
|
||||
@add-file file, true
|
||||
|
@ -315,30 +315,30 @@
|
|||
|
||||
rect = this.refs.main.get-bounding-client-rect!
|
||||
|
||||
left = e.page-x + this.refs.main.scroll-left - rect.left - window.page-x-offset
|
||||
top = e.page-y + this.refs.main.scroll-top - rect.top - window.page-y-offset
|
||||
left = e.pageX + this.refs.main.scroll-left - rect.left - window.pageXOffset
|
||||
top = e.pageY + this.refs.main.scroll-top - rect.top - window.pageYOffset
|
||||
|
||||
move = (e) =>
|
||||
this.refs.selection.style.display = 'block'
|
||||
|
||||
cursor-x = e.page-x + this.refs.main.scroll-left - rect.left - window.page-x-offset
|
||||
cursor-y = e.page-y + this.refs.main.scroll-top - rect.top - window.page-y-offset
|
||||
w = cursor-x - left
|
||||
h = cursor-y - top
|
||||
cursorX = e.pageX + this.refs.main.scroll-left - rect.left - window.pageXOffset
|
||||
cursorY = e.pageY + this.refs.main.scroll-top - rect.top - window.pageYOffset
|
||||
w = cursorX - left
|
||||
h = cursorY - top
|
||||
|
||||
if w > 0
|
||||
this.refs.selection.style.width = w + 'px'
|
||||
this.refs.selection.style.left = left + 'px'
|
||||
else
|
||||
this.refs.selection.style.width = -w + 'px'
|
||||
this.refs.selection.style.left = cursor-x + 'px'
|
||||
this.refs.selection.style.left = cursorX + 'px'
|
||||
|
||||
if h > 0
|
||||
this.refs.selection.style.height = h + 'px'
|
||||
this.refs.selection.style.top = top + 'px'
|
||||
else
|
||||
this.refs.selection.style.height = -h + 'px'
|
||||
this.refs.selection.style.top = cursor-y + 'px'
|
||||
this.refs.selection.style.top = cursorY + 'px'
|
||||
|
||||
up = (e) =>
|
||||
document.document-element.removeEventListener 'mousemove' move
|
||||
|
@ -351,7 +351,7 @@
|
|||
|
||||
this.path-oncontextmenu = (e) => {
|
||||
e.preventDefault();
|
||||
e.stop-immediate-propagation!
|
||||
e.stopImmediatePropagation();
|
||||
return false
|
||||
|
||||
this.ondragover = (e) => {
|
||||
|
@ -361,7 +361,7 @@
|
|||
// ドラッグ元が自分自身の所有するアイテムかどうか
|
||||
if !@is-drag-source
|
||||
// ドラッグされてきたものがファイルだったら
|
||||
if e.dataTransfer.effect-allowed == 'all'
|
||||
if e.dataTransfer.effectAllowed == 'all'
|
||||
e.dataTransfer.dropEffect = 'copy'
|
||||
else
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
|
@ -387,7 +387,7 @@
|
|||
|
||||
// ドロップされてきたものがファイルだったら
|
||||
if e.dataTransfer.files.length > 0
|
||||
Array.prototype.for-each.call e.dataTransfer.files, (file) =>
|
||||
Array.prototype.forEach.call e.dataTransfer.files, (file) =>
|
||||
@upload file, this.folder
|
||||
return false
|
||||
|
||||
|
@ -440,20 +440,20 @@
|
|||
|
||||
this.oncontextmenu = (e) => {
|
||||
e.preventDefault();
|
||||
e.stop-immediate-propagation!
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
ctx = document.body.appendChild document.createElement 'mk-drive-browser-base-contextmenu'
|
||||
ctx = riot.mount ctx, do
|
||||
browser: @
|
||||
browser: this
|
||||
ctx = ctx.0
|
||||
ctx.open do
|
||||
x: e.page-x - window.page-x-offset
|
||||
y: e.page-y - window.page-y-offset
|
||||
x: e.pageX - window.pageXOffset
|
||||
y: e.pageY - window.pageYOffset
|
||||
|
||||
return false
|
||||
|
||||
this.select-local-file = () => {
|
||||
this.refs.file-input.click!
|
||||
this.refs.file-input.click();
|
||||
|
||||
this.url-upload = () => {
|
||||
url <~ @input-dialog do
|
||||
|
@ -522,10 +522,10 @@
|
|||
folder_id: target-folder
|
||||
.then (folder) =>
|
||||
this.folder = folder
|
||||
this.hierarchy-folders = []
|
||||
this.hierarchyFolders = []
|
||||
|
||||
x = (f) =>
|
||||
@hierarchy-folders.unshift f
|
||||
@hierarchyFolders.unshift f
|
||||
if f.parent?
|
||||
x f.parent
|
||||
|
||||
|
@ -588,7 +588,7 @@
|
|||
this.go-root = () => {
|
||||
if this.folder != null
|
||||
this.folder = null
|
||||
this.hierarchy-folders = []
|
||||
this.hierarchyFolders = []
|
||||
this.update();
|
||||
@load!
|
||||
|
||||
|
@ -635,9 +635,9 @@
|
|||
flag = false
|
||||
complete = =>
|
||||
if flag
|
||||
load-folders.for-each (folder) =>
|
||||
load-folders.forEach (folder) =>
|
||||
@add-folder folder
|
||||
load-files.for-each (file) =>
|
||||
load-files.forEach (file) =>
|
||||
@add-file file
|
||||
this.loading = false
|
||||
this.update();
|
||||
|
|
|
@ -166,14 +166,14 @@
|
|||
if this.file._selected
|
||||
this.browser.trigger 'selected' this.file
|
||||
else
|
||||
this.browser.files.for-each (file) =>
|
||||
this.browser.files.forEach (file) =>
|
||||
file._selected = false
|
||||
this.file._selected = true
|
||||
this.browser.trigger 'change-selection' this.file
|
||||
|
||||
this.oncontextmenu = (e) => {
|
||||
e.preventDefault();
|
||||
e.stop-immediate-propagation!
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
this.is-contextmenu-showing = true
|
||||
this.update();
|
||||
|
@ -183,15 +183,15 @@
|
|||
file: this.file
|
||||
ctx = ctx.0
|
||||
ctx.open do
|
||||
x: e.page-x - window.page-x-offset
|
||||
y: e.page-y - window.page-y-offset
|
||||
x: e.pageX - window.pageXOffset
|
||||
y: e.pageY - window.pageYOffset
|
||||
ctx.on('closed', () => {
|
||||
this.is-contextmenu-showing = false
|
||||
this.update();
|
||||
return false
|
||||
|
||||
this.ondragstart = (e) => {
|
||||
e.dataTransfer.effect-allowed = 'move'
|
||||
e.dataTransfer.effectAllowed = 'move'
|
||||
e.dataTransfer.set-data 'text' JSON.stringify do
|
||||
type: 'file'
|
||||
id: this.file.id
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
// 自分自身がドラッグされていない場合
|
||||
if !@is-dragging
|
||||
// ドラッグされてきたものがファイルだったら
|
||||
if e.dataTransfer.effect-allowed == 'all'
|
||||
if e.dataTransfer.effectAllowed == 'all'
|
||||
e.dataTransfer.dropEffect = 'copy'
|
||||
else
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
|
@ -99,7 +99,7 @@
|
|||
|
||||
// ファイルだったら
|
||||
if e.dataTransfer.files.length > 0
|
||||
Array.prototype.for-each.call e.dataTransfer.files, (file) =>
|
||||
Array.prototype.forEach.call e.dataTransfer.files, (file) =>
|
||||
this.browser.upload file, this.folder
|
||||
return false
|
||||
|
||||
|
@ -147,7 +147,7 @@
|
|||
return false
|
||||
|
||||
this.ondragstart = (e) => {
|
||||
e.dataTransfer.effect-allowed = 'move'
|
||||
e.dataTransfer.effectAllowed = 'move'
|
||||
e.dataTransfer.set-data 'text' JSON.stringify do
|
||||
type: 'folder'
|
||||
id: this.folder.id
|
||||
|
@ -163,7 +163,7 @@
|
|||
|
||||
this.oncontextmenu = (e) => {
|
||||
e.preventDefault();
|
||||
e.stop-immediate-propagation!
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
this.is-contextmenu-showing = true
|
||||
this.update();
|
||||
|
@ -173,8 +173,8 @@
|
|||
folder: this.folder
|
||||
ctx = ctx.0
|
||||
ctx.open do
|
||||
x: e.page-x - window.page-x-offset
|
||||
y: e.page-y - window.page-y-offset
|
||||
x: e.pageX - window.pageXOffset
|
||||
y: e.pageY - window.pageYOffset
|
||||
ctx.on('closed', () => {
|
||||
this.is-contextmenu-showing = false
|
||||
this.update();
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
if this.folder == null and this.browser.folder == null
|
||||
e.dataTransfer.dropEffect = 'none'
|
||||
// ドラッグされてきたものがファイルだったら
|
||||
else if e.dataTransfer.effect-allowed == 'all'
|
||||
else if e.dataTransfer.effectAllowed == 'all'
|
||||
e.dataTransfer.dropEffect = 'copy'
|
||||
else
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
|
@ -53,7 +53,7 @@
|
|||
|
||||
// ファイルだったら
|
||||
if e.dataTransfer.files.length > 0
|
||||
Array.prototype.for-each.call e.dataTransfer.files, (file) =>
|
||||
Array.prototype.forEach.call e.dataTransfer.files, (file) =>
|
||||
this.browser.upload file, this.folder
|
||||
return false
|
||||
|
||||
|
|
|
@ -81,12 +81,12 @@
|
|||
this.user = user
|
||||
this.init = false
|
||||
this.update();
|
||||
@stream.on 'follow' this.on-stream-follow
|
||||
@stream.on 'unfollow' this.on-stream-unfollow
|
||||
this.stream.on 'follow' this.on-stream-follow
|
||||
this.stream.on 'unfollow' this.on-stream-unfollow
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'follow' this.on-stream-follow
|
||||
@stream.off 'unfollow' this.on-stream-unfollow
|
||||
this.stream.off 'follow' this.on-stream-follow
|
||||
this.stream.off 'unfollow' this.on-stream-unfollow
|
||||
|
||||
this.on-stream-follow = (user) => {
|
||||
if user.id == @user.id
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
|
||||
this.api 'users/recommendation' do
|
||||
limit: @limit
|
||||
offset: @limit * @page
|
||||
offset: @limit * this.page
|
||||
.then (users) =>
|
||||
this.loading = false
|
||||
this.users = users
|
||||
|
@ -154,7 +154,7 @@
|
|||
if @users.length < @limit
|
||||
this.page = 0
|
||||
else
|
||||
@page++
|
||||
this.page++
|
||||
@load!
|
||||
|
||||
this.close = () => {
|
||||
|
|
|
@ -107,10 +107,10 @@
|
|||
</style>
|
||||
<script>
|
||||
this.draw = () => {
|
||||
now = new Date!
|
||||
nd = now.get-date!
|
||||
nm = now.get-month!
|
||||
ny = now.get-full-year!
|
||||
const now = new Date();
|
||||
nd = now.getDate()
|
||||
nm = now.getMonth()
|
||||
ny = now.getFullYear()
|
||||
|
||||
this.year = ny
|
||||
this.month = nm + 1
|
||||
|
@ -140,9 +140,9 @@
|
|||
@draw!
|
||||
|
||||
this.on('mount', () => {
|
||||
this.clock = set-interval @draw, 1000ms
|
||||
this.clock = setInterval @draw, 1000ms
|
||||
|
||||
this.on('unmount', () => {
|
||||
clear-interval @clock
|
||||
clearInterval @clock
|
||||
</script>
|
||||
</mk-calendar-home-widget>
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
this.fetch = (cb) => {
|
||||
this.api 'posts/mentions' do
|
||||
following: @mode == 'following'
|
||||
following: this.mode == 'following'
|
||||
.then (posts) =>
|
||||
this.is-loading = false
|
||||
this.is-empty = posts.length == 0
|
||||
|
@ -90,7 +90,7 @@
|
|||
this.more-loading = true
|
||||
this.update();
|
||||
this.api 'posts/mentions' do
|
||||
following: @mode == 'following'
|
||||
following: this.mode == 'following'
|
||||
max_id: this.refs.timeline.tail!.id
|
||||
.then (posts) =>
|
||||
this.more-loading = false
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
this.initializing = true
|
||||
|
||||
this.on('mount', () => {
|
||||
@stream.on 'drive_file_created' this.on-stream-drive-file-created
|
||||
this.stream.on 'drive_file_created' this.on-stream-drive-file-created
|
||||
|
||||
this.api 'drive/stream' do
|
||||
type: 'image/*'
|
||||
|
@ -75,7 +75,7 @@
|
|||
this.update();
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'drive_file_created' this.on-stream-drive-file-created
|
||||
this.stream.off 'drive_file_created' this.on-stream-drive-file-created
|
||||
|
||||
this.on-stream-drive-file-created = (file) => {
|
||||
if /^image\/.+$/.test file.type
|
||||
|
|
|
@ -73,10 +73,10 @@
|
|||
|
||||
this.on('mount', () => {
|
||||
@fetch!
|
||||
this.clock = set-interval @fetch, 60000ms
|
||||
this.clock = setInterval @fetch, 60000ms
|
||||
|
||||
this.on('unmount', () => {
|
||||
clear-interval @clock
|
||||
clearInterval @clock
|
||||
|
||||
this.fetch = () => {
|
||||
this.api CONFIG.url + '/api:rss' do
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
this.no-following = this.I.following_count == 0
|
||||
|
||||
this.on('mount', () => {
|
||||
@stream.on 'post' this.on-stream-post
|
||||
@stream.on 'follow' this.on-stream-follow
|
||||
@stream.on 'unfollow' this.on-stream-unfollow
|
||||
this.stream.on 'post' this.on-stream-post
|
||||
this.stream.on 'follow' this.on-stream-follow
|
||||
this.stream.on 'unfollow' this.on-stream-unfollow
|
||||
|
||||
document.addEventListener 'keydown' this.on-document-keydown
|
||||
window.addEventListener 'scroll' this.on-scroll
|
||||
|
@ -53,9 +53,9 @@
|
|||
this.trigger('loaded');
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'post' this.on-stream-post
|
||||
@stream.off 'follow' this.on-stream-follow
|
||||
@stream.off 'unfollow' this.on-stream-unfollow
|
||||
this.stream.off 'post' this.on-stream-post
|
||||
this.stream.off 'follow' this.on-stream-follow
|
||||
this.stream.off 'unfollow' this.on-stream-unfollow
|
||||
|
||||
document.removeEventListener 'keydown' this.on-document-keydown
|
||||
window.removeEventListener 'scroll' this.on-scroll
|
||||
|
|
|
@ -43,10 +43,10 @@
|
|||
|
||||
this.on('mount', () => {
|
||||
@set!
|
||||
this.clock = set-interval @change, 20000ms
|
||||
this.clock = setInterval @change, 20000ms
|
||||
|
||||
this.on('unmount', () => {
|
||||
clear-interval @clock
|
||||
clearInterval @clock
|
||||
|
||||
this.set = () => {
|
||||
this.refs.text.innerHTML = @tips[Math.floor Math.random! * @tips.length]
|
||||
|
|
|
@ -120,13 +120,13 @@
|
|||
|
||||
this.on('mount', () => {
|
||||
@fetch!
|
||||
this.clock = set-interval =>
|
||||
this.clock = setInterval =>
|
||||
if @users.length < @limit
|
||||
@fetch true
|
||||
, 60000ms
|
||||
|
||||
this.on('unmount', () => {
|
||||
clear-interval @clock
|
||||
clearInterval @clock
|
||||
|
||||
this.fetch = (quiet = false) => {
|
||||
this.loading = true
|
||||
|
@ -134,7 +134,7 @@
|
|||
if not quiet then this.update();
|
||||
this.api 'users/recommendation' do
|
||||
limit: @limit
|
||||
offset: @limit * @page
|
||||
offset: @limit * this.page
|
||||
.then (users) =>
|
||||
this.loading = false
|
||||
this.users = users
|
||||
|
@ -146,7 +146,7 @@
|
|||
if @users.length < @limit
|
||||
this.page = 0
|
||||
else
|
||||
@page++
|
||||
this.page++
|
||||
@fetch!
|
||||
</script>
|
||||
</mk-user-recommendation-home-widget>
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
this.mode = this.opts.mode || 'timeline'
|
||||
|
||||
// https://github.com/riot/riot/issues/2080
|
||||
if @mode == '' then this.mode = 'timeline'
|
||||
if this.mode == '' then this.mode = 'timeline'
|
||||
|
||||
this.home = []
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
|||
this.refs.tl.on('loaded', () => {
|
||||
this.trigger('loaded');
|
||||
|
||||
this.I.data.home.for-each (widget) =>
|
||||
this.I.data.home.forEach (widget) =>
|
||||
try
|
||||
el = document.createElement 'mk-' + widget.name + '-home-widget'
|
||||
switch widget.place
|
||||
|
@ -84,7 +84,7 @@
|
|||
// noop
|
||||
|
||||
this.on('unmount', () => {
|
||||
@home.for-each (widget) =>
|
||||
@home.forEach (widget) =>
|
||||
widget.unmount!
|
||||
</script>
|
||||
</mk-home>
|
||||
|
|
|
@ -194,19 +194,19 @@
|
|||
.catch (err, text-status) ->
|
||||
console.error err
|
||||
|
||||
@stream.on 'notification' this.on-notification
|
||||
this.stream.on 'notification' this.on-notification
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'notification' this.on-notification
|
||||
this.stream.off 'notification' this.on-notification
|
||||
|
||||
this.on-notification = (notification) => {
|
||||
@notifications.unshift notification
|
||||
this.update();
|
||||
|
||||
this.on('update', () => {
|
||||
@notifications.for-each (notification) =>
|
||||
date = (new Date notification.created_at).get-date!
|
||||
month = (new Date notification.created_at).get-month! + 1
|
||||
@notifications.forEach (notification) =>
|
||||
date = (new Date notification.created_at).getDate()
|
||||
month = (new Date notification.created_at).getMonth() + 1
|
||||
notification._date = date
|
||||
notification._datetext = month + '月 ' + date + '日'
|
||||
</script>
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
document.title = 'Misskey'
|
||||
this.Progress.start();
|
||||
@stream.on 'post' this.on-stream-post
|
||||
this.stream.on 'post' this.on-stream-post
|
||||
document.addEventListener 'visibilitychange' @window-on-visibilitychange, false
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'post' this.on-stream-post
|
||||
this.stream.off 'post' this.on-stream-post
|
||||
document.removeEventListener 'visibilitychange' @window-on-visibilitychange
|
||||
|
||||
this.on-stream-post = (post) => {
|
||||
|
|
|
@ -110,31 +110,31 @@
|
|||
|
||||
this.post = this.opts.post
|
||||
|
||||
this.url = CONFIG.url + '/' + @post.user.username + '/' + @post.id
|
||||
this.url = CONFIG.url + '/' + this.post.user.username + '/' + this.post.id
|
||||
|
||||
this.title = @date-stringify @post.created_at
|
||||
this.title = @date-stringify this.post.created_at
|
||||
|
||||
this.on('mount', () => {
|
||||
if @post.text?
|
||||
tokens = @analyze @post.text
|
||||
if this.post.text?
|
||||
tokens = @analyze this.post.text
|
||||
this.refs.text.innerHTML = @compile tokens
|
||||
|
||||
this.refs.text.children.for-each (e) =>
|
||||
this.refs.text.children.forEach (e) =>
|
||||
if e.tag-name == 'MK-URL'
|
||||
riot.mount e
|
||||
|
||||
this.like = () => {
|
||||
if @post.is_liked
|
||||
if this.post.is_liked
|
||||
this.api 'posts/likes/delete' do
|
||||
post_id: @post.id
|
||||
post_id: this.post.id
|
||||
.then =>
|
||||
@post.is_liked = false
|
||||
this.post.is_liked = false
|
||||
this.update();
|
||||
else
|
||||
this.api 'posts/likes/create' do
|
||||
post_id: @post.id
|
||||
post_id: this.post.id
|
||||
.then =>
|
||||
@post.is_liked = true
|
||||
this.post.is_liked = true
|
||||
this.update();
|
||||
</script>
|
||||
</mk-post-detail-sub>
|
||||
|
|
|
@ -349,18 +349,18 @@
|
|||
this.post = post
|
||||
this.trigger('loaded');
|
||||
|
||||
this.is-repost = @post.repost?
|
||||
this.p = if @is-repost then @post.repost else @post
|
||||
this.is-repost = this.post.repost?
|
||||
this.p = if @is-repost then this.post.repost else this.post
|
||||
|
||||
this.title = @date-stringify @p.created_at
|
||||
this.title = @date-stringify this.p.created_at
|
||||
|
||||
this.update();
|
||||
|
||||
if @p.text?
|
||||
tokens = @analyze @p.text
|
||||
if this.p.text?
|
||||
tokens = @analyze this.p.text
|
||||
this.refs.text.innerHTML = @compile tokens
|
||||
|
||||
this.refs.text.children.for-each (e) =>
|
||||
this.refs.text.children.forEach (e) =>
|
||||
if e.tag-name == 'MK-URL'
|
||||
riot.mount e
|
||||
|
||||
|
@ -369,12 +369,12 @@
|
|||
.filter (t) -> t.type == 'link'
|
||||
.map (t) =>
|
||||
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview'
|
||||
riot.mount @preview, do
|
||||
riot.mount this.preview, do
|
||||
url: t.content
|
||||
|
||||
// Get likes
|
||||
this.api 'posts/likes' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
limit: 8
|
||||
.then (likes) =>
|
||||
this.likes = likes
|
||||
|
@ -382,7 +382,7 @@
|
|||
|
||||
// Get reposts
|
||||
this.api 'posts/reposts' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
limit: 8
|
||||
.then (reposts) =>
|
||||
this.reposts = reposts
|
||||
|
@ -390,7 +390,7 @@
|
|||
|
||||
// Get replies
|
||||
this.api 'posts/replies' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
limit: 8
|
||||
.then (replies) =>
|
||||
this.replies = replies
|
||||
|
@ -401,25 +401,25 @@
|
|||
this.reply = () => {
|
||||
form = document.body.appendChild document.createElement 'mk-post-form-window'
|
||||
riot.mount form, do
|
||||
reply: @p
|
||||
reply: this.p
|
||||
|
||||
this.repost = () => {
|
||||
form = document.body.appendChild document.createElement 'mk-repost-form-window'
|
||||
riot.mount form, do
|
||||
post: @p
|
||||
post: this.p
|
||||
|
||||
this.like = () => {
|
||||
if @p.is_liked
|
||||
if this.p.is_liked
|
||||
this.api 'posts/likes/delete' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
.then =>
|
||||
@p.is_liked = false
|
||||
this.p.is_liked = false
|
||||
this.update();
|
||||
else
|
||||
this.api 'posts/likes/create' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
.then =>
|
||||
@p.is_liked = true
|
||||
this.p.is_liked = true
|
||||
this.update();
|
||||
|
||||
this.load-context = () => {
|
||||
|
@ -427,7 +427,7 @@
|
|||
|
||||
// Get context
|
||||
this.api 'posts/context' do
|
||||
post_id: @p.reply_to_id
|
||||
post_id: this.p.reply_to_id
|
||||
.then (context) =>
|
||||
this.context = context.reverse!
|
||||
this.loading-context = false
|
||||
|
|
|
@ -348,7 +348,7 @@
|
|||
e.stopPropagation();
|
||||
this.draghover = true
|
||||
// ドラッグされてきたものがファイルだったら
|
||||
if e.dataTransfer.effect-allowed == 'all'
|
||||
if e.dataTransfer.effectAllowed == 'all'
|
||||
e.dataTransfer.dropEffect = 'copy'
|
||||
else
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
|
@ -367,7 +367,7 @@
|
|||
|
||||
// ファイルだったら
|
||||
if e.dataTransfer.files.length > 0
|
||||
Array.prototype.for-each.call e.dataTransfer.files, (file) =>
|
||||
Array.prototype.forEach.call e.dataTransfer.files, (file) =>
|
||||
@upload file
|
||||
return false
|
||||
|
||||
|
@ -390,7 +390,7 @@
|
|||
|
||||
this.onkeydown = (e) => {
|
||||
if (e.which == 10 || e.which == 13) && (e.ctrlKey || e.meta-key)
|
||||
@post!
|
||||
this.post!
|
||||
|
||||
this.onpaste = (e) => {
|
||||
data = e.clipboardData
|
||||
|
@ -402,14 +402,14 @@
|
|||
@upload item.getAsFile();
|
||||
|
||||
this.select-file = () => {
|
||||
this.refs.file.click!
|
||||
this.refs.file.click();
|
||||
|
||||
this.select-file-from-drive = () => {
|
||||
browser = document.body.appendChild document.createElement 'mk-select-file-from-drive-window'
|
||||
i = riot.mount browser, do
|
||||
multiple: true
|
||||
i[0].one 'selected' (files) =>
|
||||
files.for-each @add-file
|
||||
files.forEach @add-file
|
||||
|
||||
this.change-file = () => {
|
||||
files = this.refs.file.files
|
||||
|
@ -448,7 +448,7 @@
|
|||
text: this.refs.text.value
|
||||
media_ids: files
|
||||
reply_to_id: if @in-reply-to-post? then @in-reply-to-post.id else undefined
|
||||
poll: if @poll then this.refs.poll.get! else undefined
|
||||
poll: if this.poll then this.refs.poll.get! else undefined
|
||||
.then (data) =>
|
||||
this.trigger('post');
|
||||
@notify if @in-reply-to-post? then '返信しました!' else '投稿しました!'
|
||||
|
|
|
@ -88,6 +88,6 @@
|
|||
|
||||
this.post = this.opts.post
|
||||
|
||||
this.title = @date-stringify @post.created_at
|
||||
this.title = @date-stringify this.post.created_at
|
||||
</script>
|
||||
</mk-post-preview>
|
||||
|
|
|
@ -16,24 +16,24 @@
|
|||
this.post-promise = if @is-promise this.opts.post then this.opts.post else Promise.resolve this.opts.post
|
||||
|
||||
this.on('mount', () => {
|
||||
post <~ @post-promise.then
|
||||
post <~ this.post-promise.then
|
||||
this.post = post
|
||||
this.update();
|
||||
|
||||
this.api 'aggregation/posts/like' do
|
||||
post_id: @post.id
|
||||
post_id: this.post.id
|
||||
limit: 30days
|
||||
.then (likes) =>
|
||||
likes = likes.reverse!
|
||||
|
||||
this.api 'aggregation/posts/repost' do
|
||||
post_id: @post.id
|
||||
post_id: this.post.id
|
||||
limit: 30days
|
||||
.then (repost) =>
|
||||
repost = repost.reverse!
|
||||
|
||||
this.api 'aggregation/posts/reply' do
|
||||
post_id: @post.id
|
||||
post_id: this.post.id
|
||||
limit: 30days
|
||||
.then (replies) =>
|
||||
replies = replies.reverse!
|
||||
|
|
|
@ -63,16 +63,16 @@
|
|||
this.refs.timeline.focus();
|
||||
|
||||
this.more = () => {
|
||||
if @more-loading or @is-loading or @timeline.posts.length == 0
|
||||
if @more-loading or @is-loading or this.timeline.posts.length == 0
|
||||
return
|
||||
this.more-loading = true
|
||||
this.update();
|
||||
this.api 'posts/search' do
|
||||
query: @query
|
||||
page: @page + 1
|
||||
page: this.page + 1
|
||||
.then (posts) =>
|
||||
this.more-loading = false
|
||||
@page++
|
||||
this.page++
|
||||
this.update();
|
||||
this.refs.timeline.prepend-posts posts
|
||||
.catch (err) =>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
if @state == 'connected'
|
||||
this.root.style.opacity = 0
|
||||
|
||||
@stream-state-ev.on('connected', () => {
|
||||
this.stream-state-ev.on('connected', () => {
|
||||
this.state = @get-stream-state!
|
||||
this.update();
|
||||
setTimeout =>
|
||||
|
@ -44,7 +44,7 @@
|
|||
} 200ms 'linear'
|
||||
, 1000ms
|
||||
|
||||
@stream-state-ev.on('closed', () => {
|
||||
this.stream-state-ev.on('closed', () => {
|
||||
this.state = @get-stream-state!
|
||||
this.update();
|
||||
Velocity this.root, {
|
||||
|
|
|
@ -34,11 +34,11 @@
|
|||
this.post = this.opts.post
|
||||
|
||||
this.on('mount', () => {
|
||||
if @post.text?
|
||||
tokens = @analyze @post.text
|
||||
if this.post.text?
|
||||
tokens = @analyze this.post.text
|
||||
this.refs.text.innerHTML = @compile tokens, false
|
||||
|
||||
this.refs.text.children.for-each (e) =>
|
||||
this.refs.text.children.forEach (e) =>
|
||||
if e.tag-name == 'MK-URL'
|
||||
riot.mount e
|
||||
</script>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
this.post = this.opts.post
|
||||
|
||||
this.title = @date-stringify @post.created_at
|
||||
this.title = @date-stringify this.post.created_at
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
|
|
@ -319,25 +319,25 @@
|
|||
this.mixin('NotImplementedException');
|
||||
|
||||
this.post = this.opts.post
|
||||
this.is-repost = @post.repost? and !@post.text?
|
||||
this.p = if @is-repost then @post.repost else @post
|
||||
this.is-repost = this.post.repost? and !this.post.text?
|
||||
this.p = if @is-repost then this.post.repost else this.post
|
||||
|
||||
this.title = @date-stringify @p.created_at
|
||||
this.title = @date-stringify this.p.created_at
|
||||
|
||||
this.url = CONFIG.url + '/' + @p.user.username + '/' + @p.id
|
||||
this.url = CONFIG.url + '/' + this.p.user.username + '/' + this.p.id
|
||||
this.is-detail-opened = false
|
||||
|
||||
this.on('mount', () => {
|
||||
if @p.text?
|
||||
tokens = if @p._highlight?
|
||||
then @analyze @p._highlight
|
||||
else @analyze @p.text
|
||||
if this.p.text?
|
||||
tokens = if this.p._highlight?
|
||||
then @analyze this.p._highlight
|
||||
else @analyze this.p.text
|
||||
|
||||
this.refs.text.innerHTML = this.refs.text.innerHTML.replace '<p class="dummy"></p>' if @p._highlight?
|
||||
this.refs.text.innerHTML = this.refs.text.innerHTML.replace '<p class="dummy"></p>' if this.p._highlight?
|
||||
then @compile tokens, true, false
|
||||
else @compile tokens
|
||||
|
||||
this.refs.text.children.for-each (e) =>
|
||||
this.refs.text.children.forEach (e) =>
|
||||
if e.tag-name == 'MK-URL'
|
||||
riot.mount e
|
||||
|
||||
|
@ -346,31 +346,31 @@
|
|||
.filter (t) -> t.type == 'link'
|
||||
.map (t) =>
|
||||
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview'
|
||||
riot.mount @preview, do
|
||||
riot.mount this.preview, do
|
||||
url: t.content
|
||||
|
||||
this.reply = () => {
|
||||
form = document.body.appendChild document.createElement 'mk-post-form-window'
|
||||
riot.mount form, do
|
||||
reply: @p
|
||||
reply: this.p
|
||||
|
||||
this.repost = () => {
|
||||
form = document.body.appendChild document.createElement 'mk-repost-form-window'
|
||||
riot.mount form, do
|
||||
post: @p
|
||||
post: this.p
|
||||
|
||||
this.like = () => {
|
||||
if @p.is_liked
|
||||
if this.p.is_liked
|
||||
this.api 'posts/likes/delete' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
.then =>
|
||||
@p.is_liked = false
|
||||
this.p.is_liked = false
|
||||
this.update();
|
||||
else
|
||||
this.api 'posts/likes/create' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
.then =>
|
||||
@p.is_liked = true
|
||||
this.p.is_liked = true
|
||||
this.update();
|
||||
|
||||
this.toggle-detail = () => {
|
||||
|
@ -381,9 +381,9 @@
|
|||
should-be-cancel = true
|
||||
switch
|
||||
| e.which == 38 or e.which == 74 or (e.which == 9 and e.shift-key) => // ↑, j or Shift+Tab
|
||||
focus this.root, (e) -> e.previous-element-sibling
|
||||
focus this.root, (e) -> e.previousElementSibling
|
||||
| e.which == 40 or e.which == 75 or e.which == 9 => // ↓, k or Tab
|
||||
focus this.root, (e) -> e.next-element-sibling
|
||||
focus this.root, (e) -> e.nextElementSibling
|
||||
| e.which == 81 or e.which == 69 => // q or e
|
||||
@repost!
|
||||
| e.which == 70 or e.which == 76 => // f or l
|
||||
|
|
|
@ -51,12 +51,12 @@
|
|||
this.update();
|
||||
|
||||
this.prepend-posts = (posts) => {
|
||||
posts.for-each (post) =>
|
||||
@posts.push post
|
||||
posts.forEach (post) =>
|
||||
this.posts.push post
|
||||
this.update();
|
||||
|
||||
this.add-post = (post) => {
|
||||
@posts.unshift post
|
||||
this.posts.unshift post
|
||||
this.update();
|
||||
|
||||
this.clear = () => {
|
||||
|
@ -67,13 +67,13 @@
|
|||
this.root.children.0.focus();
|
||||
|
||||
this.on('update', () => {
|
||||
@posts.for-each (post) =>
|
||||
date = (new Date post.created_at).get-date!
|
||||
month = (new Date post.created_at).get-month! + 1
|
||||
this.posts.forEach (post) =>
|
||||
date = (new Date post.created_at).getDate()
|
||||
month = (new Date post.created_at).getMonth() + 1
|
||||
post._date = date
|
||||
post._datetext = month + '月 ' + date + '日'
|
||||
|
||||
this.tail = () => {
|
||||
@posts[@posts.length - 1]
|
||||
this.posts[this.posts.length - 1]
|
||||
</script>
|
||||
</mk-timeline>
|
||||
|
|
|
@ -177,14 +177,14 @@
|
|||
this.is-open = true
|
||||
this.update();
|
||||
all = document.query-selector-all 'body *'
|
||||
Array.prototype.for-each.call all, (el) =>
|
||||
Array.prototype.forEach.call all, (el) =>
|
||||
el.addEventListener 'mousedown' @mousedown
|
||||
|
||||
this.close = () => {
|
||||
this.is-open = false
|
||||
this.update();
|
||||
all = document.query-selector-all 'body *'
|
||||
Array.prototype.for-each.call all, (el) =>
|
||||
Array.prototype.forEach.call all, (el) =>
|
||||
el.removeEventListener 'mousedown' @mousedown
|
||||
|
||||
this.mousedown = (e) => {
|
||||
|
|
|
@ -59,15 +59,15 @@
|
|||
</style>
|
||||
<script>
|
||||
this.draw = () => {
|
||||
now = new Date!
|
||||
const now = new Date();
|
||||
|
||||
yyyy = now.get-full-year!
|
||||
mm = (\0 + (now.get-month! + 1)).slice -2
|
||||
dd = (\0 + now.get-date!).slice -2
|
||||
yyyy = now.getFullYear()
|
||||
mm = (\0 + (now.getMonth() + 1)).slice -2
|
||||
dd = (\0 + now.getDate()).slice -2
|
||||
yyyymmdd = "<span class='yyyymmdd'>#yyyy/#mm/#dd</span>"
|
||||
|
||||
hh = (\0 + now.get-hours!).slice -2
|
||||
mm = (\0 + now.get-minutes!).slice -2
|
||||
hh = (\0 + now.getHours()).slice -2
|
||||
mm = (\0 + now.getMinutes()).slice -2
|
||||
hhmm = "<span class='hhmm'>#hh:#mm</span>"
|
||||
|
||||
if now.get-seconds! % 2 == 0
|
||||
|
@ -79,9 +79,9 @@
|
|||
|
||||
this.on('mount', () => {
|
||||
@draw!
|
||||
this.clock = set-interval @draw, 1000ms
|
||||
this.clock = setInterval @draw, 1000ms
|
||||
|
||||
this.on('unmount', () => {
|
||||
clear-interval @clock
|
||||
clearInterval @clock
|
||||
</script>
|
||||
</mk-ui-header-clock>
|
||||
|
|
|
@ -84,8 +84,8 @@
|
|||
this.page = this.opts.page
|
||||
|
||||
this.on('mount', () => {
|
||||
@stream.on 'read_all_messaging_messages' this.on-read-all-messaging-messages
|
||||
@stream.on 'unread_messaging_message' this.on-unread-messaging-message
|
||||
this.stream.on 'read_all_messaging_messages' this.on-read-all-messaging-messages
|
||||
this.stream.on 'unread_messaging_message' this.on-unread-messaging-message
|
||||
|
||||
// Fetch count of unread messaging messages
|
||||
this.api 'messaging/unread'
|
||||
|
@ -95,8 +95,8 @@
|
|||
this.update();
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'read_all_messaging_messages' this.on-read-all-messaging-messages
|
||||
@stream.off 'unread_messaging_message' this.on-unread-messaging-message
|
||||
this.stream.off 'read_all_messaging_messages' this.on-read-all-messaging-messages
|
||||
this.stream.off 'unread_messaging_message' this.on-unread-messaging-message
|
||||
|
||||
this.on-read-all-messaging-messages = () => {
|
||||
this.has-unread-messaging-messages = false
|
||||
|
|
|
@ -87,14 +87,14 @@
|
|||
this.is-open = true
|
||||
this.update();
|
||||
all = document.query-selector-all 'body *'
|
||||
Array.prototype.for-each.call all, (el) =>
|
||||
Array.prototype.forEach.call all, (el) =>
|
||||
el.addEventListener 'mousedown' @mousedown
|
||||
|
||||
this.close = () => {
|
||||
this.is-open = false
|
||||
this.update();
|
||||
all = document.query-selector-all 'body *'
|
||||
Array.prototype.for-each.call all, (el) =>
|
||||
Array.prototype.forEach.call all, (el) =>
|
||||
el.removeEventListener 'mousedown' @mousedown
|
||||
|
||||
this.mousedown = (e) => {
|
||||
|
|
|
@ -36,6 +36,6 @@
|
|||
|
||||
this.onsubmit = (e) => {
|
||||
e.preventDefault();
|
||||
@page '/search:' + this.refs.q.value
|
||||
this.page '/search:' + this.refs.q.value
|
||||
</script>
|
||||
</mk-ui-header-search>
|
||||
|
|
|
@ -77,8 +77,8 @@
|
|||
limit: 9posts
|
||||
.then (posts) =>
|
||||
this.initializing = false
|
||||
posts.for-each (post) =>
|
||||
post.media.for-each (image) =>
|
||||
posts.forEach (post) =>
|
||||
post.media.forEach (image) =>
|
||||
if @images.length < 9
|
||||
@images.push image
|
||||
this.update();
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
this.fetch = (cb) => {
|
||||
this.api 'users/posts' do
|
||||
user_id: @user.id
|
||||
with_replies: @mode == 'with-replies'
|
||||
with_replies: this.mode == 'with-replies'
|
||||
.then (posts) =>
|
||||
this.is-loading = false
|
||||
this.is-empty = posts.length == 0
|
||||
|
@ -102,7 +102,7 @@
|
|||
this.update();
|
||||
this.api 'users/posts' do
|
||||
user_id: @user.id
|
||||
with_replies: @mode == 'with-replies'
|
||||
with_replies: this.mode == 'with-replies'
|
||||
max_id: this.refs.timeline.tail!.id
|
||||
.then (posts) =>
|
||||
this.more-loading = false
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
this.fetching = true
|
||||
this.update();
|
||||
obj <~ this.opts.fetch do
|
||||
@mode == 'iknow'
|
||||
this.mode == 'iknow'
|
||||
@limit
|
||||
null
|
||||
this.users = obj.users
|
||||
|
@ -117,7 +117,7 @@
|
|||
this.more-fetching = true
|
||||
this.update();
|
||||
obj <~ this.opts.fetch do
|
||||
@mode == 'iknow'
|
||||
this.mode == 'iknow'
|
||||
@limit
|
||||
@cursor
|
||||
this.users = @users.concat obj.users
|
||||
|
|
|
@ -304,7 +304,7 @@
|
|||
z = 0
|
||||
|
||||
ws = document.query-selector-all 'mk-window'
|
||||
ws.for-each (w) !=>
|
||||
ws.forEach (w) !=>
|
||||
if w == this.root then return
|
||||
m = w.query-selector ':scope > .main'
|
||||
mz = Number(document.default-view.get-computed-style m, null .z-index)
|
||||
|
|
|
@ -222,7 +222,7 @@
|
|||
cb = this.refs.cb.value
|
||||
permission = []
|
||||
|
||||
this.refs.permission.query-selector-all 'input' .for-each (el) =>
|
||||
this.refs.permission.query-selector-all 'input' .forEach (el) =>
|
||||
if el.checked then permission.push el.value
|
||||
|
||||
locker = document.body.appendChild document.createElement 'mk-locker'
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
|
||||
this.files = []
|
||||
this.folders = []
|
||||
this.hierarchy-folders = []
|
||||
this.hierarchyFolders = []
|
||||
this.selected-files = []
|
||||
|
||||
// 現在の階層(フォルダ)
|
||||
|
@ -146,10 +146,10 @@
|
|||
this.multiple = if this.opts.multiple? then this.opts.multiple else false
|
||||
|
||||
this.on('mount', () => {
|
||||
@stream.on 'drive_file_created' this.on-stream-drive-file-created
|
||||
@stream.on 'drive_file_updated' this.on-stream-drive-file-updated
|
||||
@stream.on 'drive_folder_created' this.on-stream-drive-folder-created
|
||||
@stream.on 'drive_folder_updated' this.on-stream-drive-folder-updated
|
||||
this.stream.on 'drive_file_created' this.on-stream-drive-file-created
|
||||
this.stream.on 'drive_file_updated' this.on-stream-drive-file-updated
|
||||
this.stream.on 'drive_folder_created' this.on-stream-drive-folder-created
|
||||
this.stream.on 'drive_folder_updated' this.on-stream-drive-folder-updated
|
||||
|
||||
// Riotのバグでnullを渡しても""になる
|
||||
// https://github.com/riot/riot/issues/2080
|
||||
|
@ -162,10 +162,10 @@
|
|||
@load!
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'drive_file_created' this.on-stream-drive-file-created
|
||||
@stream.off 'drive_file_updated' this.on-stream-drive-file-updated
|
||||
@stream.off 'drive_folder_created' this.on-stream-drive-folder-created
|
||||
@stream.off 'drive_folder_updated' this.on-stream-drive-folder-updated
|
||||
this.stream.off 'drive_file_created' this.on-stream-drive-file-created
|
||||
this.stream.off 'drive_file_updated' this.on-stream-drive-file-updated
|
||||
this.stream.off 'drive_folder_created' this.on-stream-drive-folder-created
|
||||
this.stream.off 'drive_folder_updated' this.on-stream-drive-folder-updated
|
||||
|
||||
this.on-stream-drive-file-created = (file) => {
|
||||
@add-file file, true
|
||||
|
@ -210,10 +210,10 @@
|
|||
folder_id: target-folder
|
||||
.then (folder) =>
|
||||
this.folder = folder
|
||||
this.hierarchy-folders = []
|
||||
this.hierarchyFolders = []
|
||||
|
||||
x = (f) =>
|
||||
@hierarchy-folders.unshift f
|
||||
@hierarchyFolders.unshift f
|
||||
if f.parent?
|
||||
x f.parent
|
||||
|
||||
|
@ -275,7 +275,7 @@
|
|||
if this.folder != null or this.file != null
|
||||
this.file = null
|
||||
this.folder = null
|
||||
this.hierarchy-folders = []
|
||||
this.hierarchyFolders = []
|
||||
this.update();
|
||||
this.trigger('move-root');
|
||||
@load!
|
||||
|
@ -325,9 +325,9 @@
|
|||
flag = false
|
||||
complete = =>
|
||||
if flag
|
||||
load-folders.for-each (folder) =>
|
||||
load-folders.forEach (folder) =>
|
||||
@add-folder folder
|
||||
load-files.for-each (file) =>
|
||||
load-files.forEach (file) =>
|
||||
@add-file file
|
||||
this.loading = false
|
||||
this.update();
|
||||
|
@ -361,10 +361,10 @@
|
|||
.then (file) =>
|
||||
this.file = file
|
||||
this.folder = null
|
||||
this.hierarchy-folders = []
|
||||
this.hierarchyFolders = []
|
||||
|
||||
x = (f) =>
|
||||
@hierarchy-folders.unshift f
|
||||
@hierarchyFolders.unshift f
|
||||
if f.parent?
|
||||
x f.parent
|
||||
|
||||
|
|
|
@ -62,12 +62,12 @@
|
|||
this.user = user
|
||||
this.init = false
|
||||
this.update();
|
||||
@stream.on 'follow' this.on-stream-follow
|
||||
@stream.on 'unfollow' this.on-stream-unfollow
|
||||
this.stream.on 'follow' this.on-stream-follow
|
||||
this.stream.on 'unfollow' this.on-stream-unfollow
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'follow' this.on-stream-follow
|
||||
@stream.off 'unfollow' this.on-stream-unfollow
|
||||
this.stream.off 'follow' this.on-stream-follow
|
||||
this.stream.off 'unfollow' this.on-stream-unfollow
|
||||
|
||||
this.on-stream-follow = (user) => {
|
||||
if user.id == @user.id
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
this.trigger('loaded');
|
||||
|
||||
this.on('mount', () => {
|
||||
@stream.on 'post' this.on-stream-post
|
||||
@stream.on 'follow' this.on-stream-follow
|
||||
@stream.on 'unfollow' this.on-stream-unfollow
|
||||
this.stream.on 'post' this.on-stream-post
|
||||
this.stream.on 'follow' this.on-stream-follow
|
||||
this.stream.on 'unfollow' this.on-stream-unfollow
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'post' this.on-stream-post
|
||||
@stream.off 'follow' this.on-stream-follow
|
||||
@stream.off 'unfollow' this.on-stream-unfollow
|
||||
this.stream.off 'post' this.on-stream-post
|
||||
this.stream.off 'follow' this.on-stream-follow
|
||||
this.stream.off 'unfollow' this.on-stream-unfollow
|
||||
|
||||
this.more = () => {
|
||||
this.api 'posts/timeline' do
|
||||
|
|
|
@ -74,19 +74,19 @@
|
|||
.catch (err, text-status) ->
|
||||
console.error err
|
||||
|
||||
@stream.on 'notification' this.on-notification
|
||||
this.stream.on 'notification' this.on-notification
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'notification' this.on-notification
|
||||
this.stream.off 'notification' this.on-notification
|
||||
|
||||
this.on-notification = (notification) => {
|
||||
@notifications.unshift notification
|
||||
this.update();
|
||||
|
||||
this.on('update', () => {
|
||||
@notifications.for-each (notification) =>
|
||||
date = (new Date notification.created_at).get-date!
|
||||
month = (new Date notification.created_at).get-month! + 1
|
||||
@notifications.forEach (notification) =>
|
||||
date = (new Date notification.created_at).getDate()
|
||||
month = (new Date notification.created_at).getMonth() + 1
|
||||
notification._date = date
|
||||
notification._datetext = month + '月 ' + date + '日'
|
||||
</script>
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
|
||||
this.Progress.start();
|
||||
|
||||
@stream.on 'post' this.on-stream-post
|
||||
this.stream.on 'post' this.on-stream-post
|
||||
document.addEventListener 'visibilitychange' @window-on-visibilitychange, false
|
||||
|
||||
this.refs.ui.refs.home.on('loaded', () => {
|
||||
this.Progress.done();
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'post' this.on-stream-post
|
||||
this.stream.off 'post' this.on-stream-post
|
||||
document.removeEventListener 'visibilitychange' @window-on-visibilitychange
|
||||
|
||||
this.on-stream-post = (post) => {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
this.ui.trigger('title', '<i class="fa fa-comments-o"></i>メッセージ');
|
||||
|
||||
this.refs.ui.refs.index.on('navigate-user', (user) => {
|
||||
@page '/i/messaging/' + user.username
|
||||
this.page '/i/messaging/' + user.username
|
||||
|
||||
</script>
|
||||
</mk-messaging-page>
|
||||
|
|
|
@ -344,18 +344,18 @@
|
|||
post_id: this.opts.post
|
||||
.then (post) =>
|
||||
this.post = post
|
||||
this.is-repost = @post.repost?
|
||||
this.p = if @is-repost then @post.repost else @post
|
||||
this.summary = @get-post-summary @p
|
||||
this.is-repost = this.post.repost?
|
||||
this.p = if @is-repost then this.post.repost else this.post
|
||||
this.summary = @get-post-summary this.p
|
||||
this.trigger('loaded');
|
||||
this.fetching = false
|
||||
this.update();
|
||||
|
||||
if @p.text?
|
||||
tokens = @analyze @p.text
|
||||
if this.p.text?
|
||||
tokens = @analyze this.p.text
|
||||
this.refs.text.innerHTML = @compile tokens
|
||||
|
||||
this.refs.text.children.for-each (e) =>
|
||||
this.refs.text.children.forEach (e) =>
|
||||
if e.tag-name == 'MK-URL'
|
||||
riot.mount e
|
||||
|
||||
|
@ -364,12 +364,12 @@
|
|||
.filter (t) -> t.type == 'link'
|
||||
.map (t) =>
|
||||
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview'
|
||||
riot.mount @preview, do
|
||||
riot.mount this.preview, do
|
||||
url: t.content
|
||||
|
||||
// Get likes
|
||||
this.api 'posts/likes' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
limit: 8
|
||||
.then (likes) =>
|
||||
this.likes = likes
|
||||
|
@ -377,7 +377,7 @@
|
|||
|
||||
// Get reposts
|
||||
this.api 'posts/reposts' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
limit: 8
|
||||
.then (reposts) =>
|
||||
this.reposts = reposts
|
||||
|
@ -385,7 +385,7 @@
|
|||
|
||||
// Get replies
|
||||
this.api 'posts/replies' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
limit: 8
|
||||
.then (replies) =>
|
||||
this.replies = replies
|
||||
|
@ -393,27 +393,27 @@
|
|||
|
||||
this.reply = () => {
|
||||
@open-post-form do
|
||||
reply: @p
|
||||
reply: this.p
|
||||
|
||||
this.repost = () => {
|
||||
text = window.prompt '「' + @summary + '」をRepost'
|
||||
if text?
|
||||
this.api 'posts/create' do
|
||||
repost_id: @p.id
|
||||
repost_id: this.p.id
|
||||
text: if text == '' then undefined else text
|
||||
|
||||
this.like = () => {
|
||||
if @p.is_liked
|
||||
if this.p.is_liked
|
||||
this.api 'posts/likes/delete' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
.then =>
|
||||
@p.is_liked = false
|
||||
this.p.is_liked = false
|
||||
this.update();
|
||||
else
|
||||
this.api 'posts/likes/create' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
.then =>
|
||||
@p.is_liked = true
|
||||
this.p.is_liked = true
|
||||
this.update();
|
||||
|
||||
this.load-context = () => {
|
||||
|
@ -421,7 +421,7 @@
|
|||
|
||||
// Get context
|
||||
this.api 'posts/context' do
|
||||
post_id: @p.reply_to_id
|
||||
post_id: this.p.reply_to_id
|
||||
.then (context) =>
|
||||
this.context = context.reverse!
|
||||
this.loading-context = false
|
||||
|
|
|
@ -202,7 +202,7 @@
|
|||
|
||||
this.onkeypress = (e) => {
|
||||
if (e.char-code == 10 || e.char-code == 13) && e.ctrlKey
|
||||
@post!
|
||||
this.post!
|
||||
else
|
||||
return true
|
||||
|
||||
|
@ -217,7 +217,7 @@
|
|||
return true
|
||||
|
||||
this.select-file = () => {
|
||||
this.refs.file.click!
|
||||
this.refs.file.click();
|
||||
|
||||
this.select-file-from-drive = () => {
|
||||
browser = document.body.appendChild document.createElement 'mk-drive-selector'
|
||||
|
@ -225,7 +225,7 @@
|
|||
multiple: true
|
||||
.0
|
||||
browser.on('selected', (files) => {
|
||||
files.for-each @add-file
|
||||
files.forEach @add-file
|
||||
|
||||
this.change-file = () => {
|
||||
files = this.refs.file.files
|
||||
|
@ -264,7 +264,7 @@
|
|||
text: this.refs.text.value
|
||||
media_ids: files
|
||||
reply_to_id: if this.opts.reply? then this.opts.reply.id else undefined
|
||||
poll: if @poll then this.refs.poll.get! else undefined
|
||||
poll: if this.poll then this.refs.poll.get! else undefined
|
||||
.then (data) =>
|
||||
this.trigger('post');
|
||||
this.unmount();
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
if @state == 'connected'
|
||||
this.root.style.opacity = 0
|
||||
|
||||
@stream-state-ev.on('connected', () => {
|
||||
this.stream-state-ev.on('connected', () => {
|
||||
this.state = @get-stream-state!
|
||||
this.update();
|
||||
setTimeout =>
|
||||
|
@ -44,7 +44,7 @@
|
|||
} 200ms 'linear'
|
||||
, 1000ms
|
||||
|
||||
@stream-state-ev.on('closed', () => {
|
||||
this.stream-state-ev.on('closed', () => {
|
||||
this.state = @get-stream-state!
|
||||
this.update();
|
||||
Velocity this.root, {
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
this.post = this.opts.post
|
||||
|
||||
this.on('mount', () => {
|
||||
if @post.text?
|
||||
tokens = @analyze @post.text
|
||||
if this.post.text?
|
||||
tokens = @analyze this.post.text
|
||||
this.refs.text.innerHTML = @compile tokens, false
|
||||
|
||||
this.refs.text.children.for-each (e) =>
|
||||
this.refs.text.children.forEach (e) =>
|
||||
if e.tag-name == 'MK-URL'
|
||||
riot.mount e
|
||||
</script>
|
||||
|
|
|
@ -292,22 +292,22 @@
|
|||
this.mixin('open-post-form');
|
||||
|
||||
this.post = this.opts.post
|
||||
this.is-repost = @post.repost? and !@post.text?
|
||||
this.p = if @is-repost then @post.repost else @post
|
||||
this.summary = @get-post-summary @p
|
||||
this.url = CONFIG.url + '/' + @p.user.username + '/' + @p.id
|
||||
this.is-repost = this.post.repost? and !this.post.text?
|
||||
this.p = if @is-repost then this.post.repost else this.post
|
||||
this.summary = @get-post-summary this.p
|
||||
this.url = CONFIG.url + '/' + this.p.user.username + '/' + this.p.id
|
||||
|
||||
this.on('mount', () => {
|
||||
if @p.text?
|
||||
tokens = if @p._highlight?
|
||||
then @analyze @p._highlight
|
||||
else @analyze @p.text
|
||||
if this.p.text?
|
||||
tokens = if this.p._highlight?
|
||||
then @analyze this.p._highlight
|
||||
else @analyze this.p.text
|
||||
|
||||
this.refs.text.innerHTML = this.refs.text.innerHTML.replace '<p class="dummy"></p>' if @p._highlight?
|
||||
this.refs.text.innerHTML = this.refs.text.innerHTML.replace '<p class="dummy"></p>' if this.p._highlight?
|
||||
then @compile tokens, true, false
|
||||
else @compile tokens
|
||||
|
||||
this.refs.text.children.for-each (e) =>
|
||||
this.refs.text.children.forEach (e) =>
|
||||
if e.tag-name == 'MK-URL'
|
||||
riot.mount e
|
||||
|
||||
|
@ -316,32 +316,32 @@
|
|||
.filter (t) -> t.type == 'link'
|
||||
.map (t) =>
|
||||
this.preview = this.refs.text.appendChild document.createElement 'mk-url-preview'
|
||||
riot.mount @preview, do
|
||||
riot.mount this.preview, do
|
||||
url: t.content
|
||||
|
||||
this.reply = () => {
|
||||
@open-post-form do
|
||||
reply: @p
|
||||
reply: this.p
|
||||
|
||||
this.repost = () => {
|
||||
text = window.prompt '「' + @summary + '」をRepost'
|
||||
if text?
|
||||
this.api 'posts/create' do
|
||||
repost_id: @p.id
|
||||
repost_id: this.p.id
|
||||
text: if text == '' then undefined else text
|
||||
|
||||
this.like = () => {
|
||||
if @p.is_liked
|
||||
if this.p.is_liked
|
||||
this.api 'posts/likes/delete' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
.then =>
|
||||
@p.is_liked = false
|
||||
this.p.is_liked = false
|
||||
this.update();
|
||||
else
|
||||
this.api 'posts/likes/create' do
|
||||
post_id: @p.id
|
||||
post_id: this.p.id
|
||||
.then =>
|
||||
@p.is_liked = true
|
||||
this.p.is_liked = true
|
||||
this.update();
|
||||
</script>
|
||||
</mk-timeline-post>
|
||||
|
|
|
@ -85,34 +85,34 @@
|
|||
@set-posts posts
|
||||
|
||||
this.on('update', () => {
|
||||
@posts.for-each (post) =>
|
||||
date = (new Date post.created_at).get-date!
|
||||
month = (new Date post.created_at).get-month! + 1
|
||||
this.posts.forEach (post) =>
|
||||
date = (new Date post.created_at).getDate()
|
||||
month = (new Date post.created_at).getMonth() + 1
|
||||
post._date = date
|
||||
post._datetext = month + '月 ' + date + '日'
|
||||
|
||||
this.more = () => {
|
||||
if @init or @fetching or @posts.length == 0 then return
|
||||
if @init or @fetching or this.posts.length == 0 then return
|
||||
this.fetching = true
|
||||
this.update();
|
||||
this.opts.more!.then (posts) =>
|
||||
this.fetching = false
|
||||
@prepend-posts posts
|
||||
this.prepend-posts posts
|
||||
|
||||
this.set-posts = (posts) => {
|
||||
this.posts = posts
|
||||
this.update();
|
||||
|
||||
this.prepend-posts = (posts) => {
|
||||
posts.for-each (post) =>
|
||||
@posts.push post
|
||||
posts.forEach (post) =>
|
||||
this.posts.push post
|
||||
this.update();
|
||||
|
||||
this.add-post = (post) => {
|
||||
@posts.unshift post
|
||||
this.posts.unshift post
|
||||
this.update();
|
||||
|
||||
this.tail = () => {
|
||||
@posts[@posts.length - 1]
|
||||
this.posts[this.posts.length - 1]
|
||||
</script>
|
||||
</mk-timeline>
|
||||
|
|
|
@ -126,6 +126,6 @@
|
|||
this.search = () => {
|
||||
query = window.prompt '検索'
|
||||
if query? and query != ''
|
||||
@page '/search:' + query
|
||||
this.page '/search:' + query
|
||||
</script>
|
||||
</mk-ui-nav>
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
// alert text
|
||||
|
||||
this.on('mount', () => {
|
||||
@stream.on 'notification' this.on-stream-notification
|
||||
this.stream.on 'notification' this.on-stream-notification
|
||||
@ready!
|
||||
|
||||
this.on('unmount', () => {
|
||||
@stream.off 'notification' this.on-stream-notification
|
||||
this.stream.off 'notification' this.on-stream-notification
|
||||
|
||||
this.ready = () => {
|
||||
@ready-count++
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
this.fetching = true
|
||||
this.update();
|
||||
obj <~ this.opts.fetch do
|
||||
@mode == 'iknow'
|
||||
this.mode == 'iknow'
|
||||
@limit
|
||||
null
|
||||
this.users = obj.users
|
||||
|
@ -99,7 +99,7 @@
|
|||
this.more-fetching = true
|
||||
this.update();
|
||||
obj <~ this.opts.fetch do
|
||||
@mode == 'iknow'
|
||||
this.mode == 'iknow'
|
||||
@limit
|
||||
@cursor
|
||||
this.users = @users.concat obj.users
|
||||
|
|
Loading…
Reference in a new issue