/* copy a string to a user's clipboard. This loads /flash/clipboard.swf . */
function copy(text2copy) {
if (false /*window.clipboardData*/) {
window.clipboardData.setData("Text",text2copy);
} else {
var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier)) {
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
}
document.getElementById(flashcopier).innerHTML = '';
var divinfo = '';
document.getElementById(flashcopier).innerHTML = divinfo;
}
}
function captureMousePosition(e) {
if (document.layers) {
// When the page scrolls in Netscape, the event's mouse position
// reflects the absolute position on the screen. innerHight/Width
// is the position from the top/left of the screen that the user is
// looking at. pageX/YOffset is the amount that the user has
// scrolled into the page. So the values will be in relation to
// each other as the total offsets into the page, no matter if
// the user has scrolled or not.
xMousePos = e.pageX;
yMousePos = e.pageY;
} else if (document.all) {
// When the page scrolls in IE, the event's mouse position
// reflects the position from the top/left of the screen the
// user is looking at. scrollLeft/Top is the amount the user
// has scrolled into the page. clientWidth/Height is the height
// width of the current page the user is looking at. So, to be
// consistent with Netscape (above), add the scroll offsets to
// both so we end up with an absolute value on the page, no
// matter if the user has scrolled or not.
xMousePos = window.event.x+document.body.scrollLeft;
yMousePos = window.event.y+document.body.scrollTop;
} else if (document.getElementById) {
// Netscape 6 behaves the same as Netscape 4 in this regard
xMousePos = e.pageX;
yMousePos = e.pageY;
}
return [ xMousePos, yMousePos ];
}
function showToolTip(obj_id, pos) {
obj = document.getElementById( obj_id );
obj.style.top = pos[1];
obj.style.left = pos[0];
obj.style.display='block';
document.onmousedown=function() {
document.getElementById(obj_id).style.display='none';
document.onmousedown=function(){};
};
}
function showToolTip_wh(obj_id, pos, width, height ) {
obj = document.getElementById( obj_id );
obj.style.top = pos[1];
obj.style.left = pos[0];
obj.style.display='block';
obj.style.height=height;
obj.style.width=width;
document.onmousedown=function() {
document.getElementById(obj_id).style.display='none';
document.onmousedown=function(){};
};
}
function revShowToolTip(obj_id, pos, width, height ) {
obj = document.getElementById( obj_id );
obj.style.top = ( pos[1] - height );
obj.style.left = ( pos[0] - width );
obj.style.display='block';
document.onmousedown=function() {
document.getelementbyid(obj_id).style.display='none';
document.onmousedown=function(){};
};
}
function showToolTipForm(obj_id, pos, width, height) {
obj = document.getElementById( obj_id );
obj.style.top = ( pos[1] - height );
obj.style.left = ( pos[0] - width );
obj.style.display='block';
obj.inner_html += 'close";
}
function episode_edit_select_library() {
// $('episode_edit_file_upload').value = '';
return false;
}
function check_episode_title() {
if (document.getElementById('episode_title').value.length > 0) {
return true;
}
alert('Title must not be blank');
return false;
}
function click_tag(elem_id, tt, index) {
$(elem_id).value += ' ' + tt;
tag_id = 'tag_'+index;
anchor_id = 'a_'+index;
$(tag_id).style.background = 'blue';
$(anchor_id).style.color = 'white';
}
function click_tag_pub(elem_id, tt, index) {
$(elem_id).value += ' ' + tt;
}
function check_tag_limit(id_val) {
var tags = document.getElementById(id_val).value;
var a_tags = tags.split(/( |,)/);
var num_tags = 0;
for (var idx = 0; idx < a_tags.length; idx++) {
if (a_tags[idx].length > 0 && !(a_tags[idx]==',' || a_tags[idx]==' ')) {
num_tags++;
}
}
if (num_tags > 12) {
alert('There is a limit of 12 tags per episode. You have '+num_tags+'.');
return false;
}
return true;
}
function convert_radio_select(selected_id) {
$('qlty_wmv').style.display = 'none';
$('qlty_mp4').style.display = 'none';
$('qlty_3gp').style.display = 'none';
if (selected_id) {
$(selected_id).style.display = 'block';
}
return true;
}
function editing_published_confirm() {
var yn = confirm("You have changed the media associated with this published episode. If you continue, your episode will become hidden from your podcast page until you complete the Review & Publish step.\n\nWould you like to continue?");
return yn;
}
function getXMLRequest() {
var xmlReq = null;
if (window.XMLHttpRequest) {
xmlReq = new XMLHttpRequest();
} else {
xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlReq;
}
/* this checks whether the media is changing
when editing an episode
*/
function episode_media_selected(upload_redirect_url, media_id) {
// given the currently selected media_item_id,
// checks the media selection widgets for changes;
// widgets include pull-down, upload file, and record
// if the episode is published, then warn user
// their episode will become hidden untill next publish
var is_upload = false; // $('episode_edit_file_upload').value.length != 0;
var should_continue = true;
if (media_id !== null) { // only passed in if episode is already published
// check if upload, media item changed, or recording
if (!is_upload) {
// check if media item changed or recording
if ($('recorded_fn') && $('recorded_fn').value.length > 0) {
should_continue = editing_published_confirm(); //is it a recording?
} else {
if ($('media_item').value != media_id) {
should_continue = editing_published_confirm(); //did the media item change?
}
}
} else {
should_continue = editing_published_confirm(); // its an upload
}
}
if (!should_continue) { return false; }
if (!is_upload) {
var media_url;
if ($('recorded_fn') && $('recorded_fn').value.length > 0) {
media_url = '/episode/recording/'+$F('id')+'?recorded_fn='+$('recorded_fn').value+'&recorded_id='+$('recorded_id').value;
} else {
var mid;
if ($('media_item')===null) {
mid = 0;
} else {
mid = $F('media_item');
}
// work around for Internet Explorer bug! WTF is wrong with Microsoft?
media_url = '/episode/mediaitem/'+$F('id')+'?mi='+mid;
// clear the form onsubmit cause its loaded with progress stuff for uploading
// $('episode_upload_form').onsubmit = null;
// $('episode_upload_form').target = null;
}
var xhReq = getXMLRequest(); // new XMLHttpRequest();
xhReq.open("GET", media_url, false);
xhReq.send(null);
var uu = '/episode/info/'+$('id').value;
parent.window.location.href = uu;
return false;
}
return true;
}
function episode_upload_selected(media_id) {
// given the currently selected media_item_id,
// checks the media selection widgets for changes;
// widgets include pull-down, upload file, and record
// if the episode is published, then warn user
// their episode will become hidden untill next publish
var uppath = $('episode_edit_file_upload').value;
if (uppath.match(/.*\/(.*\..*)/) || uppath.match(/.*\\(.*\..*)/)) {
$('upload_filename').innerHTML = ' Uploading file: '+RegExp.$1;
$('upload_filename').style.display = '';
$('upload_media_submit').style.display = 'none';
}
// $('episode_edit_file_upload').enabled = false;
var is_upload = uppath.length != 0;
// var is_upload = $('episode_edit_file_upload').value.length != 0;
var should_continue = true;
if (media_id !== null) { // only passed in if episode is already published
// check if upload, media item changed, or recording
should_continue = editing_published_confirm(); // its an upload
}
if (!should_continue) { return false; }
if (is_upload) {
var xhReq1 = getXMLRequest(); // new XMLHttpRequest();
xhReq1.open("GET", '/episode/uploading/'+$('id').value+'?state=begin', false);
xhReq1.send(null);
}
return true;
}
function clear_frame_if_upload_complete() {
// deprecated, i.e., not called
//alert("clear_frame_if_upload_complete");
if (parent.frames[0] && parent.frames[0].document.getElementById('episode_upload_complete_view')) {
if ('block' == parent.frames[0].document.getElementById('episode_upload_complete_view').style.display) {
if (parent.frames[1].window.location.href.match(/.*?episode.*?/)) {
/* upload completed, and we're editing episode, so reset frames so top is active, bottom inactive */
parent.frames[0].document.getElementById('episode_upload_progress_view').style.display = 'none';
parent.frames[0].document.getElementById('episode_upload_complete_view').style.display = 'none';
parent.frames[0].window.location.href = parent.frames[1].window.location.href;
//alert('clear_frame_if_upload_complete(): '+parent.frames[0].window.location.href);
parent.document.getElementById('upload_frameset').rows = "0, *";
}
}
}
}
function upload_finished(errors) {
if ($('is_uploading')) { $('is_uploading').style.display = 'none';}
if ($('not_uploading')) { $('not_uploading').style.display = 'block'; }
var xhReq1 = getXMLRequest(); // new XMLHttpRequest();
xhReq1.open("GET", '/episode/uploading/'+$('id').value+'?state=end', false);
xhReq1.send(null);
// $('episode_upload_progress_view').style.display = 'none';
// $('episode_upload_complete_view').style.display = 'block';
/*
if (parent.frames[0]) {
parent.frames[0].document.getElementById('episode_upload_progress_view').style.display = 'none';
parent.frames[0].document.getElementById('episode_upload_complete_view').style.display = 'block';
var hh = parent.frames[1].window.location.href;
if (hh.match(/.*?episode.*?/) || hh.match(/.*?podcast\/post.*?/)) {
parent.frames[1].window.location.reload();
parent.document.getElementById('upload_frameset').rows = "0, *";
}
}
*/
if (errors) {
alert(errors);
}
return true;
}
function deactivate_upload(elem, url) {
if (elem) {
elem.stop();
}
// must be synchronous
var xhReq = getXMLRequest(); // new XMLHttpRequest();
xhReq.open("GET", url, false);
xhReq.send(null);
//alert('deactivate_upload');
clear_frames();
// parent.document.getElementById('upload_frameset').rows = "0, *";
return false;
}
function check_frames(url) {
// if (parent.frames.length > 0)
if (parent.document.getElementById('upload_frameset')) {
var myAjax = new Ajax.Request(url, {method: 'get'});
}
}
function should_delete_episode() {
var episode_id = $('id');
if (episode_id.value) {
var url = '/episode/should_delete/'+episode_id.value;
var myAjax = new Ajax.Request(url, {method: 'get'});
}
return true;
}
function copy_post_contents() { $('gigya_code_post').innerHTML = $('post_body').innerHTML; }
function change_bmark_url(url) {
Wildfire.divWildfirePost_bmark.applyConfig({
bookmarkURL: url,
includeShareButton: 'true',
defaultContent: '',
UIConfig: '