PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.8
WpStream – Live Streaming, Video on Demand, Pay Per View v4.8
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / admin / js / wpstream_settings.js

wpstream_settings.js in WpStream – Live Streaming, Video on Demand, Pay Per View 4.8, at admin/js/wpstream_settings.js

227 lines 8.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var debounceTimer;
2
3 jQuery(document).ready(function($) {
4 // Save default channel options
5 wpstream_save_default_channel_options();
6
7 // Save settings
8 wpstream_save_settings();
9
10 wpstream_update_plugin_support_tab();
11
12 // wpstream_broadcaster_bind();
13 });
14
15 /**
16 * Save the changes to the Default Channel Settings tab
17 */
18 function wpstream_save_default_channel_options() {
19 jQuery('.theme_options_tab_wpstream .wpstream_event_option_item').on('click',function() {
20
21 wpstream_adjust_settings_general(jQuery(this));
22
23 var optionarray ={};
24 var holder = jQuery(this).parents('.wpstream_option_wrapper');
25 var nonce = jQuery('#wpstream-settings-nonce').val();
26
27 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','visible');
28 var timer = setTimeout(function() {
29 holder.find('.wpstream_event_option_item').each(function(){
30 optionarray[jQuery(this).attr('data-attr-ajaxname')]=jQuery(this).prop("checked") ? 1 : 0 ;
31 });
32
33 var jsonOptions = JSON.stringify(optionarray);
34 jQuery.ajax({
35 type: 'POST',
36 url: ajaxurl,
37 timeout: 300000,
38 data: {
39 'action' : 'wpstream_update_default_channel_settings',
40 'option' : optionarray,
41 'security' : nonce
42 },
43 success: function (data) {
44 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','hidden');
45 console.log(data);
46 },
47 error: function (jqXHR,textStatus,errorThrown) {
48 wpstream_show_error_message(jQuery('.theme_options_tab_wpstream .wpstream-save-settings'));
49 }
50 })
51 }, 300);
52 });
53 }
54
55 /**
56 * Adjust the settings for WpStream Settings
57 */
58 function wpstream_save_settings() {
59 var nonce = jQuery('#wpstream-settings-nonce').val();
60 jQuery('.wpstream_option_wrapper .wpstream_event_option_itemc').on('change',function(e){
61 // Get the new value (1 if checked, 0 if unchecked)
62 var checkedState = e.target.checked ? 1 : 0;
63
64 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','visible');
65 jQuery.ajax({
66 type: 'POST',
67 url: ajaxurl,
68 timeout: 300000,
69 data: {
70 'action' : 'wpstream_update_settings',
71 'option_name' : jQuery(this).attr('name'),
72 'option_type' : jQuery(this).attr('type'),
73 'option_value' : checkedState,
74 'security' : nonce
75 },
76 success: function (data) {
77 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','hidden');
78 },
79 error: function (jqXHR,textStatus,errorThrown) {
80 wpstream_show_error_message(jQuery('.theme_options_tab_wpstream .wpstream-save-settings'));
81 }
82 })
83 })
84
85 jQuery('.wpstream_option_wrapper .wpstream-text-input-setting').on('input',function(e){
86 var option_name = jQuery(this).attr('id');
87 var option_value = jQuery(this).val();
88 var option_type = jQuery(this).attr('type');
89
90 clearTimeout(debounceTimer);
91 debounceTimer = setTimeout( function() {
92 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','visible');
93 jQuery.ajax({
94 type: 'POST',
95 url: ajaxurl,
96 timeout: 300000,
97 data: {
98 'action' : 'wpstream_update_settings',
99 'option_name' : option_name,
100 'option_type' : option_type,
101 'option_value' : option_value,
102 'security' : nonce
103 },
104 success: function (data) {
105 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','hidden');
106 },
107 error: function (jqXHR,textStatus,errorThrown) {
108 wpstream_show_error_message(jQuery('.theme_options_tab_wpstream .wpstream-save-settings'));
109 }
110 })
111 }, 1000); // Wait for 3 seconds after the user stops typing
112 });
113
114 jQuery('.wpstream_option_wrapper select').on('change',function(e){
115 var option_name = jQuery(this).siblings('label').attr('for');
116 var option_value = jQuery(this).val();
117 var option_type = jQuery(this).prop('multiple') ? 'multiple-select' : 'select';
118
119 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','visible');
120 jQuery.ajax({
121 type: 'POST',
122 url: ajaxurl,
123 timeout: 300000,
124 data: {
125 'action' : 'wpstream_update_settings',
126 'option_name' : option_name,
127 'option_type' : option_type,
128 'option_value' : option_value,
129 'security' : nonce
130 },
131 success: function (data) {
132 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','hidden');
133 },
134 error: function (jqXHR,textStatus,errorThrown) {
135 wpstream_show_error_message(jQuery('.theme_options_tab_wpstream .wpstream-save-settings'));
136 }
137 })
138 })
139
140 jQuery('.wpstream_option_wrapper .wpstream-range-input').on('change',function(e){
141 var option_name = jQuery(this).attr('id');
142 var option_value = jQuery(this).val();
143 var option_type = jQuery(this).attr('type');
144
145 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','visible');
146 jQuery.ajax({
147 type: 'POST',
148 url: ajaxurl,
149 timeout: 300000,
150 data: {
151 'action' : 'wpstream_update_settings',
152 'option_name' : option_name,
153 'option_type' : option_type,
154 'option_value' : option_value,
155 'security' : nonce
156 },
157 success: function (data) {
158 jQuery('.theme_options_tab_wpstream .wpstream-save-settings').find('.spinner').css('visibility','hidden');
159 },
160 error: function (jqXHR,textStatus,errorThrown) {
161 wpstream_show_error_message(jQuery('.theme_options_tab_wpstream .wpstream-save-settings'));
162 }
163 })
164 })
165 }
166
167 /*
168 *
169 * Show error message when the settings are not saved
170 *
171 */
172 function wpstream_show_error_message(container) {
173 container.find('.spinner').css('visibility', 'hidden');
174 container.append('<div class="wpstream-error-message">' + wpstream_settings_vars.error_message + '</div>');
175 container.find('.wpstream-error-message').hide().fadeIn(400).delay(3000).fadeOut(400, function() {
176 jQuery(this).remove();
177 });
178 }
179
180 function wpstream_update_plugin_support_tab() {
181 var nonce = jQuery('#wpstream-settings-nonce').val();
182 jQuery('.wpstream-update-plugin-button').on('click', function(e) {
183 e.preventDefault();
184 jQuery(this).parents('.update-button-wrapper').html('Updating... <span class="spinner" style="visibility: visible;"></span>');
185 jQuery.ajax({
186 type: 'POST',
187 url: ajaxurl,
188 timeout: 300000,
189 data: {
190 'action' : 'wpstream_settings_tab_update_plugin',
191 'security' : nonce
192 },
193 success: function (data) {
194 if (data.success) {
195 jQuery('.update-button-wrapper').html(wpstream_settings_vars.update_successful);
196 } else {
197 jQuery('.update-button-wrapper').html(wpstream_settings_vars.update_failed);
198 }
199 },
200 error: function (jqXHR,textStatus,errorThrown) {
201 jQuery('.update-button-wrapper').html(wpstream_settings_vars.update_failed);
202 }
203 })
204 });
205 }
206
207 function wpstream_broadcaster_bind() {
208 jQuery('.start_webcaster').on('click', function(e) {
209 if (jQuery(this).hasClass('wpstream_inactive_icon')) {
210 return;
211 }
212 e.preventDefault();
213 e.stopPropagation();
214
215 // Get the channel ID from the data attribute
216 var channelId = jQuery(this).closest('.event_list_unit').data('show-id');
217
218 if (!channelId) {
219 return;
220 }
221
222 // Open the broadcaster in a new window
223 var broadcasterUrl = wpstream_settings_vars.broadcaster_url + channelId;
224 window.open(broadcasterUrl, 'wpstream_broadcaster_' + channelId, 'fullscreen=yes');
225 });
226
227 }