summaryrefslogtreecommitdiff
path: root/src/web/app
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-01-01 11:17:17 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-01-01 11:17:17 +0900
commit76e83a9c0e09beb5bc1ffa37ea11764db4180784 (patch)
treecbfc165a119a88e7fe6c9fcc6d856e319e9af821 /src/web/app
parentFix bug (diff)
downloadmisskey-76e83a9c0e09beb5bc1ffa37ea11764db4180784.tar.gz
misskey-76e83a9c0e09beb5bc1ffa37ea11764db4180784.tar.bz2
misskey-76e83a9c0e09beb5bc1ffa37ea11764db4180784.zip
Use tab for indantaion
Diffstat (limited to 'src/web/app')
-rw-r--r--src/web/app/boot.js180
1 files changed, 90 insertions, 90 deletions
diff --git a/src/web/app/boot.js b/src/web/app/boot.js
index 5d3a6f0ec5..b224491c1f 100644
--- a/src/web/app/boot.js
+++ b/src/web/app/boot.js
@@ -28,17 +28,17 @@ require('fetch');
// ↓ NodeList、HTMLCollectionで forEach を使えるようにする
if (NodeList.prototype.forEach === undefined) {
- NodeList.prototype.forEach = Array.prototype.forEach;
+ NodeList.prototype.forEach = Array.prototype.forEach;
}
if (HTMLCollection.prototype.forEach === undefined) {
- HTMLCollection.prototype.forEach = Array.prototype.forEach;
+ HTMLCollection.prototype.forEach = Array.prototype.forEach;
}
// ↓ iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする
try {
- localStorage.setItem('kyoppie', 'yuppie');
+ localStorage.setItem('kyoppie', 'yuppie');
} catch (e) {
- Storage.prototype.setItem = () => { }; // noop
+ Storage.prototype.setItem = () => { }; // noop
}
// MAIN PROCESS
@@ -52,118 +52,118 @@ checkForUpdate();
const i = (document.cookie.match(/i=(\w+)/) || [null, null])[1];
if (i != null) {
- log("ME: " + i);
+ log("ME: " + i);
}
// ユーザーをフェッチしてコールバックする
module.exports = callback => {
// Get cached account data
- let cachedMe = JSON.parse(localStorage.getItem('me'));
+ let cachedMe = JSON.parse(localStorage.getItem('me'));
- if (cachedMe != null && cachedMe.data != null && cachedMe.data.cache) {
- fetched(cachedMe);
+ if (cachedMe != null && cachedMe.data != null && cachedMe.data.cache) {
+ fetched(cachedMe);
// 後から新鮮なデータをフェッチ
- fetchme(i, true, freshData => {
- Object.assign(cachedMe, freshData);
- cachedMe.trigger('updated');
- });
- } else {
+ fetchme(i, true, freshData => {
+ Object.assign(cachedMe, freshData);
+ cachedMe.trigger('updated');
+ });
+ } else {
// キャッシュ無効なのにキャッシュが残ってたら掃除
- if (cachedMe != null) {
- localStorage.removeItem('me');
- }
- fetchme(i, false, fetched);
- }
+ if (cachedMe != null) {
+ localStorage.removeItem('me');
+ }
+ fetchme(i, false, fetched);
+ }
- function fetched(me) {
- if (me != null) {
- riot.observable(me);
- if (me.data.cache) {
- localStorage.setItem('me', JSON.stringify(me));
- me.on('updated', () => {
+ function fetched(me) {
+ if (me != null) {
+ riot.observable(me);
+ if (me.data.cache) {
+ localStorage.setItem('me', JSON.stringify(me));
+ me.on('updated', () => {
// キャッシュ更新
- localStorage.setItem('me', JSON.stringify(me));
- });
- }
- log("Fetched! Hello " + me.username + ".");
- }
- mixins(me);
- const init = document.getElementById('init');
- init.parentNode.removeChild(init);
- const app = document.createElement('div');
- app.setAttribute('id', 'app');
- document.body.appendChild(app);
- try {
- callback(me);
- } catch (e) {
- panic(e);
- }
- }
+ localStorage.setItem('me', JSON.stringify(me));
+ });
+ }
+ log("Fetched! Hello " + me.username + ".");
+ }
+ mixins(me);
+ const init = document.getElementById('init');
+ init.parentNode.removeChild(init);
+ const app = document.createElement('div');
+ app.setAttribute('id', 'app');
+ document.body.appendChild(app);
+ try {
+ callback(me);
+ } catch (e) {
+ panic(e);
+ }
+ }
};
// ユーザーをフェッチしてコールバックする
function fetchme(token, silent, cb) {
- let me = null;
+ let me = null;
// Return when not signed in
- if (token == null) {
- return done();
- }
+ if (token == null) {
+ return done();
+ }
// Fetch user
- fetch(CONFIG.api.url + "/i", {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
- },
- body: "i=" + token
- }).then(res => {
+ fetch(CONFIG.api.url + "/i", {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
+ },
+ body: "i=" + token
+ }).then(res => {
// When failed to authenticate user
- if (res.status !== 200) {
- signout();
- }
- res.json().then(i => {
- me = i;
- me.token = token;
+ if (res.status !== 200) {
+ signout();
+ }
+ res.json().then(i => {
+ me = i;
+ me.token = token;
// initialize it if user data is empty
- if (me.data != null) {
- done();
- } else {
- init();
- }
- });
- }).catch(() => {
- if (!silent) {
- const info = document.body.appendChild(document.createElement('mk-core-error'));
- riot.mount(info, {
- retry: () => {
- fetchme(token, false, cb);
- }
- });
+ if (me.data != null) {
+ done();
+ } else {
+ init();
+ }
+ });
+ }).catch(() => {
+ if (!silent) {
+ const info = document.body.appendChild(document.createElement('mk-core-error'));
+ riot.mount(info, {
+ retry: () => {
+ fetchme(token, false, cb);
+ }
+ });
}
- });
+ });
- function done() {
- if (cb != null) {
- cb(me);
- }
- }
+ function done() {
+ if (cb != null) {
+ cb(me);
+ }
+ }
- function init() {
- var data, this$ = this;
- data = generateDefaultUserdata();
- api(token, 'i/appdata/set', {
- data: JSON.stringify(data)
- }).then(() => {
- me.data = data;
- done();
- });
- }
+ function init() {
+ var data, this$ = this;
+ data = generateDefaultUserdata();
+ api(token, 'i/appdata/set', {
+ data: JSON.stringify(data)
+ }).then(() => {
+ me.data = data;
+ done();
+ });
+ }
}
function panic(e) {
- console.error(e);
- document.body.innerHTML = '<div id="error"><p>致命的な問題が発生しました。</p></div>';
+ console.error(e);
+ document.body.innerHTML = '<div id="error"><p>致命的な問題が発生しました。</p></div>';
}