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

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

466 lines 15.6 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
11
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'){
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
334 if ( product_type === 'video_on_demand' ) {
335 jQuery('.show_if_video_on_demand' ).show();
336
337 }
338 else if ( product_type === 'live_stream' ) {
339 $( '.show_if_live_stream' ).show();
340
341 }
342
343
344
345
346
347 function wpstream_findGetParameter(parameterName) {
348 var result = null,
349 tmp = [];
350 location.search
351 .substr(1)
352 .split("&")
353 .forEach(function (item) {
354 tmp = item.split("=");
355 if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
356 });
357 return result;
358 }
359
360
361 jQuery('#_subscript_live_event').change(function(){
362 //alert('move it'+product_type);
363 if ( product_type === 'video_on_demand' || product_type === 'live_stream' ) {
364
365 }else{
366 var value= jQuery(this).val();
367 if(value==="no"){
368 jQuery("._movie_url_field").parent().removeClass("hide_if_subscription").show();
369 }else{
370 jQuery("._movie_url_field").parent().addClass("hide_if_subscription").hide();
371 }
372 }
373 });
374
375 jQuery('#_subscript_live_event').trigger('change');
376
377
378 $('#wpstream_product_type').change(function(){
379 jQuery('.video_free').hide();
380 jQuery('.video_free_external').hide();
381
382 jQuery('.wpstream_option_vod_source').hide();
383
384 if( jQuery('#wpstream_product_type').val()=== "2"){
385 jQuery('.video_free').show();
386 jQuery('.wpstream_show_recording').show();
387 }
388 if( jQuery('#wpstream_product_type').val()=== "3"){
389 jQuery('.video_free_external').show();
390 jQuery('.wpstream_show_external').show();
391 }
392 });
393 $('#wpstream_product_type').trigger('change');
394
395
396
397 $('#wpstream_free_video_external_button').on( 'click', function(event) {
398 var formfield = $('#wpstream_free_video_external').attr('name');
399 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
400 window.send_to_editor = function (html) {
401 var pathArray = html.match(/<media>(.*)<\/media>/);
402 var mediaUrl = pathArray != null && typeof pathArray[1] != 'undefined' ? pathArray[1] : '';
403
404 if(mediaUrl===''){
405 mediaUrl = jQuery(html).attr("href");
406 }
407 jQuery('#wpstream_free_video_external').val(mediaUrl);
408 tb_remove();
409 };
410 return false;
411 });
412
413 $('.close_event').click(function(event){
414 event.preventDefault();
415 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
416 var acesta = $(this);
417 var parent = $(this).parent().parent();
418 var notification_area = $(this).parent().find('.event_list_unit_notificationx');
419 var show_id = parseFloat( $(this).attr('data-show-id') );
420 var nonce = $('#wpstream_start_event_nonce').val();
421 //$(this).unbind();
422 notification_area.text('Closing Event');
423
424
425 jQuery.ajax({
426 type: 'POST',
427 url: ajaxurl,
428 dataType: 'json',
429 data: {
430 'action' : 'wpstream_close_event',
431 'security' : nonce,
432 'show_id' : show_id
433 },
434 success: function (data) {
435 parent.remove();
436 },
437 error: function (errorThrown) {
438
439 }
440 });
441
442 });
443
444
445
446
447
448
449 $('.category_featured_image_button').on( 'click', function() {
450 var parent = $(this).parent();
451 var formfield = parent.find('#category_featured_image').attr('name');
452 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
453 window.send_to_editor = function (html) {
454 var imgurl = $('img', html).attr('src');
455 parent.find('#category_featured_image').val(imgurl);
456 var theid = $('img', html).attr('class');
457 var thenum = theid.match(/\d+$/)[0];
458 parent.find('#category_attach_id').val(thenum);
459 tb_remove();
460 };
461 return false;
462 });
463
464
465 });
466