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 / js / dashboard-script.js

dashboard-script.js in WpStream – Live Streaming, Video on Demand, Pay Per View 4.8, at js/dashboard-script.js

308 lines 12.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function (jQuery) {
2 "use strict";
3
4 jQuery('#wpstream-user-channel-selection,#wpstream_edit_category,#wpstream_edit_post_tag,#wpstream_edit_wpstream_actors,#wpstream_edit_wpstream_category,#wpstream_edit_wpstream_movie_rating,#wpstream_edit_product_cat,#wpstream_edit_product_tag').select2({
5 theme: "bootstrap-5",
6 width: jQuery(this).data('width') ? jQuery(this).data('width') : jQuery(this).hasClass('w-100') ? '100%' : 'style',
7 placeholder: jQuery(this).data('placeholder'),
8 closeOnSelect: false,
9 });
10
11
12
13 wpstream_dashboard_user_menu();
14 wpstream_edit_account_function();
15 wpstream_edit_address_function('wpstream_edit_address_save');
16 wpstream_edit_address_function('wpstream_edit_address_save_shipping');
17 wpstream_delete_profile_picture();
18 wpstream_edit_channel_function();
19 });
20
21 /**
22 * wpstream_edit_channel_function
23 */
24
25 function wpstream_edit_channel_function() {
26 jQuery('#wpstream_edit_channel_save').on('click', function () {
27
28 var nonce = jQuery('input[name="wpstream_nonce"]').val();
29 var wpstream_admin_ajax_url = wpstream_dashboard_script_vars.ajaxurl;
30 var thumb_id = jQuery('.wpstream_uploaded_images').attr('data-imageid');
31 var title = jQuery('#channel_name').val();
32 var description = jQuery('#wstream_description').val();
33 var channel_paid = 0;
34 var isChecked = jQuery('input[name="channel_paid"]').is(':checked');
35 if (isChecked) {
36 channel_paid = 1;
37 }
38
39 var channel_price = jQuery('#channel_price').val();
40 var images = jQuery('#attachid').val();
41 var postID = jQuery(this).attr('data-postID');
42
43 var categories = {};
44 // wpstream_edit_channel_taxonomy_wrapper
45
46 jQuery('.wpstream_taxonomies').each(function(){
47 var selected_tax = jQuery(this).attr('data-tax');
48 var selected_val = jQuery(this).val();
49 categories[selected_tax]=selected_val;
50 });
51
52
53
54 jQuery.ajax({
55 type: 'POST',
56 url: wpstream_admin_ajax_url, // WordPress AJAX URL,
57 dataType: 'json',
58 data: {
59 action: 'wpstream_dashboard_save_channel_data',
60 thumb_id: thumb_id,
61 title: title,
62 description: description,
63 channel_paid: channel_paid,
64 channel_price: channel_price,
65 images: images,
66 postID: postID,
67 selected_categories:categories,
68 nonce: nonce
69
70
71 },
72 success: function (response) {
73
74 if (response.success) {
75
76 jQuery('.event_thumb_wrapper').css('background-image', 'url('+response.data.thumburl+')');
77 jQuery('#wpstream_channel_title').empty().text(title);
78 jQuery('#wpstream_channel_description').empty().html(description);
79
80 if(channel_paid == 0){
81 jQuery('.wpstream-dashboard-details_price').hide();
82 }else{
83 jQuery('.wpstream-dashboard-details_price').show();
84 }
85
86 jQuery('#wpstream_channel_price').empty().text(channel_price);
87 jQuery('.wpstream_uploaded_images_wrapper').empty().html(response.data.images);
88 jQuery('.wpstream-theme-dashboard-chanel-gallery__list').empty().html(response.data.images);
89
90 jQuery('.wpstream_taxonomies_wrapper').empty().html(response.data.taxonomies);
91 jQuery('#wpstream_edit_channel_modal').modal('hide');
92
93 // Check if there is a trailer video
94 var trailerVideoWrapper = jQuery('.wpstream-theme-dashboard-channel-video-trailer__video');
95 if ( trailerVideoWrapper.find('#wpstream-video-trailer').length > 0 ) {
96 jQuery('#wpstream-video-trailer video source').attr('src', response.data.video_trailer);
97 jQuery('#wpstream-video-trailer video')[0].load();
98 } else {
99 // If there is no trailer video, create it
100 trailerVideoWrapper.empty();
101 trailerVideoWrapper.append(`<div class="wpstream-video-trailer" id="wpstream-video-trailer">` +
102 `<video height="240" controls><source src="${response.data.video_trailer}" type="video/mp4"></video></div>`);
103 }
104 // Check if there is a preview video
105 var previewVideoWrapper = jQuery('.wpstream-theme-dashboard-channel-video-preview__video');
106 if ( previewVideoWrapper.find('#wpstream-video-preview').length > 0 ) {
107 jQuery('#wpstream-video-preview video source').attr('src', response.data.video_preview);
108 jQuery('#wpstream-video-preview video')[0].load();
109 } else {
110 // If there is no preview video, create it
111 previewVideoWrapper.empty();
112 previewVideoWrapper.append(`<div class="wpstream-video-preview" id="wpstream-video-preview">` +
113 `<video height="240" controls><source src="${response.data.video_preview}" type="video/mp4"></video></div>`);
114 }
115 } else {
116 console.log('Error');
117 }
118
119
120 },
121 error: function (err) {
122 console.log(err);
123 // Handle AJAX error
124 alert('AJAX request failed.');
125 }
126 });
127 });
128 }
129
130 /**
131 * wpstream_dashboard_user_menu
132 */
133 var popover;
134 function wpstream_dashboard_user_menu() {
135 var profileImage = document.getElementById('dashboard-header_profile-image');
136 if(typeof popover !== 'undefined' ){
137 popover.dispose();
138 }
139 popover = new bootstrap.Popover(profileImage, {
140 placement: 'bottom',
141 });
142 }
143
144 /**
145 * edit address profile
146 */
147 function wpstream_edit_address_function(button_id) {
148 jQuery('#' + button_id).on('click', function () {
149 var nonce = jQuery('input[name="wpstream_nonce"]').val();
150 var wpstream_admin_ajax_url = wpstream_dashboard_script_vars.ajaxurl;
151
152 // Get the values from the form fields
153 var modalBody = jQuery(this).closest('.modal-content');
154 var inputData = [];
155
156 // Find all input elements in the modal body.
157 //var inputs = jQuery('.modal-body input,.modal-body select');
158 var inputs = modalBody.find('input, select');
159
160 // Loop through each input element and add its ID and value to the array.
161 inputs.each(function () {
162 var element = jQuery(this);
163 var inputId = element.attr('id');
164 var inputValue = element.val();
165 inputData.push({id: inputId, value: inputValue});
166 });
167
168 jQuery.ajax({
169 type: 'POST',
170 url: wpstream_admin_ajax_url, // WordPress AJAX URL,
171 dataType: 'json',
172 data: {
173 action: 'wpstream_dashboard_save_user_address',
174 nonce: nonce,
175 inputData: inputData,
176 type: 'billing'
177 },
178 success: function (response) {
179
180 if (response.success) {
181 jQuery('#wpstream_edit_addr_modal').modal('hide');
182 jQuery('#wpstream_edit_addr_modal_shipping').modal('hide');
183 for (var i = 0; i < inputData.length; i++) {
184 var inputId = inputData[i].id;
185 var inputValue = inputData[i].value;
186 // Set the value of the input element based on its ID.
187 jQuery('#wpstream_display_' + inputId).empty().text(inputValue);
188 }
189 } else {
190
191 }
192 },
193 error: function () {
194 // Handle AJAX error
195 alert('AJAX request failed.');
196 }
197 });
198 }
199 )
200 }
201
202 /**
203 * delete profile
204 */
205 function wpstream_delete_profile_picture() {
206 jQuery('#wpstream_remove_profile').on('click', function () {
207 var imageId = jQuery('#wpstream_remove_profile').attr('data-image-id');
208 var ajaxurl = wpstream_dashboard_script_vars.ajaxurl;
209 var nonce = jQuery('#wpstream_profile_image_upload').val();
210
211 jQuery.ajax({
212 type: 'POST',
213 url: ajaxurl,
214 dataType: 'json',
215 data: {
216 action: 'wpstream_delete_profile_attachment',
217 image_id: imageId,
218 security: nonce,
219 },
220 success: function (response) {
221 if (response.success) {
222 jQuery('#wpstream_remove_profile').attr('data-image-id', '');
223 jQuery('#profile-image,#dashboard-header_profile-image').attr('src', response.data.default);
224 }
225 }
226 });
227 });
228 }
229
230 /**
231 * edit account
232 */
233 function wpstream_edit_account_function() {
234 jQuery('#wpstream_edit_account_save').on('click', function () {
235 // Get the values from the form fields
236 var firstName = jQuery('#account_first_name').val();
237 var lastName = jQuery('#account_last_name').val();
238 var displayName = jQuery('#account_display_name').val();
239 var email = jQuery('#account_email').val();
240 var aboutMe = jQuery('#account_about_me').val();
241 var currentPassword = jQuery('#password_current').val();
242 var newPassword1 = jQuery('#password_1').val();
243 var newPassword2 = jQuery('#password_2').val();
244 var message_password = jQuery('.wpstream_passoword_change_notification');
245 var message_account = jQuery('.wpstream_account_change_notification');
246 var nonce = jQuery('input[name="wpstream_nonce"]').val();
247 var wpstream_admin_ajax_url = wpstream_dashboard_script_vars.ajaxurl;
248
249
250 // Check if the passwords meet the conditions
251 if (newPassword1 !== '' && newPassword2 !== '') {
252 if (currentPassword === '') {
253 message_password.empty().text(wpstream_dashboard_script_vars.currentPassEmpty)
254 return
255 } else if (newPassword1 != newPassword2) {
256 message_password.empty().text(wpstream_dashboard_script_vars.passNoMatch)
257 return
258 }
259 }
260
261 // Make an AJAX request to save the user's data
262 jQuery.ajax({
263 type: 'POST',
264 url: wpstream_admin_ajax_url, // WordPress AJAX URL,
265 dataType: 'json',
266 data: {
267 action: 'wpstream_dashboard_save_user_data',
268 nonce: nonce,
269 firstName: firstName,
270 lastName: lastName,
271 displayName: displayName,
272 email: email,
273 newPassword1: newPassword1,
274 newPassword2: newPassword2,
275 currentPassword: currentPassword,
276 aboutMe
277 },
278 success: function (response) {
279
280 if (response.success) {
281 message_password.empty().text(response.message);
282 jQuery('#wpstream_first_name_value').empty().text(firstName);
283 jQuery('#wpstream_last_name_value').empty().text(lastName);
284 jQuery('#wpstream_display_name_value').empty().text(displayName);
285 jQuery('#wpstream_email_value').empty().text(email);
286 jQuery('#wpstream_about_me_value').empty().text(aboutMe);
287 jQuery('#wpstream_edit_account_modal').modal('hide');
288
289 jQuery('.dashboard-header_profile-username').text(firstName+' '+lastName);
290
291 if (response.data.passwordchanged) {
292 location.reload();
293 }
294 } else {
295 if (response.data.failpass) {
296 message_password.empty().text(response.data.failpass)
297 } else if (response.data.failaccount) {
298 message_account.empty().text(response.data.failaccount)
299 }
300 }
301 },
302 error: function () {
303 // Handle AJAX error
304 alert('AJAX request failed.');
305 }
306 });
307 });
308 }