@@ -58,6 +58,20 @@ $(document).ready(function () {
5858} ) ;
5959
6060$ ( document ) . ready ( function ( ) {
61+ $ . support . cors = true ; // force cross-site scripting (as of jQuery 1.5)
62+ function serviceCall ( operation , accessToken , label ) {
63+ label . text ( 'fetching...' ) ;
64+ $ . ajax ( {
65+ url : "http://localhost:65169" + encodeURI ( operation ) ,
66+ headers : {
67+ "Authorization" : "Bearer " + accessToken
68+ } ,
69+ cache : false ,
70+ success : function ( data , textStatus , jqXHR ) { label . text ( data . toString ( ) ) ; } ,
71+ error : function ( jqXHR , textStatus , errorThrown ) { label . text ( textStatus + ": " + errorThrown ) ; }
72+ } ) ;
73+ } ;
74+
6175 var fragmentIndex = document . location . href . indexOf ( '#' ) ;
6276 if ( fragmentIndex > 0 ) {
6377 var fragment = document . location . href . substring ( fragmentIndex + 1 ) ;
@@ -69,13 +83,19 @@ $(document).ready(function () {
6983 authorizationLabel . text ( 'Authorization received! ' + suffix ) ;
7084
7185 var scopes = args [ 'scope' ] . split ( ' ' ) ;
72- for ( var scope in scopes ) {
73- var button = $ ( 'input[operation="' + scopes [ scope ] + '"]' ) [ 0 ] ;
74- button . disabled = false ;
75-
76- var checkbox = $ ( 'input[value="' + scopes [ scope ] + '"]' ) [ 0 ] ;
86+ for ( var scopeIndex in scopes ) {
87+ var scope = scopes [ scopeIndex ] ;
88+ var button = $ ( 'input[operation="' + scope + '"]' ) ;
89+ button [ 0 ] . disabled = false ;
90+ button . click ( ( function ( value ) {
91+ return function ( ) {
92+ var label = $ ( 'span[operation="' + value + '"]' ) ;
93+ serviceCall ( value , args [ 'access_token' ] , label ) ;
94+ } ;
95+ } ) ( scope ) ) ;
96+ var checkbox = $ ( 'input[value="' + scope + '"]' ) [ 0 ] ;
7797 checkbox . checked = true ;
78- }
98+ } ;
7999 }
80100 }
81101} ) ;
0 commit comments