2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								( function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									var  num _users  =  document . getElementById ( 'number_of_users' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-28 10:56:38 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										post _stats  =  document . getElementById ( 'post_stats' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										latest _user  =  document . getElementById ( 'latest_user' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										active _users  =  document . getElementById ( 'active_users' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										user _label  =  document . getElementById ( 'user_label' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										active _record  =  document . getElementById ( 'active_record' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										right _menu  =  document . getElementById ( 'right-menu' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 05:16:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									socket . emit ( 'user.count' ,  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									socket . on ( 'user.count' ,  function ( data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										num _users . innerHTML  =  "We currently have <b>"  +  data . count  +  "</b> registered users." ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-28 10:56:38 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									socket . emit ( 'post.stats' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									socket . on ( 'post.stats' ,  function ( data )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-07-13 22:57:04 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										post _stats . innerHTML  =  "Our users have created <b>"  +  data . topics  +  "</b> topics and made <b>"  +  data . posts  +  "</b> posts." ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-28 10:56:38 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									socket . emit ( 'user.latest' ,  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									socket . on ( 'user.latest' ,  function ( data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( data . username  ==  '' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-06 13:30:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											latest _user . innerHTML  =  '' ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-26 23:31:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											latest _user . innerHTML  =  "The most recent user to register is <b><a href='/users/" + data . userslug + "'>"  +  data . username  +  "</a></b>." ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-28 10:56:38 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									socket . emit ( 'api:user.active.get' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									socket . on ( 'api:user.active.get' ,  function ( data )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 05:16:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										var  plural _users  =  parseInt ( data . users )  !==  1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											plural _anon  =  parseInt ( data . anon )  !==  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										active _users . innerHTML  =  'There '  +  ( plural _users  ?  'are'  :  'is' )  +  ' <strong>'  +  data . users  +  '</strong> user'  +  ( plural _users  ?  's'  :  '' )  +  ' and <strong>'  +  data . anon  +  '</strong> guest'  +  ( plural _anon  ?  's'  :  '' )  +  ' online' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 05:16:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									socket . emit ( 'api:user.active.get_record' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									socket . on ( 'api:user.active.get_record' ,  function ( data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										active _record . innerHTML  =  "most users ever online was <strong>"  +  data . record  +  "</strong> on <strong>"  +  ( new  Date ( parseInt ( data . timestamp , 10 ) ) ) . toUTCString ( )  +  "</strong>" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-06-24 14:33:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									socket . emit ( 'api:updateHeader' ,  {  fields :  [ 'username' ,  'picture' ,  'userslug' ]  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 05:16:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									socket . on ( 'api:updateHeader' ,  function ( data )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 05:16:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-08-31 02:59:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										jQuery ( '#search-button' ) . on ( 'click' ,  function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											jQuery ( '#search-fields' ) . removeClass ( 'hide' ) . show ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											jQuery ( this ) . hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											jQuery ( '#search-fields input' ) . focus ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											jQuery ( '#search-form' ) . on ( 'submit' ,  function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												jQuery ( '#search-fields' ) . hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												jQuery ( '#search-button' ) . show ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 11:45:15 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											$ ( '#search-fields input' ) . on ( 'blur' ,  function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												$ ( '#search-fields' ) . hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												$ ( '#search-button' ) . show ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-31 02:59:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 11:45:15 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-08-22 00:40:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										var  rightMenu  =  $ ( '#right-menu' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											isLoggedIn  =  data . uid  >  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( isLoggedIn )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											jQuery ( '.nodebb-loggedin' ) . show ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											jQuery ( '.nodebb-loggedout' ) . hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-20 11:55:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-06-19 09:35:44 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  userLabel  =  rightMenu . find ( '#user_label' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-20 11:55:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if ( userLabel . length )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-07-10 11:20:31 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if ( data [ 'userslug' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													userLabel . attr ( 'href' , '/users/'  +  data [ 'userslug' ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if ( data [ 'picture' ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2013-07-18 14:47:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													userLabel . find ( 'img' ) . attr ( 'src' , data [ 'picture' ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-07-10 11:20:31 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if ( data [ 'username' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													userLabel . find ( 'span' ) . html ( data [ 'username' ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-22 00:40:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-20 11:55:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												var  userli  =  $ ( ' < li >  \ 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-24 14:33:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																	< a  id = "user_label"  href = "/users/'+data['userslug']+'" >  \ 
							 
						 
					
						
							
								
									
										
										
										
											2013-07-18 14:47:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																		< img  src = "'+data['picture']+'" / >  \ 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-20 11:55:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																		< span > '+data[' username ']+' < / s p a n >   \ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																	< / a >   \ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																< / l i > ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												rightMenu . append ( userli ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-07-10 21:31:58 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												var  logoutli  =  $ ( '<li><a href="'  +  RELATIVE _PATH  +  '/logout">Log out</a></li>' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-20 11:55:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												rightMenu . append ( logoutli ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 11:45:15 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											$ ( '#search-button' ) . hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-22 00:40:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											jQuery ( '.nodebb-loggedin' ) . hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											jQuery ( '.nodebb-loggedout' ) . show ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
											rightMenu . html ( '' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											var  registerEl  =  document . createElement ( 'li' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												loginEl  =  document . createElement ( 'li' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											registerEl . innerHTML  =  '<a href="/register">Register</a>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											loginEl . innerHTML  =  '<a href="/login">Login</a>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											right _menu . appendChild ( registerEl ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											right _menu . appendChild ( loginEl ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									// Notifications dropdown
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									var  notifContainer  =  document . getElementsByClassName ( 'notifications' ) [ 0 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										notifTrigger  =  notifContainer . querySelector ( 'a' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-07 22:42:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										notifList  =  document . getElementById ( 'notif-list' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										notifIcon  =  document . querySelector ( '.notifications a i' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-07-22 15:45:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									notifTrigger . addEventListener ( 'click' ,  function ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										e . preventDefault ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-07 22:42:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( notifContainer . className . indexOf ( 'open' )  ===  - 1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-26 15:20:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											socket . emit ( 'api:notifications.get' ,  null ,  function ( data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												var 	notifFrag  =  document . createDocumentFragment ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													notifEl  =  document . createElement ( 'li' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													numRead  =  data . read . length , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													numUnread  =  data . unread . length , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												notifList . innerHTML  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( ( data . read . length  +  data . unread . length )  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													for ( x = 0 ; x < numUnread ; x ++ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														notifEl . setAttribute ( 'data-nid' ,  data . unread [ x ] . nid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														notifEl . className  =  'unread' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														notifEl . innerHTML  =  '<a href="'  +  data . unread [ x ] . path  +  '"><span class="pull-right">'  +  utils . relativeTime ( data . unread [ x ] . datetime ,  true )  +  '</span>'  +  data . unread [ x ] . text  +  '</a>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														notifFrag . appendChild ( notifEl . cloneNode ( true ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													for ( x = 0 ; x < numRead ; x ++ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														notifEl . setAttribute ( 'data-nid' ,  data . read [ x ] . nid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														notifEl . className  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														notifEl . innerHTML  =  '<a href="'  +  data . read [ x ] . path  +  '"><span class="pull-right">'  +  utils . relativeTime ( data . read [ x ] . datetime ,  true )  +  '</span>'  +  data . read [ x ] . text  +  '</a>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														notifFrag . appendChild ( notifEl . cloneNode ( true ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													notifEl . innerHTML  =  '<a>You have no notifications</a>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													notifFrag . appendChild ( notifEl ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												notifList . appendChild ( notifFrag ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( data . unread . length  >  0 )  notifIcon . className  =  'icon-circle active' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												else  notifIcon . className  =  'icon-circle-blank' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												socket . emit ( 'api:notifications.mark_all_read' ,  null ,  function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													notifIcon . className  =  'icon-circle-blank' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													utils . refreshTitle ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-07 22:42:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 12:10:23 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									notifList . addEventListener ( 'click' ,  function ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										var  target ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										switch ( e . target . nodeName )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											case  'SPAN' :  target  =  e . target . parentNode . parentNode ;  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											case  'A' :  target  =  e . target . parentNode ;  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											case  'li' :  target  =  e . target ;  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( target )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											var  nid  =  parseInt ( target . getAttribute ( 'data-nid' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( nid  >  0 )  socket . emit ( 'api:notifications.mark_read' ,  nid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-07 22:42:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 12:10:23 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									socket . on ( 'event:new_notification' ,  function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										document . querySelector ( '.notifications a i' ) . className  =  'icon-circle active' ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-21 23:08:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . alert ( { 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-26 16:42:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											alert _id :  'new_notif' , 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-21 23:08:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											title :  'New notification' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											message :  'You have unread notifications.' , 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 05:16:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											type :  'warning' , 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-21 23:08:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											timeout :  2000 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-11 16:41:49 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										utils . refreshTitle ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-05 16:01:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-06-26 21:41:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									socket . on ( 'chatMessage' ,  function ( data )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 05:16:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-06-26 21:41:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										require ( [ 'chat' ] ,  function ( chat )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-28 22:08:46 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  modal  =  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if ( chat . modalExists ( data . fromuid ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												modal  =  chat . getModal ( data . fromuid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												chat . appendChatMessage ( modal ,  data . message ,  data . timestamp ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-31 02:59:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												modal  =  chat . createModal ( data . username ,  data . fromuid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-28 22:08:46 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-27 12:10:23 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-08-28 22:08:46 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											chat . load ( modal . attr ( 'UUID' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-26 21:41:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-26 12:32:30 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-06-05 16:01:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									require ( [ 'mobileMenu' ] ,  function ( mobileMenu )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										mobileMenu . init ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 12:17:44 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} ( ) ) ;