File tree 2 files changed +37
-0
lines changed 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*global document */
2
+ ( async function ( ) {
3
+ if ( ! window . location . href . includes ( 'parseplatform.org' ) ) {
4
+ return ;
5
+ }
6
+ const sdk = window . location . href . split ( 'parseplatform.org/' ) [ 1 ] . split ( '/' ) [ 0 ] ;
7
+ if ( sdk !== 'Parse-SDK-JS' && sdk !== 'parse-server' ) {
8
+ return ;
9
+ }
10
+ const location = window . location . href . split ( 'api/' ) ;
11
+ if ( location . length === 1 || ! location [ 1 ] ) {
12
+ return ;
13
+ }
14
+ const apiVersion = location [ 1 ] . split ( '/' ) [ 0 ] ;
15
+ const { url } = await fetch (
16
+ `https://unpkg.com/browse/parse${
17
+ sdk === 'parse-server' ? '-server' : ''
18
+ } /package.json`
19
+ ) ;
20
+ const latest = url . split ( '@' ) [ 1 ] . split ( '/' ) [ 0 ] ;
21
+ if ( apiVersion !== latest ) {
22
+ const main = document . getElementById ( 'main' ) ;
23
+ const alertDiv = document . createElement ( 'div' ) ;
24
+ alertDiv . style . width = '100%' ;
25
+ alertDiv . style . paddingTop = '20px' ;
26
+ alertDiv . style . textAlign = 'center' ;
27
+ alertDiv . style . color = 'red' ;
28
+ alertDiv . innerHTML = 'This version of the SDK is outdated.' ;
29
+ const link = document . createElement ( 'a' ) ;
30
+ link . style . marginLeft = '10px' ;
31
+ link . setAttribute ( 'href' , window . location . href . split ( apiVersion ) [ 0 ] ) ;
32
+ link . innerHTML = `Go to ${ latest } ` ;
33
+ alertDiv . appendChild ( link ) ;
34
+ main . insertBefore ( alertDiv , main . firstChild ) ;
35
+ }
36
+ } ) ( ) ;
Original file line number Diff line number Diff line change 43
43
44
44
<script>prettyPrint();</script>
45
45
<script src="scripts/linenumber.js"></script>
46
+ <script src="scripts/check_version.js"></script>
46
47
</body>
47
48
</html>
You can’t perform that action at this time.
0 commit comments