PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.5.11.5
WpStream – Live Streaming, Video on Demand, Pay Per View v4.5.11.5
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.5, at admin/js/admin_control.js

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