PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.5.11.6
WpStream – Live Streaming, Video on Demand, Pay Per View v4.5.11.6
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 / admin_control.js

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

536 lines 16.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*global $, jQuery, */
2 var counters={};
3
4 jQuery(document).ready(function ($) {
5 "use strict";
6
7
8 generate_download_link();
9 generate_delete_link();
10 wpstream_handle_video_selection();
11 wpstream_upload_images_in_wpadmin();
12
13
14 function social_media_toggle(social_class){
15
16 jQuery('.'+social_class).on('change',function(){
17
18 if( $(this).prop('checked') ){
19 jQuery($(this).parent().parent().find( '.'+social_class+'_container' )).slideDown('100');
20 }else{
21 jQuery($(this).parent().parent().find( '.'+social_class+'_container' )).slideUp('100');
22 }
23
24 });
25 }
26
27
28
29 jQuery('.wpstream_notices .notice-dismiss').on('click',function(){
30
31 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
32 var notice_type = $(this).parent().attr('data-notice-type');
33 var nonce = $('#wpstream_notice_nonce').val();
34
35
36 jQuery.ajax({
37 type: 'POST',
38 url: ajaxurl,
39 data: {
40 'action' : 'wpstream_update_cache_notice',
41 'notice_type' : notice_type,
42 'security' : nonce
43 },
44 success: function (data) {
45
46
47 },
48 error: function (errorThrown) {
49
50 }
51 });
52 });
53
54
55
56
57 function generate_delete_link(){
58 $('.wpstream_delete_media').on('click',function(){
59
60
61 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
62 var video_name = $(this).attr('data-filename').trim();
63 var acesta = $(this);
64 var parent = $(this).parent();
65
66
67 jQuery.ajax({
68 type: 'POST',
69 url: ajaxurl,
70 dataType: 'json',
71 data: {
72 'action' : 'wpstream_get_delete_file',
73 'video_name' : video_name
74
75 },
76 success: function (data) {
77
78 if(data.success===true){
79 parent.remove();
80 }
81
82
83 },
84 error: function (errorThrown) {
85 }
86 });
87 });
88
89
90 }
91
92 function generate_download_link(){
93
94 $('.wpstream_get_download_link').on('click',function(){
95 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
96 var video_name = $(this).attr('data-filename');
97 var acesta = $(this);
98 var parent = $(this).parent();
99
100 jQuery(this).remove();
101 parent.find('.wpstream_download_link').show().text('please wait...');
102
103
104
105 jQuery.ajax({
106 type: 'POST',
107 url: ajaxurl,
108 dataType: 'json',
109 data: {
110 'action' : 'wpstream_get_download_link',
111 'video_name' : video_name,
112
113 },
114 success: function (data) {
115
116
117
118 if(data.success===true){
119 parent.find('.wpstream_download_link').show().text(wpstream_admin_control_vars.download_mess);
120 parent.find('.wpstream_download_link').show().attr('href',data.url);
121 }else{
122 var error_message=data.error;
123
124 if(data.error==='NOT_ENOUGH_TRAFFIC'){
125 error_message = 'Not Enough data to download!';
126
127 }
128
129 parent.find('.wpstream_download_link').show().text(error_message);
130 }
131
132
133
134 },
135 error: function (errorThrown) {
136 }
137 });
138 });
139
140 }
141
142
143
144
145
146 $( '.inputfile' ).each( function(){
147 var $input = $( this ),
148 $label = $input.next( 'label' ),
149 labelVal = $label.html();
150
151 $input.on( 'change', function( e )
152 {
153 var fileName = '';
154
155 if( this.files && this.files.length > 1 )
156 fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length );
157 else if( e.target.value )
158 fileName = e.target.value.split( '\\' ).pop();
159
160 if( fileName )
161 $label.find( 'span' ).html( fileName );
162 else
163 $label.html( labelVal );
164 });
165
166 // Firefox bug fix
167 $input
168 .on( 'focus', function(){ $input.addClass( 'has-focus' ); })
169 .on( 'blur', function(){ $input.removeClass( 'has-focus' ); });
170 });
171
172
173
174 /*
175 *
176 * File Upload
177 *
178 */
179
180
181 var form = $('.direct-upload');
182 var filesUploaded = [];
183 var folders = [];
184
185 // var new_file_name='';
186
187 form.fileupload({
188
189 url: form.attr('action'),
190 type: form.attr('method'),
191
192 datatype: 'xml',
193 add: function (event, data) {
194
195
196 if( data.files[0].type!=='video/mp4' && data.files[0].type!=='video/quicktime'){
197 jQuery('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.not_accepted);
198 return;
199 }
200
201
202
203 var file_size = (parseInt(data.files[0].size,10))/1000000;
204 var user_storage = jQuery('#wpstream_storage').val();
205 var user_band = jQuery('#wpstream_band').val();
206
207
208
209 if(file_size > user_storage || file_size>user_band){
210 jQuery('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.no_band_no_store);
211 return;
212 }
213
214
215 $('#wpstream_label_action').text(wpstream_admin_control_vars.uploading)
216
217 jQuery('#wpstream_uploaded_mes').empty().html();
218 // Show warning message if your leaving the page during an upload.
219 window.onbeforeunload = function () {
220 return 'You have unsaved changes.';
221 };
222
223 var file = data.files[0];
224
225
226 form.find('input[name="Content-Type"]').val(file.type);
227 form.find('input[name="Content-Length"]').val(file.size);
228
229 // Actually submit to form to S3.
230 data.submit();
231
232 // Show the progress bar
233 // Uses the file size as a unique identifier
234 var bar = $('<div class="progress" data-mod="'+file.size+'"><div class="bar"></div></div>');
235 $('.progress-bar-area').append(bar);
236 bar.slideDown('fast');
237 },
238 progress: function (e, data) {
239 // This is what makes everything really cool, thanks to that callback
240 // you can now update the progress bar based on the upload progress.
241 var percent = Math.round((data.loaded / data.total) * 100);
242 $('.progress[data-mod="'+data.files[0].size+'"] .bar').css('width', percent + '%').html(percent+'%');
243 },
244
245 fail: function (e, data) {
246
247 // Remove the 'unsaved changes' message.
248 window.onbeforeunload = null;
249 $('.progress[data-mod="'+data.files[0].size+'"] .bar').css('width', '100%').addClass('red').html('');
250 $('.bar').remove();
251 $('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.upload_failed);
252 $('#wpstream_label_action').empty().html(wpstream_admin_control_vars.upload_failed2);
253 },
254
255 error: function (e, data) {
256
257 // Remove the 'unsaved changes' message.
258 window.onbeforeunload = null;
259 $('.progress[data-mod="'+data.files[0].size+'"] .bar').css('width', '100%').addClass('red').html('');
260 $('.bar').remove();
261 $('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.upload_failed);
262 $('#wpstream_label_action').empty().html(wpstream_admin_control_vars.upload_failed2);
263 },
264 done: function (event, data) {
265
266 window.onbeforeunload = null;
267 $('.bar').remove();
268 $('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.upload_complete);
269 $('#wpstream_label_action').text(wpstream_admin_control_vars.upload_complete2);
270
271 var new_file_name=data.files[0].name;
272
273
274 var new_file_name_array = data.files[0].name.split(".");
275 var temp_file_name = new_file_name_array[0].split(' ').join('_');
276 temp_file_name = temp_file_name.replace(/\W/g, '');
277 new_file_name = temp_file_name+'.'+new_file_name_array[new_file_name_array.length-1];
278
279
280
281
282 var onclick_string=' Are you sure you wish to delete '+new_file_name+' ? ';
283
284 var to_insert='<div class="wpstream_video_wrapper"><div class="wpstream_video_title"><div class="wpstream_video_notice"></div></div><div class="wpstream_video_title">';
285 to_insert=to_insert+'<strong class="storage_file_name">File Name :</strong><span class="storage_file_name_real">'+new_file_name+' </span></div>';
286 to_insert=to_insert+'<div class="wpstream_delete_media" ';
287 to_insert=to_insert+' onclick=" return confirm('+onclick_string+') "';
288 to_insert=to_insert+' data-filename="'+new_file_name+'" >delete file</div>';
289 to_insert=to_insert+'<div class="wpstream_get_download_link" data-filename="'+new_file_name+'">download</div> ';
290 to_insert=to_insert+'<a href="" class="wpstream_download_link">Click to download! The url will work for the next 20 minutes!</a></div>';
291
292 $('#video_management_title').after(to_insert);
293
294
295
296 $('.wpstream_get_download_link').unbind('click');
297 $('.wpstream_delete_media').unbind('click');
298
299 generate_download_link();
300 generate_delete_link();
301
302 setTimeout(function(){ window.location.href = window.location.href; }, 1000);
303
304
305 }
306 });
307
308
309
310
311
312
313
314
315 jQuery('#product-type').on('change',function(){
316
317 var product_type= jQuery('#product-type').val();
318 if(product_type==='live_stream' || product_type==='video_on_demand' || product_type==='wpstream_bundle' ){
319 jQuery('._sold_individually_field').show();
320 }
321
322 });
323
324 if(wpstream_findGetParameter('new_video_name')!=='' && wpstream_findGetParameter('new_video_name')!=null ){
325 jQuery('#product-type').val('video_on_demand').trigger('change');
326 }
327
328 if(wpstream_findGetParameter('new_stream')!=='' && wpstream_findGetParameter('new_stream')!=null ){
329 jQuery('#product-type').val('live_stream').trigger('change');
330 }
331
332 var product_type= jQuery('#product-type').val();
333 console.log('xxx '+product_type);
334 if ( product_type === 'video_on_demand' ) {
335 jQuery('.show_if_video_on_demand' ).show();
336 }else if ( product_type === 'live_stream' ) {
337 jQuery( '.show_if_live_stream' ).show();
338 } else if ( product_type === 'wpstream_bundle' ) {
339 jQuery( '.show_if_wpstream_bundle' ).show();
340 console.log ('we do click');
341 var element= jQuery('.general_tab');
342 console.log(element);
343 jQuery('.general_tab').trigger('click');
344 $('a[href="#general_product_data"]').click();
345 $('.product_data_tabs .tab.general_tab').click();
346 }
347
348
349
350
351
352 function wpstream_findGetParameter(parameterName) {
353 var result = null,
354 tmp = [];
355 location.search
356 .substr(1)
357 .split("&")
358 .forEach(function (item) {
359 tmp = item.split("=");
360 if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
361 });
362 return result;
363 }
364
365
366 jQuery('#_subscript_live_event').change(function(){
367 //alert('move it'+product_type);
368 if ( product_type === 'video_on_demand' || product_type === 'live_stream' || product_type === 'wpstream_bundle' ) {
369
370 }else{
371 var value= jQuery(this).val();
372 if(value==="no"){
373 jQuery("._movie_url_field").parent().removeClass("hide_if_subscription").show();
374 }else{
375 jQuery("._movie_url_field").parent().addClass("hide_if_subscription").hide();
376 }
377 }
378 });
379
380 jQuery('#_subscript_live_event').trigger('change');
381
382
383 $('#wpstream_product_type').change(function(){
384 jQuery('.video_free').hide();
385 jQuery('.video_free_external').hide();
386
387 jQuery('.wpstream_option_vod_source').hide();
388
389 if( jQuery('#wpstream_product_type').val()=== "2"){
390 jQuery('.video_free').show();
391 jQuery('.wpstream_show_recording').show();
392 }
393 if( jQuery('#wpstream_product_type').val()=== "3"){
394 jQuery('.video_free_external').show();
395 jQuery('.wpstream_show_external').show();
396 }
397 });
398 $('#wpstream_product_type').trigger('change');
399
400
401
402
403
404
405 $('.close_event').click(function(event){
406 event.preventDefault();
407 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
408 var acesta = $(this);
409 var parent = $(this).parent().parent();
410 var notification_area = $(this).parent().find('.event_list_unit_notificationx');
411 var show_id = parseFloat( $(this).attr('data-show-id') );
412 var nonce = $('#wpstream_start_event_nonce').val();
413 //$(this).unbind();
414 notification_area.text('Closing Event');
415
416
417 jQuery.ajax({
418 type: 'POST',
419 url: ajaxurl,
420 dataType: 'json',
421 data: {
422 'action' : 'wpstream_close_event',
423 'security' : nonce,
424 'show_id' : show_id
425 },
426 success: function (data) {
427 parent.remove();
428 },
429 error: function (errorThrown) {
430
431 }
432 });
433
434 });
435
436
437
438
439
440
441
442 });
443
444
445
446 /*
447 * Upload images in admin
448 *
449 */
450 function wpstream_upload_images_in_wpadmin(){
451 console.log('wpstream_upload_images_in_wpadmin');
452 var idList = ["category_featured_image_button"];
453
454 for (var i = 0; i < idList.length; i++) {
455 var currentId = idList[i];
456 jQuery('#'+currentId).on( 'click', function(event) {
457 var parent=jQuery(this).parent();
458 wpstream_admin_return_uploaded_image().then(function(image) {
459 parent.find('.wpestate_landing_upload').val(image.url);
460 parent.find('.wpestate_landing_upload_id').val(image.id);
461
462 });
463
464 });
465
466 }
467 }
468
469
470 /*
471 * return uploaded image
472 *
473 */
474 function wpstream_admin_return_uploaded_image(){
475
476 return new Promise(function(resolve, reject) {
477 var mediaUploader = wp.media({
478 frame: "post",
479 state: "insert",
480 multiple: false
481 });
482
483 mediaUploader.on("insert", function(){
484 var image = mediaUploader.state().get("selection").first().toJSON();
485 resolve(image);
486 });
487
488 mediaUploader.open();
489 });
490 }
491
492
493
494
495
496 /*
497 * handle video selection for recording
498 *
499 */
500
501 function wpstream_handle_video_selection(){
502
503 jQuery('#wpstream_free_video_external_button').on( 'click', function(event) {
504 var parent=jQuery(this).parent();
505 wpstream_admin_return_uploaded_image().then(function(image) {
506 parent.find('#wpstream_free_video_external').val(image.url);
507 });
508 });
509 }
510
511
512
513 /*
514 * return uploaded image
515 *
516 */
517 function wpstream_admin_return_uploaded_image(){
518
519
520 return new Promise(function(resolve, reject) {
521 var mediaUploader = wp.media({
522 frame: "post",
523 state: "insert",
524 multiple: false
525 });
526
527 mediaUploader.on("insert", function(){
528 var image = mediaUploader.state().get("selection").first().toJSON();
529 resolve(image);
530 });
531
532 mediaUploader.open();
533 });
534 }
535
536