99 < script type ="text/javascript ">
1010 $ ( function ( ) {
1111 var authUser , userStats , siteStats , qSource = "questions" , qLabel = "Latest Questions" ;
12-
13- if ( window . localStorage ) {
14- authUser = localStorage . getItem ( "authUser" ) ;
15- if ( typeof authUser == "string" ) authUser = $ . parseJSON ( authUser ) ;
16- if ( authUser )
17- {
18- loginUser ( authUser . DisplayName ) ;
19- refresh ( ) ;
20- }
21- }
2212
2313 $ ( document ) . click ( function ( e ) {
2414 var el = e . target ;
5949 }
6050 var toTwitterTime = function ( a ) {
6151 var b = new Date ( ) ;
62- var c = typeof a == "Date " ? a : new Date ( a ) ;
52+ var c = typeof a == "date " ? a : new Date ( a ) ;
6353 var d = b - c ;
6454 var e = 1000 , minute = e * 60 , hour = minute * 60 , day = hour * 24 , week = day * 7 ;
6555 if ( isNaN ( d ) || d < 0 ) { return "" }
7868 return html . replace ( '<' , '<' ) . replace ( '>' , '>' ) . replace ( '"' , '"' ) ;
7969 }
8070
81- window . onpopstate = function ( e ) {
82- e = e || event ;
83- if ( ! e . state ) return ;
84- qSource = e . state . qSource ;
85- qLabel = e . state . qLabel ;
86- refresh ( null , true ) ;
87- } ;
88-
8971 function refresh ( callback , skipPushState ) {
9072 if ( ! skipPushState && window . history . pushState )
91- window . history . pushState ( { qSource :qSource , qLabel :qLabel } , qLabel ) ;
73+ {
74+ var frag = "#!" + qSource + "/" + encodeURIComponent ( qLabel . replace ( / / g, '_' ) ) ;
75+ window . history . pushState ( { qSource :qSource , qLabel :qLabel } , qLabel , frag ) ;
76+ }
9277
9378 var asyncCount = 0 ;
9479 if ( authUser )
167152 + '<div class="by">'
168153 + "<i data-cmd='users/" + u . Id + "/questions' data-label='Questions by "
169154 + enc ( u . DisplayName ) + "'>by " + enc ( u . DisplayName ) + "</i>"
170- + '<em>' + toTwitterTime ( date . toUTCString ( ) ) + '</em>'
155+ + '<em>' + toTwitterTime ( date ) + '</em>'
171156 + '<br />'
172157 + '</div>'
173158 + '</div>'
251236 if ( -- asyncCount == 0 && callback ) callback ( ) ;
252237 } ) ;
253238 } ;
239+
240+ var loaded = false ;
241+ window . onpopstate = function ( e ) {
242+ if ( ! loaded ) { return ; }
243+ e = e || event ;
244+ if ( ! e . state ) return ;
245+ qSource = e . state . qSource ;
246+ qLabel = e . state . qLabel ;
247+ refresh ( null , true ) ;
248+ } ;
249+
250+ var hash = location . hash . indexOf ( '#!' ) === 0 && location . hash . substr ( 2 ) ;
251+ if ( hash ) {
252+ var parts = hash . split ( '/' ) ;
253+ qLabel = parts . length == 1 ? qLabel : decodeURIComponent ( parts . pop ( ) ) . replace ( / _ / g, ' ' ) ;
254+ qSource = parts . join ( '/' ) ;
255+ }
256+
257+ if ( window . localStorage ) {
258+ authUser = localStorage . getItem ( "authUser" ) ;
259+ if ( typeof authUser == "string" ) authUser = $ . parseJSON ( authUser ) ;
260+ }
261+ if ( authUser ) loginUser ( authUser . DisplayName ) ;
254262 refresh ( ) ;
255263
256264 $ ( "#user A#login" ) . attr ( 'href' , 'javascript:void(0)' ) ;
290298 $ ( "#add INPUT, #add TEXTAREA" ) . removeClass ( 'error' ) ;
291299 if ( ! title ) $ ( "#qtitle" ) . addClass ( 'error' ) ;
292300 if ( ! body ) $ ( "#qbody" ) . addClass ( 'error' ) ;
293- if ( ! tags ) $ ( "#qtags" ) . addClass ( 'error' ) ;
301+ var invalidTags = ! tags || / [ & \< \> ] / . test ( tags ) ;
302+ if ( invalidTags ) $ ( "#qtags" ) . addClass ( 'error' ) ;
294303
295- if ( ! title || ! body || ! tags ) return ;
304+ if ( ! title || ! body || invalidTags ) return ;
296305
297306 var dtoTags = tags . split ( / [ , ; ] / ) . join ( "," ) ;
298307
@@ -370,7 +379,12 @@ <h3>Application Features</h3>
370379 < a href ="servicestack/metadata "> Checkout the complete Web Services API</ a >
371380 </ dd >
372381 < dd >
373- Uses only OSS software and is freely available at:
382+ < a href ="http://www.servicestack.net "> Uses</ a >
383+ < a href ="http://redis.io "> only</ a >
384+ < a href ="http://www.mono-project.com "> OSS</ a >
385+ < a href ="http://wiki.nginx.org "> software</ a >
386+ < a href ="http://jquery.com "> and is</ a >
387+ freely available at:
374388 </ dd >
375389 </ dl >
376390
@@ -385,13 +399,15 @@ <h3>Application Features</h3>
385399 < h2 > </ h2 >
386400 < div id ="results "> </ div >
387401 < div id ="paging "> </ div >
402+ < a id ="mono " href ="http://www.mono-project.com "> < img src ="img/Mono-powered-big.png " alt ="Powered by Mono " /> </ a >
388403 < div id ="disclaimer "> *Not affiliated with Stack Overflow, which is a trademark of Stack Overflow Internet Services Inc.</ div >
389404 </ div >
390405
391406 < div id ="footer ">
392407 Simple StackOverlow-like Ajax website using only < a href ="http://jquery.com "> jQuery</ a > for UI,
393408 calling < a href ="http://www.servicestack.net "> Service Stack's</ a > REST-ful web services,
394- powered entirely by < a href ="http://redis.io "> Redis</ a > .< br />
409+ powered entirely by < a href ="http://redis.io "> Redis</ a >
410+ on < a href ="http://www.mono-project.com "> Mono</ a > .< br />
395411
396412 Takes advantage of
397413 < a href ="http://redis.io/commands#string "> STRING</ a > ,
0 commit comments