1+ /*
2+ First-Coder Teamspeak 3 Webinterface for everyone
3+ Copyright (C) 2017 by L.Gmann
4+
5+ This program is free software: you can redistribute it and/or modify
6+ it under the terms of the GNU General Public License as published by
7+ the Free Software Foundation, either version 3 of the License, or
8+ any later version.
9+
10+ This program is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ GNU General Public License for more details.
14+
15+ You should have received a copy of the GNU General Public License
16+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+ for help look http://first-coder.de/
19+ */
20+
21+ /*
22+ Querybot: Save Botsettings
23+ */
24+ function saveBotSettings ( tablename )
25+ {
26+ switch ( tablename )
27+ {
28+ case "bot_settigns_afk" :
29+ var postData = {
30+ isAfkMoving : ( $ ( '#setAfkModul' ) . is ( ':checked' ) ) ? "1" : "0" ,
31+ isMovingMicMuted : ( $ ( '#setAfkMicMuted' ) . is ( ':checked' ) ) ? "1" : "0" ,
32+ isMovingHeadsetMuted : ( $ ( '#setAfkHeadsetMuted' ) . is ( ':checked' ) ) ? "1" : "0" ,
33+ isMovingAway : ( $ ( '#setAfkAway' ) . is ( ':checked' ) ) ? "1" : "0" ,
34+ AfkMovingChannel : $ ( '#afkChannel' ) . val ( ) ,
35+ isMovingIdleTime : $ ( '#setAfkIdleTime' ) . val ( ) ,
36+ isMovingIdleWarningMessage : ( $ ( '#setAfkIdleWarningMessage' ) . is ( ':checked' ) ) ? "1" : "0" ,
37+ MovingIdleWarningMessage : $ ( '#setAfkIdleMessage' ) . val ( ) ,
38+ afkMoveingImmunSgroups : JSON . stringify ( $ ( '#setAfkImmunSgroups' ) . tagsinput ( 'items' ) )
39+ } ;
40+ break ;
41+ } ;
42+
43+ $ . ajax ( {
44+ type : "POST" ,
45+ url : "./php/functions/functionsBotPost.php" ,
46+ data : {
47+ action : 'saveBotSettings' ,
48+ botid : botid ,
49+ table : tablename ,
50+ data : JSON . stringify ( postData )
51+ } ,
52+ success : function ( data ) {
53+ /*if(data == "done" && which == "language")
54+ {
55+ setNotifySuccess("Language set! Reload the page to see your site in the new language!");
56+ }
57+ else if(data == 'done')
58+ {
59+ setNotifySuccess(lang.settigns_saved);
60+ }
61+ else
62+ {
63+ setNotifyFailed("Ups, something Failed :/");
64+ };*/
65+ console . log ( data ) ;
66+ }
67+ } ) ;
68+ } ;
69+
70+ /*
71+ Querybot: Show Botdetails
72+ */
73+ function showQueryBot ( id , instanz , port )
74+ {
75+ $ ( "#mainContent" ) . fadeOut ( "fast" , function ( )
76+ {
77+ $ ( "#mainContent" ) . load ( './php/bot/web_bot_query_info.php' , { "id" : id , "instanz" : instanz , "port" : port } , function ( )
78+ {
79+ $ ( "#mainContent" ) . fadeIn ( "fast" ) ;
80+ } ) ;
81+ } ) ;
82+ } ;
83+
84+ /*
85+ Querybot: Create Querybot
86+ */
87+ function createQueryBot ( )
88+ {
89+ $ . ajax ( {
90+ type : "POST" ,
91+ url : "./php/functions/functionsBotPost.php" ,
92+ data : {
93+ action : 'createQueryBot' ,
94+ instanz : $ ( '#selectCreateQueryBotInstance' ) . val ( ) ,
95+ port : $ ( '#selectCreateQueryBotPort' ) . val ( ) ,
96+ name : encodeURIComponent ( $ ( '#createQueryBotName' ) . val ( ) )
97+ } ,
98+ success : function ( data ) {
99+ console . log ( data ) ;
100+ }
101+ } ) ;
102+ } ;
103+
104+ /*
105+ Querybot: Delete Querybot
106+ */
107+ function deleteQueryBot ( id )
108+ {
109+ $ . ajax ( {
110+ type : "POST" ,
111+ url : "./php/functions/functionsBotPost.php" ,
112+ data : {
113+ action : 'deleteQueryBot' ,
114+ id : id
115+ } ,
116+ success : function ( data ) {
117+ console . log ( data ) ;
118+ }
119+ } ) ;
120+ } ;
121+
122+ /*
123+ Querybot: Change Selectmenu on Querybot Create
124+ */
125+ function addQueryBotChangePort ( )
126+ {
127+ var instanz = $ ( '#selectCreateQueryBotInstance' ) . val ( ) ;
128+
129+ if ( instanz != 'nope' )
130+ {
131+ $ . ajax ( {
132+ type : "POST" ,
133+ url : "./php/functions/functionsTeamspeakPost.php" ,
134+ data : {
135+ action : 'getTeamspeakPorts' ,
136+ instanz : instanz
137+ } ,
138+ success : function ( data ) {
139+ var element = document . getElementById ( 'selectCreateQueryBotPort' ) ;
140+
141+ while ( element . childNodes . length >= 1 )
142+ {
143+ element . removeChild ( element . firstChild ) ;
144+ } ;
145+
146+ if ( data != "[]" )
147+ {
148+ var ports = JSON . parse ( data ) ;
149+ for ( i = 0 ; i < ports . length ; i ++ )
150+ {
151+ port = document . createElement ( 'option' ) ;
152+ port . value = ports [ i ] ;
153+ port . text = ports [ i ] ;
154+ element . appendChild ( port ) ;
155+ } ;
156+
157+ $ ( '#bttnCreateQueryBot' ) . prop ( "disabled" , false ) ;
158+ }
159+ else
160+ {
161+ nope = document . createElement ( 'option' ) ;
162+ nope . value = 'nope' ;
163+ nope . text = unescape ( lang . ts3_no_copy ) ;
164+ element . appendChild ( nope ) ;
165+
166+ $ ( '#bttnCreateQueryBot' ) . prop ( "disabled" , true ) ;
167+ } ;
168+ }
169+ } ) ;
170+ }
171+ else
172+ {
173+ var element = document . getElementById ( 'selectCreateQueryBotSid' ) ;
174+
175+ while ( element . childNodes . length >= 1 )
176+ {
177+ element . removeChild ( element . firstChild ) ;
178+ } ;
179+
180+ nope = document . createElement ( 'option' ) ;
181+ nope . value = 'nope' ;
182+ nope . text = unescape ( lang . ts3_no_copy ) ;
183+ element . appendChild ( nope ) ;
184+ } ;
185+ } ;
0 commit comments