From 43f9fcb31bf930f7205bd713fe0bfc066832e934 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 09:17:10 +0900 Subject: Remove unused file --- src/web/app/common/scripts/log.ls | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/web/app/common/scripts/log.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/common/scripts/log.ls b/src/web/app/common/scripts/log.ls deleted file mode 100644 index 6e1e3735d8..0000000000 --- a/src/web/app/common/scripts/log.ls +++ /dev/null @@ -1,18 +0,0 @@ -riot = require \riot - -logs = [] - -ev = riot.observable! - -function log(msg) - logs.push do - date: new Date! - message: msg - ev.trigger \log - -riot.mixin \log do - logs: logs - log: log - log-event: ev - -module.exports = log -- cgit v1.2.3-freya From 6f6723e1c2acd902908a4e0fe22cc8915c21017b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 10:52:51 +0900 Subject: :v: --- src/web/app/common/scripts/date-stringify.js | 13 +++++++++++++ src/web/app/common/scripts/date-stringify.ls | 14 -------------- 2 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 src/web/app/common/scripts/date-stringify.js delete mode 100644 src/web/app/common/scripts/date-stringify.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/common/scripts/date-stringify.js b/src/web/app/common/scripts/date-stringify.js new file mode 100644 index 0000000000..48e19704d5 --- /dev/null +++ b/src/web/app/common/scripts/date-stringify.js @@ -0,0 +1,13 @@ +module.exports = date => { + if (typeof date == 'string') date = new Date(date); + return ( + date.getFullYear() + '年' + + date.getMonth() + 1 + '月' + + date.getDate() + '日' + + ' ' + + date.getHours() + '時' + + date.getMinutes() + '分' + + ' ' + + `(${['日', '月', '火', '水', '木', '金', '土'][date.getDay()]})` + ); +}; diff --git a/src/web/app/common/scripts/date-stringify.ls b/src/web/app/common/scripts/date-stringify.ls deleted file mode 100644 index 7e85192ce7..0000000000 --- a/src/web/app/common/scripts/date-stringify.ls +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = (date) -> - if typeof date == \string then date = new Date date - - text = - date.get-full-year! + \年 + - date.get-month! + 1 + \月 + - date.get-date! + \日 + - ' ' + - date.get-hours! + \時 + - date.get-minutes! + \分 + - ' ' + - "(#{[\日 \月 \火 \水 \木 \金 \土][date.get-day!]})" - - return text -- cgit v1.2.3-freya From 6836662bffc501911902b4168e08716a90595ae8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 13:07:34 +0900 Subject: :v: --- src/web/app/common/mixins.ls | 2 +- src/web/app/common/scripts/get-post-summary.js | 37 ++++++++++++++++++++++++++ src/web/app/common/scripts/get-post-summary.ls | 30 --------------------- 3 files changed, 38 insertions(+), 31 deletions(-) create mode 100644 src/web/app/common/scripts/get-post-summary.js delete mode 100644 src/web/app/common/scripts/get-post-summary.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/common/mixins.ls b/src/web/app/common/mixins.ls index 812bcae102..ca27e03579 100644 --- a/src/web/app/common/mixins.ls +++ b/src/web/app/common/mixins.ls @@ -21,7 +21,7 @@ module.exports = (me) ~> is-promise: require './scripts/is-promise.ls' riot.mixin \get-post-summary do - get-post-summary: require './scripts/get-post-summary.ls' + get-post-summary: require './scripts/get-post-summary.js' riot.mixin \date-stringify do date-stringify: require './scripts/date-stringify.ls' diff --git a/src/web/app/common/scripts/get-post-summary.js b/src/web/app/common/scripts/get-post-summary.js new file mode 100644 index 0000000000..8e17d54e81 --- /dev/null +++ b/src/web/app/common/scripts/get-post-summary.js @@ -0,0 +1,37 @@ +const getPostSummary = post => { + let = post.text ? post.text : ''; + + // メディアが添付されているとき + if (post.media) { + summary += ` (${post.media.length}つのメディア)`; + } + + // 投票が添付されているとき + if (post.poll) { + summary += ' (投票)'; + } + + // 返信のとき + if (post.reply_to_id) { + if (post.reply_to) { + replySummary = getPostSummary(post.reply_to); + summary += ` RE: ${replySummary}`; + } else { + summary += ' RE: ...'; + } + } + + // Repostのとき + if (post.repost_id) { + if (post.repost) { + repostSummary = getPostSummary(post.repost); + summary += ` RP: ${repostSummary}`; + } else { + summary += ' RP: ...'; + } + } + + return summary.trim(); +}; + +module.exports = getPostSummary; diff --git a/src/web/app/common/scripts/get-post-summary.ls b/src/web/app/common/scripts/get-post-summary.ls deleted file mode 100644 index 67178bc324..0000000000 --- a/src/web/app/common/scripts/get-post-summary.ls +++ /dev/null @@ -1,30 +0,0 @@ -get-post-summary = (post) ~> - summary = if post.text? then post.text else '' - - # メディアが添付されているとき - if post.media? - summary += " (#{post.media.length}つのメディア)" - - # 投票が添付されているとき - if post.poll? - summary += " (投票)" - - # 返信のとき - if post.reply_to_id? - if post.reply_to? - reply-summary = get-post-summary post.reply_to - summary += " RE: #{reply-summary}" - else - summary += " RE: ..." - - # Repostのとき - if post.repost_id? - if post.repost? - repost-summary = get-post-summary post.repost - summary += " RP: #{repost-summary}" - else - summary += " RP: ..." - - return summary.trim! - -module.exports = get-post-summary -- cgit v1.2.3-freya From d168ac6106d282ad21e637ba0e5cf986ef109eb3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 13:13:43 +0900 Subject: :v: --- src/web/app/common/mixins.ls | 2 +- src/web/app/common/scripts/signout.js | 5 +++++ src/web/app/common/scripts/signout.ls | 4 ---- 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 src/web/app/common/scripts/signout.js delete mode 100644 src/web/app/common/scripts/signout.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/common/mixins.ls b/src/web/app/common/mixins.ls index ca27e03579..3999851a98 100644 --- a/src/web/app/common/mixins.ls +++ b/src/web/app/common/mixins.ls @@ -12,7 +12,7 @@ module.exports = (me) ~> Cropper: require \cropperjs riot.mixin \signout do - signout: require './scripts/signout.ls' + signout: require './scripts/signout.js' riot.mixin \messaging-stream do MessagingStreamConnection: require './scripts/messaging-stream.ls' diff --git a/src/web/app/common/scripts/signout.js b/src/web/app/common/scripts/signout.js new file mode 100644 index 0000000000..cd752423da --- /dev/null +++ b/src/web/app/common/scripts/signout.js @@ -0,0 +1,5 @@ +module.exports = () => { + localStorage.removeItem('me'); + document.cookie = `i=; domain=.${CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`; + location.href = '/'; +}; diff --git a/src/web/app/common/scripts/signout.ls b/src/web/app/common/scripts/signout.ls deleted file mode 100644 index a647922678..0000000000 --- a/src/web/app/common/scripts/signout.ls +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = -> - local-storage.remove-item \me - document.cookie = "i=; domain=.#{CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;" - location.href = \/ -- cgit v1.2.3-freya From 4770e1fab89b35671f9fd1eb3080efca717e27ac Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 13:18:59 +0900 Subject: :v: --- src/web/app/common/scripts/stream.js | 39 +++++++++++++++++++++++++++++++++++ src/web/app/common/scripts/stream.ls | 39 ----------------------------------- src/web/app/desktop/scripts/stream.ls | 4 ++-- src/web/app/mobile/scripts/stream.ls | 2 +- 4 files changed, 42 insertions(+), 42 deletions(-) create mode 100644 src/web/app/common/scripts/stream.js delete mode 100644 src/web/app/common/scripts/stream.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/common/scripts/stream.js b/src/web/app/common/scripts/stream.js new file mode 100644 index 0000000000..b31e570444 --- /dev/null +++ b/src/web/app/common/scripts/stream.js @@ -0,0 +1,39 @@ +const ReconnectingWebSocket = require('reconnecting-websocket'); +const riot = require('riot'); + +module.exports = me => { + let state = 'initializing'; + const stateEv = riot.observable(); + const event = riot.observable(); + const host = CONFIG.api.url.replace('http', 'ws'); + const socket = new ReconnectingWebSocket(`${host}?i=${me.token}`); + + socket.onopen = () => { + state = 'connected'; + stateEv.trigger('connected'); + }; + + socket.onclose = () => { + state = 'reconnecting'; + stateEv.trigger('closed'); + }; + + socket.onmessage = message => { + try { + const message = JSON.parse(message.data); + if (message.type) { + event.trigger(message.type, message.body); + } + } catch (e) { + // noop + } + }; + + event.on('i_updated', me.update); + + return { + stateEv: stateEv, + getState: () => state, + event: event + }; +}; diff --git a/src/web/app/common/scripts/stream.ls b/src/web/app/common/scripts/stream.ls deleted file mode 100644 index c2c061603e..0000000000 --- a/src/web/app/common/scripts/stream.ls +++ /dev/null @@ -1,39 +0,0 @@ -# Stream -#================================ - -ReconnectingWebSocket = require \reconnecting-websocket -riot = require \riot - -module.exports = (me) ~> - state = \initializing - state-ev = riot.observable! - event = riot.observable! - - host = CONFIG.api.url.replace \http \ws - socket = new ReconnectingWebSocket "#{host}?i=#{me.token}" - - socket.onopen = ~> - state := \connected - state-ev.trigger \connected - - socket.onclose = ~> - state := \reconnecting - state-ev.trigger \closed - - socket.onmessage = (message) ~> - try - message = JSON.parse message.data - if message.type? - event.trigger message.type, message.body - catch - # ignore - - get-state = ~> state - - event.on \i_updated me.update - - { - state-ev - get-state - event - } diff --git a/src/web/app/desktop/scripts/stream.ls b/src/web/app/desktop/scripts/stream.ls index f84d6097a7..88dac16cb6 100644 --- a/src/web/app/desktop/scripts/stream.ls +++ b/src/web/app/desktop/scripts/stream.ls @@ -1,8 +1,8 @@ # Stream #================================ -stream = require '../../common/scripts/stream.ls' -get-post-summary = require '../../common/scripts/get-post-summary.ls' +stream = require '../../common/scripts/stream' +get-post-summary = require '../../common/scripts/get-post-summary' riot = require \riot module.exports = (me) ~> diff --git a/src/web/app/mobile/scripts/stream.ls b/src/web/app/mobile/scripts/stream.ls index b7810b49ae..28418d7788 100644 --- a/src/web/app/mobile/scripts/stream.ls +++ b/src/web/app/mobile/scripts/stream.ls @@ -1,7 +1,7 @@ # Stream #================================ -stream = require '../../common/scripts/stream.ls' +stream = require '../../common/scripts/stream' riot = require \riot module.exports = (me) ~> -- cgit v1.2.3-freya From 33cf76221157522ee62503e7cc7e70abf3d6500b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 16:37:22 +0900 Subject: :v: --- src/web/app/boot.js | 4 +- .../common/scripts/generate-default-userdata.js | 47 ++++++++++++++++++++++ .../common/scripts/generate-default-userdata.ls | 28 ------------- 3 files changed, 49 insertions(+), 30 deletions(-) create mode 100644 src/web/app/common/scripts/generate-default-userdata.js delete mode 100644 src/web/app/common/scripts/generate-default-userdata.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 32950071a2..a77bdd6dae 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -5,8 +5,8 @@ const riot = require('riot'); require('velocity-animate'); const api = require('./common/scripts/api'); -const signout = require('./common/scripts/signout.ls'); -const generateDefaultUserdata = require('./common/scripts/generate-default-userdata.ls'); +const signout = require('./common/scripts/signout'); +const generateDefaultUserdata = require('./common/scripts/generate-default-userdata'); const mixins = require('./common/mixins.ls'); const checkForUpdate = require('./common/scripts/check-for-update.ls'); require('./common/tags'); diff --git a/src/web/app/common/scripts/generate-default-userdata.js b/src/web/app/common/scripts/generate-default-userdata.js new file mode 100644 index 0000000000..f6c8c2fe58 --- /dev/null +++ b/src/web/app/common/scripts/generate-default-userdata.js @@ -0,0 +1,47 @@ +const uuid = require('./uuid.js'); + +const home = { + left: [ + 'profile', + 'calendar', + 'rss-reader', + 'photo-stream' + ], + right: [ + 'broadcast', + 'notifications', + 'user-recommendation', + 'donation', + 'nav', + 'tips' + ] +}; + +module.exports = () => { + const homeData = []; + + home.left.forEach(widget => { + homeData.push({ + name: widget, + id: uuid(), + place: 'left' + }); + }); + + home.right.forEach(widget => { + homeData.push({ + name: widget, + id: uuid(), + place: 'right' + }); + }); + + const data = { + cache: true, + debug: false, + nya: true, + home: homeData + }; + + return data; +}; diff --git a/src/web/app/common/scripts/generate-default-userdata.ls b/src/web/app/common/scripts/generate-default-userdata.ls deleted file mode 100644 index c13d221bb9..0000000000 --- a/src/web/app/common/scripts/generate-default-userdata.ls +++ /dev/null @@ -1,28 +0,0 @@ -uuid = require './uuid.js' - -home = - left: [ \profile \calendar \rss-reader \photo-stream ] - right: [ \broadcast \notifications \user-recommendation \donation \nav \tips ] - -module.exports = ~> - home-data = [] - - home.left.for-each (widget) ~> - home-data.push do - name: widget - id: uuid! - place: \left - - home.right.for-each (widget) ~> - home-data.push do - name: widget - id: uuid! - place: \right - - data = - cache: true - debug: false - nya: true - home: home-data - - return data -- cgit v1.2.3-freya From 168b5bb723e9dd136ef33e958640778720a7827d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 16:42:41 +0900 Subject: :v: --- src/web/app/common/mixins.ls | 2 +- src/web/app/common/scripts/i.js | 20 ++++++++++++++++++++ src/web/app/common/scripts/i.ls | 13 ------------- 3 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 src/web/app/common/scripts/i.js delete mode 100644 src/web/app/common/scripts/i.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/common/mixins.ls b/src/web/app/common/mixins.ls index 3999851a98..947fad553d 100644 --- a/src/web/app/common/mixins.ls +++ b/src/web/app/common/mixins.ls @@ -3,7 +3,7 @@ riot = require \riot module.exports = (me) ~> i = if me? then me.token else null - (require './scripts/i.ls') me + (require './scripts/i') me riot.mixin \api do api: (require './scripts/api').bind null i diff --git a/src/web/app/common/scripts/i.js b/src/web/app/common/scripts/i.js new file mode 100644 index 0000000000..66ce37d506 --- /dev/null +++ b/src/web/app/common/scripts/i.js @@ -0,0 +1,20 @@ +const riot = require('riot'); + +module.exports = me => { + riot.mixin('i', { + init: () => { + this.I = me; + this.SIGNIN = me != null; + + if (this.SIGNIN) { + this.on('mount', () => { + me.on('updated', this.update); + }); + this.on('unmount', () => { + me.off('updated', this.update); + }); + } + }, + me: me + }); +}; diff --git a/src/web/app/common/scripts/i.ls b/src/web/app/common/scripts/i.ls deleted file mode 100644 index 9b5fa87441..0000000000 --- a/src/web/app/common/scripts/i.ls +++ /dev/null @@ -1,13 +0,0 @@ -riot = require \riot - -module.exports = (me) -> - riot.mixin \i do - init: -> - @I = me - @SIGNIN = me? - - if @SIGNIN - @on \mount ~> me.on \updated @update - @on \unmount ~> me.off \updated @update - - me: me \ No newline at end of file -- cgit v1.2.3-freya From b4046da451ea0be70a5ded1a277ea3784c838050 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 16:51:11 +0900 Subject: :v: --- src/web/app/common/mixins.ls | 2 +- src/web/app/common/scripts/messaging-stream.js | 36 ++++++++++++++++++++++++++ src/web/app/common/scripts/messaging-stream.ls | 34 ------------------------ 3 files changed, 37 insertions(+), 35 deletions(-) create mode 100644 src/web/app/common/scripts/messaging-stream.js delete mode 100644 src/web/app/common/scripts/messaging-stream.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/common/mixins.ls b/src/web/app/common/mixins.ls index 947fad553d..1194793994 100644 --- a/src/web/app/common/mixins.ls +++ b/src/web/app/common/mixins.ls @@ -15,7 +15,7 @@ module.exports = (me) ~> signout: require './scripts/signout.js' riot.mixin \messaging-stream do - MessagingStreamConnection: require './scripts/messaging-stream.ls' + MessagingStreamConnection: require './scripts/messaging-stream' riot.mixin \is-promise do is-promise: require './scripts/is-promise.ls' diff --git a/src/web/app/common/scripts/messaging-stream.js b/src/web/app/common/scripts/messaging-stream.js new file mode 100644 index 0000000000..e6fc6f8bd0 --- /dev/null +++ b/src/web/app/common/scripts/messaging-stream.js @@ -0,0 +1,36 @@ +const ReconnectingWebSocket = require('reconnecting-websocket'); +const riot = require('riot'); + +class Connection { + constructor(me, otherparty) { + this.event = riot.observable(); + this.me = me; + + const host = CONFIG.api.url.replace('http', 'ws'); + this.socket = new ReconnectingWebSocket(`${host}/messaging?i=${me.token}&otherparty=${otherparty}`); + this.socket.addEventListener('open', this.onOpen); + this.socket.addEventListener('message', this.onMessage); + } + + onOpen() { + this.socket.send(JSON.stringify({ + i: this.me.token + })); + } + + onMessage(message) { + try { + const message = JSON.parse(message.data); + if (message.type) this.event.trigger(message.type, message.body); + } catch(e) { + // noop + } + } + + close() { + this.socket.removeEventListener('open', this.onOpen); + this.socket.removeEventListener('message', this.onMessage); + } +} + +module.exports = Connection; diff --git a/src/web/app/common/scripts/messaging-stream.ls b/src/web/app/common/scripts/messaging-stream.ls deleted file mode 100644 index ac3e74f1f5..0000000000 --- a/src/web/app/common/scripts/messaging-stream.ls +++ /dev/null @@ -1,34 +0,0 @@ -# Stream -#================================ - -ReconnectingWebSocket = require 'reconnecting-websocket' -riot = require 'riot' - -class Connection - (me, otherparty) ~> - @event = riot.observable! - @me = me - host = CONFIG.api.url.replace \http \ws - @socket = new ReconnectingWebSocket "#{host}/messaging?i=#{me.token}&otherparty=#{otherparty}" - - @socket.add-event-listener \open @on-open - @socket.add-event-listener \message @on-message - - on-open: ~> - @socket.send JSON.stringify do - i: @me.token - - on-message: (message) ~> - try - message = JSON.parse message.data - if message.type? - @event.trigger message.type, message.body - catch - # ignore - - close: ~> - @socket.remove-event-listener \open @on-open - @socket.remove-event-listener \message @on-message - @socket.close! - -module.exports = Connection -- cgit v1.2.3-freya From f6f1eb1bca8209714a24b997c720fb27a9f15b86 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 16:52:14 +0900 Subject: :v: --- src/web/app/common/mixins.ls | 12 ++++++------ src/web/app/common/scripts/is-promise.js | 1 + src/web/app/common/scripts/is-promise.ls | 1 - 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 src/web/app/common/scripts/is-promise.js delete mode 100644 src/web/app/common/scripts/is-promise.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/common/mixins.ls b/src/web/app/common/mixins.ls index 1194793994..c412e3b322 100644 --- a/src/web/app/common/mixins.ls +++ b/src/web/app/common/mixins.ls @@ -12,23 +12,23 @@ module.exports = (me) ~> Cropper: require \cropperjs riot.mixin \signout do - signout: require './scripts/signout.js' + signout: require './scripts/signout' riot.mixin \messaging-stream do MessagingStreamConnection: require './scripts/messaging-stream' riot.mixin \is-promise do - is-promise: require './scripts/is-promise.ls' + is-promise: require './scripts/is-promise' riot.mixin \get-post-summary do - get-post-summary: require './scripts/get-post-summary.js' + get-post-summary: require './scripts/get-post-summary' riot.mixin \date-stringify do - date-stringify: require './scripts/date-stringify.ls' + date-stringify: require './scripts/date-stringify' riot.mixin \text do - analyze: require '../../../common/text/index.js' - compile: require './scripts/text-compiler.js' + analyze: require '../../../common/text/index' + compile: require './scripts/text-compiler' riot.mixin \get-password-strength do get-password-strength: require 'syuilo-password-strength' diff --git a/src/web/app/common/scripts/is-promise.js b/src/web/app/common/scripts/is-promise.js new file mode 100644 index 0000000000..fd3dc42da3 --- /dev/null +++ b/src/web/app/common/scripts/is-promise.js @@ -0,0 +1 @@ +module.exports = x => typeof x.then == 'function'; diff --git a/src/web/app/common/scripts/is-promise.ls b/src/web/app/common/scripts/is-promise.ls deleted file mode 100644 index e3c7adff85..0000000000 --- a/src/web/app/common/scripts/is-promise.ls +++ /dev/null @@ -1 +0,0 @@ -module.exports = (x) -> typeof x.then == \function -- cgit v1.2.3-freya From 4dc96b87ddb9d2146116a54c7031d1682b236b18 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 16:53:46 +0900 Subject: :v: --- src/web/app/common/scripts/loading.js | 21 +++++++++++++++++++++ src/web/app/common/scripts/loading.ls | 16 ---------------- 2 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 src/web/app/common/scripts/loading.js delete mode 100644 src/web/app/common/scripts/loading.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/common/scripts/loading.js b/src/web/app/common/scripts/loading.js new file mode 100644 index 0000000000..fa7eafaf96 --- /dev/null +++ b/src/web/app/common/scripts/loading.js @@ -0,0 +1,21 @@ +const NProgress = require('nprogress'); +NProgress.configure({ + trickleSpeed: 500, + showSpinner: false +}); + +const root = document.getElementsByTagName('html')[0]; + +module.exports = { + start: () => { + root.classList.add('progress'); + NProgress.start(); + }, + done: () => { + root.classList.remove('progress'); + NProgress.done(); + }, + set: val => { + NProgress.set(val); + } +}; diff --git a/src/web/app/common/scripts/loading.ls b/src/web/app/common/scripts/loading.ls deleted file mode 100644 index 8ebede6db4..0000000000 --- a/src/web/app/common/scripts/loading.ls +++ /dev/null @@ -1,16 +0,0 @@ -NProgress = require \nprogress -NProgress.configure do - trickle-speed: 500ms - show-spinner: false - -root = document.get-elements-by-tag-name \html .0 - -module.exports = - start: ~> - root.class-list.add \progress - NProgress.start! - done: ~> - root.class-list.remove \progress - NProgress.done! - set: (val) ~> - NProgress.set val -- cgit v1.2.3-freya From f7444c6c0b01a70e3ed064df274de14c164e987a Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 16:57:16 +0900 Subject: :v: --- src/web/app/boot.js | 2 +- src/web/app/common/mixins.js | 2 +- src/web/app/common/scripts/check-for-update.js | 11 +++++++++++ src/web/app/common/scripts/check-for-update.ls | 9 --------- 4 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 src/web/app/common/scripts/check-for-update.js delete mode 100644 src/web/app/common/scripts/check-for-update.ls (limited to 'src/web/app/common/scripts') diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 75a7086d1c..b98602d402 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -8,7 +8,7 @@ const api = require('./common/scripts/api'); const signout = require('./common/scripts/signout'); const generateDefaultUserdata = require('./common/scripts/generate-default-userdata'); const mixins = require('./common/mixins'); -const checkForUpdate = require('./common/scripts/check-for-update.ls'); +const checkForUpdate = require('./common/scripts/check-for-update'); require('./common/tags'); /** diff --git a/src/web/app/common/mixins.js b/src/web/app/common/mixins.js index 208d0fdf54..220e033846 100644 --- a/src/web/app/common/mixins.js +++ b/src/web/app/common/mixins.js @@ -43,6 +43,6 @@ module.exports = me => { }); riot.mixin('ui-progress', { - Progress: require('./scripts/loading.ls') + Progress: require('./scripts/loading') }); }; diff --git a/src/web/app/common/scripts/check-for-update.js b/src/web/app/common/scripts/check-for-update.js new file mode 100644 index 0000000000..cd7279e3b8 --- /dev/null +++ b/src/web/app/common/scripts/check-for-update.js @@ -0,0 +1,11 @@ +module.exports = () => { + fetch('/api:meta').then(res => { + res.json().then(meta => { + if (meta.commit.hash !== VERSION) { + if (window.confirm('新しいMisskeyのバージョンがあります。更新しますか?\r\n(このメッセージが繰り返し表示される場合は、サーバーにデータがまだ届いていない可能性があるので、少し時間を置いてから再度お試しください)')) { + location.reload(true); + } + } + }); + }); +}; diff --git a/src/web/app/common/scripts/check-for-update.ls b/src/web/app/common/scripts/check-for-update.ls deleted file mode 100644 index 48e250a4c7..0000000000 --- a/src/web/app/common/scripts/check-for-update.ls +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = -> - fetch \/api:meta - .then (res) ~> - meta <~ res.json!.then - if meta.commit.hash != VERSION - if window.confirm '新しいMisskeyのバージョンがあります。更新しますか?\r\n(このメッセージが繰り返し表示される場合は、サーバーにデータがまだ届いていない可能性があるので、少し時間を置いてから再度お試しください)' - location.reload true - .catch ~> - # ignore -- cgit v1.2.3-freya