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

515 lines 16.5 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'){
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
335 if ( product_type === 'video_on_demand' ) {
336 jQuery('.show_if_video_on_demand' ).show();
337
338 }
339 else if ( product_type === 'live_stream' ) {
340 $( '.show_if_live_stream' ).show();
341
342 }
343
344
345
346
347
348 function wpstream_findGetParameter(parameterName) {
349 var result = null,
350 tmp = [];
351 location.search
352 .substr(1)
353 .split("&")
354 .forEach(function (item) {
355 tmp = item.split("=");
356 if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
357 });
358 return result;
359 }
360
361
362 jQuery('#_subscript_live_event').change(function(){
363 //alert('move it'+product_type);
364 if ( product_type === 'video_on_demand' || product_type === 'live_stream' ) {
365
366 }else{
367 var value= jQuery(this).val();
368 if(value==="no"){
369 jQuery("._movie_url_field").parent().removeClass("hide_if_subscription").show();
370 }else{
371 jQuery("._movie_url_field").parent().addClass("hide_if_subscription").hide();
372 }
373 }
374 });
375
376 jQuery('#_subscript_live_event').trigger('change');
377
378
379 $('#wpstream_product_type').change(function(){
380 jQuery('.video_free').hide();
381 jQuery('.video_free_external').hide();
382
383 jQuery('.wpstream_option_vod_source').hide();
384
385 if( jQuery('#wpstream_product_type').val()=== "2"){
386 jQuery('.video_free').show();
387 jQuery('.wpstream_show_recording').show();
388 }
389 if( jQuery('#wpstream_product_type').val()=== "3"){
390 jQuery('.video_free_external').show();
391 jQuery('.wpstream_show_external').show();
392 }
393 });
394 $('#wpstream_product_type').trigger('change');
395
396
397 /*
398 $('#wpstream_free_video_external_button').on( 'click', function(event) {
399 var formfield = $('#wpstream_free_video_external').attr('name');
400 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
401 window.send_to_editor = function (html) {
402 var pathArray = html.match(/<media>(.*)<\/media>/);
403 var mediaUrl = pathArray != null && typeof pathArray[1] != 'undefined' ? pathArray[1] : '';
404
405 if(mediaUrl===''){
406 mediaUrl = jQuery(html).attr("href");
407 }
408 jQuery('#wpstream_free_video_external').val(mediaUrl);
409 tb_remove();
410 };
411 return false;
412 });
413 */
414
415
416
417
418
419
420 $('.close_event').click(function(event){
421 event.preventDefault();
422 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
423 var acesta = $(this);
424 var parent = $(this).parent().parent();
425 var notification_area = $(this).parent().find('.event_list_unit_notificationx');
426 var show_id = parseFloat( $(this).attr('data-show-id') );
427 var nonce = $('#wpstream_start_event_nonce').val();
428 //$(this).unbind();
429 notification_area.text('Closing Event');
430
431
432 jQuery.ajax({
433 type: 'POST',
434 url: ajaxurl,
435 dataType: 'json',
436 data: {
437 'action' : 'wpstream_close_event',
438 'security' : nonce,
439 'show_id' : show_id
440 },
441 success: function (data) {
442 parent.remove();
443 },
444 error: function (errorThrown) {
445
446 }
447 });
448
449 });
450
451
452
453
454
455
456 $('.category_featured_image_button').on( 'click', function() {
457 var parent = $(this).parent();
458 var formfield = parent.find('#category_featured_image').attr('name');
459 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
460 window.send_to_editor = function (html) {
461 var imgurl = $('img', html).attr('src');
462 parent.find('#category_featured_image').val(imgurl);
463 var theid = $('img', html).attr('class');
464 var thenum = theid.match(/\d+$/)[0];
465 parent.find('#category_attach_id').val(thenum);
466 tb_remove();
467 };
468 return false;
469 });
470
471
472 });
473
474
475 /*
476 * handle video selection for recording
477 *
478 */
479
480 function wpstream_handle_video_selection(){
481
482 jQuery('#wpstream_free_video_external_button').on( 'click', function(event) {
483 var parent=jQuery(this).parent();
484 wpstream_admin_return_uploaded_image().then(function(image) {
485 parent.find('#wpstream_free_video_external').val(image.url);
486 });
487 });
488 }
489
490
491
492 /*
493 * return uploaded image
494 *
495 */
496 function wpstream_admin_return_uploaded_image(){
497
498
499 return new Promise(function(resolve, reject) {
500 var mediaUploader = wp.media({
501 frame: "post",
502 state: "insert",
503 multiple: false
504 });
505
506 mediaUploader.on("insert", function(){
507 var image = mediaUploader.state().get("selection").first().toJSON();
508 resolve(image);
509 });
510
511 mediaUploader.open();
512 });
513 }
514
515