| 1 |
/*global $, jQuery, */ |
| 2 |
var counters={}; |
| 3 |
|
| 4 |
jQuery(document).ready(function ($) { |
| 5 |
"use strict"; |
| 6 |
|
| 7 |
wpstream_check_live_connections(); |
| 8 |
generate_download_link(); |
| 9 |
generate_delete_link(); |
| 10 |
social_media_toggle('wpstream_on_facebook'); |
| 11 |
social_media_toggle('wpstream_on_youtube'); |
| 12 |
social_media_toggle('wpstream_on_twich'); |
| 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('.wpestate_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 |
|
| 72 |
data: { |
| 73 |
'action' : 'wpstream_get_delete_file', |
| 74 |
'video_name' : video_name |
| 75 |
|
| 76 |
}, |
| 77 |
success: function (data) { |
| 78 |
parent.remove(); |
| 79 |
|
| 80 |
|
| 81 |
}, |
| 82 |
error: function (errorThrown) { |
| 83 |
} |
| 84 |
}); |
| 85 |
}); |
| 86 |
|
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
function generate_download_link(){ |
| 91 |
|
| 92 |
$('.wpstream_get_download_link').on('click',function(){ |
| 93 |
var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php'; |
| 94 |
var video_name = $(this).attr('data-filename'); |
| 95 |
var acesta = $(this); |
| 96 |
var parent = $(this).parent(); |
| 97 |
|
| 98 |
jQuery(this).remove(); |
| 99 |
parent.find('.wpstream_download_link').show().text('please wait...'); |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
jQuery.ajax({ |
| 104 |
type: 'POST', |
| 105 |
url: ajaxurl, |
| 106 |
|
| 107 |
data: { |
| 108 |
'action' : 'wpstream_get_download_link', |
| 109 |
'video_name' : video_name, |
| 110 |
|
| 111 |
}, |
| 112 |
success: function (data) { |
| 113 |
|
| 114 |
if(String(data)==='toolarge'){ |
| 115 |
parent.find('.wpstream_download_link').show().text(wpstream_admin_control_vars.no_band); |
| 116 |
}else{ |
| 117 |
parent.find('.wpstream_download_link').show().text(wpstream_admin_control_vars.download_mess); |
| 118 |
parent.find('.wpstream_download_link').show().attr('href',data); |
| 119 |
|
| 120 |
} |
| 121 |
|
| 122 |
}, |
| 123 |
error: function (errorThrown) { |
| 124 |
} |
| 125 |
}); |
| 126 |
}); |
| 127 |
|
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
$( '.inputfile' ).each( function(){ |
| 135 |
var $input = $( this ), |
| 136 |
$label = $input.next( 'label' ), |
| 137 |
labelVal = $label.html(); |
| 138 |
|
| 139 |
$input.on( 'change', function( e ) |
| 140 |
{ |
| 141 |
var fileName = ''; |
| 142 |
|
| 143 |
if( this.files && this.files.length > 1 ) |
| 144 |
fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length ); |
| 145 |
else if( e.target.value ) |
| 146 |
fileName = e.target.value.split( '\\' ).pop(); |
| 147 |
|
| 148 |
if( fileName ) |
| 149 |
$label.find( 'span' ).html( fileName ); |
| 150 |
else |
| 151 |
$label.html( labelVal ); |
| 152 |
}); |
| 153 |
|
| 154 |
// Firefox bug fix |
| 155 |
$input |
| 156 |
.on( 'focus', function(){ $input.addClass( 'has-focus' ); }) |
| 157 |
.on( 'blur', function(){ $input.removeClass( 'has-focus' ); }); |
| 158 |
}); |
| 159 |
|
| 160 |
var form = $('.direct-upload'); |
| 161 |
var filesUploaded = []; |
| 162 |
var folders = []; |
| 163 |
|
| 164 |
// var new_file_name=''; |
| 165 |
|
| 166 |
form.fileupload({ |
| 167 |
url: form.attr('action'), |
| 168 |
type: form.attr('method'), |
| 169 |
datatype: 'xml', |
| 170 |
add: function (event, data) { |
| 171 |
|
| 172 |
|
| 173 |
if( data.files[0].type!=='video/mp4' && data.files[0].type!=='video/quicktime'){ |
| 174 |
jQuery('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.not_accepted); |
| 175 |
return; |
| 176 |
} |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
var file_size=(parseInt(data.files[0].size,10))/1000000; |
| 181 |
var user_storage = jQuery('#wpstream_storage').val(); |
| 182 |
var user_band = jQuery('#wpstream_band').val(); |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
if(file_size > user_storage || file_size>user_band){ |
| 187 |
jQuery('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.no_band_no_store); |
| 188 |
return; |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
$('#wpstream_label_action').text(wpstream_admin_control_vars.uploading) |
| 193 |
|
| 194 |
jQuery('#wpstream_uploaded_mes').empty().html(); |
| 195 |
// Show warning message if your leaving the page during an upload. |
| 196 |
window.onbeforeunload = function () { |
| 197 |
return 'You have unsaved changes.'; |
| 198 |
}; |
| 199 |
|
| 200 |
var file = data.files[0]; |
| 201 |
|
| 202 |
//console.log('file'+JSON.stringify(file)); |
| 203 |
form.find('input[name="Content-Type"]').val(file.type); |
| 204 |
form.find('input[name="Content-Length"]').val(file.size); |
| 205 |
|
| 206 |
// Actually submit to form to S3. |
| 207 |
data.submit(); |
| 208 |
|
| 209 |
// Show the progress bar |
| 210 |
// Uses the file size as a unique identifier |
| 211 |
var bar = $('<div class="progress" data-mod="'+file.size+'"><div class="bar"></div></div>'); |
| 212 |
$('.progress-bar-area').append(bar); |
| 213 |
bar.slideDown('fast'); |
| 214 |
}, |
| 215 |
progress: function (e, data) { |
| 216 |
// This is what makes everything really cool, thanks to that callback |
| 217 |
// you can now update the progress bar based on the upload progress. |
| 218 |
var percent = Math.round((data.loaded / data.total) * 100); |
| 219 |
$('.progress[data-mod="'+data.files[0].size+'"] .bar').css('width', percent + '%').html(percent+'%'); |
| 220 |
}, |
| 221 |
|
| 222 |
fail: function (e, data) { |
| 223 |
// Remove the 'unsaved changes' message. |
| 224 |
window.onbeforeunload = null; |
| 225 |
$('.progress[data-mod="'+data.files[0].size+'"] .bar').css('width', '100%').addClass('red').html(''); |
| 226 |
}, |
| 227 |
done: function (event, data) { |
| 228 |
|
| 229 |
window.onbeforeunload = null; |
| 230 |
$('.bar').remove(); |
| 231 |
$('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.upload_complete); |
| 232 |
$('#wpstream_label_action').text(wpstream_admin_control_vars.upload_complete2); |
| 233 |
|
| 234 |
var new_file_name=data.files[0].name; |
| 235 |
|
| 236 |
|
| 237 |
var new_file_name_array= data.files[0].name.split("."); |
| 238 |
var temp_file_name= new_file_name_array[0].split(' ').join('_'); |
| 239 |
temp_file_name= temp_file_name.replace(/\W/g, ''); |
| 240 |
new_file_name=temp_file_name+'.'+new_file_name_array[new_file_name_array.length-1]; |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
var onclick_string=' Are you sure you wish to delete '+new_file_name+' ? '; |
| 246 |
|
| 247 |
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">'; |
| 248 |
to_insert=to_insert+'<strong class="storage_file_name">File Name :</strong><span class="storage_file_name_real">'+new_file_name+' </span></div>'; |
| 249 |
to_insert=to_insert+'<div class="wpstream_delete_media" '; |
| 250 |
to_insert=to_insert+' onclick=" return confirm('+onclick_string+') "'; |
| 251 |
to_insert=to_insert+' data-filename="'+new_file_name+'" >delete file</div>'; |
| 252 |
to_insert=to_insert+'<div class="wpstream_get_download_link" data-filename="'+new_file_name+'">get download link</div> '; |
| 253 |
to_insert=to_insert+'<a href="" class="wpstream_download_link">Click to download! The url will work for the next 20 minutes!</a></div>'; |
| 254 |
|
| 255 |
$('#video_management_title').after(to_insert); |
| 256 |
|
| 257 |
$('.wpstream_get_download_link').unbind('click'); |
| 258 |
$('.wpstream_delete_media').unbind('click'); |
| 259 |
|
| 260 |
generate_download_link(); |
| 261 |
generate_delete_link(); |
| 262 |
|
| 263 |
|
| 264 |
} |
| 265 |
}); |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
jQuery('.copy_live_uri').click(function(){ |
| 272 |
var value_uri = jQuery(this).parent().find('.wpstream_live_uri_text').text(); |
| 273 |
var temp = jQuery("<input>"); |
| 274 |
jQuery("body").append(temp); |
| 275 |
jQuery(temp).val(value_uri).select(); |
| 276 |
document.execCommand("copy"); |
| 277 |
jQuery(temp).remove(); |
| 278 |
|
| 279 |
}); |
| 280 |
|
| 281 |
jQuery('.copy_live_key').click(function(){ |
| 282 |
var value_uri = jQuery(this).parent().find('.wpstream_live_key_text').text(); |
| 283 |
var temp = jQuery("<input>"); |
| 284 |
jQuery("body").append(temp); |
| 285 |
jQuery(temp).val(value_uri).select(); |
| 286 |
document.execCommand("copy"); |
| 287 |
jQuery(temp).remove(); |
| 288 |
}); |
| 289 |
|
| 290 |
|
| 291 |
jQuery('#product-type').on('change',function(){ |
| 292 |
|
| 293 |
var product_type= jQuery('#product-type').val(); |
| 294 |
if(product_type==='live_stream' || product_type==='video_on_demand'){ |
| 295 |
jQuery('._sold_individually_field').show(); |
| 296 |
} |
| 297 |
|
| 298 |
}); |
| 299 |
|
| 300 |
if(wpstream_findGetParameter('new_video_name')!=='' && wpstream_findGetParameter('new_video_name')!=null ){ |
| 301 |
jQuery('#product-type').val('video_on_demand').trigger('change'); |
| 302 |
} |
| 303 |
|
| 304 |
if(wpstream_findGetParameter('new_stream')!=='' && wpstream_findGetParameter('new_stream')!=null ){ |
| 305 |
jQuery('#product-type').val('live_stream').trigger('change'); |
| 306 |
} |
| 307 |
|
| 308 |
var product_type= jQuery('#product-type').val(); |
| 309 |
|
| 310 |
if ( product_type === 'video_on_demand' ) { |
| 311 |
jQuery('.show_if_video_on_demand' ).show(); |
| 312 |
|
| 313 |
} |
| 314 |
else if ( product_type === 'live_stream' ) { |
| 315 |
$( '.show_if_live_stream' ).show(); |
| 316 |
|
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
function wpstream_findGetParameter(parameterName) { |
| 324 |
var result = null, |
| 325 |
tmp = []; |
| 326 |
location.search |
| 327 |
.substr(1) |
| 328 |
.split("&") |
| 329 |
.forEach(function (item) { |
| 330 |
tmp = item.split("="); |
| 331 |
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]); |
| 332 |
}); |
| 333 |
return result; |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
jQuery('#_subscript_live_event').change(function(){ |
| 338 |
//alert('move it'+product_type); |
| 339 |
if ( product_type === 'video_on_demand' || product_type === 'live_stream' ) { |
| 340 |
|
| 341 |
}else{ |
| 342 |
var value= jQuery(this).val(); |
| 343 |
if(value==="no"){ |
| 344 |
jQuery("._movie_url_field").parent().removeClass("hide_if_subscription").show(); |
| 345 |
}else{ |
| 346 |
jQuery("._movie_url_field").parent().addClass("hide_if_subscription").hide(); |
| 347 |
} |
| 348 |
} |
| 349 |
}); |
| 350 |
|
| 351 |
jQuery('#_subscript_live_event').trigger('change'); |
| 352 |
|
| 353 |
|
| 354 |
$('#wpstream_product_type').change(function(){ |
| 355 |
$('.video_free').hide(); |
| 356 |
$('.video_free_external').hide(); |
| 357 |
|
| 358 |
if( $('#wpstream_product_type').val()=== "2"){ |
| 359 |
$('.video_free').show(); |
| 360 |
} |
| 361 |
if( $('#wpstream_product_type').val()=== "3"){ |
| 362 |
$('.video_free_external').show(); |
| 363 |
} |
| 364 |
}); |
| 365 |
$('#wpstream_product_type').trigger('change'); |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
$('#wpstream_free_video_external_button').on( 'click', function(event) { |
| 370 |
var formfield = $('#wpstream_free_video_external').attr('name'); |
| 371 |
tb_show('', 'media-upload.php?type=image&TB_iframe=true'); |
| 372 |
window.send_to_editor = function (html) { |
| 373 |
var pathArray = html.match(/<media>(.*)<\/media>/); |
| 374 |
var mediaUrl = pathArray != null && typeof pathArray[1] != 'undefined' ? pathArray[1] : ''; |
| 375 |
|
| 376 |
if(mediaUrl===''){ |
| 377 |
mediaUrl = jQuery(html).attr("href"); |
| 378 |
} |
| 379 |
jQuery('#wpstream_free_video_external').val(mediaUrl); |
| 380 |
tb_remove(); |
| 381 |
}; |
| 382 |
return false; |
| 383 |
}); |
| 384 |
|
| 385 |
$('.close_event').click(function(event){ |
| 386 |
event.preventDefault(); |
| 387 |
var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php'; |
| 388 |
var acesta = $(this); |
| 389 |
var parent = $(this).parent().parent(); |
| 390 |
var notification_area = $(this).parent().find('.event_list_unit_notificationx'); |
| 391 |
var show_id = parseFloat( $(this).attr('data-show-id') ); |
| 392 |
var nonce = $('#wpstream_start_event_nonce').val(); |
| 393 |
$(this).unbind(); |
| 394 |
notification_area.text('Closing Event'); |
| 395 |
|
| 396 |
|
| 397 |
jQuery.ajax({ |
| 398 |
type: 'POST', |
| 399 |
url: ajaxurl, |
| 400 |
dataType: 'json', |
| 401 |
data: { |
| 402 |
'action' : 'wpstream_close_event', |
| 403 |
'security' : nonce, |
| 404 |
'show_id' : show_id |
| 405 |
}, |
| 406 |
success: function (data) { |
| 407 |
parent.remove(); |
| 408 |
}, |
| 409 |
error: function (errorThrown) { |
| 410 |
|
| 411 |
} |
| 412 |
}); |
| 413 |
|
| 414 |
}); |
| 415 |
|
| 416 |
$('.start_webcaster').on('click',function(){ |
| 417 |
var caster_url = $(this).attr('data-webcaster-url'); |
| 418 |
$(this).parent().find('.external_software_streaming').slideUp() |
| 419 |
window.open(caster_url, '_blank', 'location=yes,height=390,width=660,scrollbars=yes,status=yes'); |
| 420 |
}) |
| 421 |
|
| 422 |
$('.start_external').on('click',function(){ |
| 423 |
$(this).parent().parent().find('.external_software_streaming').slideToggle(); |
| 424 |
}); |
| 425 |
|
| 426 |
|
| 427 |
function wpstream_check_live_connections(){ |
| 428 |
|
| 429 |
if( $('.pending_streaming.pending_trigger').length>0 ){ |
| 430 |
$('.pending_streaming.pending_trigger').each(function(){ |
| 431 |
var server_url = $(this).attr('data-server-url'); |
| 432 |
var counter = ''; |
| 433 |
var acesta = $(this); |
| 434 |
|
| 435 |
var show_id = $(this).attr('data-show-id'); |
| 436 |
var server_id = $(this).attr('data-server-id'); |
| 437 |
|
| 438 |
wpstream_check_live_connections_from_database(acesta,show_id,server_id); |
| 439 |
var counter_long = ''; |
| 440 |
counter_long = setInterval( function (){ wpstream_check_live_connections_from_database(acesta,show_id,server_id)},60000); |
| 441 |
counters[show_id]=counter_long; |
| 442 |
|
| 443 |
}); |
| 444 |
} |
| 445 |
|
| 446 |
} |
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
function wpstream_check_live_connections_step( acesta,server_url){ |
| 451 |
|
| 452 |
var server_status = wpstream_check_server_status(server_url, |
| 453 |
function( server_status ){ |
| 454 |
|
| 455 |
if(server_status ){ |
| 456 |
acesta.removeClass('show_stream_data').addClass('hide_stream_data'); |
| 457 |
acesta.parent().find('.wpstream_ready_to_stream').removeClass('hide_stream_data').addClass('show_stream_data'); |
| 458 |
clearInterval( counters[server_url]); |
| 459 |
} |
| 460 |
}); |
| 461 |
|
| 462 |
} |
| 463 |
|
| 464 |
function wpstream_check_live_connections_on_start( parent,show_id,server_id,data){ |
| 465 |
|
| 466 |
// server_url is dns change |
| 467 |
|
| 468 |
wpstream_check_dns_avb_callback(show_id,server_id, |
| 469 |
function(server_status){ |
| 470 |
|
| 471 |
if(server_status.status==='active' ){ |
| 472 |
clearInterval( counters[server_id]); |
| 473 |
|
| 474 |
|
| 475 |
parent.find('.pending_streaming').removeClass('show_stream_data').addClass('hide_stream_data'); |
| 476 |
parent.find('.wpstream_ready_to_stream ').removeClass('hide_stream_data').addClass('show_stream_data'); |
| 477 |
parent.find('.external_software_streaming ').removeClass('hide_stream_data').addClass('show_stream_data'); |
| 478 |
parent.find('.view_channel').addClass('show_stream_data'); |
| 479 |
|
| 480 |
parent.find('.wpstream_ready_to_stream .start_webcaster').attr('data-webcaster-url',server_status.webCasterUrl); |
| 481 |
parent.find('.wpstream_live_uri_text').text(server_status.obs_uri); |
| 482 |
parent.find('.wpstream_live_key_text').text(server_status.obs_stream); |
| 483 |
|
| 484 |
}else if(server_status.status==='error' ){ |
| 485 |
clearInterval( counters[server_id]); |
| 486 |
var curent_content = parent.find('.wpstream_channel_status'); |
| 487 |
curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>Failed to start the channel. Please try again in a few minutes.</div>'); |
| 488 |
} |
| 489 |
}); |
| 490 |
|
| 491 |
} |
| 492 |
|
| 493 |
function wpstream_check_live_connections_from_database( acesta,show_id,server_id){ |
| 494 |
|
| 495 |
var server_status = wpstream_check_dns_avb_callback(show_id,server_id, |
| 496 |
function(server_status){ |
| 497 |
|
| 498 |
if(server_status.status==='active' ){ |
| 499 |
|
| 500 |
acesta.removeClass('show_stream_data').addClass('hide_stream_data'); |
| 501 |
acesta.parent().find('.wpstream_ready_to_stream').removeClass('hide_stream_data').addClass('show_stream_data'); |
| 502 |
acesta.parent().find('.view_channel').addClass('show_stream_data'); |
| 503 |
|
| 504 |
acesta.parent().find('.wpstream_ready_to_stream .start_webcaster').attr('data-webcaster-url',server_status.webCasterUrl); |
| 505 |
acesta.parent().find('.wpstream_live_uri_text').text(server_status.obs_uri); |
| 506 |
acesta.parent().find('.wpstream_live_key_text').text(server_status.obs_stream); |
| 507 |
|
| 508 |
|
| 509 |
clearInterval( counters[show_id]); |
| 510 |
}else if(server_status.status==='error' ){ |
| 511 |
|
| 512 |
clearInterval( counters[show_id]); |
| 513 |
var curent_content = acesta.parent().find('.wpstream_channel_status '); |
| 514 |
curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>Failed to start the channel. Please try again in a few minutes.</div>'); |
| 515 |
} |
| 516 |
}); |
| 517 |
|
| 518 |
} |
| 519 |
|
| 520 |
|
| 521 |
function wpstream_check_server_status(url_param,callback) { |
| 522 |
|
| 523 |
var url = url_param ; |
| 524 |
var status=''; |
| 525 |
$.ajax({ |
| 526 |
url: url, |
| 527 |
type: "get", |
| 528 |
cache: false, |
| 529 |
dataType: 'jsonp', // it is for supporting crossdomain |
| 530 |
crossDomain : true, |
| 531 |
asynchronous : false, |
| 532 |
timeout : 1500, // set a timeout in milliseconds |
| 533 |
callback:'', |
| 534 |
complete : function(xhr) { |
| 535 |
|
| 536 |
if(xhr.status == "200" || xhr.status == "400") { |
| 537 |
callback(true); |
| 538 |
} |
| 539 |
else { |
| 540 |
callback(false); |
| 541 |
} |
| 542 |
} |
| 543 |
}); |
| 544 |
} |
| 545 |
|
| 546 |
$('.start_event').click(function(event){ |
| 547 |
event.preventDefault(); |
| 548 |
var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php'; |
| 549 |
var acesta = $(this); |
| 550 |
var notification_area = $(this).parent().find('.event_list_unit_notification'); |
| 551 |
var curent_content = $(this).parent().find('.server_notification'); |
| 552 |
var is_record = false; |
| 553 |
var is_encrypt = false; |
| 554 |
var show_id = parseFloat( $(this).attr('data-show-id') ); |
| 555 |
var nonce = $('#wpstream_start_event_nonce').val(); |
| 556 |
var parent = $(this).parent().parent(); |
| 557 |
|
| 558 |
if( $(this).parent().find('.record_event').is(":checked") ){ |
| 559 |
is_record = true; |
| 560 |
} |
| 561 |
|
| 562 |
if( $(this).parent().find('.encrypt_event').is(":checked") ){ |
| 563 |
is_encrypt = true; |
| 564 |
} |
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
var is_fb = 0; |
| 571 |
var is_youtube = 0; |
| 572 |
var is_twich = 0; |
| 573 |
var youtube_rtmp = $(this).parent().find('.wpstream_youtube_rtmp').val(); |
| 574 |
var twich_rtmp = $(this).parent().find('.wpstream_twich_rtmp').val(); |
| 575 |
|
| 576 |
if( $(this).parent().find('.wpstream_on_facebook').is(":checked") ){ |
| 577 |
is_fb = 1; |
| 578 |
} |
| 579 |
|
| 580 |
if( $(this).parent().find('.wpstream_on_youtube').is(":checked") ){ |
| 581 |
is_youtube = 1; |
| 582 |
} |
| 583 |
|
| 584 |
if( $(this).parent().find('.wpstream_on_twich').is(":checked") ){ |
| 585 |
is_twich = 1; |
| 586 |
} |
| 587 |
|
| 588 |
|
| 589 |
$(this).unbind(); |
| 590 |
$(this).hide(); |
| 591 |
parent.find('.record_wrapper').hide(); |
| 592 |
parent.find('.close_event ').hide(); |
| 593 |
curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>Getting ready to stream. Please wait...<img class="" src="'+wpstream_admin_control_vars.loading_url+'" alt="loading"></div>'); |
| 594 |
parent.find('.multiple_warning_events').html('* Starting a channel can take 1-2 minutes or more. Please be patient.'); |
| 595 |
|
| 596 |
|
| 597 |
jQuery.ajax({ |
| 598 |
type: 'POST', |
| 599 |
url: ajaxurl, |
| 600 |
dataType: 'json', |
| 601 |
timeout: 300000, |
| 602 |
|
| 603 |
data: { |
| 604 |
'action' : 'wpstream_give_me_live_uri', |
| 605 |
'security' : nonce, |
| 606 |
'show_id' : show_id, |
| 607 |
'is_record' : is_record, |
| 608 |
'is_encrypt' : is_encrypt, |
| 609 |
'is_fb' : is_fb, |
| 610 |
'is_youtube' : is_youtube, |
| 611 |
'is_twich' : is_twich, |
| 612 |
'youtube_rtmp' : youtube_rtmp, |
| 613 |
'twich_rtmp' : twich_rtmp |
| 614 |
|
| 615 |
}, |
| 616 |
success: function (data) { |
| 617 |
|
| 618 |
if(data.conected===true){ |
| 619 |
|
| 620 |
if(data.event_data==='err1'){ |
| 621 |
curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>You don\'t have enough streaming bandwidth to start a new event!</div>'); |
| 622 |
}else if(data.event_data ==='failed event creation'){ |
| 623 |
curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>Failed to start the channel. Please try again in a few minutes.</div>'); |
| 624 |
}else{ |
| 625 |
curent_content.empty(); |
| 626 |
parent.find('.wpstream_no_stream').removeClass('show_stream_data').addClass('hide_stream_data'); |
| 627 |
parent.find('.pending_streaming').removeClass('hide_stream_data').addClass('show_stream_data'); |
| 628 |
|
| 629 |
var counter = setInterval( function (){ wpstream_check_live_connections_on_start(parent,show_id,data.event_data,data)},10000); |
| 630 |
counters[data.event_data]=counter; |
| 631 |
} |
| 632 |
|
| 633 |
}else{ |
| 634 |
parent.find('.wpstream_no_stream').addClass('show_stream_data').empty().html(data.error); |
| 635 |
} |
| 636 |
|
| 637 |
}, |
| 638 |
error: function (jqXHR,textStatus,errorThrown) { |
| 639 |
|
| 640 |
} |
| 641 |
}); |
| 642 |
|
| 643 |
}); |
| 644 |
|
| 645 |
$('.category_featured_image_button').on( 'click', function() { |
| 646 |
var parent = $(this).parent(); |
| 647 |
var formfield = parent.find('#category_featured_image').attr('name'); |
| 648 |
tb_show('', 'media-upload.php?type=image&TB_iframe=true'); |
| 649 |
window.send_to_editor = function (html) { |
| 650 |
var imgurl = $('img', html).attr('src'); |
| 651 |
parent.find('#category_featured_image').val(imgurl); |
| 652 |
var theid = $('img', html).attr('class'); |
| 653 |
var thenum = theid.match(/\d+$/)[0]; |
| 654 |
parent.find('#category_attach_id').val(thenum); |
| 655 |
tb_remove(); |
| 656 |
}; |
| 657 |
return false; |
| 658 |
}); |
| 659 |
|
| 660 |
|
| 661 |
}); |
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
function wpstream_check_dns_avb_callback(show_id,server_id,callback){ |
| 666 |
|
| 667 |
var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php'; |
| 668 |
jQuery.ajax({ |
| 669 |
type: 'POST', |
| 670 |
url: ajaxurl, |
| 671 |
timeout: 3000000, |
| 672 |
|
| 673 |
data: { |
| 674 |
'action' : 'wpstream_check_event_status', |
| 675 |
'server_id' : server_id, |
| 676 |
'show_id' : show_id |
| 677 |
|
| 678 |
}, |
| 679 |
success: function (data) { |
| 680 |
var obj = JSON.parse(data); |
| 681 |
|
| 682 |
if(obj.status=='active'){ |
| 683 |
callback(obj); |
| 684 |
}else if(obj.status=='error'){ |
| 685 |
callback(obj); |
| 686 |
}else{ |
| 687 |
callback(false); |
| 688 |
} |
| 689 |
|
| 690 |
}, error: function (jqXHR,textStatus,errorThrown) { |
| 691 |
|
| 692 |
} |
| 693 |
}); |
| 694 |
} |
| 695 |
|
| 696 |
|
| 697 |
function wpstream_enable_cliboard(parent){ |
| 698 |
|
| 699 |
jQuery(parent).find('.copy_live_uri').click(function(){ |
| 700 |
alert('click'); |
| 701 |
var value_uri = jQuery(parent).find('.wpstream_live_uri_text').text(); |
| 702 |
var temp = jQuery("<input>"); |
| 703 |
jQuery("body").append(temp); |
| 704 |
jQuery(temp).val(value_uri).select(); |
| 705 |
document.execCommand("copy"); |
| 706 |
jQuery(temp).remove(); |
| 707 |
|
| 708 |
}); |
| 709 |
|
| 710 |
jQuery(parent).find('.copy_live_key').click(function(){ |
| 711 |
var value_uri = jQuery(parent).find('.wpstream_live_key_text').text(); |
| 712 |
var temp = jQuery("<input>"); |
| 713 |
jQuery("body").append(temp); |
| 714 |
jQuery(temp).val(value_uri).select(); |
| 715 |
document.execCommand("copy"); |
| 716 |
jQuery(temp).remove(); |
| 717 |
|
| 718 |
}); |
| 719 |
} |