2013-06-12 17:07:58 +00:00
( function ( ) {
2013-06-15 21:45:07 +00:00
$ ( "#channelsettingswrap div.span12" ) . each ( function ( ) {
2013-06-12 17:07:58 +00:00
$ ( this ) . hide ( ) ;
} ) ;
function clickHandler ( selector , div ) {
$ ( selector ) . click ( function ( ) {
2013-06-15 21:45:07 +00:00
$ ( "#csdropdown_title" ) . text ( $ ( selector ) . text ( ) ) ;
$ ( "#channelsettingswrap div.span12" ) . each ( function ( ) {
2013-06-12 17:07:58 +00:00
$ ( this ) . hide ( ) ;
} ) ;
$ ( div ) . show ( ) ;
} ) ;
}
2013-06-18 20:18:41 +00:00
$ ( "#hide_settings" ) . click ( function ( ) {
$ ( "#csdropdown_title" ) . text ( "Moderation Menu" ) ;
$ ( "#channelsettingswrap div.span12" ) . each ( function ( ) {
$ ( this ) . hide ( ) ;
} ) ;
} ) ;
2013-06-12 17:07:58 +00:00
clickHandler ( "#show_optedit" , "#optedit" ) ;
clickHandler ( "#show_permedit" , "#permedit" ) ;
clickHandler ( "#show_motdedit" , "#motdedit" ) ;
2013-06-15 21:45:07 +00:00
clickHandler ( "#show_filteredit" , "#filteredit" ) ;
2013-06-18 14:57:53 +00:00
$ ( "#show_filteredit" ) . click ( function ( ) {
socket . emit ( "requestChatFilters" ) ;
} ) ;
2013-06-15 21:45:07 +00:00
clickHandler ( "#show_cssedit" , "#cssedit" ) ;
clickHandler ( "#show_jsedit" , "#jsedit" ) ;
2013-06-18 03:57:29 +00:00
clickHandler ( "#show_banlist" , "#banlist" ) ;
2013-06-18 04:26:44 +00:00
$ ( "#show_banlist" ) . click ( function ( ) {
socket . emit ( "requestBanlist" ) ;
} ) ;
2013-06-18 03:57:29 +00:00
clickHandler ( "#show_loginhistory" , "#loginhistory" ) ;
$ ( "#show_loginhistory" ) . click ( function ( ) {
socket . emit ( "requestLoginHistory" ) ;
} ) ;
2013-06-18 14:46:28 +00:00
clickHandler ( "#show_channelranks" , "#channelranks" ) ;
$ ( "#show_channelranks" ) . click ( function ( ) {
socket . emit ( "requestChannelRanks" ) ;
} ) ;
2013-06-17 22:16:59 +00:00
genPermissionsEditor ( ) ;
$ ( "#chanopts_submit" ) . click ( function ( ) {
socket . emit ( "setOptions" , {
allow _voteskip : $ ( "#opt_allow_voteskip" ) . prop ( "checked" ) ,
voteskip _ratio : parseFloat ( $ ( "#opt_voteskip_ratio" ) . val ( ) ) ,
pagetitle : $ ( "#opt_pagetitle" ) . val ( ) || CHANNEL . name ,
externalcss : $ ( "#opt_externalcss" ) . val ( ) ,
externaljs : $ ( "#opt_externaljs" ) . val ( ) ,
chat _antiflood : $ ( "#opt_chat_antiflood" ) . prop ( "checked" ) ,
show _public : $ ( "#opt_show_public" ) . prop ( "checked" ) ,
enable _link _regex : $ ( "#opt_enable_link_regex" ) . prop ( "checked" )
} ) ;
} ) ;
2013-06-20 18:54:15 +00:00
$ ( "#chanopts_unregister" ) . click ( function ( ) {
var res = confirm ( "You are about to unregister your channel. This will PERMANENTLY delete your channel data, including ranks, bans, and library videos. This cannot be undone. Are you sure you want to continue?" ) ;
if ( res ) {
socket . emit ( "unregisterChannel" ) ;
}
} ) ;
2013-06-17 22:16:59 +00:00
$ ( "#save_motd" ) . click ( function ( ) {
socket . emit ( "setMotd" , {
motd : $ ( "#motdtext" ) . val ( )
} ) ;
} ) ;
$ ( "#csstext" ) . keydown ( function ( ev ) {
if ( ev . keyCode == 9 ) {
$ ( "#csstext" ) . text ( $ ( "#csstext" ) . val ( ) + " " ) ;
ev . preventDefault ( ) ;
return false ;
}
} ) ;
$ ( "#save_css" ) . click ( function ( ) {
socket . emit ( "setChannelCSS" , {
css : $ ( "#csstext" ) . val ( )
} ) ;
} ) ;
$ ( "#jstext" ) . keydown ( function ( ev ) {
if ( ev . keyCode == 9 ) {
$ ( "#jstext" ) . text ( $ ( "#jstext" ) . val ( ) + " " ) ;
ev . preventDefault ( ) ;
return false ;
}
} ) ;
$ ( "#save_js" ) . click ( function ( ) {
socket . emit ( "setChannelJS" , {
js : $ ( "#jstext" ) . val ( )
} ) ;
} ) ;
2013-06-18 19:59:45 +00:00
$ ( "#newfilter_submit" ) . click ( function ( ) {
var re = $ ( "#newfilter_regex" ) . val ( ) ;
var flags = $ ( "#newfilter_flags" ) . val ( ) ;
try {
new RegExp ( re , flags ) ;
}
catch ( e ) {
makeAlert ( "Invalid Regex" , e , "alert-error" )
. insertAfter ( $ ( "#filteredit form" ) ) ;
return ;
}
socket . emit ( "updateFilter" , {
name : $ ( "#newfilter_name" ) . val ( ) ,
source : re ,
flags : flags ,
replace : $ ( "#newfilter_replace" ) . val ( ) ,
filterlinks : $ ( "#newfilter_filterlinks" ) . prop ( "checked" ) ,
active : true
} ) ;
$ ( "#newfilter_name" ) . val ( "" ) ;
$ ( "#newfilter_regex" ) . val ( "" ) ;
$ ( "#newfilter_flags" ) . val ( "" ) ;
$ ( "#newfilter_replace" ) . val ( "" ) ;
} ) ;
2013-06-12 17:07:58 +00:00
} ) ( ) ;