/***************************************************************************** * * File: viLib.js for VAS * * Description: * Javascript library for use on all VI sites using VAS. Function * calls can be made in the templates, leaving the developer to pass * through the arguments. * * Copyright (c) 2000 Virage, Inc. All rights reserved. * *****************************************************************************/ /* uses a vtl_loop to resolve any macros in the code */ /***************************************************************************** * Function: vi_browserCheck * * Description: * A browser object used to detect browser name and version, as well * as platform. * * Arguments: none * * Return value: none * * Side Effects: * Uses the object to assign a browser name and version to * serve up specific content. * *****************************************************************************/ function vi_browserCheck() { var browser_type = navigator.appName if (browser_type == "Netscape") this.browser_type = "ns" else if (browser_type == "Microsoft Internet Explorer") this.browser_type = "ie" else this.browser_type = browser_type this.version = parseInt(navigator.appVersion) this.platform = navigator.appVersion this.w = this.platform.indexOf("Win") this.m = this.platform.indexOf("Mac") /* Netscape tests */ this.ns = (this.browser_type == "ns" && this.version >= 4) this.nswin = (this.browser_type == "ns" && this.w != -1 && this.version >= 4) this.nsmac = (this.browser_type == "ns" && this.m != -1 && this.version >= 4) this.ns4win = (this.browser_type=="ns" && this.w != -1 && this.version == 4) this.ns4mac = (this.browser_type == "ns" && this.m != -1 && this.version == 4) this.ns5win = (this.browser_type == "ns" && this.w != -1 && this.version == 5) this.ns5mac = (this.browser_type == "ns" && this.m != -1 && this.version == 5) /* Internet Explorer tests */ this.ie = (this.browser_type == "ie" && this.version >= 4) this.iewin = (this.browser_type == "ie" && this.w != -1 && this.version >= 4) this.iemac = (this.browser_type == "ie" && this.m != -1 && this.version >= 4) this.ie4win = (navigator.userAgent.indexOf('MSIE 4') > 0 && this.w != -1) this.ie4mac = (navigator.userAgent.indexOf('MSIE 4') > 0 && this.m != -1) this.ie5win = (navigator.userAgent.indexOf('MSIE 5') > 0 && this.m != -1) this.ie5mac = (navigator.userAgent.indexOf('MSIE 5') > 0 && this.m != -1) if (this.ie5) this.version = 5 this.min = (this.ns||this.ie) } webBrowser = new vi_browserCheck() /***************************************************************************** * Function: vi_Player * * Description: * Passes through numerous arguments to build a URL. * * * Arguments: * server - path to the vss_SR * template - the template to display in the pop-up * assetid - the asset id, e.g. * query - the query macro: * playtime - the start time for the clip. Differs depending * on whether or not we are playing from clip * or a point in the transcript. From clip use * or from transcript use * . * height & width - sizing parameters for the window * * Return Value: A fully resolved url to the redirect page. * * Side Effects: * This function passes through all the essential info * so the URL can fully resolve for each clip and launch the window. * *****************************************************************************/ function vi_Player(server,template,assetid,query,flex_time,height,width,scroll,fetch) { var specs; var visuals; topposition = (screen.height) ? (screen.height-height)/2 : 0; leftposition = (screen.width) ? (screen.width-width)/2 : 0; specs = server; specs += "template="; specs += template; specs += ";asset_id="; specs += assetid; specs += ";query="; specs += query; specs += ";flex_time="; specs += flex_time; specs += ";fetch_records="; specs += fetch; visuals = "status=1,height="; visuals += height; visuals += ",width="; visuals += width; visuals += ",top="; visuals += topposition; visuals += ",left="; visuals += leftposition; visuals += ",menu=0,scrollbars=" + scroll + ",resizable=0,toolbar=0"; window.open(specs, "vasPlayer", visuals); } //Pop up a window to view/print a transcript or to pop open an email window. function vi_PopWin(server,template,windowName,assetid,query,flex_time,height,width,scroll,fetch,maxhighlights) { var specs; var visuals; topposition = (screen.height) ? (screen.height-height)/2 : 0; leftposition = (screen.width) ? (screen.width-width)/2 : 0; specs = server; specs += "template="; specs += template; specs += ";asset_id="; specs += assetid; specs += ";query="; specs += query; specs += ";flex_time="; specs += flex_time; specs += ";fetch_records="; specs += fetch; specs += ";max_highlights="; specs += maxhighlights; visuals = "status=1,height="; visuals += height; visuals += ",width="; visuals += width; visuals += ",top="; visuals += topposition; visuals += ",left="; visuals += leftposition; visuals += ",menu=0,scrollbars=" + scroll + ",resizable=0,toolbar=0"; window.open(specs, windowName, visuals); } /***************************************************************************** * Function: vi_Window * * Description: * Similar to vi_Player, this function passes through arguments * to build a URL to some static info in a pop-up window. * * Arguments: * server - path to the vss_SR * template - the template to display in the pop-up * windowName - the name of the pop-up window * height & width - sizing parameters for the window * * Return Value: A fully resolved url to display static html. * * Side Effects: * Static information like search tips is displayed in pop-up * windows. *****************************************************************************/ //Pops up search tips window. function vi_Window(server,template,windowName,height,width) { var specs; var visuals; topposition = (screen.height) ? (screen.height-height)/2 : 0; leftposition = (screen.width) ? (screen.width-width)/2 : 0; specs = server; specs += "template="; specs += template; visuals = "status=1,height="; visuals += height; visuals += ",width="; visuals += width; visuals += ",top="; visuals += topposition; visuals += ",left="; visuals += leftposition; visuals += ",menu=0,scrolling=0,resizable=0,toolbar=0"; window.open(specs, windowName, visuals); } //Function to pop open the Transcript Player window. function vi_PlayerTran(server,template,windowName,assetid,query,flex_time,height,width,scroll,fetch,maxhighlights) { var specs; var visuals; topposition = (screen.height) ? (screen.height-height)/2 : 0; leftposition = (screen.width) ? (screen.width-width)/2 : 0; specs = server; specs += "template="; specs += template; specs += ";asset_id="; specs += assetid; specs += ";query="; specs += query; specs += ";flex_time="; specs += flex_time; specs += ";fetch_records="; specs += fetch; specs += ";max_highlights="; specs += maxhighlights; visuals = "status=1,height="; visuals += height; visuals += ",width="; visuals += width; visuals += ",top="; visuals += topposition; visuals += ",left="; visuals += leftposition; visuals += ",menu=0,scrolling=0,resizable=0,toolbar=0"; window.open(specs, windowName, visuals); } /***************************************************************************** * Function: vi_checkCookie * * Description: * Searches through document.cookie and checks for the assigned * cookie name/value pair. * * Arguments: * prefName - the name of the preferences page without * the .tmpl extension. * cookieName - this is the account name * * Return Value: none * * Side Effects: * Sends the user to the preferences page if there is no cookie set * and uses the vi_getCookie function to retrieve the value if there is * a cookie set. * *****************************************************************************/ function vi_checkCookie(prefName,cookieName) { var allcookies = document.cookie; var pos = allcookies.indexOf(cookieName+"="); var today, expires, player; if (pos == -1) { today = new Date; today.setFullYear(2020); expires = today.toGMTString(); document.cookie = cookieName + "=" + prefName + ";expires=" + expires; self.location.href = "/vss-bin/vss_SR/masters/play?template=" + prefName + ".tmpl;asset_id=;video_asset_id=;query=;timein_msec=;timeout_msec=;timein=;timeout=;flex_time="; } else { player = vi_getCookie(cookieName); /* Get a handle on the cookie value, and test if it is the default playprefs. If a user launches the player, and fails to choose a format/bitrate, the cookie value is set to playprefs. This is a problem since we append add "play" and append "clip.tmpl" onto the cookie value to use as a template name. We would end up with a player name called playplayprefsclip.tmpl. A file which does not exist */ if(player == "playprefs") { player = player + ".tmpl"; } else { player = "play" + player + "clip.tmpl"; } self.location.href = "/vss-bin/vss_SR/masters/play?asset_id=;video_asset_id=;query=;cinfo_timein_msec=;cinfo_timeout_msec=;cinfo_timein=;cinfo_timeout=;flex_time=;template=" + player; } } /***************************************************************************** * Function: vi_getCookie * * Description: * Gets the cookie value from the variable allcookies. * * Arguments: * cookieName - the account name * * Return Value: * the cookie value, which is equal to the bitrate + * format. e.g. 56asf * * Side Effects: * This function is called within the vi_checkCookie function, as well * as in the vi_setRadioPrefs function to retrieve the value of the * previously chosen format and bitrate. * *****************************************************************************/ function vi_getCookie(cookieName) { var allcookies = document.cookie; var pos = allcookies.indexOf(cookieName+"="); var num, start, end, rawValue, value; num = parseInt(cookieName.length) + 1; start = pos + num; end = allcookies.indexOf(";", start); if(end == -1) end = allcookies.length; rawValue = allcookies.substring(start, end); value = unescape(rawValue); return value; } /***************************************************************************** * Function: vi_setCookie * * Description: * This function is called to set the cookie value. * * Arguments: * cookieValue - the cookie value to set. e.g. 56asf, 56ram * cookieName - this is the account name * * Return Value: sets cookieName = value. * * Side Effects: * The result is a cookie set to the appropriate bitrate and format. * The standard is to use this function exclusively in playprefs.tmpl. * *****************************************************************************/ function vi_setCookie(cookieValue,cookieName) { var allcookies = window.document.cookie; var pos = allcookies.indexOf(cookieName + "="); var today; var expires; today = new Date; today.setFullYear(2020); expires = today.toGMTString(); window.document.cookie = cookieName + "=" + cookieValue + ";expires=" + expires; } /***************************************************************************** * Function: vi_loadVideo * * Description: * Loops through the radio values, and then stores their choice * into a variable. * * Arguments: * formName - name of the form. * radioName - name of the group of radio buttons. * * Return Value: none * * Side Effects: * The user is sent to the page that contains the player with their * chosen bitrate and format. * *****************************************************************************/ function vi_loadVideo(formName,radioName) { var player; var i_Radio; for( i_Radio = 0; i_Radio < document[formName][radioName].length; i_Radio++ ) { if (document[formName][radioName][i_Radio].checked) { player = "play" + document[formName][radioName][i_Radio].value + "clip.tmpl"; } } self.location.href = "/vss-bin/vss_SR/masters/play?template=" + player + ";asset_id=;query=;timein_msec=;timeout_msec=;timein=;timeout=;flex_time="; } /***************************************************************************** * Function: vi_setRadioPrefs * * Description: * Uses the vi_getCookie function to retrieve the cookie value. * and then loops through the radio button values and does a * comparison to find the match. * * Arguments: * formName - name of the prefs form * radioName - name of radio buttons * cookieName - this is the account name * * Return Value: the cookie value * * Side Effects: * The radio buttons on the preferences page will reflect their * previous choice in bitrate and/or format. * *****************************************************************************/ function vi_setRadioPrefs(formName,radioName,cookieName) { var format = vi_getCookie(cookieName); var i_Radio; for ( i_Radio = 0; i_Radio < document[formName][radioName].length; i_Radio++ ) { if (format == document[formName][radioName][i_Radio].value) { document[formName][radioName][i_Radio].checked = true; } } } /***************************************************************************** * Function: vi_setDropDowns * * Description: * Loops through the arguments, then loops through the option * values in the drop-downs to compare the query field with the * selectedIndex. * * Arguments: * takes in name/value pairs for the drop-downs. * e.g. vi_setDropDowns('query1','') * * Return Value: none * * Side Effects: * The drop-down menus are set to reflect what the user previously * searched on. * *****************************************************************************/ function vi_setDropDowns() { var i_Drop; var j_Select; var fieldName; var valName; for ( i_Drop = 0; arguments.length > i_Drop ; i_Drop += 2) { fieldName = arguments[i_Drop]; valName = arguments[i_Drop + 1]; for ( j_Select = 0; j_Select < document.vasForm[fieldName].length; j_Select++ ) { if (document.vasForm[fieldName][j_Select].value == valName) { document.vasForm[fieldName].selectedIndex = j_Select; } } } } function clipDuration(clipLength){ var duration = clipLength; var length = duration.length;//how many characters in duration var duration = duration.substring(6,length);//get duration in minutes,seconds,frames var colon = duration.lastIndexOf(":", length) + 1; //find colon var period = duration.indexOf("."); //find period var seconds = duration.substring(colon,period)//capture seconds var minutes = clipLength.split(":"); minutes = minutes[minutes.length-2]; seconds = seconds; document.write(minutes + ":" + seconds); } /******************************************* * we are through the file, and do not * need to resolve any other macros * so we close the vtl_loop *******************************************/