Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
336
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
23
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
76e83a9c
Commit
76e83a9c
authored
8 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Use tab for indantaion
parent
26d0d131
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/web/app/boot.js
+93
-93
93 additions, 93 deletions
src/web/app/boot.js
with
93 additions
and
93 deletions
src/web/app/boot.js
+
93
−
93
View file @
76e83a9c
...
@@ -28,17 +28,17 @@ require('fetch');
...
@@ -28,17 +28,17 @@ require('fetch');
// ↓ NodeList、HTMLCollectionで forEach を使えるようにする
// ↓ NodeList、HTMLCollectionで forEach を使えるようにする
if
(
NodeList
.
prototype
.
forEach
===
undefined
)
{
if
(
NodeList
.
prototype
.
forEach
===
undefined
)
{
NodeList
.
prototype
.
forEach
=
Array
.
prototype
.
forEach
;
NodeList
.
prototype
.
forEach
=
Array
.
prototype
.
forEach
;
}
}
if
(
HTMLCollection
.
prototype
.
forEach
===
undefined
)
{
if
(
HTMLCollection
.
prototype
.
forEach
===
undefined
)
{
HTMLCollection
.
prototype
.
forEach
=
Array
.
prototype
.
forEach
;
HTMLCollection
.
prototype
.
forEach
=
Array
.
prototype
.
forEach
;
}
}
// ↓ iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする
// ↓ iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする
try
{
try
{
localStorage
.
setItem
(
'
kyoppie
'
,
'
yuppie
'
);
localStorage
.
setItem
(
'
kyoppie
'
,
'
yuppie
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
Storage
.
prototype
.
setItem
=
()
=>
{
};
// noop
Storage
.
prototype
.
setItem
=
()
=>
{
};
// noop
}
}
// MAIN PROCESS
// MAIN PROCESS
...
@@ -52,118 +52,118 @@ checkForUpdate();
...
@@ -52,118 +52,118 @@ checkForUpdate();
const
i
=
(
document
.
cookie
.
match
(
/i=
(\w
+
)
/
)
||
[
null
,
null
])[
1
];
const
i
=
(
document
.
cookie
.
match
(
/i=
(\w
+
)
/
)
||
[
null
,
null
])[
1
];
if
(
i
!=
null
)
{
if
(
i
!=
null
)
{
log
(
"
ME:
"
+
i
);
log
(
"
ME:
"
+
i
);
}
}
// ユーザーをフェッチしてコールバックする
// ユーザーをフェッチしてコールバックする
module
.
exports
=
callback
=>
{
module
.
exports
=
callback
=>
{
// Get cached account data
// 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
)
{
if
(
cachedMe
!=
null
&&
cachedMe
.
data
!=
null
&&
cachedMe
.
data
.
cache
)
{
fetched
(
cachedMe
);
fetched
(
cachedMe
);
// 後から新鮮なデータをフェッチ
// 後から新鮮なデータをフェッチ
fetchme
(
i
,
true
,
freshData
=>
{
fetchme
(
i
,
true
,
freshData
=>
{
Object
.
assign
(
cachedMe
,
freshData
);
Object
.
assign
(
cachedMe
,
freshData
);
cachedMe
.
trigger
(
'
updated
'
);
cachedMe
.
trigger
(
'
updated
'
);
});
});
}
else
{
}
else
{
// キャッシュ無効なのにキャッシュが残ってたら掃除
// キャッシュ無効なのにキャッシュが残ってたら掃除
if
(
cachedMe
!=
null
)
{
if
(
cachedMe
!=
null
)
{
localStorage
.
removeItem
(
'
me
'
);
localStorage
.
removeItem
(
'
me
'
);
}
}
fetchme
(
i
,
false
,
fetched
);
fetchme
(
i
,
false
,
fetched
);
}
}
function
fetched
(
me
)
{
function
fetched
(
me
)
{
if
(
me
!=
null
)
{
if
(
me
!=
null
)
{
riot
.
observable
(
me
);
riot
.
observable
(
me
);
if
(
me
.
data
.
cache
)
{
if
(
me
.
data
.
cache
)
{
localStorage
.
setItem
(
'
me
'
,
JSON
.
stringify
(
me
));
localStorage
.
setItem
(
'
me
'
,
JSON
.
stringify
(
me
));
me
.
on
(
'
updated
'
,
()
=>
{
me
.
on
(
'
updated
'
,
()
=>
{
// キャッシュ更新
// キャッシュ更新
localStorage
.
setItem
(
'
me
'
,
JSON
.
stringify
(
me
));
localStorage
.
setItem
(
'
me
'
,
JSON
.
stringify
(
me
));
});
});
}
}
log
(
"
Fetched! Hello
"
+
me
.
username
+
"
.
"
);
log
(
"
Fetched! Hello
"
+
me
.
username
+
"
.
"
);
}
}
mixins
(
me
);
mixins
(
me
);
const
init
=
document
.
getElementById
(
'
init
'
);
const
init
=
document
.
getElementById
(
'
init
'
);
init
.
parentNode
.
removeChild
(
init
);
init
.
parentNode
.
removeChild
(
init
);
const
app
=
document
.
createElement
(
'
div
'
);
const
app
=
document
.
createElement
(
'
div
'
);
app
.
setAttribute
(
'
id
'
,
'
app
'
);
app
.
setAttribute
(
'
id
'
,
'
app
'
);
document
.
body
.
appendChild
(
app
);
document
.
body
.
appendChild
(
app
);
try
{
try
{
callback
(
me
);
callback
(
me
);
}
catch
(
e
)
{
}
catch
(
e
)
{
panic
(
e
);
panic
(
e
);
}
}
}
}
};
};
// ユーザーをフェッチしてコールバックする
// ユーザーをフェッチしてコールバックする
function
fetchme
(
token
,
silent
,
cb
)
{
function
fetchme
(
token
,
silent
,
cb
)
{
let
me
=
null
;
let
me
=
null
;
// Return when not signed in
// Return when not signed in
if
(
token
==
null
)
{
if
(
token
==
null
)
{
return
done
();
return
done
();
}
}
// Fetch user
// Fetch user
fetch
(
CONFIG
.
api
.
url
+
"
/i
"
,
{
fetch
(
CONFIG
.
api
.
url
+
"
/i
"
,
{
method
:
'
POST
'
,
method
:
'
POST
'
,
headers
:
{
headers
:
{
'
Content-Type
'
:
'
application/x-www-form-urlencoded; charset=utf-8
'
'
Content-Type
'
:
'
application/x-www-form-urlencoded; charset=utf-8
'
},
},
body
:
"
i=
"
+
token
body
:
"
i=
"
+
token
}).
then
(
res
=>
{
}).
then
(
res
=>
{
// When failed to authenticate user
// When failed to authenticate user
if
(
res
.
status
!==
200
)
{
if
(
res
.
status
!==
200
)
{
signout
();
signout
();
}
}
res
.
json
().
then
(
i
=>
{
res
.
json
().
then
(
i
=>
{
me
=
i
;
me
=
i
;
me
.
token
=
token
;
me
.
token
=
token
;
// initialize it if user data is empty
// initialize it if user data is empty
if
(
me
.
data
!=
null
)
{
if
(
me
.
data
!=
null
)
{
done
();
done
();
}
else
{
}
else
{
init
();
init
();
}
}
});
});
}).
catch
(()
=>
{
}).
catch
(()
=>
{
if
(
!
silent
)
{
if
(
!
silent
)
{
const
info
=
document
.
body
.
appendChild
(
document
.
createElement
(
'
mk-core-error
'
));
const
info
=
document
.
body
.
appendChild
(
document
.
createElement
(
'
mk-core-error
'
));
riot
.
mount
(
info
,
{
riot
.
mount
(
info
,
{
retry
:
()
=>
{
retry
:
()
=>
{
fetchme
(
token
,
false
,
cb
);
fetchme
(
token
,
false
,
cb
);
}
}
});
});
}
});
function
done
()
{
if
(
cb
!=
null
)
{
cb
(
me
);
}
}
});
}
function
done
()
{
function
init
()
{
if
(
cb
!=
null
)
{
var
data
,
this
$
=
this
;
cb
(
me
);
data
=
generateDefaultUserdata
();
}
api
(
token
,
'
i/appdata/set
'
,
{
}
data
:
JSON
.
stringify
(
data
)
}).
then
(()
=>
{
function
init
()
{
me
.
data
=
data
;
var
data
,
this
$
=
this
;
done
();
data
=
generateDefaultUserdata
();
});
api
(
token
,
'
i/appdata/set
'
,
{
}
data
:
JSON
.
stringify
(
data
)
}).
then
(()
=>
{
me
.
data
=
data
;
done
();
});
}
}
}
function
panic
(
e
)
{
function
panic
(
e
)
{
console
.
error
(
e
);
console
.
error
(
e
);
document
.
body
.
innerHTML
=
'
<div id="error"><p>致命的な問題が発生しました。</p></div>
'
;
document
.
body
.
innerHTML
=
'
<div id="error"><p>致命的な問題が発生しました。</p></div>
'
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment