1
+ <!DOCTYPE html>
2
+ < link rel ="stylesheet " href ="/adorn/adorn.css "/>
3
+ < script src ="/adorn/adorn.js " async > </ script >
4
+ < script src ="client_ids.js "> </ script >
5
+ < style >
6
+ .alert {
7
+ display : block;
8
+ padding : 15px ;
9
+ margin-bottom : 20px ;
10
+ border : 1px solid rgba (0 , 0 , 0 , 0 );
11
+ border-radius : 4px ;
12
+ }
13
+ .alert-warning {
14
+ color : # 8A6D3B ;
15
+ background-color : # FCF8E3 ;
16
+ border-color : # FAEBCC ;
17
+ }
18
+ .alert .alert-warning : before {
19
+ content : "Warning: " ;
20
+ font-weight : bold;
21
+ }
22
+ </ style >
23
+
24
+
25
+ < title > hello( box )</ title >
26
+ < h1 > hello( box )</ h1 >
27
+
28
+
29
+ < blockquote >
30
+ Box.com only provides authentication from apps which are using HTTPS. < a href ="https://developers.box.com/docs/#api-basics "> See Box.com API documentation</ a >
31
+ </ blockquote >
32
+
33
+ < script >
34
+ if ( document . location . href . indexOf ( 'https://' ) !== 0 ) {
35
+ document . body . appendChild ( ( function ( ) {
36
+ var div = document . createElement ( 'div' ) ;
37
+ div . className = "alert alert-warning" ;
38
+ div . appendChild ( ( function ( ) {
39
+ var a = document . createElement ( 'a' ) ;
40
+ a . href = document . location . href . replace ( 'http://' , 'https://' ) ;
41
+ a . innerHTML = "Launch page with secure protocol - https://" ;
42
+ return a ;
43
+ } ) ( ) ) ;
44
+ return div ;
45
+ } ) ( ) ) ;
46
+ }
47
+ </ script >
48
+
49
+ < button onclick ="login(); " id ="profile "> Login Box</ button >
50
+
51
+ < script src ="../src/hello.js " class ="pre "> </ script >
52
+ < script src ="../src/modules/box.js " class ="pre "> </ script >
53
+
54
+ < script class ="pre ">
55
+
56
+ var profile = document . getElementById ( 'profile' ) ;
57
+
58
+ function login ( ) {
59
+
60
+ var box = hello ( 'box' ) ;
61
+
62
+ box
63
+ . login ( )
64
+ . then ( function ( ) {
65
+ return box . api ( 'me' )
66
+ } )
67
+ . then ( function ( r ) {
68
+
69
+ profile . innerHTML = "<img src='" + r . thumbnail + "' width=24/>Connected to Box.com as " + r . name ;
70
+
71
+ } , console . error . bind ( console ) ) ;
72
+
73
+ }
74
+ </ script >
75
+
76
+ < p > Initiate box client</ p >
77
+
78
+ < script >
79
+ var BOX_CLIENT_ID = {
80
+ 'local.knarly.com' : 'rdyb5se2fcuioryle3qdw2wcrps959x4' ,
81
+ 'adodson.com' : '264d13a33ba845f396a152cc326e6f5d'
82
+ } [ window . location . hostname ] ;
83
+ </ script >
84
+
85
+ < script class ="pre ">
86
+ hello . init ( {
87
+ box : BOX_CLIENT_ID
88
+ } , {
89
+ redirect_uri :'../redirect.html' ,
90
+ response_type :'code'
91
+ } ) ;
92
+ </ script >
0 commit comments