From 17f1afb0bd78696374582262063ad4edab542beb Mon Sep 17 00:00:00 2001 From: ranyefet Date: Sun, 14 Jul 2013 13:00:08 +0300 Subject: [PATCH 001/132] Added KMC v6.0.6 JS files --- alpha/web/lib/js/kmc-full-6.0.6.js | 4247 ++++++++++++++++++++++++ alpha/web/lib/js/kmc-full-6.0.6.min.js | 6 + 2 files changed, 4253 insertions(+) create mode 100644 alpha/web/lib/js/kmc-full-6.0.6.js create mode 100644 alpha/web/lib/js/kmc-full-6.0.6.min.js diff --git a/alpha/web/lib/js/kmc-full-6.0.6.js b/alpha/web/lib/js/kmc-full-6.0.6.js new file mode 100644 index 00000000000..7443eb7803b --- /dev/null +++ b/alpha/web/lib/js/kmc-full-6.0.6.js @@ -0,0 +1,4247 @@ +/*! KMC - v6.0.6 - 2013-07-14 +* https://github.com/kaltura/KMC_V2 +* Copyright (c) 2013 Ran Yefet; Licensed GNU */ +/*! Kaltura Embed Code Generator - v1.0.6 - 2013-02-28 +* https://github.com/kaltura/EmbedCodeGenerator +* Copyright (c) 2013 Ran Yefet; Licensed MIT */ + +// lib/handlebars/base.js + +/*jshint eqnull:true*/ +this.Handlebars = {}; + +(function(Handlebars) { + +Handlebars.VERSION = "1.0.rc.2"; + +Handlebars.helpers = {}; +Handlebars.partials = {}; + +Handlebars.registerHelper = function(name, fn, inverse) { + if(inverse) { fn.not = inverse; } + this.helpers[name] = fn; +}; + +Handlebars.registerPartial = function(name, str) { + this.partials[name] = str; +}; + +Handlebars.registerHelper('helperMissing', function(arg) { + if(arguments.length === 2) { + return undefined; + } else { + throw new Error("Could not find property '" + arg + "'"); + } +}); + +var toString = Object.prototype.toString, functionType = "[object Function]"; + +Handlebars.registerHelper('blockHelperMissing', function(context, options) { + var inverse = options.inverse || function() {}, fn = options.fn; + + + var ret = ""; + var type = toString.call(context); + + if(type === functionType) { context = context.call(this); } + + if(context === true) { + return fn(this); + } else if(context === false || context == null) { + return inverse(this); + } else if(type === "[object Array]") { + if(context.length > 0) { + return Handlebars.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + return fn(context); + } +}); + +Handlebars.K = function() {}; + +Handlebars.createFrame = Object.create || function(object) { + Handlebars.K.prototype = object; + var obj = new Handlebars.K(); + Handlebars.K.prototype = null; + return obj; +}; + +Handlebars.logger = { + DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3, + + methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'}, + + // can be overridden in the host environment + log: function(level, obj) { + if (Handlebars.logger.level <= level) { + var method = Handlebars.logger.methodMap[level]; + if (typeof console !== 'undefined' && console[method]) { + console[method].call(console, obj); + } + } + } +}; + +Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); }; + +Handlebars.registerHelper('each', function(context, options) { + var fn = options.fn, inverse = options.inverse; + var i = 0, ret = "", data; + + if (options.data) { + data = Handlebars.createFrame(options.data); + } + + if(context && typeof context === 'object') { + if(context instanceof Array){ + for(var j = context.length; i": ">", + '"': """, + "'": "'", + "`": "`" + }; + + var badChars = /[&<>"'`]/g; + var possible = /[&<>"'`]/; + + var escapeChar = function(chr) { + return escape[chr] || "&"; + }; + + Handlebars.Utils = { + escapeExpression: function(string) { + // don't escape SafeStrings, since they're already safe + if (string instanceof Handlebars.SafeString) { + return string.toString(); + } else if (string == null || string === false) { + return ""; + } + + if(!possible.test(string)) { return string; } + return string.replace(badChars, escapeChar); + }, + + isEmpty: function(value) { + if (!value && value !== 0) { + return true; + } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) { + return true; + } else { + return false; + } + } + }; +})();; +// lib/handlebars/runtime.js +Handlebars.VM = { + template: function(templateSpec) { + // Just add water + var container = { + escapeExpression: Handlebars.Utils.escapeExpression, + invokePartial: Handlebars.VM.invokePartial, + programs: [], + program: function(i, fn, data) { + var programWrapper = this.programs[i]; + if(data) { + return Handlebars.VM.program(fn, data); + } else if(programWrapper) { + return programWrapper; + } else { + programWrapper = this.programs[i] = Handlebars.VM.program(fn); + return programWrapper; + } + }, + programWithDepth: Handlebars.VM.programWithDepth, + noop: Handlebars.VM.noop + }; + + return function(context, options) { + options = options || {}; + return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data); + }; + }, + + programWithDepth: function(fn, data, $depth) { + var args = Array.prototype.slice.call(arguments, 2); + + return function(context, options) { + options = options || {}; + + return fn.apply(this, [context, options.data || data].concat(args)); + }; + }, + program: function(fn, data) { + return function(context, options) { + options = options || {}; + + return fn(context, options.data || data); + }; + }, + noop: function() { return ""; }, + invokePartial: function(partial, name, context, helpers, partials, data) { + var options = { helpers: helpers, partials: partials, data: data }; + + if(partial === undefined) { + throw new Handlebars.Exception("The partial " + name + " could not be found"); + } else if(partial instanceof Function) { + return partial(context, options); + } else if (!Handlebars.compile) { + throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode"); + } else { + partials[name] = Handlebars.compile(partial, {data: data !== undefined}); + return partials[name](context, options); + } + } +}; + +Handlebars.template = Handlebars.VM.template; +; + +(function (window, Handlebars, undefined ) { +/** +* Transforms flashVars object into a string for Url or Flashvars string. +* +* @method flashVarsToUrl +* @param {Object} flashVarsObject A flashvars object +* @param {String} paramName The name parameter to add to url +* @return {String} Returns flashVars string like: &foo=bar or ¶m[foo]=bar +*/ +var flashVarsToUrl = function( flashVarsObject, paramName ) { + var params = ''; + + var paramPrefix = (paramName) ? paramName + '[' : ''; + var paramSuffix = (paramName) ? ']' : ''; + + for( var i in flashVarsObject ){ + // check for object representation of plugin config: + if( typeof flashVarsObject[i] == 'object' ){ + for( var j in flashVarsObject[i] ){ + params+= '&' + paramPrefix + encodeURIComponent( i ) + + '.' + encodeURIComponent( j ) + paramSuffix + + '=' + encodeURIComponent( flashVarsObject[i][j] ); + } + } else { + params+= '&' + paramPrefix + encodeURIComponent( i ) + paramSuffix + '=' + encodeURIComponent( flashVarsObject[i] ); + } + } + return params; +}; + +// Setup handlebars helpers +Handlebars.registerHelper('flashVarsUrl', function(flashVars) { + return flashVarsToUrl(flashVars, 'flashvars'); +}); +Handlebars.registerHelper('flashVarsString', function(flashVars) { + return flashVarsToUrl(flashVars); +}); +Handlebars.registerHelper('elAttributes', function( attributes ) { + var str = ''; + for( var i in attributes ) { + str += ' ' + i + '="' + attributes[i] + '"'; + } + return str; +}); +// Include kaltura links +Handlebars.registerHelper('kalturaLinks', function() { + if( ! this.includeKalturaLinks ) { + return ''; + } + var template = Handlebars.templates['kaltura_links']; + return template(); +}); + +Handlebars.registerHelper('seoMetadata', function() { + var template = Handlebars.templates['seo_metadata']; + return template(this); +}); + +})(this, this.Handlebars); +(function(){var a=Handlebars.template,b=Handlebars.templates=Handlebars.templates||{};b.auto=a(function(a,b,c,d,e){function p(a,b){var d="",e,f;d+='
",i=c.seoMetadata,e=i||a.seoMetadata,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"seoMetadata",{hash:{}}));if(e||e===0)d+=e;i=c.kalturaLinks,e=i||a.kalturaLinks,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"kalturaLinks",{hash:{}}));if(e||e===0)d+=e;return d+="
\n",d}function q(a,b){var d="",e;return d+="&entry_id=",i=c.entryId,e=i||a.entryId,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"entryId",{hash:{}})),d+=o(e),d}function r(a,b){var d="",e;return d+="&cache_st=",i=c.cacheSt,e=i||a.cacheSt,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"cacheSt",{hash:{}})),d+=o(e),d}c=c||a.helpers;var f="",g,h,i,j,k=this,l="function",m=c.helperMissing,n=void 0,o=this.escapeExpression;i=c.includeSeoMetadata,g=i||b.includeSeoMetadata,h=c["if"],j=k.program(1,p,e),j.hash={},j.fn=j,j.inverse=k.noop,g=h.call(b,g,j);if(g||g===0)f+=g;f+='\n
",i=c.seoMetadata,g=i||b.seoMetadata,typeof g===k?g=g.call(b,{hash:{}}):g===m&&(g=l.call(b,"seoMetadata",{hash:{}}));if(g||g===0)f+=g;i=c.kalturaLinks,g=i||b.kalturaLinks,typeof g===k?g=g.call(b,{hash:{}}):g===m&&(g=l.call(b,"kalturaLinks",{hash:{}}));if(g||g===0)f+=g;f+="
\n",f}),b.iframe=a(function(a,b,c,d,e){function p(a,b){var d="",e;return d+="&entry_id=",i=c.entryId,e=i||a.entryId,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"entryId",{hash:{}})),d+=o(e),d}c=c||a.helpers;var f="",g,h,i,j,k=this,l="function",m=c.helperMissing,n=void 0,o=this.escapeExpression;f+='",f}),b.kaltura_links=a(function(a,b,c,d,e){c=c||a.helpers;var f,g=this;return'Video Platform\nVideo Management \nVideo Solutions\nVideo Player'}),b.legacy=a(function(a,b,c,d,e){function p(a,b){var d="",e;return d+='\n',d}function q(a,b){var d="",e;return d+='\n \n \n \n \n \n \n ',d}c=c||a.helpers;var f="",g,h,i,j,k=this,l="function",m=c.helperMissing,n=void 0,o=this.escapeExpression;i=c.includeHtml5Library,g=i||b.includeHtml5Library,h=c["if"],j=k.program(1,p,e),j.hash={},j.fn=j,j.inverse=k.noop,g=h.call(b,g,j);if(g||g===0)f+=g;f+='\n \n \n \n \n \n \n ',i=c.includeSeoMetadata,g=i||b.includeSeoMetadata,h=c["if"],j=k.program(3,q,e),j.hash={},j.fn=j,j.inverse=k.noop,g=h.call(b,g,j);if(g||g===0)f+=g;i=c.kalturaLinks,g=i||b.kalturaLinks,typeof g===l?g=g.call(b,{hash:{}}):g===n&&(g=m.call(b,"kalturaLinks",{hash:{}}));if(g||g===0)f+=g;return f+="\n",f}),b.seo_metadata=a(function(a,b,c,d,e){function o(a,b){var d="",e;return d+='\n\n\n\n\n\n\n',d}c=c||a.helpers;var f,g,h,i,j=this,k="function",l=c.helperMissing,m=void 0,n=this.escapeExpression;return h=c.includeSeoMetadata,f=h||b.includeSeoMetadata,g=c["if"],i=j.program(1,o,e),i.hash={},i.fn=i,i.inverse=j.noop,f=g.call(b,f,i),f||f===0?f:""})})() +// Add indexOf to array object +if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = 0; + if (arguments.length > 1) { + n = Number(arguments[1]); + if (n !== n) { // shortcut for verifying if it's NaN + n = 0; + } else if (n !== 0 && n !== Infinity && n !== -Infinity) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + if (n >= len) { + return -1; + } + var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); + for (; k < len; k++) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + }; +} +// Add keys for Object +if (!Object.keys) { + Object.keys = (function () { + var hasOwnProperty = Object.prototype.hasOwnProperty, + hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'), + dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ], + dontEnumsLength = dontEnums.length; + + return function (obj) { + if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) { + throw new TypeError('Object.keys called on non-object'); + } + + var result = []; + + for (var prop in obj) { + if (hasOwnProperty.call(obj, prop)) { + result.push(prop); + } + } + + if (hasDontEnumBug) { + for (var i=0; i < dontEnumsLength; i++) { + if (hasOwnProperty.call(obj, dontEnums[i])) { + result.push(dontEnums[i]); + } + } + } + return result; + }; + })(); +} +(function( window, undefined ) { +/** +* Kaltura Embed Code Generator +* Used to generate different type of embed codes +* Depended on Handlebars ( http://handlebarsjs.com/ ) +* +* @class EmbedCodeGenerator +* @constructor +*/ +var EmbedCodeGenerator = function( options ) { + this.init( options ); +}; + +EmbedCodeGenerator.prototype = { + + types: ['auto', 'dynamic', 'thumb', 'iframe', 'legacy'], + required: ['widgetId', 'partnerId', 'uiConfId'], + + defaults: { + /** + * Embed code type to generate + * Can we one of: ['auto', 'dynamic', 'thumb', 'iframe', 'legacy'] + * + * @property embedType + * @type {String} + * @default "auto" + */ + embedType: 'auto', + /** + * The Player element Id / Name that will be used for embed code + * + * @property playerId + * @type {String} + * @default "kaltura_player" + */ + playerId: 'kaltura_player', + /** + * Embed HTTP protocol to use + * Can we one of: ['http', 'https'] + * + * @property protocol + * @type {String} + * @default "http" + */ + protocol: 'http', + /** + * Host for loading html5 library & kdp swf + * + * @property host + * @type {String} + * @default "www.kaltura.com" + */ + host: 'www.kaltura.com', + /** + * Secured host for loading html5 library & kdp swf + * Used if protocol is: 'https' + * + * @property securedHost + * @type {String} + * @default "www.kaltura.com" + */ + securedHost: 'www.kaltura.com', + /** + * Kaltura Widget Id + * + * @property widgetId + * @type {String} + * @default "_{partnerId}" + */ + widgetId: null, + /** + * Kaltura Partner Id + * + * @property partnerId + * @type {Number} + * @default null, + */ + partnerId: null, + /** + * Add cacheSt parameter to bust cache + * Should be unix timestamp of future time + * + * @property cacheSt + * @type {Number} + * @default null, + */ + cacheSt: null, + /** + * Kaltura UiConf Id + * + * @property uiConfId + * @type {Number} + * @default null, + */ + uiConfId: null, + /** + * Kaltura Entry Id + * + * @property entryId + * @type {String} + * @default null, + */ + entryId: null, + /** + * Entry Object similar to: + * { + * name: 'Foo', + * description: 'Bar', + * thumbUrl: 'http://cdnbakmi.kaltura.com/thumbnail/...' + * } + * + * @property entryMeta + * @type {Object} + * @default {}, + */ + entryMeta: {}, + /** + * Sets Player Width + * + * @property width + * @type {Number} + * @default 400, + */ + width: 400, + /** + * Sets Player Height + * + * @property height + * @type {Number} + * @default 330, + */ + height: 330, + /** + * Adds additonal attributes to embed code. + * Example: + * { + * "class": "player" + * } + * + * @property attributes + * @type {Object} + * @default {}, + */ + attributes: {}, + /** + * Adds flashVars to player + * Example: + * { + * "autoPlay": "true" + * } + * + * @property flashVars + * @type {Object} + * @default {}, + */ + flashVars: {}, + /** + * Include Kaltura SEO links to embed code + * + * @property includeKalturaLinks + * @type {Boolean} + * @default true, + */ + includeKalturaLinks: true, + /** + * Include Entry Seo Metadata + * Metadata is taken from {entryMeta} object + * + * @property includeSeoMetadata + * @type {Boolean} + * @default false, + */ + includeSeoMetadata: false, + /** + * Include HTML5 library script + * + * @property includeHtml5Library + * @type {Boolean} + * @default true, + */ + includeHtml5Library: true + }, + /** + * Merge two object together + * + * @method extend + * @param {Object} destination object to merge into + * @param {Object} sourece object to merge from + * @return {Object} Merged object + */ + extend: function(destination, source) { + for (var property in source) { + if (source.hasOwnProperty(property) && !destination.hasOwnProperty(property)) { + destination[property] = source[property]; + } + } + return destination; + }, + /** + * Check if property is null + * + * @method isNull + * @param {Any} property some var + * @return {Boolean} + */ + isNull: function( property ) { + if (property.length && property.length > 0) { + return false; + } + if (property.length && property.length === 0) { + return true; + } + if( typeof property === 'object' ) { + return (Object.keys(property).length > 0) ? false : true; + } + return !property; + }, + /** + * Set default options to EmbedCodeGenerator instance + * + * @method init + * @param {Object} options Configuration object based on defaults object + * @return {Object} Returns the current instance + */ + init: function( options ) { + + options = options || {}; + + var defaults = this.defaults; + + // Make sure Handlebars is available + if( typeof Handlebars === undefined ) { + throw 'Handlebars is not defined, please include Handlebars.js before this script'; + } + + // Merge options with defaults + if( typeof options === 'object' ) { + this.options = this.extend(options, this.defaults); + } + // Set widgetId to partnerId if not defined + if( ! this.config('widgetId') && this.config('partnerId') ) { + this.config('widgetId', '_' + this.config('partnerId')); + } + + return this; + }, + /** + * Get or Set default configuration + * + * @method config + * @param {String} key configuration property name + * @param {Any} value to set + * @return {Mixed} Return the value for the key, configuration object or null + */ + config: function( key, val ) { + // Used as getter + if( val === undefined && typeof key === 'string' && this.options.hasOwnProperty(key) ) { + return this.options[ key ]; + } + // Get all options + if( key === undefined && val === undefined ) { + return this.options; + } + // Used as setter + if( typeof key === 'string' && val !== undefined ) { + this.options[ key ] = val; + } + return null; + }, + /** + * Check if required parameters are missing + * + * @method checkRequiredParams + * @param {Object} Configuration object + * @return throws exception if missing parameters + */ + checkRequiredParams: function( params ) { + var requiredLength = this.required.length, + i = 0; + // Check for required configuration + for(i; i= 7) { + this.setupTypeNumber(test); + } + + if (this.dataCache == null) { + this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList); + } + + this.mapData(this.dataCache, maskPattern); + }, + + setupPositionProbePattern : function(row, col) { + + for (var r = -1; r <= 7; r++) { + + if (row + r <= -1 || this.moduleCount <= row + r) continue; + + for (var c = -1; c <= 7; c++) { + + if (col + c <= -1 || this.moduleCount <= col + c) continue; + + if ( (0 <= r && r <= 6 && (c == 0 || c == 6) ) + || (0 <= c && c <= 6 && (r == 0 || r == 6) ) + || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + }, + + getBestMaskPattern : function() { + + var minLostPoint = 0; + var pattern = 0; + + for (var i = 0; i < 8; i++) { + + this.makeImpl(true, i); + + var lostPoint = QRUtil.getLostPoint(this); + + if (i == 0 || minLostPoint > lostPoint) { + minLostPoint = lostPoint; + pattern = i; + } + } + + return pattern; + }, + + createMovieClip : function(target_mc, instance_name, depth) { + + var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth); + var cs = 1; + + this.make(); + + for (var row = 0; row < this.modules.length; row++) { + + var y = row * cs; + + for (var col = 0; col < this.modules[row].length; col++) { + + var x = col * cs; + var dark = this.modules[row][col]; + + if (dark) { + qr_mc.beginFill(0, 100); + qr_mc.moveTo(x, y); + qr_mc.lineTo(x + cs, y); + qr_mc.lineTo(x + cs, y + cs); + qr_mc.lineTo(x, y + cs); + qr_mc.endFill(); + } + } + } + + return qr_mc; + }, + + setupTimingPattern : function() { + + for (var r = 8; r < this.moduleCount - 8; r++) { + if (this.modules[r][6] != null) { + continue; + } + this.modules[r][6] = (r % 2 == 0); + } + + for (var c = 8; c < this.moduleCount - 8; c++) { + if (this.modules[6][c] != null) { + continue; + } + this.modules[6][c] = (c % 2 == 0); + } + }, + + setupPositionAdjustPattern : function() { + + var pos = QRUtil.getPatternPosition(this.typeNumber); + + for (var i = 0; i < pos.length; i++) { + + for (var j = 0; j < pos.length; j++) { + + var row = pos[i]; + var col = pos[j]; + + if (this.modules[row][col] != null) { + continue; + } + + for (var r = -2; r <= 2; r++) { + + for (var c = -2; c <= 2; c++) { + + if (r == -2 || r == 2 || c == -2 || c == 2 + || (r == 0 && c == 0) ) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + } + } + }, + + setupTypeNumber : function(test) { + + var bits = QRUtil.getBCHTypeNumber(this.typeNumber); + + for (var i = 0; i < 18; i++) { + var mod = (!test && ( (bits >> i) & 1) == 1); + this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod; + } + + for (var i = 0; i < 18; i++) { + var mod = (!test && ( (bits >> i) & 1) == 1); + this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod; + } + }, + + setupTypeInfo : function(test, maskPattern) { + + var data = (this.errorCorrectLevel << 3) | maskPattern; + var bits = QRUtil.getBCHTypeInfo(data); + + // vertical + for (var i = 0; i < 15; i++) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 6) { + this.modules[i][8] = mod; + } else if (i < 8) { + this.modules[i + 1][8] = mod; + } else { + this.modules[this.moduleCount - 15 + i][8] = mod; + } + } + + // horizontal + for (var i = 0; i < 15; i++) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 8) { + this.modules[8][this.moduleCount - i - 1] = mod; + } else if (i < 9) { + this.modules[8][15 - i - 1 + 1] = mod; + } else { + this.modules[8][15 - i - 1] = mod; + } + } + + // fixed module + this.modules[this.moduleCount - 8][8] = (!test); + + }, + + mapData : function(data, maskPattern) { + + var inc = -1; + var row = this.moduleCount - 1; + var bitIndex = 7; + var byteIndex = 0; + + for (var col = this.moduleCount - 1; col > 0; col -= 2) { + + if (col == 6) col--; + + while (true) { + + for (var c = 0; c < 2; c++) { + + if (this.modules[row][col - c] == null) { + + var dark = false; + + if (byteIndex < data.length) { + dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1); + } + + var mask = QRUtil.getMask(maskPattern, row, col - c); + + if (mask) { + dark = !dark; + } + + this.modules[row][col - c] = dark; + bitIndex--; + + if (bitIndex == -1) { + byteIndex++; + bitIndex = 7; + } + } + } + + row += inc; + + if (row < 0 || this.moduleCount <= row) { + row -= inc; + inc = -inc; + break; + } + } + } + + } + +}; + +QRCode.PAD0 = 0xEC; +QRCode.PAD1 = 0x11; + +QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) { + + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel); + + var buffer = new QRBitBuffer(); + + for (var i = 0; i < dataList.length; i++) { + var data = dataList[i]; + buffer.put(data.mode, 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) ); + data.write(buffer); + } + + // calc num max data. + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalDataCount += rsBlocks[i].dataCount; + } + + if (buffer.getLengthInBits() > totalDataCount * 8) { + throw new Error("code length overflow. (" + + buffer.getLengthInBits() + + ">" + + totalDataCount * 8 + + ")"); + } + + // end code + if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) { + buffer.put(0, 4); + } + + // padding + while (buffer.getLengthInBits() % 8 != 0) { + buffer.putBit(false); + } + + // padding + while (true) { + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD0, 8); + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD1, 8); + } + + return QRCode.createBytes(buffer, rsBlocks); +} + +QRCode.createBytes = function(buffer, rsBlocks) { + + var offset = 0; + + var maxDcCount = 0; + var maxEcCount = 0; + + var dcdata = new Array(rsBlocks.length); + var ecdata = new Array(rsBlocks.length); + + for (var r = 0; r < rsBlocks.length; r++) { + + var dcCount = rsBlocks[r].dataCount; + var ecCount = rsBlocks[r].totalCount - dcCount; + + maxDcCount = Math.max(maxDcCount, dcCount); + maxEcCount = Math.max(maxEcCount, ecCount); + + dcdata[r] = new Array(dcCount); + + for (var i = 0; i < dcdata[r].length; i++) { + dcdata[r][i] = 0xff & buffer.buffer[i + offset]; + } + offset += dcCount; + + var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); + var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1); + + var modPoly = rawPoly.mod(rsPoly); + ecdata[r] = new Array(rsPoly.getLength() - 1); + for (var i = 0; i < ecdata[r].length; i++) { + var modIndex = i + modPoly.getLength() - ecdata[r].length; + ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0; + } + + } + + var totalCodeCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalCodeCount += rsBlocks[i].totalCount; + } + + var data = new Array(totalCodeCount); + var index = 0; + + for (var i = 0; i < maxDcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < dcdata[r].length) { + data[index++] = dcdata[r][i]; + } + } + } + + for (var i = 0; i < maxEcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < ecdata[r].length) { + data[index++] = ecdata[r][i]; + } + } + } + + return data; + +} + +//--------------------------------------------------------------------- +// QRMode +//--------------------------------------------------------------------- + +var QRMode = { + MODE_NUMBER : 1 << 0, + MODE_ALPHA_NUM : 1 << 1, + MODE_8BIT_BYTE : 1 << 2, + MODE_KANJI : 1 << 3 +}; + +//--------------------------------------------------------------------- +// QRErrorCorrectLevel +//--------------------------------------------------------------------- + +var QRErrorCorrectLevel = { + L : 1, + M : 0, + Q : 3, + H : 2 +}; + +//--------------------------------------------------------------------- +// QRMaskPattern +//--------------------------------------------------------------------- + +var QRMaskPattern = { + PATTERN000 : 0, + PATTERN001 : 1, + PATTERN010 : 2, + PATTERN011 : 3, + PATTERN100 : 4, + PATTERN101 : 5, + PATTERN110 : 6, + PATTERN111 : 7 +}; + +//--------------------------------------------------------------------- +// QRUtil +//--------------------------------------------------------------------- + +var QRUtil = { + + PATTERN_POSITION_TABLE : [ + [], + [6, 18], + [6, 22], + [6, 26], + [6, 30], + [6, 34], + [6, 22, 38], + [6, 24, 42], + [6, 26, 46], + [6, 28, 50], + [6, 30, 54], + [6, 32, 58], + [6, 34, 62], + [6, 26, 46, 66], + [6, 26, 48, 70], + [6, 26, 50, 74], + [6, 30, 54, 78], + [6, 30, 56, 82], + [6, 30, 58, 86], + [6, 34, 62, 90], + [6, 28, 50, 72, 94], + [6, 26, 50, 74, 98], + [6, 30, 54, 78, 102], + [6, 28, 54, 80, 106], + [6, 32, 58, 84, 110], + [6, 30, 58, 86, 114], + [6, 34, 62, 90, 118], + [6, 26, 50, 74, 98, 122], + [6, 30, 54, 78, 102, 126], + [6, 26, 52, 78, 104, 130], + [6, 30, 56, 82, 108, 134], + [6, 34, 60, 86, 112, 138], + [6, 30, 58, 86, 114, 142], + [6, 34, 62, 90, 118, 146], + [6, 30, 54, 78, 102, 126, 150], + [6, 24, 50, 76, 102, 128, 154], + [6, 28, 54, 80, 106, 132, 158], + [6, 32, 58, 84, 110, 136, 162], + [6, 26, 54, 82, 110, 138, 166], + [6, 30, 58, 86, 114, 142, 170] + ], + + G15 : (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0), + G18 : (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0), + G15_MASK : (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1), + + getBCHTypeInfo : function(data) { + var d = data << 10; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) { + d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) ); + } + return ( (data << 10) | d) ^ QRUtil.G15_MASK; + }, + + getBCHTypeNumber : function(data) { + var d = data << 12; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) { + d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) ); + } + return (data << 12) | d; + }, + + getBCHDigit : function(data) { + + var digit = 0; + + while (data != 0) { + digit++; + data >>>= 1; + } + + return digit; + }, + + getPatternPosition : function(typeNumber) { + return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]; + }, + + getMask : function(maskPattern, i, j) { + + switch (maskPattern) { + + case QRMaskPattern.PATTERN000 : return (i + j) % 2 == 0; + case QRMaskPattern.PATTERN001 : return i % 2 == 0; + case QRMaskPattern.PATTERN010 : return j % 3 == 0; + case QRMaskPattern.PATTERN011 : return (i + j) % 3 == 0; + case QRMaskPattern.PATTERN100 : return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; + case QRMaskPattern.PATTERN101 : return (i * j) % 2 + (i * j) % 3 == 0; + case QRMaskPattern.PATTERN110 : return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; + case QRMaskPattern.PATTERN111 : return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; + + default : + throw new Error("bad maskPattern:" + maskPattern); + } + }, + + getErrorCorrectPolynomial : function(errorCorrectLength) { + + var a = new QRPolynomial([1], 0); + + for (var i = 0; i < errorCorrectLength; i++) { + a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0) ); + } + + return a; + }, + + getLengthInBits : function(mode, type) { + + if (1 <= type && type < 10) { + + // 1 - 9 + + switch(mode) { + case QRMode.MODE_NUMBER : return 10; + case QRMode.MODE_ALPHA_NUM : return 9; + case QRMode.MODE_8BIT_BYTE : return 8; + case QRMode.MODE_KANJI : return 8; + default : + throw new Error("mode:" + mode); + } + + } else if (type < 27) { + + // 10 - 26 + + switch(mode) { + case QRMode.MODE_NUMBER : return 12; + case QRMode.MODE_ALPHA_NUM : return 11; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 10; + default : + throw new Error("mode:" + mode); + } + + } else if (type < 41) { + + // 27 - 40 + + switch(mode) { + case QRMode.MODE_NUMBER : return 14; + case QRMode.MODE_ALPHA_NUM : return 13; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 12; + default : + throw new Error("mode:" + mode); + } + + } else { + throw new Error("type:" + type); + } + }, + + getLostPoint : function(qrCode) { + + var moduleCount = qrCode.getModuleCount(); + + var lostPoint = 0; + + // LEVEL1 + + for (var row = 0; row < moduleCount; row++) { + + for (var col = 0; col < moduleCount; col++) { + + var sameCount = 0; + var dark = qrCode.isDark(row, col); + + for (var r = -1; r <= 1; r++) { + + if (row + r < 0 || moduleCount <= row + r) { + continue; + } + + for (var c = -1; c <= 1; c++) { + + if (col + c < 0 || moduleCount <= col + c) { + continue; + } + + if (r == 0 && c == 0) { + continue; + } + + if (dark == qrCode.isDark(row + r, col + c) ) { + sameCount++; + } + } + } + + if (sameCount > 5) { + lostPoint += (3 + sameCount - 5); + } + } + } + + // LEVEL2 + + for (var row = 0; row < moduleCount - 1; row++) { + for (var col = 0; col < moduleCount - 1; col++) { + var count = 0; + if (qrCode.isDark(row, col ) ) count++; + if (qrCode.isDark(row + 1, col ) ) count++; + if (qrCode.isDark(row, col + 1) ) count++; + if (qrCode.isDark(row + 1, col + 1) ) count++; + if (count == 0 || count == 4) { + lostPoint += 3; + } + } + } + + // LEVEL3 + + for (var row = 0; row < moduleCount; row++) { + for (var col = 0; col < moduleCount - 6; col++) { + if (qrCode.isDark(row, col) + && !qrCode.isDark(row, col + 1) + && qrCode.isDark(row, col + 2) + && qrCode.isDark(row, col + 3) + && qrCode.isDark(row, col + 4) + && !qrCode.isDark(row, col + 5) + && qrCode.isDark(row, col + 6) ) { + lostPoint += 40; + } + } + } + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount - 6; row++) { + if (qrCode.isDark(row, col) + && !qrCode.isDark(row + 1, col) + && qrCode.isDark(row + 2, col) + && qrCode.isDark(row + 3, col) + && qrCode.isDark(row + 4, col) + && !qrCode.isDark(row + 5, col) + && qrCode.isDark(row + 6, col) ) { + lostPoint += 40; + } + } + } + + // LEVEL4 + + var darkCount = 0; + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount; row++) { + if (qrCode.isDark(row, col) ) { + darkCount++; + } + } + } + + var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; + lostPoint += ratio * 10; + + return lostPoint; + } + +}; + + +//--------------------------------------------------------------------- +// QRMath +//--------------------------------------------------------------------- + +var QRMath = { + + glog : function(n) { + + if (n < 1) { + throw new Error("glog(" + n + ")"); + } + + return QRMath.LOG_TABLE[n]; + }, + + gexp : function(n) { + + while (n < 0) { + n += 255; + } + + while (n >= 256) { + n -= 255; + } + + return QRMath.EXP_TABLE[n]; + }, + + EXP_TABLE : new Array(256), + + LOG_TABLE : new Array(256) + +}; + +for (var i = 0; i < 8; i++) { + QRMath.EXP_TABLE[i] = 1 << i; +} +for (var i = 8; i < 256; i++) { + QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] + ^ QRMath.EXP_TABLE[i - 5] + ^ QRMath.EXP_TABLE[i - 6] + ^ QRMath.EXP_TABLE[i - 8]; +} +for (var i = 0; i < 255; i++) { + QRMath.LOG_TABLE[QRMath.EXP_TABLE[i] ] = i; +} + +//--------------------------------------------------------------------- +// QRPolynomial +//--------------------------------------------------------------------- + +function QRPolynomial(num, shift) { + + if (num.length == undefined) { + throw new Error(num.length + "/" + shift); + } + + var offset = 0; + + while (offset < num.length && num[offset] == 0) { + offset++; + } + + this.num = new Array(num.length - offset + shift); + for (var i = 0; i < num.length - offset; i++) { + this.num[i] = num[i + offset]; + } +} + +QRPolynomial.prototype = { + + get : function(index) { + return this.num[index]; + }, + + getLength : function() { + return this.num.length; + }, + + multiply : function(e) { + + var num = new Array(this.getLength() + e.getLength() - 1); + + for (var i = 0; i < this.getLength(); i++) { + for (var j = 0; j < e.getLength(); j++) { + num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i) ) + QRMath.glog(e.get(j) ) ); + } + } + + return new QRPolynomial(num, 0); + }, + + mod : function(e) { + + if (this.getLength() - e.getLength() < 0) { + return this; + } + + var ratio = QRMath.glog(this.get(0) ) - QRMath.glog(e.get(0) ); + + var num = new Array(this.getLength() ); + + for (var i = 0; i < this.getLength(); i++) { + num[i] = this.get(i); + } + + for (var i = 0; i < e.getLength(); i++) { + num[i] ^= QRMath.gexp(QRMath.glog(e.get(i) ) + ratio); + } + + // recursive call + return new QRPolynomial(num, 0).mod(e); + } +}; + +//--------------------------------------------------------------------- +// QRRSBlock +//--------------------------------------------------------------------- + +function QRRSBlock(totalCount, dataCount) { + this.totalCount = totalCount; + this.dataCount = dataCount; +} + +QRRSBlock.RS_BLOCK_TABLE = [ + + // L + // M + // Q + // H + + // 1 + [1, 26, 19], + [1, 26, 16], + [1, 26, 13], + [1, 26, 9], + + // 2 + [1, 44, 34], + [1, 44, 28], + [1, 44, 22], + [1, 44, 16], + + // 3 + [1, 70, 55], + [1, 70, 44], + [2, 35, 17], + [2, 35, 13], + + // 4 + [1, 100, 80], + [2, 50, 32], + [2, 50, 24], + [4, 25, 9], + + // 5 + [1, 134, 108], + [2, 67, 43], + [2, 33, 15, 2, 34, 16], + [2, 33, 11, 2, 34, 12], + + // 6 + [2, 86, 68], + [4, 43, 27], + [4, 43, 19], + [4, 43, 15], + + // 7 + [2, 98, 78], + [4, 49, 31], + [2, 32, 14, 4, 33, 15], + [4, 39, 13, 1, 40, 14], + + // 8 + [2, 121, 97], + [2, 60, 38, 2, 61, 39], + [4, 40, 18, 2, 41, 19], + [4, 40, 14, 2, 41, 15], + + // 9 + [2, 146, 116], + [3, 58, 36, 2, 59, 37], + [4, 36, 16, 4, 37, 17], + [4, 36, 12, 4, 37, 13], + + // 10 + [2, 86, 68, 2, 87, 69], + [4, 69, 43, 1, 70, 44], + [6, 43, 19, 2, 44, 20], + [6, 43, 15, 2, 44, 16], + + // 11 + [4, 101, 81], + [1, 80, 50, 4, 81, 51], + [4, 50, 22, 4, 51, 23], + [3, 36, 12, 8, 37, 13], + + // 12 + [2, 116, 92, 2, 117, 93], + [6, 58, 36, 2, 59, 37], + [4, 46, 20, 6, 47, 21], + [7, 42, 14, 4, 43, 15], + + // 13 + [4, 133, 107], + [8, 59, 37, 1, 60, 38], + [8, 44, 20, 4, 45, 21], + [12, 33, 11, 4, 34, 12], + + // 14 + [3, 145, 115, 1, 146, 116], + [4, 64, 40, 5, 65, 41], + [11, 36, 16, 5, 37, 17], + [11, 36, 12, 5, 37, 13], + + // 15 + [5, 109, 87, 1, 110, 88], + [5, 65, 41, 5, 66, 42], + [5, 54, 24, 7, 55, 25], + [11, 36, 12], + + // 16 + [5, 122, 98, 1, 123, 99], + [7, 73, 45, 3, 74, 46], + [15, 43, 19, 2, 44, 20], + [3, 45, 15, 13, 46, 16], + + // 17 + [1, 135, 107, 5, 136, 108], + [10, 74, 46, 1, 75, 47], + [1, 50, 22, 15, 51, 23], + [2, 42, 14, 17, 43, 15], + + // 18 + [5, 150, 120, 1, 151, 121], + [9, 69, 43, 4, 70, 44], + [17, 50, 22, 1, 51, 23], + [2, 42, 14, 19, 43, 15], + + // 19 + [3, 141, 113, 4, 142, 114], + [3, 70, 44, 11, 71, 45], + [17, 47, 21, 4, 48, 22], + [9, 39, 13, 16, 40, 14], + + // 20 + [3, 135, 107, 5, 136, 108], + [3, 67, 41, 13, 68, 42], + [15, 54, 24, 5, 55, 25], + [15, 43, 15, 10, 44, 16], + + // 21 + [4, 144, 116, 4, 145, 117], + [17, 68, 42], + [17, 50, 22, 6, 51, 23], + [19, 46, 16, 6, 47, 17], + + // 22 + [2, 139, 111, 7, 140, 112], + [17, 74, 46], + [7, 54, 24, 16, 55, 25], + [34, 37, 13], + + // 23 + [4, 151, 121, 5, 152, 122], + [4, 75, 47, 14, 76, 48], + [11, 54, 24, 14, 55, 25], + [16, 45, 15, 14, 46, 16], + + // 24 + [6, 147, 117, 4, 148, 118], + [6, 73, 45, 14, 74, 46], + [11, 54, 24, 16, 55, 25], + [30, 46, 16, 2, 47, 17], + + // 25 + [8, 132, 106, 4, 133, 107], + [8, 75, 47, 13, 76, 48], + [7, 54, 24, 22, 55, 25], + [22, 45, 15, 13, 46, 16], + + // 26 + [10, 142, 114, 2, 143, 115], + [19, 74, 46, 4, 75, 47], + [28, 50, 22, 6, 51, 23], + [33, 46, 16, 4, 47, 17], + + // 27 + [8, 152, 122, 4, 153, 123], + [22, 73, 45, 3, 74, 46], + [8, 53, 23, 26, 54, 24], + [12, 45, 15, 28, 46, 16], + + // 28 + [3, 147, 117, 10, 148, 118], + [3, 73, 45, 23, 74, 46], + [4, 54, 24, 31, 55, 25], + [11, 45, 15, 31, 46, 16], + + // 29 + [7, 146, 116, 7, 147, 117], + [21, 73, 45, 7, 74, 46], + [1, 53, 23, 37, 54, 24], + [19, 45, 15, 26, 46, 16], + + // 30 + [5, 145, 115, 10, 146, 116], + [19, 75, 47, 10, 76, 48], + [15, 54, 24, 25, 55, 25], + [23, 45, 15, 25, 46, 16], + + // 31 + [13, 145, 115, 3, 146, 116], + [2, 74, 46, 29, 75, 47], + [42, 54, 24, 1, 55, 25], + [23, 45, 15, 28, 46, 16], + + // 32 + [17, 145, 115], + [10, 74, 46, 23, 75, 47], + [10, 54, 24, 35, 55, 25], + [19, 45, 15, 35, 46, 16], + + // 33 + [17, 145, 115, 1, 146, 116], + [14, 74, 46, 21, 75, 47], + [29, 54, 24, 19, 55, 25], + [11, 45, 15, 46, 46, 16], + + // 34 + [13, 145, 115, 6, 146, 116], + [14, 74, 46, 23, 75, 47], + [44, 54, 24, 7, 55, 25], + [59, 46, 16, 1, 47, 17], + + // 35 + [12, 151, 121, 7, 152, 122], + [12, 75, 47, 26, 76, 48], + [39, 54, 24, 14, 55, 25], + [22, 45, 15, 41, 46, 16], + + // 36 + [6, 151, 121, 14, 152, 122], + [6, 75, 47, 34, 76, 48], + [46, 54, 24, 10, 55, 25], + [2, 45, 15, 64, 46, 16], + + // 37 + [17, 152, 122, 4, 153, 123], + [29, 74, 46, 14, 75, 47], + [49, 54, 24, 10, 55, 25], + [24, 45, 15, 46, 46, 16], + + // 38 + [4, 152, 122, 18, 153, 123], + [13, 74, 46, 32, 75, 47], + [48, 54, 24, 14, 55, 25], + [42, 45, 15, 32, 46, 16], + + // 39 + [20, 147, 117, 4, 148, 118], + [40, 75, 47, 7, 76, 48], + [43, 54, 24, 22, 55, 25], + [10, 45, 15, 67, 46, 16], + + // 40 + [19, 148, 118, 6, 149, 119], + [18, 75, 47, 31, 76, 48], + [34, 54, 24, 34, 55, 25], + [20, 45, 15, 61, 46, 16] +]; + +QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) { + + var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel); + + if (rsBlock == undefined) { + throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel); + } + + var length = rsBlock.length / 3; + + var list = new Array(); + + for (var i = 0; i < length; i++) { + + var count = rsBlock[i * 3 + 0]; + var totalCount = rsBlock[i * 3 + 1]; + var dataCount = rsBlock[i * 3 + 2]; + + for (var j = 0; j < count; j++) { + list.push(new QRRSBlock(totalCount, dataCount) ); + } + } + + return list; +} + +QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) { + + switch(errorCorrectLevel) { + case QRErrorCorrectLevel.L : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; + case QRErrorCorrectLevel.M : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; + case QRErrorCorrectLevel.Q : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; + case QRErrorCorrectLevel.H : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; + default : + return undefined; + } +} + +//--------------------------------------------------------------------- +// QRBitBuffer +//--------------------------------------------------------------------- + +function QRBitBuffer() { + this.buffer = new Array(); + this.length = 0; +} + +QRBitBuffer.prototype = { + + get : function(index) { + var bufIndex = Math.floor(index / 8); + return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1; + }, + + put : function(num, length) { + for (var i = 0; i < length; i++) { + this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1); + } + }, + + getLengthInBits : function() { + return this.length; + }, + + putBit : function(bit) { + + var bufIndex = Math.floor(this.length / 8); + if (this.buffer.length <= bufIndex) { + this.buffer.push(0); + } + + if (bit) { + this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) ); + } + + this.length++; + } +}; + // if options is string, + if( typeof options === 'string' ){ + options = { text: options }; + } + + // set default values + // typeNumber < 1 for automatic calculation + options = $.extend( {}, { + render : "canvas", + width : 256, + height : 256, + typeNumber : -1, + correctLevel : QRErrorCorrectLevel.H, + background : "#ffffff", + foreground : "#000000" + }, options); + + var createCanvas = function(){ + // create the qrcode itself + var qrcode = new QRCode(options.typeNumber, options.correctLevel); + qrcode.addData(options.text); + qrcode.make(); + + // create canvas element + var canvas = document.createElement('canvas'); + canvas.width = options.width; + canvas.height = options.height; + var ctx = canvas.getContext('2d'); + + // compute tileW/tileH based on options.width/options.height + var tileW = options.width / qrcode.getModuleCount(); + var tileH = options.height / qrcode.getModuleCount(); + + // draw in the canvas + for( var row = 0; row < qrcode.getModuleCount(); row++ ){ + for( var col = 0; col < qrcode.getModuleCount(); col++ ){ + ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background; + var w = (Math.ceil((col+1)*tileW) - Math.floor(col*tileW)); + var h = (Math.ceil((row+1)*tileW) - Math.floor(row*tileW)); + ctx.fillRect(Math.round(col*tileW),Math.round(row*tileH), w, h); + } + } + // return just built canvas + return canvas; + } + + // from Jon-Carlos Rivera (https://github.com/imbcmdth) + var createTable = function(){ + // create the qrcode itself + var qrcode = new QRCode(options.typeNumber, options.correctLevel); + qrcode.addData(options.text); + qrcode.make(); + + // create table element + var $table = $('
') + .css("width", options.width+"px") + .css("height", options.height+"px") + .css("border", "0px") + .css("border-collapse", "collapse") + .css('background-color', options.background); + + // compute tileS percentage + var tileW = options.width / qrcode.getModuleCount(); + var tileH = options.height / qrcode.getModuleCount(); + + // draw in the table + for(var row = 0; row < qrcode.getModuleCount(); row++ ){ + var $row = $('').css('height', tileH+"px").appendTo($table); + + for(var col = 0; col < qrcode.getModuleCount(); col++ ){ + $('') + .css('width', tileW+"px") + .css('background-color', qrcode.isDark(row, col) ? options.foreground : options.background) + .appendTo($row); + } + } + // return just built canvas + return $table; + } + + + return this.each(function(){ + var element = options.render == "canvas" ? createCanvas() : createTable(); + $(element).appendTo(this); + }); + }; +})( jQuery ); + +// jQuery.XDomainRequest.js +// Author: Jason Moon - @JSONMOON +// IE8+ +if ( window.XDomainRequest ) { + jQuery.ajaxTransport(function( s ) { + if ( s.crossDomain && s.async ) { + if ( s.timeout ) { + s.xdrTimeout = s.timeout; + delete s.timeout; + } + var xdr; + return { + send: function( _, complete ) { + function callback( status, statusText, responses, responseHeaders ) { + xdr.onload = xdr.onerror = xdr.ontimeout = jQuery.noop; + xdr = undefined; + complete( status, statusText, responses, responseHeaders ); + } + xdr = new XDomainRequest(); + xdr.onload = function() { + callback( 200, "OK", { text: xdr.responseText }, "Content-Type: " + xdr.contentType ); + }; + xdr.onerror = function() { + callback( 404, "Not Found" ); + }; + xdr.onprogress = jQuery.noop; + xdr.ontimeout = function() { + callback( 0, "timeout" ); + }; + xdr.timeout = s.xdrTimeout || Number.MAX_VALUE; + xdr.open( s.type, s.url ); + xdr.send( ( s.hasContent && s.data ) || null ); + }, + abort: function() { + if ( xdr ) { + xdr.onerror = jQuery.noop; + xdr.abort(); + } + } + }; + } + }); +} +/*! + * zeroclipboard + * The Zero Clipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie, and a JavaScript interface. + * Copyright 2012 Jon Rohan, James M. Greene, . + * Released under the MIT license + * http://jonrohan.github.com/ZeroClipboard/ + * v1.1.7 + */(function() { + "use strict"; + var _getStyle = function(el, prop) { + var y = el.style[prop]; + if (el.currentStyle) y = el.currentStyle[prop]; else if (window.getComputedStyle) y = document.defaultView.getComputedStyle(el, null).getPropertyValue(prop); + if (y == "auto" && prop == "cursor") { + var possiblePointers = [ "a" ]; + for (var i = 0; i < possiblePointers.length; i++) { + if (el.tagName.toLowerCase() == possiblePointers[i]) { + return "pointer"; + } + } + } + return y; + }; + var _elementMouseOver = function(event) { + if (!ZeroClipboard.prototype._singleton) return; + if (!event) { + event = window.event; + } + var target; + if (this !== window) { + target = this; + } else if (event.target) { + target = event.target; + } else if (event.srcElement) { + target = event.srcElement; + } + ZeroClipboard.prototype._singleton.setCurrent(target); + }; + var _addEventHandler = function(element, method, func) { + if (element.addEventListener) { + element.addEventListener(method, func, false); + } else if (element.attachEvent) { + element.attachEvent("on" + method, func); + } + }; + var _removeEventHandler = function(element, method, func) { + if (element.removeEventListener) { + element.removeEventListener(method, func, false); + } else if (element.detachEvent) { + element.detachEvent("on" + method, func); + } + }; + var _addClass = function(element, value) { + if (element.addClass) { + element.addClass(value); + return element; + } + if (value && typeof value === "string") { + var classNames = (value || "").split(/\s+/); + if (element.nodeType === 1) { + if (!element.className) { + element.className = value; + } else { + var className = " " + element.className + " ", setClass = element.className; + for (var c = 0, cl = classNames.length; c < cl; c++) { + if (className.indexOf(" " + classNames[c] + " ") < 0) { + setClass += " " + classNames[c]; + } + } + element.className = setClass.replace(/^\s+|\s+$/g, ""); + } + } + } + return element; + }; + var _removeClass = function(element, value) { + if (element.removeClass) { + element.removeClass(value); + return element; + } + if (value && typeof value === "string" || value === undefined) { + var classNames = (value || "").split(/\s+/); + if (element.nodeType === 1 && element.className) { + if (value) { + var className = (" " + element.className + " ").replace(/[\n\t]/g, " "); + for (var c = 0, cl = classNames.length; c < cl; c++) { + className = className.replace(" " + classNames[c] + " ", " "); + } + element.className = className.replace(/^\s+|\s+$/g, ""); + } else { + element.className = ""; + } + } + } + return element; + }; + var _getDOMObjectPosition = function(obj) { + var info = { + left: 0, + top: 0, + width: obj.width || obj.offsetWidth || 0, + height: obj.height || obj.offsetHeight || 0, + zIndex: 9999 + }; + var zi = _getStyle(obj, "zIndex"); + if (zi && zi != "auto") { + info.zIndex = parseInt(zi, 10); + } + while (obj) { + var borderLeftWidth = parseInt(_getStyle(obj, "borderLeftWidth"), 10); + var borderTopWidth = parseInt(_getStyle(obj, "borderTopWidth"), 10); + info.left += isNaN(obj.offsetLeft) ? 0 : obj.offsetLeft; + info.left += isNaN(borderLeftWidth) ? 0 : borderLeftWidth; + info.top += isNaN(obj.offsetTop) ? 0 : obj.offsetTop; + info.top += isNaN(borderTopWidth) ? 0 : borderTopWidth; + obj = obj.offsetParent; + } + return info; + }; + var _noCache = function(path) { + return (path.indexOf("?") >= 0 ? "&" : "?") + "nocache=" + (new Date).getTime(); + }; + var _vars = function(options) { + var str = []; + if (options.trustedDomains) { + if (typeof options.trustedDomains === "string") { + str.push("trustedDomain=" + options.trustedDomains); + } else { + str.push("trustedDomain=" + options.trustedDomains.join(",")); + } + } + return str.join("&"); + }; + var _inArray = function(elem, array) { + if (array.indexOf) { + return array.indexOf(elem); + } + for (var i = 0, length = array.length; i < length; i++) { + if (array[i] === elem) { + return i; + } + } + return -1; + }; + var _prepGlue = function(elements) { + if (typeof elements === "string") throw new TypeError("ZeroClipboard doesn't accept query strings."); + if (!elements.length) return [ elements ]; + return elements; + }; + var ZeroClipboard = function(elements, options) { + if (elements) (ZeroClipboard.prototype._singleton || this).glue(elements); + if (ZeroClipboard.prototype._singleton) return ZeroClipboard.prototype._singleton; + ZeroClipboard.prototype._singleton = this; + this.options = {}; + for (var kd in _defaults) this.options[kd] = _defaults[kd]; + for (var ko in options) this.options[ko] = options[ko]; + this.handlers = {}; + if (ZeroClipboard.detectFlashSupport()) _bridge(); + }; + var currentElement, gluedElements = []; + ZeroClipboard.prototype.setCurrent = function(element) { + currentElement = element; + this.reposition(); + if (element.getAttribute("title")) { + this.setTitle(element.getAttribute("title")); + } + this.setHandCursor(_getStyle(element, "cursor") == "pointer"); + }; + ZeroClipboard.prototype.setText = function(newText) { + if (newText && newText !== "") { + this.options.text = newText; + if (this.ready()) this.flashBridge.setText(newText); + } + }; + ZeroClipboard.prototype.setTitle = function(newTitle) { + if (newTitle && newTitle !== "") this.htmlBridge.setAttribute("title", newTitle); + }; + ZeroClipboard.prototype.setSize = function(width, height) { + if (this.ready()) this.flashBridge.setSize(width, height); + }; + ZeroClipboard.prototype.setHandCursor = function(enabled) { + if (this.ready()) this.flashBridge.setHandCursor(enabled); + }; + ZeroClipboard.version = "1.1.7"; + var _defaults = { + moviePath: "ZeroClipboard.swf", + trustedDomains: null, + text: null, + hoverClass: "zeroclipboard-is-hover", + activeClass: "zeroclipboard-is-active", + allowScriptAccess: "sameDomain" + }; + ZeroClipboard.setDefaults = function(options) { + for (var ko in options) _defaults[ko] = options[ko]; + }; + ZeroClipboard.destroy = function() { + ZeroClipboard.prototype._singleton.unglue(gluedElements); + var bridge = ZeroClipboard.prototype._singleton.htmlBridge; + bridge.parentNode.removeChild(bridge); + delete ZeroClipboard.prototype._singleton; + }; + ZeroClipboard.detectFlashSupport = function() { + var hasFlash = false; + try { + if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) { + hasFlash = true; + } + } catch (error) { + if (navigator.mimeTypes["application/x-shockwave-flash"]) { + hasFlash = true; + } + } + return hasFlash; + }; + var _bridge = function() { + var client = ZeroClipboard.prototype._singleton; + var container = document.getElementById("global-zeroclipboard-html-bridge"); + if (!container) { + var html = ' '; + container = document.createElement("div"); + container.id = "global-zeroclipboard-html-bridge"; + container.setAttribute("class", "global-zeroclipboard-container"); + container.setAttribute("data-clipboard-ready", false); + container.style.position = "absolute"; + container.style.left = "-9999px"; + container.style.top = "-9999px"; + container.style.width = "15px"; + container.style.height = "15px"; + container.style.zIndex = "9999"; + container.innerHTML = html; + document.body.appendChild(container); + } + client.htmlBridge = container; + client.flashBridge = document["global-zeroclipboard-flash-bridge"] || container.children[0].lastElementChild; + }; + ZeroClipboard.prototype.resetBridge = function() { + this.htmlBridge.style.left = "-9999px"; + this.htmlBridge.style.top = "-9999px"; + this.htmlBridge.removeAttribute("title"); + this.htmlBridge.removeAttribute("data-clipboard-text"); + _removeClass(currentElement, this.options.activeClass); + currentElement = null; + this.options.text = null; + }; + ZeroClipboard.prototype.ready = function() { + var ready = this.htmlBridge.getAttribute("data-clipboard-ready"); + return ready === "true" || ready === true; + }; + ZeroClipboard.prototype.reposition = function() { + if (!currentElement) return false; + var pos = _getDOMObjectPosition(currentElement); + this.htmlBridge.style.top = pos.top + "px"; + this.htmlBridge.style.left = pos.left + "px"; + this.htmlBridge.style.width = pos.width + "px"; + this.htmlBridge.style.height = pos.height + "px"; + this.htmlBridge.style.zIndex = pos.zIndex + 1; + this.setSize(pos.width, pos.height); + }; + ZeroClipboard.dispatch = function(eventName, args) { + ZeroClipboard.prototype._singleton.receiveEvent(eventName, args); + }; + ZeroClipboard.prototype.on = function(eventName, func) { + var events = eventName.toString().split(/\s/g); + for (var i = 0; i < events.length; i++) { + eventName = events[i].toLowerCase().replace(/^on/, ""); + if (!this.handlers[eventName]) this.handlers[eventName] = func; + } + if (this.handlers.noflash && !ZeroClipboard.detectFlashSupport()) { + this.receiveEvent("onNoFlash", null); + } + }; + ZeroClipboard.prototype.addEventListener = ZeroClipboard.prototype.on; + ZeroClipboard.prototype.off = function(eventName, func) { + var events = eventName.toString().split(/\s/g); + for (var i = 0; i < events.length; i++) { + eventName = events[i].toLowerCase().replace(/^on/, ""); + for (var event in this.handlers) { + if (event === eventName && this.handlers[event] === func) { + delete this.handlers[event]; + } + } + } + }; + ZeroClipboard.prototype.removeEventListener = ZeroClipboard.prototype.off; + ZeroClipboard.prototype.receiveEvent = function(eventName, args) { + eventName = eventName.toString().toLowerCase().replace(/^on/, ""); + var element = currentElement; + switch (eventName) { + case "load": + if (args && parseFloat(args.flashVersion.replace(",", ".").replace(/[^0-9\.]/gi, "")) < 10) { + this.receiveEvent("onWrongFlash", { + flashVersion: args.flashVersion + }); + return; + } + this.htmlBridge.setAttribute("data-clipboard-ready", true); + break; + case "mouseover": + _addClass(element, this.options.hoverClass); + break; + case "mouseout": + _removeClass(element, this.options.hoverClass); + this.resetBridge(); + break; + case "mousedown": + _addClass(element, this.options.activeClass); + break; + case "mouseup": + _removeClass(element, this.options.activeClass); + break; + case "datarequested": + var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId ? null : document.getElementById(targetId); + if (targetEl) { + var textContent = targetEl.value || targetEl.textContent || targetEl.innerText; + if (textContent) this.setText(textContent); + } else { + var defaultText = element.getAttribute("data-clipboard-text"); + if (defaultText) this.setText(defaultText); + } + break; + case "complete": + this.options.text = null; + break; + } + if (this.handlers[eventName]) { + var func = this.handlers[eventName]; + if (typeof func == "function") { + func.call(element, this, args); + } else if (typeof func == "string") { + window[func].call(element, this, args); + } + } + }; + ZeroClipboard.prototype.glue = function(elements) { + elements = _prepGlue(elements); + for (var i = 0; i < elements.length; i++) { + if (_inArray(elements[i], gluedElements) == -1) { + gluedElements.push(elements[i]); + _addEventHandler(elements[i], "mouseover", _elementMouseOver); + } + } + }; + ZeroClipboard.prototype.unglue = function(elements) { + elements = _prepGlue(elements); + for (var i = 0; i < elements.length; i++) { + _removeEventHandler(elements[i], "mouseover", _elementMouseOver); + var arrayIndex = _inArray(elements[i], gluedElements); + if (arrayIndex != -1) gluedElements.splice(arrayIndex, 1); + } + }; + if (typeof module !== "undefined") { + module.exports = ZeroClipboard; + } else if (typeof define === "function" && define.amd) { + define(function() { + return ZeroClipboard; + }); + } else { + window.ZeroClipboard = ZeroClipboard; + } +})(); +(function(kmc) { + + /* + * TODO: + * Use ng-view for preview template + * Use filters for delivery + */ + + var Preview = kmc.Preview || {}; + + // Preview Partner Defaults + kmc.vars.previewDefaults = { + showAdvancedOptions: false, + includeKalturaLinks: (!kmc.vars.ignore_seo_links), + includeSeoMetadata: (!kmc.vars.ignore_entry_seo), + deliveryType: kmc.vars.default_delivery_type, + embedType: kmc.vars.default_embed_code_type, + secureEmbed: kmc.vars.embed_code_protocol_https + }; + + // Check for current protocol and update secureEmbed + if(window.location.protocol == 'https:') { + kmc.vars.previewDefaults.secureEmbed = true; + } + + Preview.storageName = 'previewDefaults'; + Preview.el = '#previewModal'; + Preview.iframeContainer = 'previewIframe'; + + // We use this flag to ignore all change evnets when we initilize the preview ( on page start up ) + // We will set that to true once Preview is opened. + Preview.ignoreChangeEvents = true; + + // Set generator + Preview.getGenerator = function() { + if(!this.generator) { + this.generator = new kEmbedCodeGenerator({ + host: kmc.vars.embed_host, + securedHost: kmc.vars.embed_host_https, + partnerId: kmc.vars.partner_id, + includeKalturaLinks: kmc.vars.previewDefaults.includeKalturaLinks + }); + } + return this.generator; + }; + + Preview.clipboard = new ZeroClipboard($('.copy-code'), { + moviePath: "/lib/flash/ZeroClipboard.swf", + trustedDomains: ['*'], + allowScriptAccess: "always" + }); + + Preview.clipboard.on('complete', function() { + var $this = $(this); + // Mark embed code as selected + $('#' + $this.data('clipboard-target')).select(); + // Close preview + if($this.data('close') === true) { + Preview.closeModal(Preview.el); + } + }); + + Preview.objectToArray = function(obj) { + var arr = []; + for(var key in obj) { + obj[key].id = key; + arr.push(obj[key]); + } + return arr; + }; + + Preview.getObjectById = function(id, arr) { + var result = $.grep(arr, function(e) { + return e.id == id; + }); + return(result.length) ? result[0] : false; + }; + + Preview.getDefault = function(setting) { + var defaults = localStorage.getItem(Preview.storageName); + if(defaults) { + defaults = JSON.parse(defaults); + } else { + defaults = kmc.vars.previewDefaults; + } + if(defaults[setting] !== undefined) { + return defaults[setting]; + } + return null; + }; + + Preview.savePreviewState = function() { + var previewService = this.Service; + var defaults = { + embedType: previewService.get('embedType'), + secureEmbed: previewService.get('secureEmbed'), + includeSeoMetadata: previewService.get('includeSeo'), + deliveryType: previewService.get('deliveryType').id, + showAdvancedOptions: previewService.get('showAdvancedOptions') + }; + // Save defaults to localStorage + localStorage.setItem(Preview.storageName, JSON.stringify(defaults)); + }; + + Preview.getDeliveryTypeFlashVars = function(deliveryType) { + // Not delivery type, exit + if(!deliveryType) return {}; + + // Get original delivery type flashvars + var originalFlashVars = (deliveryType.flashvars) ? deliveryType.flashvars : {}; + + // Clone flashVars object + var newFlashVars = $.extend({}, originalFlashVars); + + // Add streamerType and mediaProtocol flashVars + if(deliveryType.streamerType) + newFlashVars.streamerType = deliveryType.streamerType; + + if(deliveryType.mediaProtocol) + newFlashVars.mediaProtocol = deliveryType.mediaProtocol; + + // Return the new Flashvars object + return newFlashVars; + }; + + Preview.getPreviewTitle = function(options) { + if(options.entryMeta && options.entryMeta.name) { + return 'Embedding: ' + options.entryMeta.name; + } + if(options.playlistName) { + return 'Playlist: ' + options.playlistName; + } + if(options.playerOnly) { + return 'Player Name:' + options.name; + } + }; + + Preview.openPreviewEmbed = function(options, previewService) { + + var _this = this; + var el = _this.el; + + // Enable preview events + this.ignoreChangeEvents = false; + + var defaults = { + entryId: null, + entryMeta: {}, + playlistId: null, + playlistName: null, + previewOnly: false, + liveBitrates: null, + playerOnly: false, + uiConfId: null, + name: null + }; + + options = $.extend({}, defaults, options); + // In case of live entry preview, set delivery type to auto + if( options.liveBitrates ) { + previewService.setDeliveryType('auto'); + } + // Update our players + previewService.updatePlayers(options); + // Set options + previewService.set(options); + + var title = this.getPreviewTitle(options); + + var $previewModal = $(el); + $previewModal.find(".title h2").text(title).attr('title', title); + $previewModal.find(".close").unbind('click').click(function() { + _this.closeModal(el); + }); + + // Show our preview modal + var modalHeight = $('body').height() - 173; + $previewModal.find('.content').height(modalHeight); + kmc.layout.modal.show(el, false); + }; + + Preview.closeModal = function(el) { + this.savePreviewState(); + this.emptyDiv(this.iframeContainer); + $(el).fadeOut(300, function() { + kmc.layout.overlay.hide(); + kmc.utils.hideFlash(); + }); + }; + + Preview.emptyDiv = function(divId) { + var $targetDiv = $('#' + divId); + var $previewIframe = $('#previewIframe iframe'); + if( $previewIframe.length ) { + try { + var $iframeDoc = $($previewIframe[0].contentWindow.document); + $iframeDoc.find('#framePlayerContainer').empty(); + } catch (e) {} + } + + if( $targetDiv.length ) { + $targetDiv.empty(); + return $targetDiv[0]; + } + return false; + }; + + Preview.hasIframe = function() { + return $('#' + this.iframeContainer + ' iframe').length; + }; + + Preview.getCacheSt = function() { + var d = new Date(); + return Math.floor(d.getTime() / 1000) + (15 * 60); // start caching in 15 minutes + }; + + Preview.generateIframe = function(embedCode) { + + var ltIE10 = $('html').hasClass('lt-ie10'); + var style = ''; + var container = this.emptyDiv(this.iframeContainer); + var iframe = document.createElement('iframe'); + // Reset iframe style + iframe.frameborder = "0"; + iframe.frameBorder = "0"; + iframe.marginheight="0"; + iframe.marginwidth="0"; + iframe.frameborder="0"; + + container.appendChild(iframe); + + if(ltIE10) { + iframe.src = this.getPreviewUrl(this.Service, true); + } else { + var newDoc = iframe.contentDocument; + newDoc.open(); + newDoc.write('' + style + '
' + embedCode + '
'); + newDoc.close(); + } + }; + + Preview.getEmbedProtocol = function(previewService, previewPlayer) { + if(previewPlayer === true) { + return location.protocol.substring(0, location.protocol.length - 1); // Get host protocol + } + return (previewService.get('secureEmbed')) ? 'https' : 'http'; + }; + + Preview.getEmbedFlashVars = function(previewService, addKs) { + var protocol = this.getEmbedProtocol(previewService, addKs); + var player = previewService.get('player'); + var flashVars = this.getDeliveryTypeFlashVars(previewService.get('deliveryType')); + if(addKs === true) { + flashVars.ks = kmc.vars.ks; + } + + var playlistId = previewService.get('playlistId'); + if(playlistId) { + // Use new kpl0Id flashvar for new players only + var html5_version = kmc.functions.getVersionFromPath(player.html5Url); + var kdpVersionCheck = kmc.functions.versionIsAtLeast(kmc.vars.min_kdp_version_for_playlist_api_v3, player.swf_version); + var html5VersionCheck = kmc.functions.versionIsAtLeast(kmc.vars.min_html5_version_for_playlist_api_v3, html5_version); + if( kdpVersionCheck && html5VersionCheck ) { + flashVars['playlistAPI.kpl0Id'] = playlistId; + } else { + flashVars['playlistAPI.autoInsert'] = 'true'; + flashVars['playlistAPI.kpl0Name'] = previewService.get('playlistName'); + flashVars['playlistAPI.kpl0Url'] = protocol + '://' + kmc.vars.api_host + '/index.php/partnerservices2/executeplaylist?' + 'partner_id=' + kmc.vars.partner_id + '&subp_id=' + kmc.vars.partner_id + '00' + '&format=8&ks={ks}&playlist_id=' + playlistId; + } + } + return flashVars; + }; + + Preview.getEmbedCode = function(previewService, previewPlayer) { + var player = previewService.get('player'); + if(!player || !previewService.get('embedType')) { + return ''; + } + var cacheSt = this.getCacheSt(); + var params = { + protocol: this.getEmbedProtocol(previewService, previewPlayer), + embedType: previewService.get('embedType'), + uiConfId: player.id, + width: player.width, + height: player.height, + entryMeta: previewService.get('entryMeta'), + includeSeoMetadata: previewService.get('includeSeo'), + playerId: 'kaltura_player_' + cacheSt, + cacheSt: cacheSt, + flashVars: this.getEmbedFlashVars(previewService, previewPlayer) + }; + + if(previewService.get('entryId')) { + params.entryId = previewService.get('entryId'); + } + + var code = this.getGenerator().getCode(params); + return code; + }; + + Preview.getPreviewUrl = function(previewService, framed) { + var player = previewService.get('player'); + if(!player || !previewService.get('embedType')) { + return ''; + } + + var protocol = this.getEmbedProtocol(previewService, framed); + var url = protocol + '://' + kmc.vars.base_host + '/index.php/kmc/preview'; + //var url = protocol + '://' + window.location.host + '/KMC_V2/preview.php'; + url += '/partner_id/' + kmc.vars.partner_id; + url += '/uiconf_id/' + player.id; + // Add entry Id + if(previewService.get('entryId')) { + url += '/entry_id/' + previewService.get('entryId'); + } + url += '/embed/' + previewService.get('embedType'); + url += '?' + kmc.functions.flashVarsToUrl(this.getEmbedFlashVars(previewService, framed)); + if( framed === true ) { + url += '&framed=true'; + } + return url; + }; + + Preview.generateQrCode = function(url) { + var $qrCode = $('#qrcode').empty(); + if(!url) return ; + if($('html').hasClass('lt-ie9')) return; + $qrCode.qrcode({ + width: 80, + height: 80, + text: url + }); + }; + + Preview.generateShortUrl = function(url, callback) { + if(!url) return ; + kmc.client.createShortURL(url, callback); + }; + + kmc.Preview = Preview; + +})(window.kmc); + +var kmcApp = angular.module('kmcApp', []); +kmcApp.factory('previewService', ['$rootScope', function($rootScope) { + var previewProps = {}; + return { + get: function(key) { + if(key === undefined) return previewProps; + return previewProps[key]; + }, + set: function(key, value, quiet) { + if(typeof key == 'object') { + angular.extend(previewProps, key); + } else { + previewProps[key] = value; + } + if(!quiet) { + $rootScope.$broadcast('previewChanged'); + } + }, + updatePlayers: function(options) { + $rootScope.$broadcast('playersUpdated', options); + }, + changePlayer: function(playerId) { + $rootScope.$broadcast('changePlayer', playerId); + }, + setDeliveryType: function( deliveryTypeId ) { + $rootScope.$broadcast('changeDelivery', deliveryTypeId); + } + }; +}]); +kmcApp.directive('showSlide', function() { + return { + //restrict it's use to attribute only. + restrict: 'A', + + //set up the directive. + link: function(scope, elem, attr) { + + //get the field to watch from the directive attribute. + var watchField = attr.showSlide; + + //set up the watch to toggle the element. + scope.$watch(attr.showSlide, function(v) { + if(v && !elem.is(':visible')) { + elem.slideDown(); + } else { + elem.slideUp(); + } + }); + } + }; +}); + +kmcApp.controller('PreviewCtrl', ['$scope', 'previewService', function($scope, previewService) { + + var draw = function() { + if(!$scope.$$phase) { + $scope.$apply(); + } + }; + + var Preview = kmc.Preview; + Preview.playlistMode = false; + + Preview.Service = previewService; + + var updatePlayers = function(options) { + options = options || {}; + var playerId = (options.uiConfId) ? options.uiConfId : undefined; + // Exit if player not loaded + if(!kmc.vars.playlists_list || !kmc.vars.players_list) { + return ; + } + // List of players + if(options.playlistId || options.playerOnly) { + $scope.players = kmc.vars.playlists_list; + if(!Preview.playlistMode) { + Preview.playlistMode = true; + $scope.$broadcast('changePlayer', playerId); + } + } else { + $scope.players = kmc.vars.players_list; + if(Preview.playlistMode || !$scope.player) { + Preview.playlistMode = false; + $scope.$broadcast('changePlayer', playerId); + } + } + if(playerId){ + $scope.$broadcast('changePlayer', playerId); + } + }; + + var setDeliveryTypes = function(player) { + var deliveryTypes = Preview.objectToArray(kmc.vars.delivery_types); + var defaultType = $scope.deliveryType || Preview.getDefault('deliveryType'); + var validDeliveryTypes = []; + $.each(deliveryTypes, function() { + if(this.minVersion && !kmc.functions.versionIsAtLeast(this.minVersion, player.swf_version)) { + if(this.id == defaultType) { + defaultType = null; + } + return true; + } + validDeliveryTypes.push(this); + }); + // List of delivery types + $scope.deliveryTypes = validDeliveryTypes; + // Set default delivery type + if(!defaultType) { + defaultType = $scope.deliveryTypes[0].id; + } + previewService.setDeliveryType(defaultType); + }; + + var setEmbedTypes = function(player) { + var embedTypes = Preview.objectToArray(kmc.vars.embed_code_types); + var defaultType = $scope.embedType || Preview.getDefault('embedType'); + var validEmbedTypes = []; + $.each(embedTypes, function() { + // Don't add embed code that are entry only for playlists + if(Preview.playlistMode && this.entryOnly) { + if(this.id == defaultType) { + defaultType = null; + } + return true; + } + // Check for library minimum version to eanble embed type + var libVersion = kmc.functions.getVersionFromPath(player.html5Url); + if(this.minVersion && !kmc.functions.versionIsAtLeast(this.minVersion, libVersion)) { + if(this.id == defaultType) { + defaultType = null; + } + return true; + } + validEmbedTypes.push(this); + }); + // List of embed types + $scope.embedTypes = validEmbedTypes; + // Set default embed type + if(!defaultType) { + defaultType = $scope.embedTypes[0].id; + } + $scope.embedType = defaultType; + }; + + // Set defaults + $scope.players = []; + $scope.player = null; + $scope.deliveryTypes = []; + $scope.deliveryType = null; + $scope.embedTypes = []; + $scope.embedType = null; + $scope.secureEmbed = Preview.getDefault('secureEmbed'); + $scope.includeSeo = Preview.getDefault('includeSeoMetadata'); + $scope.previewOnly = false; + $scope.playerOnly = false; + $scope.liveBitrates = false; + $scope.showAdvancedOptionsStatus = Preview.getDefault('showAdvancedOptions'); + $scope.shortLinkGenerated = false; + + // Set players on update + $scope.$on('playersUpdated', function(e, options) { + updatePlayers(options); + }); + + $scope.$on('changePlayer', function(e, playerId) { + playerId = ( playerId ) ? playerId : $scope.players[0].id; + $scope.player = playerId; + draw(); + }); + + $scope.$on('changeDelivery', function(e, deliveryTypeId) { + $scope.deliveryType = deliveryTypeId; + draw(); + }); + + $scope.showAdvancedOptions = function($event, show) { + $event.preventDefault(); + previewService.set('showAdvancedOptions', show, true); + $scope.showAdvancedOptionsStatus = show; + }; + + $scope.$watch('showAdvancedOptionsStatus', function() { + Preview.clipboard.reposition(); + }); + + // Listen to player change + $scope.$watch('player', function() { + var player = Preview.getObjectById($scope.player, $scope.players); + if(!player) { return ; } + setDeliveryTypes(player); + setEmbedTypes(player); + previewService.set('player', player); + }); + $scope.$watch('deliveryType', function() { + previewService.set('deliveryType', Preview.getObjectById($scope.deliveryType, $scope.deliveryTypes)); + }); + $scope.$watch('embedType', function() { + previewService.set('embedType', $scope.embedType); + }); + $scope.$watch('secureEmbed', function() { + previewService.set('secureEmbed', $scope.secureEmbed); + }); + $scope.$watch('includeSeo', function() { + previewService.set('includeSeo', $scope.includeSeo); + }); + $scope.$watch('embedCodePreview', function() { + Preview.generateIframe($scope.embedCodePreview); + }); + $scope.$watch('previewOnly', function() { + if($scope.previewOnly) { + $scope.closeButtonText = 'Close'; + } else { + $scope.closeButtonText = 'Copy Embed & Close'; + } + draw(); + }); + $scope.$on('previewChanged', function() { + if(Preview.ignoreChangeEvents) return; + var previewUrl = Preview.getPreviewUrl(previewService); + $scope.embedCode = Preview.getEmbedCode(previewService); + $scope.embedCodePreview = Preview.getEmbedCode(previewService, true); + $scope.previewOnly = previewService.get('previewOnly'); + $scope.playerOnly = previewService.get('playerOnly'); + $scope.liveBitrates = previewService.get('liveBitrates'); + draw(); + // Generate Iframe if not exist + if(!Preview.hasIframe()) { + Preview.generateIframe($scope.embedCodePreview); + } + // Update Short url + $scope.previewUrl = 'Updating...'; + $scope.shortLinkGenerated = false; + Preview.generateShortUrl(previewUrl, function(tinyUrl) { + if(!tinyUrl) { + // Set tinyUrl to fullUrl + tinyUrl = previewUrl; + } + $scope.shortLinkGenerated = true; + $scope.previewUrl = tinyUrl; + // Generate QR Code + Preview.generateQrCode(tinyUrl); + draw(); + }); + }); + +}]); +// Prevent the page to be framed +if(kmc.vars.allowFrame == false && top != window) { top.location = window.location; } + +/* kmc and kmc.vars defined in script block in kmc4success.php */ + +// For debug enable to true. Debug will show information in the browser console +kmc.vars.debug = false; + +// Quickstart guide (should be moved to kmc4success.php) +kmc.vars.quickstart_guide = "/content/docs/pdf/KMC_User_Manual.pdf"; +kmc.vars.help_url = kmc.vars.service_url + '/kmc5help.html'; + +// Set base URL +kmc.vars.port = (window.location.port) ? ":" + window.location.port : ""; +kmc.vars.base_host = window.location.hostname + kmc.vars.port; +kmc.vars.base_url = window.location.protocol + '//' + kmc.vars.base_host; +kmc.vars.api_host = kmc.vars.host; +kmc.vars.api_url = window.location.protocol + '//' + kmc.vars.api_host; + +// Holds the minimum version for html5 & kdp with the api_v3 for playlists +kmc.vars.min_kdp_version_for_playlist_api_v3 = '3.6.15'; +kmc.vars.min_html5_version_for_playlist_api_v3 = '1.7.1.3'; + +// Log function +kmc.log = function() { + if( kmc.vars.debug && typeof console !='undefined' && console.log ){ + if (arguments.length == 1) { + console.log( arguments[0] ); + } else { + var args = Array.prototype.slice.call(arguments); + console.log( args[0], args.slice( 1 ) ); + } + } +}; + +kmc.functions = { + + loadSwf : function() { + + var kmc_swf_url = window.location.protocol + '//' + kmc.vars.cdn_host + '/flash/kmc/' + kmc.vars.kmc_version + '/kmc.swf'; + var flashvars = { + // kmc configuration + kmc_uiconf : kmc.vars.kmc_general_uiconf, + + //permission uiconf id: + permission_uiconf : kmc.vars.kmc_permissions_uiconf, + + host : kmc.vars.host, + cdnhost : kmc.vars.cdn_host, + srvurl : "api_v3/index.php", + protocol : window.location.protocol + '//', + partnerid : kmc.vars.partner_id, + subpid : kmc.vars.partner_id + '00', + ks : kmc.vars.ks, + entryId : "-1", + kshowId : "-1", + debugmode : "true", + widget_id : "_" + kmc.vars.partner_id, + urchinNumber : kmc.vars.google_analytics_account, // "UA-12055206-1"" + firstLogin : kmc.vars.first_login, + openPlayer : "kmc.preview_embed.doPreviewEmbed", // @todo: remove for 2.0.9 ? + openPlaylist : "kmc.preview_embed.doPreviewEmbed", + openCw : "kmc.functions.openKcw", + language : (kmc.vars.language || "") + }; + // Disable analytics + if( kmc.vars.disable_analytics ) { + flashvars.disableAnalytics = true; + } + var params = { + allowNetworking: "all", + allowScriptAccess: "always" + }; + + swfobject.embedSWF(kmc_swf_url, "kcms", "100%", "100%", "10.0.0", false, flashvars, params); + $("#kcms").attr('style', ''); // Reset the object style + }, + + checkForOngoingProcess : function() { + var warning_message; + try { + warning_message = $("#kcms")[0].hasOngoingProcess(); + } + catch(e) { + warning_message = null; + } + + if(warning_message !== null) { + return warning_message; + } + return; + }, + + expired : function() { + kmc.user.logout(); + }, + + openKcw : function(conversion_profile, uiconf_tag) { + + conversion_profile = conversion_profile || ""; + + // uiconf_tag - uploadWebCam or uploadImport + var kcw_uiconf = (uiconf_tag == "uploadWebCam") ? kmc.vars.kcw_webcam_uiconf : kmc.vars.kcw_import_uiconf; + + var flashvars = { + host : kmc.vars.host, + cdnhost : kmc.vars.cdn_host, + protocol : window.location.protocol.slice(0, -1), + partnerid : kmc.vars.partner_id, + subPartnerId : kmc.vars.partner_id + '00', + sessionId : kmc.vars.ks, + devFlag : "true", + entryId : "-1", + kshow_id : "-1", + terms_of_use : kmc.vars.terms_of_use, + close : "kmc.functions.onCloseKcw", + quick_edit : 0, + kvar_conversionQuality : conversion_profile + }; + + var params = { + allowscriptaccess: "always", + allownetworking: "all", + bgcolor: "#DBE3E9", + quality: "high", + movie: kmc.vars.service_url + "/kcw/ui_conf_id/" + kcw_uiconf + }; + + kmc.layout.modal.open( { + 'width' : 700, + 'height' : 420, + 'content' : '
' + } ); + + swfobject.embedSWF(params.movie, "kcw", "680", "400" , "9.0.0", false, flashvars , params); + }, + onCloseKcw : function() { + kmc.layout.modal.close(); + $("#kcms")[0].gotoPage({ + moduleName: "content", + subtab: "manage" + }); + }, + // Should be moved into user object + openChangePwd : function(email) { + kmc.user.changeSetting('password'); + }, + openChangeEmail : function(email) { + kmc.user.changeSetting('email'); + }, + openChangeName : function(fname, lname, email) { + kmc.user.changeSetting('name'); + }, + getAddPanelPosition : function() { + var el = $("#add").parent(); + return (el.position().left + el.width() - 10); + }, + openClipApp : function( entry_id, mode ) { + + var iframe_url = kmc.vars.base_url + '/apps/clipapp/' + kmc.vars.clipapp.version; + iframe_url += '/?kdpUiconf=' + kmc.vars.clipapp.kdp + '&kclipUiconf=' + kmc.vars.clipapp.kclip; + iframe_url += '&partnerId=' + kmc.vars.partner_id + '&host=' + kmc.vars.host + '&mode=' + mode + '&config=kmc&entryId=' + entry_id; + + var title = ( mode == 'trim' ) ? 'Trimming Tool' : 'Clipping Tool'; + + kmc.layout.modal.open( { + 'width' : 950, + 'height' : 616, + 'title' : title, + 'content' : '', + 'className' : 'iframe', + 'closeCallback': function() { + $("#kcms")[0].gotoPage({ + moduleName: "content", + subtab: "manage" + }); + } + } ); + }, + flashVarsToUrl: function( flashVarsObject ){ + var params = ''; + for( var i in flashVarsObject ){ + var curVal = typeof flashVarsObject[i] == 'object'? + JSON.stringify( flashVarsObject[i] ): + flashVarsObject[i]; + params+= '&' + 'flashvars[' + encodeURIComponent( i ) + ']=' + + encodeURIComponent( curVal ); + } + return params; + }, + versionIsAtLeast: function( minVersion, clientVersion ) { + if( ! clientVersion ){ + return false; + } + var minVersionParts = minVersion.split('.'); + var clientVersionParts = clientVersion.split('.'); + for( var i =0; i < minVersionParts.length; i++ ) { + if( parseInt( clientVersionParts[i] ) > parseInt( minVersionParts[i] ) ) { + return true; + } + if( parseInt( clientVersionParts[i] ) < parseInt( minVersionParts[i] ) ) { + return false; + } + } + // Same version: + return true; + }, + getVersionFromPath: function( path ) { + return (typeof path == 'string') ? path.split("/v")[1].split("/")[0] : false; + } +}; + +kmc.utils = { + // Backward compatability + closeModal : function() {kmc.layout.modal.close();}, + + handleMenu : function() { + + // Activate menu links + kmc.utils.activateHeader(); + + // Calculate menu width + var menu_width = 10; + $("#user_links > *").each( function() { + menu_width += $(this).width(); + }); + + var openMenu = function() { + + // Set close menu to true + kmc.vars.close_menu = true; + + var menu_default_css = { + "width": 0, + "visibility": 'visible', + "top": '6px', + "right": '6px' + }; + + var menu_animation_css = { + "width": menu_width + 'px', + "padding-top": '2px', + "padding-bottom": '2px' + }; + + $("#user_links").css( menu_default_css ); + $("#user_links").animate( menu_animation_css , 500); + }; + + $("#user").hover( openMenu ).click( openMenu ); + $("#user_links").mouseover( function(){ + kmc.vars.close_menu = false; + } ); + $("#user_links").mouseleave( function() { + kmc.vars.close_menu = true; + setTimeout( kmc.utils.closeMenu , 650 ); + } ); + $("#closeMenu").click( function() { + kmc.vars.close_menu = true; + kmc.utils.closeMenu(); + } ); + }, + + closeMenu : function() { + if( kmc.vars.close_menu ) { + $("#user_links").animate( { + width: 0 + } , 500, function() { + $("#user_links").css( { + width: 'auto', + visibility: 'hidden' + } ); + }); + } + }, + + activateHeader : function() { + $("#user_links a").click(function(e) { + var tab = (e.target.tagName == "A") ? e.target.id : $(e.target).parent().attr("id"); + + switch(tab) { + case "Quickstart Guide" : + this.href = kmc.vars.quickstart_guide; + return true; + case "Logout" : + kmc.user.logout(); + return false; + case "Support" : + kmc.user.openSupport(this); + return false; + case "ChangePartner" : + kmc.user.changePartner(); + return false; + default : + return false; + } + }); + }, + + resize : function() { + var min_height = ($.browser.ie) ? 640 : 590; + var doc_height = $(document).height(), + offset = $.browser.mozilla ? 37 : 74; + doc_height = (doc_height-offset); + doc_height = (doc_height < min_height) ? min_height : doc_height; // Flash minimum height is 590 px + $("#flash_wrap").height(doc_height + "px"); + $("#server_wrap iframe").height(doc_height + "px"); + $("#server_wrap").css("margin-top", "-"+ (doc_height + 2) +"px"); + }, + isModuleLoaded : function() { + if($("#flash_wrap object").length || $("#flash_wrap embed").length) { + kmc.utils.resize(); + clearInterval(kmc.vars.isLoadedInterval); + kmc.vars.isLoadedInterval = null; + } + }, + debug : function() { + try{ + console.info(" ks: ",kmc.vars.ks); + console.info(" partner_id: ",kmc.vars.partner_id); + } + catch(err) {} + }, + + // we should have only one overlay for both flash & html modals + maskHeader : function(hide) { + if(hide) { + $("#mask").hide(); + } + else { + $("#mask").show(); + } + }, + + // Create dynamic tabs + createTabs : function(arr) { + // Close the user link menu + $("#closeMenu").trigger('click'); + + if(arr) { + var module_url = kmc.vars.service_url + '/index.php/kmc/kmc4', + arr_len = arr.length, + tabs_html = '', + tab_class; + for( var i = 0; i < arr_len; i++ ) { + tab_class = (arr[i].type == "action") ? 'class="menu" ' : ''; + tabs_html += '
  • ' + arr[i].display_name + '
  • '; + } + + $('#hTabs').html(tabs_html); + + // Get maximum width for user name + var max_user_width = ( $("body").width() - ($("#logo").width() + $("#hTabs").width() + 100) ); + if( ($("#user").width()+ 20) > max_user_width ) { + $("#user").width(max_user_width); + } + + $('#hTabs a').click(function(e) { + var tab = (e.target.tagName == "A") ? e.target.id : $(e.target).parent().attr("id"); + var subtab = (e.target.tagName == "A") ? $(e.target).attr("rel") : $(e.target).parent().attr("rel"); + + var go_to = { + moduleName : tab, + subtab : subtab + }; + $("#kcms")[0].gotoPage(go_to); + return false; + + }); + } else { + alert('Error geting tabs'); + } + }, + + setTab : function(module, resetAll){ + if( resetAll ) {$("#kmcHeader ul li a").removeClass("active");} + $("a#" + module).addClass("active"); + }, + + // Reset active tab + resetTab : function(module) { + $("a#" + module).removeClass("active"); + }, + + // we should combine the two following functions into one + hideFlash : function(hide) { + var ltIE8 = $('html').hasClass('lt-ie8'); + if(hide) { + if( ltIE8 ) { + // For IE only we're positioning outside of the screen + $("#flash_wrap").css("margin-right","3333px"); + } else { + // For other browsers we're just make it + $("#flash_wrap").css("visibility","hidden"); + $("#flash_wrap object").css("visibility","hidden"); + } + } else { + if( ltIE8 ) { + $("#flash_wrap").css("margin-right","0"); + } else { + $("#flash_wrap").css("visibility","visible"); + $("#flash_wrap object").css("visibility","visible"); + } + } + }, + showFlash : function() { + $("#server_wrap").hide(); + $("#server_frame").removeAttr('src'); + if( !kmc.layout.modal.isOpen() ) { + $("#flash_wrap").css("visibility","visible"); + } + $("#server_wrap").css("margin-top", 0); + }, + + // HTML Tab iframe + openIframe : function(url) { + $("#flash_wrap").css("visibility","hidden"); + $("#server_frame").attr("src", url); + $("#server_wrap").css("margin-top", "-"+ ($("#flash_wrap").height() + 2) +"px"); + $("#server_wrap").show(); + }, + + openHelp: function( key ) { + $("#kcms")[0].doHelp( key ); + }, + + setClientIP: function() { + kmc.vars.clientIP = ""; + if( kmc.vars.akamaiEdgeServerIpURL ) { + $.ajax({ + url: window.location.protocol + '//' + kmc.vars.akamaiEdgeServerIpURL, + crossDomain: true, + success: function( data ) { + kmc.vars.clientIP = $(data).find('serverip').text(); + } + }); + } + }, + getClientIP: function() { + return kmc.vars.clientIP; + } + +}; + +kmc.mediator = { + + writeUrlHash : function(module,subtab){ + location.hash = module + "|" + subtab; + document.title = "KMC > " + module + ((subtab && subtab !== "") ? " > " + subtab + " |" : ""); + }, + readUrlHash : function() { + var module = "dashboard", + subtab = "", + extra = {}, + hash, nohash; + + try { + hash = location.hash.split("#")[1].split("|"); + } + catch(err) { + nohash=true; + } + if(!nohash && hash[0]!=="") { + module = hash[0]; + subtab = hash[1]; + + if (hash[2]) + { + var tmp = hash[2].split("&"); + for (var i = 0; idrilldown->flavors->preview + doFlavorPreview : function(entryId, entryName, flavorDetails) { + + var player = kmc.vars.default_kdp; + var code = kmc.Preview.getGenerator().getCode({ + protocol: location.protocol.substring(0, location.protocol.length - 1), + embedType: 'legacy', + entryId: entryId, + uiConfId: parseInt(player.id), + width: player.width, + height: player.height, + includeSeoMetadata: false, + includeHtml5Library: false, + flashVars: { + 'ks': kmc.vars.ks, + 'flavorId': flavorDetails.asset_id + } + }); + + var modal_content = '
    ' + code + '
    ' + + '
    Entry Name:
     ' + entryName + '
    ' + + '
    Entry Id:
     ' + entryId + '
    ' + + '
    Flavor Name:
     ' + flavorDetails.flavor_name + '
    ' + + '
    Flavor Asset Id:
     ' + flavorDetails.asset_id + '
    ' + + '
    Bitrate:
     ' + flavorDetails.bitrate + '
    ' + + '
    Codec:
     ' + flavorDetails.codec + '
    ' + + '
    Dimensions:
     ' + flavorDetails.dimensions.width + ' x ' + flavorDetails.dimensions.height + '
    ' + + '
    Format:
     ' + flavorDetails.format + '
    ' + + '
    Size (KB):
     ' + flavorDetails.sizeKB + '
    ' + + '
    Status:
     ' + flavorDetails.status + '
    ' + + '
    '; + + kmc.layout.modal.open( { + 'width' : parseInt(player.width) + 120, + 'height' : parseInt(player.height) + 300, + 'title' : 'Flavor Preview', + 'content' : '
    ' + modal_content + '
    ' + } ); + + }, + updateList : function(is_playlist) { + var type = is_playlist ? "playlist" : "player"; + $.ajax({ + url: kmc.vars.base_url + kmc.vars.getuiconfs_url, + type: "POST", + data: { + "type": type, + "partner_id": kmc.vars.partner_id, + "ks": kmc.vars.ks + }, + dataType: "json", + success: function(data) { + if (data && data.length) { + if(is_playlist) { + kmc.vars.playlists_list = data; + } + else { + kmc.vars.players_list = data; + } + kmc.Preview.Service.updatePlayers(); + } + } + }); + } +}; + +kmc.client = { + makeRequest: function( service, action, params, callback ) { + var serviceUrl = kmc.vars.api_url + '/api_v3/index.php?service='+service+'&action='+action; + var defaultParams = { + "ks" : kmc.vars.ks, + "format" : 9 + }; + // Merge params and defaults + $.extend( params, defaultParams); + + var ksort = function ( arr ) { + var sArr = []; + var tArr = []; + var n = 0; + for ( var k in arr ){ + tArr[n++] = k+"|"+arr[k]; + } + tArr = tArr.sort(); + for (var i=0; i
    '); + }, + overlay: { + show: function() {$("#overlay").show();}, + hide: function() {$("#overlay").hide();} + }, + modal: { + el: '#modal', + + create: function(data) { + var options = { + 'el': kmc.layout.modal.el, + 'title': '', + 'content': '', + 'help': '', + 'width': 680, + 'height': 'auto', + 'className': '' + }; + // Overwrite defaults with data + $.extend(options, data); + // Set defaults + var $modal = $(options.el), + $modal_title = $modal.find(".title h2"), + $modal_content = $modal.find(".content"); + + // Add default ".modal" class + options.className = 'modal ' + options.className; + + // Set width & height + $modal.css( { + 'width' : options.width, + 'height' : options.height + }).attr('class', options.className); + + // Insert data into modal + if( options.title ) { + $modal_title.text(options.title).attr('title', options.title).parent().show(); + } else { + $modal_title.parent().hide(); + $modal_content.addClass('flash_only'); + } + $modal.find(".help").remove(); + $modal_title.parent().append( options.help ); + $modal_content[0].innerHTML = options.content; + + // Activate close button + $modal.find(".close").click( function() { + kmc.layout.modal.close(options.el); + if( $.isFunction( data.closeCallback ) ) { + data.closeCallback(); + } + }); + + return $modal; + }, + + show: function(el, position) { + position = (position === undefined) ? true : position; + el = el || kmc.layout.modal.el; + var $modal = $(el); + + kmc.utils.hideFlash(true); + kmc.layout.overlay.show(); + $modal.fadeIn(600); + + if( ! $.browser.msie ) { + $modal.css('display', 'table'); + } + + if( position ) { + this.position(el); + } + }, + + open: function(data) { + this.create(data); + var el = data.el || kmc.layout.modal.el; + this.show(el); + }, + + position: function(el) { + el = el || kmc.layout.modal.el; + var $modal = $(el); + // Calculate Modal Position + var mTop = ( ($(window).height() - $modal.height()) / 2 ), + mLeft = ( ($(window).width() - $modal.width()) / (2+$(window).scrollLeft()) ); + mTop = (mTop < 40) ? 40 : mTop; + // Apply style + $modal.css( { + 'top' : mTop + "px", + 'left' : mLeft + "px" + }); + + }, + close: function(el) { + el = el || kmc.layout.modal.el; + $(el).fadeOut(300, function() { + $(el).find(".content").html(''); + kmc.layout.overlay.hide(); + kmc.utils.hideFlash(); + }); + }, + isOpen: function(el) { + el = el || kmc.layout.modal.el; + return $(el).is(":visible"); + } + } +}; + +kmc.user = { + + openSupport: function(el) { + var href = el.href; + // Show overlay + kmc.utils.hideFlash(true); + kmc.layout.overlay.show(); + + // We want the show the modal only after the iframe is loaded so we use "create" instead of "open" + var modal_content = ''; + kmc.layout.modal.create( { + 'width' : 550, + 'title' : 'Support Request', + 'content' : modal_content + } ); + + // Wait until iframe loads and then show the modal + $("#support").load(function() { + // In order to get the iframe content height the modal must be visible + kmc.layout.modal.show(); + // Get iframe content height & update iframe + if( ! kmc.vars.support_frame_height ) { + kmc.vars.support_frame_height = $("#support")[0].contentWindow.document.body.scrollHeight; + } + $("#support").height( kmc.vars.support_frame_height ); + // Re-position the modal box + kmc.layout.modal.position(); + }); + }, + + logout: function() { + var message = kmc.functions.checkForOngoingProcess(); + if( message ) {alert( message );return false;} + var state = kmc.mediator.readUrlHash(); + // Cookies are HTTP only, we delete them using logoutAction + $.ajax({ + url: kmc.vars.base_url + "/index.php/kmc/logout", + type: "POST", + data: { + "ks": kmc.vars.ks + }, + dataType: "json", + complete: function() { + if (kmc.vars.logoutUrl) + window.location = kmc.vars.logoutUrl; + else + window.location = kmc.vars.service_url + "/index.php/kmc/kmc#" + state.moduleName + "|" + state.subtab; + } + }); + }, + + changeSetting: function(action) { + // Set title + var title, iframe_height; + switch(action) { + case "password": + title = "Change Password"; + iframe_height = 180; + break; + case "email": + title = "Change Email Address"; + iframe_height = 160; + break; + case "name": + title = "Edit Name"; + iframe_height = 200; + break; + } + + // setup url + var http_protocol = (kmc.vars.kmc_secured || location.protocol == 'https:') ? 'https' : 'http'; + var from_domain = http_protocol + '://' + window.location.hostname; + var url = from_domain + kmc.vars.port + "/index.php/kmc/updateLoginData/type/" + action; + // pass the parent url for the postMessage to work + url = url + '?parent=' + encodeURIComponent(document.location.href); + + var modal_content = ''; + + kmc.layout.modal.open( { + 'width' : 370, + 'title' : title, + 'content' : modal_content + } ); + + // setup a callback to handle the dispatched MessageEvent. if window.postMessage is supported the passed + // event will have .data, .origin and .source properties. otherwise, it will only have the .data property. + XD.receiveMessage(function(message){ + kmc.layout.modal.close(); + if(message.data == "reload") { + if( ($.browser.msie) && ($.browser.version < 8) ) { + window.location.hash = "account|user"; + } + window.location.reload(); + } + }, from_domain); + }, + + changePartner: function() { + + var i, pid = 0, selected, bolded, + total = kmc.vars.allowed_partners.length; + + var modal_content = '
    Please choose partner:
    '; + + for( i=0; i < total; i++ ) { + pid = kmc.vars.allowed_partners[i].id; + if( kmc.vars.partner_id == pid ) { + selected = ' checked="checked"'; + bolded = ' style="font-weight: bold"'; + } else { + selected = ''; + bolded = ''; + } + modal_content += '  ' + kmc.vars.allowed_partners[i].name + ''; + } + modal_content += '
    '; + + kmc.layout.modal.open( { + 'width' : 300, + 'title' : 'Change Account', + 'content' : modal_content + } ); + + $("#do_change_partner").click(function() { + + var url = kmc.vars.base_url + '/index.php/kmc/extlogin'; + + // Setup input fields + var ks_input = $('').attr({ + 'type': 'hidden', + 'name': 'ks', + 'value': kmc.vars.ks + }); + var partner_id_input = $('').attr({ + 'type': 'hidden', + 'name': 'partner_id', + 'value': $('input[name=pid]:radio:checked').val() // grab the selected partner id + }); + + var $form = $('
    ') + .attr({ + 'action': url, + 'method': 'post', + 'style': 'display: none' + }) + .append( ks_input, partner_id_input ); + + // Submit the form + $('body').append( $form ); + $form[0].submit(); + }); + + return false; + } +}; + +// Maintain support for old kmc2 functions: +function openPlayer(title, width, height, uiconf_id, previewOnly) { + if (previewOnly===true) $("#kcms")[0].alert('previewOnly from studio'); + kmc.preview_embed.doPreviewEmbed("multitab_playlist", title, null, previewOnly, true, uiconf_id, false, false, false); +} +function playlistAdded() {kmc.preview_embed.updateList(true);} +function playerAdded() {kmc.preview_embed.updateList(false);} +/*** end old functions ***/ + +// When page ready initilize KMC +$(function() { + kmc.layout.init(); + kmc.utils.handleMenu(); + kmc.functions.loadSwf(); + + // Set resize event to update the flash object size + $(window).wresize(kmc.utils.resize); + kmc.vars.isLoadedInterval = setInterval(kmc.utils.isModuleLoaded,200); + + // Load kdp player & playlists for preview & embed + kmc.preview_embed.updateList(); // Load players + kmc.preview_embed.updateList(true); // Load playlists + + // Set client IP + kmc.utils.setClientIP(); +}); + +// Auto resize modal windows +$(window).resize(function() { + // Exit if not open + if( kmc.layout.modal.isOpen() ) { + kmc.layout.modal.position(); + } +}); + +// If we have ongoing process, we show a warning message when the user try to leaves the page +window.onbeforeunload = kmc.functions.checkForOngoingProcess; + +/* WResize: plugin for fixing the IE window resize bug (http://noteslog.com/) */ +(function($){$.fn.wresize=function(f){version='1.1';wresize={fired:false,width:0};function resizeOnce(){if($.browser.msie){if(!wresize.fired){wresize.fired=true}else{var version=parseInt($.browser.version,10);wresize.fired=false;if(version<7){return false}else if(version==7){var width=$(window).width();if(width!=wresize.width){wresize.width=width;return false}}}}return true}function handleWResize(e){if(resizeOnce()){return f.apply(this,[e])}}this.each(function(){if(this==window){$(this).resize(handleWResize)}else{$(this).resize(f)}});return this}})(jQuery); + +/* XD: a backwards compatable implementation of postMessage (http://www.onlineaspect.com/2010/01/15/backwards-compatible-postmessage/) */ +var XD=function(){var e,g,h=1,f,d=this;return{postMessage:function(c,b,a){if(b)if(a=a||parent,d.postMessage)a.postMessage(c,b.replace(/([^:]+:\/\/[^\/]+).*/,"$1"));else if(b)a.location=b.replace(/#.*$/,"")+"#"+ +new Date+h++ +"&"+c},receiveMessage:function(c,b){if(d.postMessage)if(c&&(f=function(a){if(typeof b==="string"&&a.origin!==b||Object.prototype.toString.call(b)==="[object Function]"&&b(a.origin)===!1)return!1;c(a)}),d.addEventListener)d[c?"addEventListener":"removeEventListener"]("message", +f,!1);else d[c?"attachEvent":"detachEvent"]("onmessage",f);else e&&clearInterval(e),e=null,c&&(e=setInterval(function(){var a=document.location.hash,b=/^#?\d+&/;a!==g&&b.test(a)&&(g=a,c({data:a.replace(b,"")}))},100))}}}(); + +/* md5 and utf8_encode from phpjs.org */ +function md5(str){var xl;var rotateLeft=function(lValue,iShiftBits){return(lValue<>>(32-iShiftBits));};var addUnsigned=function(lX,lY){var lX4,lY4,lX8,lY8,lResult;lX8=(lX&0x80000000);lY8=(lY&0x80000000);lX4=(lX&0x40000000);lY4=(lY&0x40000000);lResult=(lX&0x3FFFFFFF)+(lY&0x3FFFFFFF);if(lX4&lY4){return(lResult^0x80000000^lX8^lY8);} +if(lX4|lY4){if(lResult&0x40000000){return(lResult^0xC0000000^lX8^lY8);}else{return(lResult^0x40000000^lX8^lY8);}}else{return(lResult^lX8^lY8);}};var _F=function(x,y,z){return(x&y)|((~x)&z);};var _G=function(x,y,z){return(x&z)|(y&(~z));};var _H=function(x,y,z){return(x^y^z);};var _I=function(x,y,z){return(y^(x|(~z)));};var _FF=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(_F(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var _GG=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(_G(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var _HH=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(_H(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var _II=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(_I(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var convertToWordArray=function(str){var lWordCount;var lMessageLength=str.length;var lNumberOfWords_temp1=lMessageLength+8;var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1%64))/64;var lNumberOfWords=(lNumberOfWords_temp2+1)*16;var lWordArray=new Array(lNumberOfWords-1);var lBytePosition=0;var lByteCount=0;while(lByteCount>>29;return lWordArray;};var wordToHex=function(lValue){var wordToHexValue="",wordToHexValue_temp="",lByte,lCount;for(lCount=0;lCount<=3;lCount++){lByte=(lValue>>>(lCount*8))&255;wordToHexValue_temp="0"+lByte.toString(16);wordToHexValue=wordToHexValue+wordToHexValue_temp.substr(wordToHexValue_temp.length-2,2);} +return wordToHexValue;};var x=[],k,AA,BB,CC,DD,a,b,c,d,S11=7,S12=12,S13=17,S14=22,S21=5,S22=9,S23=14,S24=20,S31=4,S32=11,S33=16,S34=23,S41=6,S42=10,S43=15,S44=21;str=this.utf8_encode(str);x=convertToWordArray(str);a=0x67452301;b=0xEFCDAB89;c=0x98BADCFE;d=0x10325476;xl=x.length;for(k=0;k127&&c1<2048){enc=String.fromCharCode((c1>>6)|192)+String.fromCharCode((c1&63)|128);}else{enc=String.fromCharCode((c1>>12)|224)+String.fromCharCode(((c1>>6)&63)|128)+String.fromCharCode((c1&63)|128);} +if(enc!==null){if(end>start){utftext+=string.slice(start,end);} +utftext+=enc;start=end=n+1;}} +if(end>start){utftext+=string.slice(start,stringl);} +return utftext;} \ No newline at end of file diff --git a/alpha/web/lib/js/kmc-full-6.0.6.min.js b/alpha/web/lib/js/kmc-full-6.0.6.min.js new file mode 100644 index 00000000000..765f0be9779 --- /dev/null +++ b/alpha/web/lib/js/kmc-full-6.0.6.min.js @@ -0,0 +1,6 @@ +/*! KMC - v6.0.6 - 2013-07-14 +* https://github.com/kaltura/KMC_V2 +* Copyright (c) 2013 Ran Yefet; Licensed GNU */ +function openPlayer(e,t,r,a,n){n===!0&&$("#kcms")[0].alert("previewOnly from studio"),kmc.preview_embed.doPreviewEmbed("multitab_playlist",e,null,n,!0,a,!1,!1,!1)}function playlistAdded(){kmc.preview_embed.updateList(!0)}function playerAdded(){kmc.preview_embed.updateList(!1)}function md5(e){var t,r,a,n,i,o,s,l,c,d,h=function(e,t){return e<>>32-t},u=function(e,t){var r,a,n,i,o;return n=2147483648&e,i=2147483648&t,r=1073741824&e,a=1073741824&t,o=(1073741823&e)+(1073741823&t),r&a?2147483648^o^n^i:r|a?1073741824&o?3221225472^o^n^i:1073741824^o^n^i:o^n^i},p=function(e,t,r){return e&t|~e&r},f=function(e,t,r){return e&r|t&~r},m=function(e,t,r){return e^t^r},v=function(e,t,r){return t^(e|~r)},g=function(e,t,r,a,n,i,o){return e=u(e,u(u(p(t,r,a),n),o)),u(h(e,i),t)},y=function(e,t,r,a,n,i,o){return e=u(e,u(u(f(t,r,a),n),o)),u(h(e,i),t)},b=function(e,t,r,a,n,i,o){return e=u(e,u(u(m(t,r,a),n),o)),u(h(e,i),t)},w=function(e,t,r,a,n,i,o){return e=u(e,u(u(v(t,r,a),n),o)),u(h(e,i),t)},k=function(e){for(var t,r=e.length,a=r+8,n=(a-a%64)/64,i=16*(n+1),o=Array(i-1),s=0,l=0;r>l;)t=(l-l%4)/4,s=8*(l%4),o[t]=o[t]|e.charCodeAt(l)<>>29,o},_=function(e){var t,r,a="",n="";for(r=0;3>=r;r++)t=255&e>>>8*r,n="0"+t.toString(16),a+=n.substr(n.length-2,2);return a},C=[],I=7,T=12,E=17,P=22,M=5,A=9,S=14,L=20,$=4,x=11,N=16,B=23,D=6,O=10,H=15,U=21;for(e=this.utf8_encode(e),C=k(e),s=1732584193,l=4023233417,c=2562383102,d=271733878,t=C.length,r=0;t>r;r+=16)a=s,n=l,i=c,o=d,s=g(s,l,c,d,C[r+0],I,3614090360),d=g(d,s,l,c,C[r+1],T,3905402710),c=g(c,d,s,l,C[r+2],E,606105819),l=g(l,c,d,s,C[r+3],P,3250441966),s=g(s,l,c,d,C[r+4],I,4118548399),d=g(d,s,l,c,C[r+5],T,1200080426),c=g(c,d,s,l,C[r+6],E,2821735955),l=g(l,c,d,s,C[r+7],P,4249261313),s=g(s,l,c,d,C[r+8],I,1770035416),d=g(d,s,l,c,C[r+9],T,2336552879),c=g(c,d,s,l,C[r+10],E,4294925233),l=g(l,c,d,s,C[r+11],P,2304563134),s=g(s,l,c,d,C[r+12],I,1804603682),d=g(d,s,l,c,C[r+13],T,4254626195),c=g(c,d,s,l,C[r+14],E,2792965006),l=g(l,c,d,s,C[r+15],P,1236535329),s=y(s,l,c,d,C[r+1],M,4129170786),d=y(d,s,l,c,C[r+6],A,3225465664),c=y(c,d,s,l,C[r+11],S,643717713),l=y(l,c,d,s,C[r+0],L,3921069994),s=y(s,l,c,d,C[r+5],M,3593408605),d=y(d,s,l,c,C[r+10],A,38016083),c=y(c,d,s,l,C[r+15],S,3634488961),l=y(l,c,d,s,C[r+4],L,3889429448),s=y(s,l,c,d,C[r+9],M,568446438),d=y(d,s,l,c,C[r+14],A,3275163606),c=y(c,d,s,l,C[r+3],S,4107603335),l=y(l,c,d,s,C[r+8],L,1163531501),s=y(s,l,c,d,C[r+13],M,2850285829),d=y(d,s,l,c,C[r+2],A,4243563512),c=y(c,d,s,l,C[r+7],S,1735328473),l=y(l,c,d,s,C[r+12],L,2368359562),s=b(s,l,c,d,C[r+5],$,4294588738),d=b(d,s,l,c,C[r+8],x,2272392833),c=b(c,d,s,l,C[r+11],N,1839030562),l=b(l,c,d,s,C[r+14],B,4259657740),s=b(s,l,c,d,C[r+1],$,2763975236),d=b(d,s,l,c,C[r+4],x,1272893353),c=b(c,d,s,l,C[r+7],N,4139469664),l=b(l,c,d,s,C[r+10],B,3200236656),s=b(s,l,c,d,C[r+13],$,681279174),d=b(d,s,l,c,C[r+0],x,3936430074),c=b(c,d,s,l,C[r+3],N,3572445317),l=b(l,c,d,s,C[r+6],B,76029189),s=b(s,l,c,d,C[r+9],$,3654602809),d=b(d,s,l,c,C[r+12],x,3873151461),c=b(c,d,s,l,C[r+15],N,530742520),l=b(l,c,d,s,C[r+2],B,3299628645),s=w(s,l,c,d,C[r+0],D,4096336452),d=w(d,s,l,c,C[r+7],O,1126891415),c=w(c,d,s,l,C[r+14],H,2878612391),l=w(l,c,d,s,C[r+5],U,4237533241),s=w(s,l,c,d,C[r+12],D,1700485571),d=w(d,s,l,c,C[r+3],O,2399980690),c=w(c,d,s,l,C[r+10],H,4293915773),l=w(l,c,d,s,C[r+1],U,2240044497),s=w(s,l,c,d,C[r+8],D,1873313359),d=w(d,s,l,c,C[r+15],O,4264355552),c=w(c,d,s,l,C[r+6],H,2734768916),l=w(l,c,d,s,C[r+13],U,1309151649),s=w(s,l,c,d,C[r+4],D,4149444226),d=w(d,s,l,c,C[r+11],O,3174756917),c=w(c,d,s,l,C[r+2],H,718787259),l=w(l,c,d,s,C[r+9],U,3951481745),s=u(s,a),l=u(l,n),c=u(c,i),d=u(d,o);var j=_(s)+_(l)+_(c)+_(d);return j.toLowerCase()}function utf8_encode(e){if(null===e||e===void 0)return"";var t,r,a=e+"",n="",i=0;t=r=0,i=a.length;for(var o=0;i>o;o++){var s=a.charCodeAt(o),l=null;128>s?r++:l=s>127&&2048>s?String.fromCharCode(192|s>>6)+String.fromCharCode(128|63&s):String.fromCharCode(224|s>>12)+String.fromCharCode(128|63&s>>6)+String.fromCharCode(128|63&s),null!==l&&(r>t&&(n+=a.slice(t,r)),n+=l,t=r=o+1)}return r>t&&(n+=a.slice(t,i)),n}this.Handlebars={},function(e){e.VERSION="1.0.rc.2",e.helpers={},e.partials={},e.registerHelper=function(e,t,r){r&&(t.not=r),this.helpers[e]=t},e.registerPartial=function(e,t){this.partials[e]=t},e.registerHelper("helperMissing",function(e){if(2===arguments.length)return void 0;throw Error("Could not find property '"+e+"'")});var t=Object.prototype.toString,r="[object Function]";e.registerHelper("blockHelperMissing",function(a,n){var i=n.inverse||function(){},o=n.fn,s=t.call(a);return s===r&&(a=a.call(this)),a===!0?o(this):a===!1||null==a?i(this):"[object Array]"===s?a.length>0?e.helpers.each(a,n):i(this):o(a)}),e.K=function(){},e.createFrame=Object.create||function(t){e.K.prototype=t;var r=new e.K;return e.K.prototype=null,r},e.logger={DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,methodMap:{0:"debug",1:"info",2:"warn",3:"error"},log:function(t,r){if(t>=e.logger.level){var a=e.logger.methodMap[t];"undefined"!=typeof console&&console[a]&&console[a].call(console,r)}}},e.log=function(t,r){e.logger.log(t,r)},e.registerHelper("each",function(t,r){var a,n=r.fn,i=r.inverse,o=0,s="";if(r.data&&(a=e.createFrame(r.data)),t&&"object"==typeof t)if(t instanceof Array)for(var l=t.length;l>o;o++)a&&(a.index=o),s+=n(t[o],{data:a});else for(var c in t)t.hasOwnProperty(c)&&(a&&(a.key=c),s+=n(t[c],{data:a}),o++);return 0===o&&(s=i(this)),s}),e.registerHelper("if",function(a,n){var i=t.call(a);return i===r&&(a=a.call(this)),!a||e.Utils.isEmpty(a)?n.inverse(this):n.fn(this)}),e.registerHelper("unless",function(t,r){var a=r.fn,n=r.inverse;return r.fn=n,r.inverse=a,e.helpers["if"].call(this,t,r)}),e.registerHelper("with",function(e,t){return t.fn(e)}),e.registerHelper("log",function(t,r){var a=r.data&&null!=r.data.level?parseInt(r.data.level,10):1;e.log(a,t)})}(this.Handlebars);var errorProps=["description","fileName","lineNumber","message","name","number","stack"];Handlebars.Exception=function(){for(var e=Error.prototype.constructor.apply(this,arguments),t=0;errorProps.length>t;t++)this[errorProps[t]]=e[errorProps[t]]},Handlebars.Exception.prototype=Error(),Handlebars.SafeString=function(e){this.string=e},Handlebars.SafeString.prototype.toString=function(){return""+this.string},function(){var e={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},t=/[&<>"'`]/g,r=/[&<>"'`]/,a=function(t){return e[t]||"&"};Handlebars.Utils={escapeExpression:function(e){return e instanceof Handlebars.SafeString?""+e:null==e||e===!1?"":r.test(e)?e.replace(t,a):e},isEmpty:function(e){return e||0===e?"[object Array]"===Object.prototype.toString.call(e)&&0===e.length?!0:!1:!0}}}(),Handlebars.VM={template:function(e){var t={escapeExpression:Handlebars.Utils.escapeExpression,invokePartial:Handlebars.VM.invokePartial,programs:[],program:function(e,t,r){var a=this.programs[e];return r?Handlebars.VM.program(t,r):a?a:a=this.programs[e]=Handlebars.VM.program(t)},programWithDepth:Handlebars.VM.programWithDepth,noop:Handlebars.VM.noop};return function(r,a){return a=a||{},e.call(t,Handlebars,r,a.helpers,a.partials,a.data)}},programWithDepth:function(e,t){var r=Array.prototype.slice.call(arguments,2);return function(a,n){return n=n||{},e.apply(this,[a,n.data||t].concat(r))}},program:function(e,t){return function(r,a){return a=a||{},e(r,a.data||t)}},noop:function(){return""},invokePartial:function(e,t,r,a,n,i){var o={helpers:a,partials:n,data:i};if(void 0===e)throw new Handlebars.Exception("The partial "+t+" could not be found");if(e instanceof Function)return e(r,o);if(Handlebars.compile)return n[t]=Handlebars.compile(e,{data:void 0!==i}),n[t](r,o);throw new Handlebars.Exception("The partial "+t+" could not be compiled when running in runtime-only mode")}},Handlebars.template=Handlebars.VM.template,function(e,t){var r=function(e,t){var r="",a=t?t+"[":"",n=t?"]":"";for(var i in e)if("object"==typeof e[i])for(var o in e[i])r+="&"+a+encodeURIComponent(i)+"."+encodeURIComponent(o)+n+"="+encodeURIComponent(e[i][o]);else r+="&"+a+encodeURIComponent(i)+n+"="+encodeURIComponent(e[i]);return r};t.registerHelper("flashVarsUrl",function(e){return r(e,"flashvars")}),t.registerHelper("flashVarsString",function(e){return r(e)}),t.registerHelper("elAttributes",function(e){var t="";for(var r in e)t+=" "+r+'="'+e[r]+'"';return t}),t.registerHelper("kalturaLinks",function(){if(!this.includeKalturaLinks)return"";var e=t.templates.kaltura_links;return e()}),t.registerHelper("seoMetadata",function(){var e=t.templates.seo_metadata;return e(this)})}(this,this.Handlebars),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.auto=e(function(e,t,r,a,n){function i(e){var t,a,n="";return n+='
    ",d=r.seoMetadata,t=d||e.seoMetadata,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"seoMetadata",{hash:{}})),(t||0===t)&&(n+=t),d=r.kalturaLinks,t=d||e.kalturaLinks,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"kalturaLinks",{hash:{}})),(t||0===t)&&(n+=t),n+="
    \n"}function o(e){var t,a="";return a+="&entry_id=",d=r.entryId,t=d||e.entryId,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"entryId",{hash:{}})),a+=g(t)}function s(e){var t,a="";return a+="&cache_st=",d=r.cacheSt,t=d||e.cacheSt,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"cacheSt",{hash:{}})),a+=g(t)}r=r||e.helpers;var l,c,d,h,u="",p=this,f="function",m=r.helperMissing,v=void 0,g=this.escapeExpression;return d=r.includeSeoMetadata,l=d||t.includeSeoMetadata,c=r["if"],h=p.program(1,i,n),h.hash={},h.fn=h,h.inverse=p.noop,l=c.call(t,l,h),(l||0===l)&&(u+=l),u+=''}),t.dynamic=e(function(e,t,r){r=r||e.helpers;var a,n,i,o="",s="function",l=r.helperMissing,c=void 0,d=this.escapeExpression;return o+='\n
    ",i=r.seoMetadata,a=i||t.seoMetadata,typeof a===s?a=a.call(t,{hash:{}}):a===c&&(a=l.call(t,"seoMetadata",{hash:{}})),(a||0===a)&&(o+=a),i=r.kalturaLinks,a=i||t.kalturaLinks,typeof a===s?a=a.call(t,{hash:{}}):a===c&&(a=l.call(t,"kalturaLinks",{hash:{}})),(a||0===a)&&(o+=a),o+="
    \n"}),t.iframe=e(function(e,t,r,a,n){function i(e){var t,a="";return a+="&entry_id=",l=r.entryId,t=l||e.entryId,typeof t===u?t=t.call(e,{hash:{}}):t===f&&(t=p.call(e,"entryId",{hash:{}})),a+=m(t)}r=r||e.helpers;var o,s,l,c,d="",h=this,u="function",p=r.helperMissing,f=void 0,m=this.escapeExpression;return d+='"}),t.kaltura_links=e(function(e,t,r){return r=r||e.helpers,'Video Platform\nVideo Management \nVideo Solutions\nVideo Player'}),t.legacy=e(function(e,t,r,a,n){function i(e){var t,a="";return a+='\n'}function o(e){var t,a="";return a+='\n \n \n \n \n \n \n '}r=r||e.helpers;var s,l,c,d,h="",u=this,p="function",f=r.helperMissing,m=void 0,v=this.escapeExpression;return c=r.includeHtml5Library,s=c||t.includeHtml5Library,l=r["if"],d=u.program(1,i,n),d.hash={},d.fn=d,d.inverse=u.noop,s=l.call(t,s,d),(s||0===s)&&(h+=s),h+='\n \n \n \n \n \n \n ',c=r.includeSeoMetadata,s=c||t.includeSeoMetadata,l=r["if"],d=u.program(3,o,n),d.hash={},d.fn=d,d.inverse=u.noop,s=l.call(t,s,d),(s||0===s)&&(h+=s),c=r.kalturaLinks,s=c||t.kalturaLinks,typeof s===p?s=s.call(t,{hash:{}}):s===m&&(s=f.call(t,"kalturaLinks",{hash:{}})),(s||0===s)&&(h+=s),h+="\n"}),t.seo_metadata=e(function(e,t,r,a,n){function i(e){var t,a="";return a+='\n\n\n\n\n\n\n'}r=r||e.helpers;var o,s,l,c,d=this,h="function",u=r.helperMissing,p=void 0,f=this.escapeExpression;return l=r.includeSeoMetadata,o=l||t.includeSeoMetadata,s=r["if"],c=d.program(1,i,n),c.hash={},c.fn=c,c.inverse=d.noop,o=s.call(t,o,c),o||0===o?o:""})}(),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){"use strict";if(null==this)throw new TypeError;var t=Object(this),r=t.length>>>0;if(0===r)return-1;var a=0;if(arguments.length>1&&(a=Number(arguments[1]),a!==a?a=0:0!==a&&1/0!==a&&a!==-1/0&&(a=(a>0||-1)*Math.floor(Math.abs(a)))),a>=r)return-1;for(var n=a>=0?a:Math.max(r-Math.abs(a),0);r>n;n++)if(n in t&&t[n]===e)return n;return-1}),Object.keys||(Object.keys=function(){var e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=r.length;return function(n){if("object"!=typeof n&&"function"!=typeof n||null===n)throw new TypeError("Object.keys called on non-object");var i=[];for(var o in n)e.call(n,o)&&i.push(o);if(t)for(var s=0;a>s;s++)e.call(n,r[s])&&i.push(r[s]);return i}}()),function(e,t){var r=function(e){this.init(e)};r.prototype={types:["auto","dynamic","thumb","iframe","legacy"],required:["widgetId","partnerId","uiConfId"],defaults:{embedType:"auto",playerId:"kaltura_player",protocol:"http",host:"www.kaltura.com",securedHost:"www.kaltura.com",widgetId:null,partnerId:null,cacheSt:null,uiConfId:null,entryId:null,entryMeta:{},width:400,height:330,attributes:{},flashVars:{},includeKalturaLinks:!0,includeSeoMetadata:!1,includeHtml5Library:!0},extend:function(e,t){for(var r in t)t.hasOwnProperty(r)&&!e.hasOwnProperty(r)&&(e[r]=t[r]);return e},isNull:function(e){return e.length&&e.length>0?!1:e.length&&0===e.length?!0:"object"==typeof e?Object.keys(e).length>0?!1:!0:!e},init:function(e){if(e=e||{},this.defaults,typeof Handlebars===t)throw"Handlebars is not defined, please include Handlebars.js before this script";return"object"==typeof e&&(this.options=this.extend(e,this.defaults)),!this.config("widgetId")&&this.config("partnerId")&&this.config("widgetId","_"+this.config("partnerId")),this},config:function(e,r){return r===t&&"string"==typeof e&&this.options.hasOwnProperty(e)?this.options[e]:e===t&&r===t?this.options:("string"==typeof e&&r!==t&&(this.options[e]=r),null)},checkRequiredParams:function(e){var t=this.required.length,r=0;for(r;t>r;r++)if(this.isNull(e[this.required[r]]))throw"Missing required parameter: "+this.required[r]},checkValidType:function(e){var t=-1!==this.types.indexOf(e)?!0:!1;if(!t)throw"Embed type: "+e+" is not valid. Available types: "+this.types.join(",")},getTemplate:function(e){return e="thumb"==e?"dynamic":e,e&&Handlebars.templates&&Handlebars.templates[e]?Handlebars.templates[e]:null},isKWidgetEmbed:function(e){return"dynamic"==e||"thumb"==e?!0:!1},getHost:function(e){return"http"===e.protocol?e.host:e.securedHost},getScriptUrl:function(e){return e.protocol+"://"+this.getHost(e)+"/p/"+e.partnerId+"/sp/"+e.partnerId+"00/embedIframeJs/uiconf_id/"+e.uiConfId+"/partner_id/"+e.partnerId},getSwfUrl:function(e){var t=e.cacheSt?"/cache_st/"+e.cacheSt:"",r=e.entryId?"/entry_id/"+e.entryId:"";return e.protocol+"://"+this.getHost(e)+"/index.php/kwidget"+t+"/wid/"+e.widgetId+"/uiconf_id/"+e.uiConfId+r},getAttributes:function(e){var t={};return(this.isKWidgetEmbed(e.embedType)||e.includeSeoMetadata)&&(t.style="width: "+e.width+"px; height: "+e.height+"px;"),e.includeSeoMetadata&&("legacy"==e.embedType?(t["xmlns:dc"]="http://purl.org/dc/terms/",t["xmlns:media"]="http://search.yahoo.com/searchmonkey/media/",t.rel="media:video",t.resource=this.getSwfUrl(e)):(t.itemprop="video",t["itemscope itemtype"]="http://schema.org/VideoObject")),t},getEmbedObject:function(e){var t={targetId:e.playerId,wid:e.widgetId,uiconf_id:e.uiConfId,flashvars:e.flashVars};return e.cacheSt&&(t.cache_st=e.cacheSt),e.entryId&&(t.entry_id=e.entryId),JSON.stringify(t,null,2)},getCode:function(e){var r=e===t?{}:this.extend({},e);r=this.extend(r,this.config()),!r.widgetId&&r.partnerId&&(r.widgetId="_"+r.partnerId),this.checkRequiredParams(r),this.checkValidType(r.embedType);var a=this.getTemplate(r.embedType);if(!a)throw"Template: "+r.embedType+" is not defined as Handlebars template";var n={host:this.getHost(r),scriptUrl:this.getScriptUrl(r),attributes:this.getAttributes(r)};return"legacy"===r.embedType&&(n.swfUrl=this.getSwfUrl(r)),this.isKWidgetEmbed(r.embedType)&&(n.embedMethod="dynamic"==r.embedType?"embed":"thumbEmbed",n.kWidgetObject=this.getEmbedObject(r)),n=this.extend(n,r),a(n)}},e.kEmbedCodeGenerator=r}(this),function(e){e.fn.qrcode=function(t){function r(e){this.mode=s.MODE_8BIT_BYTE,this.data=e}function a(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function n(e,t){if(void 0==e.length)throw Error(e.length+"/"+t);for(var r=0;e.length>r&&0==e[r];)r++;this.num=Array(e.length-r+t);for(var a=0;e.length-r>a;a++)this.num[a]=e[a+r]}function i(e,t){this.totalCount=e,this.dataCount=t}function o(){this.buffer=[],this.length=0}r.prototype={getLength:function(){return this.data.length},write:function(e){for(var t=0;this.data.length>t;t++)e.put(this.data.charCodeAt(t),8)}},a.prototype={addData:function(e){var t=new r(e);this.dataList.push(t),this.dataCache=null},isDark:function(e,t){if(0>e||e>=this.moduleCount||0>t||t>=this.moduleCount)throw Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){var e=1;for(e=1;40>e;e++){for(var t=i.getRSBlocks(e,this.errorCorrectLevel),r=new o,a=0,n=0;t.length>n;n++)a+=t[n].dataCount;for(var n=0;this.dataList.length>n;n++){var s=this.dataList[n];r.put(s.mode,4),r.put(s.getLength(),d.getLengthInBits(s.mode,e)),s.write(r)}if(8*a>=r.getLengthInBits())break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,t){this.moduleCount=4*this.typeNumber+17,this.modules=Array(this.moduleCount);for(var r=0;this.moduleCount>r;r++){this.modules[r]=Array(this.moduleCount);for(var n=0;this.moduleCount>n;n++)this.modules[r][n]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,t),this.typeNumber>=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=a.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;7>=r;r++)if(!(-1>=e+r||e+r>=this.moduleCount))for(var a=-1;7>=a;a++)-1>=t+a||t+a>=this.moduleCount||(this.modules[e+r][t+a]=r>=0&&6>=r&&(0==a||6==a)||a>=0&&6>=a&&(0==r||6==r)||r>=2&&4>=r&&a>=2&&4>=a?!0:!1)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;8>r;r++){this.makeImpl(!0,r);var a=d.getLostPoint(this);(0==r||e>a)&&(e=a,t=r)}return t},createMovieClip:function(e,t,r){var a=e.createEmptyMovieClip(t,r),n=1;this.make();for(var i=0;this.modules.length>i;i++)for(var o=i*n,s=0;this.modules[i].length>s;s++){var l=s*n,c=this.modules[i][s];c&&(a.beginFill(0,100),a.moveTo(l,o),a.lineTo(l+n,o),a.lineTo(l+n,o+n),a.lineTo(l,o+n),a.endFill())}return a},setupTimingPattern:function(){for(var e=8;this.moduleCount-8>e;e++)null==this.modules[e][6]&&(this.modules[e][6]=0==e%2);for(var t=8;this.moduleCount-8>t;t++)null==this.modules[6][t]&&(this.modules[6][t]=0==t%2)},setupPositionAdjustPattern:function(){for(var e=d.getPatternPosition(this.typeNumber),t=0;e.length>t;t++)for(var r=0;e.length>r;r++){var a=e[t],n=e[r];if(null==this.modules[a][n])for(var i=-2;2>=i;i++)for(var o=-2;2>=o;o++)this.modules[a+i][n+o]=-2==i||2==i||-2==o||2==o||0==i&&0==o?!0:!1}},setupTypeNumber:function(e){for(var t=d.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var a=!e&&1==(1&t>>r);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=a}for(var r=0;18>r;r++){var a=!e&&1==(1&t>>r);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=a}},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,a=d.getBCHTypeInfo(r),n=0;15>n;n++){var i=!e&&1==(1&a>>n);6>n?this.modules[n][8]=i:8>n?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(var n=0;15>n;n++){var i=!e&&1==(1&a>>n);8>n?this.modules[8][this.moduleCount-n-1]=i:9>n?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,a=this.moduleCount-1,n=7,i=0,o=this.moduleCount-1;o>0;o-=2)for(6==o&&o--;;){for(var s=0;2>s;s++)if(null==this.modules[a][o-s]){var l=!1;e.length>i&&(l=1==(1&e[i]>>>n));var c=d.getMask(t,a,o-s);c&&(l=!l),this.modules[a][o-s]=l,n--,-1==n&&(i++,n=7)}if(a+=r,0>a||a>=this.moduleCount){a-=r,r=-r;break}}}},a.PAD0=236,a.PAD1=17,a.createData=function(e,t,r){for(var n=i.getRSBlocks(e,t),s=new o,l=0;r.length>l;l++){var c=r[l];s.put(c.mode,4),s.put(c.getLength(),d.getLengthInBits(c.mode,e)),c.write(s)}for(var h=0,l=0;n.length>l;l++)h+=n[l].dataCount;if(s.getLengthInBits()>8*h)throw Error("code length overflow. ("+s.getLengthInBits()+">"+8*h+")");for(8*h>=s.getLengthInBits()+4&&s.put(0,4);0!=s.getLengthInBits()%8;)s.putBit(!1);for(;;){if(s.getLengthInBits()>=8*h)break;if(s.put(a.PAD0,8),s.getLengthInBits()>=8*h)break;s.put(a.PAD1,8)}return a.createBytes(s,n)},a.createBytes=function(e,t){for(var r=0,a=0,i=0,o=Array(t.length),s=Array(t.length),l=0;t.length>l;l++){var c=t[l].dataCount,h=t[l].totalCount-c;a=Math.max(a,c),i=Math.max(i,h),o[l]=Array(c);for(var u=0;o[l].length>u;u++)o[l][u]=255&e.buffer[u+r];r+=c;var p=d.getErrorCorrectPolynomial(h),f=new n(o[l],p.getLength()-1),m=f.mod(p);s[l]=Array(p.getLength()-1);for(var u=0;s[l].length>u;u++){var v=u+m.getLength()-s[l].length;s[l][u]=v>=0?m.get(v):0}}for(var g=0,u=0;t.length>u;u++)g+=t[u].totalCount;for(var y=Array(g),b=0,u=0;a>u;u++)for(var l=0;t.length>l;l++)o[l].length>u&&(y[b++]=o[l][u]);for(var u=0;i>u;u++)for(var l=0;t.length>l;l++)s[l].length>u&&(y[b++]=s[l][u]);return y};for(var s={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},l={L:1,M:0,Q:3,H:2},c={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},d={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var t=e<<10;d.getBCHDigit(t)-d.getBCHDigit(d.G15)>=0;)t^=d.G15<=0;)t^=d.G18<>>=1;return t},getPatternPosition:function(e){return d.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case c.PATTERN000:return 0==(t+r)%2;case c.PATTERN001:return 0==t%2;case c.PATTERN010:return 0==r%3;case c.PATTERN011:return 0==(t+r)%3;case c.PATTERN100:return 0==(Math.floor(t/2)+Math.floor(r/3))%2;case c.PATTERN101:return 0==t*r%2+t*r%3;case c.PATTERN110:return 0==(t*r%2+t*r%3)%2;case c.PATTERN111:return 0==(t*r%3+(t+r)%2)%2;default:throw Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new n([1],0),r=0;e>r;r++)t=t.multiply(new n([1,h.gexp(r)],0));return t},getLengthInBits:function(e,t){if(t>=1&&10>t)switch(e){case s.MODE_NUMBER:return 10;case s.MODE_ALPHA_NUM:return 9;case s.MODE_8BIT_BYTE:return 8;case s.MODE_KANJI:return 8;default:throw Error("mode:"+e)}else if(27>t)switch(e){case s.MODE_NUMBER:return 12;case s.MODE_ALPHA_NUM:return 11;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 10;default:throw Error("mode:"+e)}else{if(!(41>t))throw Error("type:"+t);switch(e){case s.MODE_NUMBER:return 14;case s.MODE_ALPHA_NUM:return 13;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 12;default:throw Error("mode:"+e)}}},getLostPoint:function(e){for(var t=e.getModuleCount(),r=0,a=0;t>a;a++)for(var n=0;t>n;n++){for(var i=0,o=e.isDark(a,n),s=-1;1>=s;s++)if(!(0>a+s||a+s>=t))for(var l=-1;1>=l;l++)0>n+l||n+l>=t||(0!=s||0!=l)&&o==e.isDark(a+s,n+l)&&i++; +i>5&&(r+=3+i-5)}for(var a=0;t-1>a;a++)for(var n=0;t-1>n;n++){var c=0;e.isDark(a,n)&&c++,e.isDark(a+1,n)&&c++,e.isDark(a,n+1)&&c++,e.isDark(a+1,n+1)&&c++,(0==c||4==c)&&(r+=3)}for(var a=0;t>a;a++)for(var n=0;t-6>n;n++)e.isDark(a,n)&&!e.isDark(a,n+1)&&e.isDark(a,n+2)&&e.isDark(a,n+3)&&e.isDark(a,n+4)&&!e.isDark(a,n+5)&&e.isDark(a,n+6)&&(r+=40);for(var n=0;t>n;n++)for(var a=0;t-6>a;a++)e.isDark(a,n)&&!e.isDark(a+1,n)&&e.isDark(a+2,n)&&e.isDark(a+3,n)&&e.isDark(a+4,n)&&!e.isDark(a+5,n)&&e.isDark(a+6,n)&&(r+=40);for(var d=0,n=0;t>n;n++)for(var a=0;t>a;a++)e.isDark(a,n)&&d++;var h=Math.abs(100*d/t/t-50)/5;return r+=10*h}},h={glog:function(e){if(1>e)throw Error("glog("+e+")");return h.LOG_TABLE[e]},gexp:function(e){for(;0>e;)e+=255;for(;e>=256;)e-=255;return h.EXP_TABLE[e]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},u=0;8>u;u++)h.EXP_TABLE[u]=1<u;u++)h.EXP_TABLE[u]=h.EXP_TABLE[u-4]^h.EXP_TABLE[u-5]^h.EXP_TABLE[u-6]^h.EXP_TABLE[u-8];for(var u=0;255>u;u++)h.LOG_TABLE[h.EXP_TABLE[u]]=u;n.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=Array(this.getLength()+e.getLength()-1),r=0;this.getLength()>r;r++)for(var a=0;e.getLength()>a;a++)t[r+a]^=h.gexp(h.glog(this.get(r))+h.glog(e.get(a)));return new n(t,0)},mod:function(e){if(0>this.getLength()-e.getLength())return this;for(var t=h.glog(this.get(0))-h.glog(e.get(0)),r=Array(this.getLength()),a=0;this.getLength()>a;a++)r[a]=this.get(a);for(var a=0;e.getLength()>a;a++)r[a]^=h.gexp(h.glog(e.get(a))+t);return new n(r,0).mod(e)}},i.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],i.getRSBlocks=function(e,t){var r=i.getRsBlockTable(e,t);if(void 0==r)throw Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+t);for(var a=r.length/3,n=[],o=0;a>o;o++)for(var s=r[3*o+0],l=r[3*o+1],c=r[3*o+2],d=0;s>d;d++)n.push(new i(l,c));return n},i.getRsBlockTable=function(e,t){switch(t){case l.L:return i.RS_BLOCK_TABLE[4*(e-1)+0];case l.M:return i.RS_BLOCK_TABLE[4*(e-1)+1];case l.Q:return i.RS_BLOCK_TABLE[4*(e-1)+2];case l.H:return i.RS_BLOCK_TABLE[4*(e-1)+3];default:return void 0}},o.prototype={get:function(e){var t=Math.floor(e/8);return 1==(1&this.buffer[t]>>>7-e%8)},put:function(e,t){for(var r=0;t>r;r++)this.putBit(1==(1&e>>>t-r-1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);t>=this.buffer.length&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},"string"==typeof t&&(t={text:t}),t=e.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,correctLevel:l.H,background:"#ffffff",foreground:"#000000"},t);var p=function(){var e=new a(t.typeNumber,t.correctLevel);e.addData(t.text),e.make();var r=document.createElement("canvas");r.width=t.width,r.height=t.height;for(var n=r.getContext("2d"),i=t.width/e.getModuleCount(),o=t.height/e.getModuleCount(),s=0;e.getModuleCount()>s;s++)for(var l=0;e.getModuleCount()>l;l++){n.fillStyle=e.isDark(s,l)?t.foreground:t.background;var c=Math.ceil((l+1)*i)-Math.floor(l*i),d=Math.ceil((s+1)*i)-Math.floor(s*i);n.fillRect(Math.round(l*i),Math.round(s*o),c,d)}return r},f=function(){var r=new a(t.typeNumber,t.correctLevel);r.addData(t.text),r.make();for(var n=e("
    ").css("width",t.width+"px").css("height",t.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",t.background),i=t.width/r.getModuleCount(),o=t.height/r.getModuleCount(),s=0;r.getModuleCount()>s;s++)for(var l=e("").css("height",o+"px").appendTo(n),c=0;r.getModuleCount()>c;c++)e("").css("width",i+"px").css("background-color",r.isDark(s,c)?t.foreground:t.background).appendTo(l);return n};return this.each(function(){var r="canvas"==t.render?p():f();e(r).appendTo(this)})}}(jQuery),window.XDomainRequest&&jQuery.ajaxTransport(function(e){if(e.crossDomain&&e.async){e.timeout&&(e.xdrTimeout=e.timeout,delete e.timeout);var t;return{send:function(r,a){function n(e,r,n,i){t.onload=t.onerror=t.ontimeout=jQuery.noop,t=void 0,a(e,r,n,i)}t=new XDomainRequest,t.onload=function(){n(200,"OK",{text:t.responseText},"Content-Type: "+t.contentType)},t.onerror=function(){n(404,"Not Found")},t.onprogress=jQuery.noop,t.ontimeout=function(){n(0,"timeout")},t.timeout=e.xdrTimeout||Number.MAX_VALUE,t.open(e.type,e.url),t.send(e.hasContent&&e.data||null)},abort:function(){t&&(t.onerror=jQuery.noop,t.abort())}}}}),function(){"use strict";var e,t=function(e,t){var r=e.style[t];if(e.currentStyle?r=e.currentStyle[t]:window.getComputedStyle&&(r=document.defaultView.getComputedStyle(e,null).getPropertyValue(t)),"auto"==r&&"cursor"==t)for(var a=["a"],n=0;a.length>n;n++)if(e.tagName.toLowerCase()==a[n])return"pointer";return r},r=function(e){if(u.prototype._singleton){e||(e=window.event);var t;this!==window?t=this:e.target?t=e.target:e.srcElement&&(t=e.srcElement),u.prototype._singleton.setCurrent(t)}},a=function(e,t,r){e.addEventListener?e.addEventListener(t,r,!1):e.attachEvent&&e.attachEvent("on"+t,r)},n=function(e,t,r){e.removeEventListener?e.removeEventListener(t,r,!1):e.detachEvent&&e.detachEvent("on"+t,r)},i=function(e,t){if(e.addClass)return e.addClass(t),e;if(t&&"string"==typeof t){var r=(t||"").split(/\s+/);if(1===e.nodeType)if(e.className){for(var a=" "+e.className+" ",n=e.className,i=0,o=r.length;o>i;i++)0>a.indexOf(" "+r[i]+" ")&&(n+=" "+r[i]);e.className=n.replace(/^\s+|\s+$/g,"")}else e.className=t}return e},o=function(e,t){if(e.removeClass)return e.removeClass(t),e;if(t&&"string"==typeof t||void 0===t){var r=(t||"").split(/\s+/);if(1===e.nodeType&&e.className)if(t){for(var a=(" "+e.className+" ").replace(/[\n\t]/g," "),n=0,i=r.length;i>n;n++)a=a.replace(" "+r[n]+" "," ");e.className=a.replace(/^\s+|\s+$/g,"")}else e.className=""}return e},s=function(e){var r={left:0,top:0,width:e.width||e.offsetWidth||0,height:e.height||e.offsetHeight||0,zIndex:9999},a=t(e,"zIndex");for(a&&"auto"!=a&&(r.zIndex=parseInt(a,10));e;){var n=parseInt(t(e,"borderLeftWidth"),10),i=parseInt(t(e,"borderTopWidth"),10);r.left+=isNaN(e.offsetLeft)?0:e.offsetLeft,r.left+=isNaN(n)?0:n,r.top+=isNaN(e.offsetTop)?0:e.offsetTop,r.top+=isNaN(i)?0:i,e=e.offsetParent}return r},l=function(e){return(e.indexOf("?")>=0?"&":"?")+"nocache="+(new Date).getTime()},c=function(e){var t=[];return e.trustedDomains&&("string"==typeof e.trustedDomains?t.push("trustedDomain="+e.trustedDomains):t.push("trustedDomain="+e.trustedDomains.join(","))),t.join("&")},d=function(e,t){if(t.indexOf)return t.indexOf(e);for(var r=0,a=t.length;a>r;r++)if(t[r]===e)return r;return-1},h=function(e){if("string"==typeof e)throw new TypeError("ZeroClipboard doesn't accept query strings.");return e.length?e:[e]},u=function(e,t){if(e&&(u.prototype._singleton||this).glue(e),u.prototype._singleton)return u.prototype._singleton;u.prototype._singleton=this,this.options={};for(var r in f)this.options[r]=f[r];for(var a in t)this.options[a]=t[a];this.handlers={},u.detectFlashSupport()&&m()},p=[];u.prototype.setCurrent=function(r){e=r,this.reposition(),r.getAttribute("title")&&this.setTitle(r.getAttribute("title")),this.setHandCursor("pointer"==t(r,"cursor"))},u.prototype.setText=function(e){e&&""!==e&&(this.options.text=e,this.ready()&&this.flashBridge.setText(e))},u.prototype.setTitle=function(e){e&&""!==e&&this.htmlBridge.setAttribute("title",e)},u.prototype.setSize=function(e,t){this.ready()&&this.flashBridge.setSize(e,t)},u.prototype.setHandCursor=function(e){this.ready()&&this.flashBridge.setHandCursor(e)},u.version="1.1.7";var f={moviePath:"ZeroClipboard.swf",trustedDomains:null,text:null,hoverClass:"zeroclipboard-is-hover",activeClass:"zeroclipboard-is-active",allowScriptAccess:"sameDomain"};u.setDefaults=function(e){for(var t in e)f[t]=e[t]},u.destroy=function(){u.prototype._singleton.unglue(p);var e=u.prototype._singleton.htmlBridge;e.parentNode.removeChild(e),delete u.prototype._singleton},u.detectFlashSupport=function(){var e=!1;try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(e=!0)}catch(t){navigator.mimeTypes["application/x-shockwave-flash"]&&(e=!0)}return e};var m=function(){var e=u.prototype._singleton,t=document.getElementById("global-zeroclipboard-html-bridge");if(!t){var r=' ';t=document.createElement("div"),t.id="global-zeroclipboard-html-bridge",t.setAttribute("class","global-zeroclipboard-container"),t.setAttribute("data-clipboard-ready",!1),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="15px",t.style.height="15px",t.style.zIndex="9999",t.innerHTML=r,document.body.appendChild(t)}e.htmlBridge=t,e.flashBridge=document["global-zeroclipboard-flash-bridge"]||t.children[0].lastElementChild};u.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),o(e,this.options.activeClass),e=null,this.options.text=null},u.prototype.ready=function(){var e=this.htmlBridge.getAttribute("data-clipboard-ready");return"true"===e||e===!0},u.prototype.reposition=function(){if(!e)return!1;var t=s(e);this.htmlBridge.style.top=t.top+"px",this.htmlBridge.style.left=t.left+"px",this.htmlBridge.style.width=t.width+"px",this.htmlBridge.style.height=t.height+"px",this.htmlBridge.style.zIndex=t.zIndex+1,this.setSize(t.width,t.height)},u.dispatch=function(e,t){u.prototype._singleton.receiveEvent(e,t)},u.prototype.on=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++)e=r[a].toLowerCase().replace(/^on/,""),this.handlers[e]||(this.handlers[e]=t);this.handlers.noflash&&!u.detectFlashSupport()&&this.receiveEvent("onNoFlash",null)},u.prototype.addEventListener=u.prototype.on,u.prototype.off=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++){e=r[a].toLowerCase().replace(/^on/,"");for(var n in this.handlers)n===e&&this.handlers[n]===t&&delete this.handlers[n]}},u.prototype.removeEventListener=u.prototype.off,u.prototype.receiveEvent=function(t,r){t=(""+t).toLowerCase().replace(/^on/,"");var a=e;switch(t){case"load":if(r&&10>parseFloat(r.flashVersion.replace(",",".").replace(/[^0-9\.]/gi,"")))return this.receiveEvent("onWrongFlash",{flashVersion:r.flashVersion}),void 0;this.htmlBridge.setAttribute("data-clipboard-ready",!0);break;case"mouseover":i(a,this.options.hoverClass);break;case"mouseout":o(a,this.options.hoverClass),this.resetBridge();break;case"mousedown":i(a,this.options.activeClass);break;case"mouseup":o(a,this.options.activeClass);break;case"datarequested":var n=a.getAttribute("data-clipboard-target"),s=n?document.getElementById(n):null;if(s){var l=s.value||s.textContent||s.innerText;l&&this.setText(l)}else{var c=a.getAttribute("data-clipboard-text");c&&this.setText(c)}break;case"complete":this.options.text=null}if(this.handlers[t]){var d=this.handlers[t];"function"==typeof d?d.call(a,this,r):"string"==typeof d&&window[d].call(a,this,r)}},u.prototype.glue=function(e){e=h(e);for(var t=0;e.length>t;t++)-1==d(e[t],p)&&(p.push(e[t]),a(e[t],"mouseover",r))},u.prototype.unglue=function(e){e=h(e);for(var t=0;e.length>t;t++){n(e[t],"mouseover",r);var a=d(e[t],p);-1!=a&&p.splice(a,1)}},"undefined"!=typeof module?module.exports=u:"function"==typeof define&&define.amd?define(function(){return u}):window.ZeroClipboard=u}(),function(e){var t=e.Preview||{};e.vars.previewDefaults={showAdvancedOptions:!1,includeKalturaLinks:!e.vars.ignore_seo_links,includeSeoMetadata:!e.vars.ignore_entry_seo,deliveryType:e.vars.default_delivery_type,embedType:e.vars.default_embed_code_type,secureEmbed:e.vars.embed_code_protocol_https},"https:"==window.location.protocol&&(e.vars.previewDefaults.secureEmbed=!0),t.storageName="previewDefaults",t.el="#previewModal",t.iframeContainer="previewIframe",t.ignoreChangeEvents=!0,t.getGenerator=function(){return this.generator||(this.generator=new kEmbedCodeGenerator({host:e.vars.embed_host,securedHost:e.vars.embed_host_https,partnerId:e.vars.partner_id,includeKalturaLinks:e.vars.previewDefaults.includeKalturaLinks})),this.generator},t.clipboard=new ZeroClipboard($(".copy-code"),{moviePath:"/lib/flash/ZeroClipboard.swf",trustedDomains:["*"],allowScriptAccess:"always"}),t.clipboard.on("complete",function(){var e=$(this);$("#"+e.data("clipboard-target")).select(),e.data("close")===!0&&t.closeModal(t.el)}),t.objectToArray=function(e){var t=[];for(var r in e)e[r].id=r,t.push(e[r]);return t},t.getObjectById=function(e,t){var r=$.grep(t,function(t){return t.id==e});return r.length?r[0]:!1},t.getDefault=function(r){var a=localStorage.getItem(t.storageName);return a=a?JSON.parse(a):e.vars.previewDefaults,void 0!==a[r]?a[r]:null},t.savePreviewState=function(){var e=this.Service,r={embedType:e.get("embedType"),secureEmbed:e.get("secureEmbed"),includeSeoMetadata:e.get("includeSeo"),deliveryType:e.get("deliveryType").id,showAdvancedOptions:e.get("showAdvancedOptions")};localStorage.setItem(t.storageName,JSON.stringify(r))},t.getDeliveryTypeFlashVars=function(e){if(!e)return{};var t=e.flashvars?e.flashvars:{},r=$.extend({},t);return e.streamerType&&(r.streamerType=e.streamerType),e.mediaProtocol&&(r.mediaProtocol=e.mediaProtocol),r},t.getPreviewTitle=function(e){return e.entryMeta&&e.entryMeta.name?"Embedding: "+e.entryMeta.name:e.playlistName?"Playlist: "+e.playlistName:e.playerOnly?"Player Name:"+e.name:void 0},t.openPreviewEmbed=function(t,r){var a=this,n=a.el;this.ignoreChangeEvents=!1;var i={entryId:null,entryMeta:{},playlistId:null,playlistName:null,previewOnly:!1,liveBitrates:null,playerOnly:!1,uiConfId:null,name:null};t=$.extend({},i,t),t.liveBitrates&&r.setDeliveryType("auto"),r.updatePlayers(t),r.set(t);var o=this.getPreviewTitle(t),s=$(n);s.find(".title h2").text(o).attr("title",o),s.find(".close").unbind("click").click(function(){a.closeModal(n)});var l=$("body").height()-173;s.find(".content").height(l),e.layout.modal.show(n,!1)},t.closeModal=function(t){this.savePreviewState(),this.emptyDiv(this.iframeContainer),$(t).fadeOut(300,function(){e.layout.overlay.hide(),e.utils.hideFlash()})},t.emptyDiv=function(e){var t=$("#"+e),r=$("#previewIframe iframe");if(r.length)try{var a=$(r[0].contentWindow.document);a.find("#framePlayerContainer").empty()}catch(n){}return t.length?(t.empty(),t[0]):!1},t.hasIframe=function(){return $("#"+this.iframeContainer+" iframe").length},t.getCacheSt=function(){var e=new Date;return Math.floor(e.getTime()/1e3)+900},t.generateIframe=function(e){var t=$("html").hasClass("lt-ie10"),r="",a=this.emptyDiv(this.iframeContainer),n=document.createElement("iframe");if(n.frameborder="0",n.frameBorder="0",n.marginheight="0",n.marginwidth="0",n.frameborder="0",a.appendChild(n),t)n.src=this.getPreviewUrl(this.Service,!0);else{var i=n.contentDocument;i.open(),i.write(""+r+'
    '+e+"
    "),i.close()}},t.getEmbedProtocol=function(e,t){return t===!0?location.protocol.substring(0,location.protocol.length-1):e.get("secureEmbed")?"https":"http"},t.getEmbedFlashVars=function(t,r){var a=this.getEmbedProtocol(t,r),n=t.get("player"),i=this.getDeliveryTypeFlashVars(t.get("deliveryType"));r===!0&&(i.ks=e.vars.ks);var o=t.get("playlistId");if(o){var s=e.functions.getVersionFromPath(n.html5Url),l=e.functions.versionIsAtLeast(e.vars.min_kdp_version_for_playlist_api_v3,n.swf_version),c=e.functions.versionIsAtLeast(e.vars.min_html5_version_for_playlist_api_v3,s);l&&c?i["playlistAPI.kpl0Id"]=o:(i["playlistAPI.autoInsert"]="true",i["playlistAPI.kpl0Name"]=t.get("playlistName"),i["playlistAPI.kpl0Url"]=a+"://"+e.vars.api_host+"/index.php/partnerservices2/executeplaylist?"+"partner_id="+e.vars.partner_id+"&subp_id="+e.vars.partner_id+"00"+"&format=8&ks={ks}&playlist_id="+o)}return i},t.getEmbedCode=function(e,t){var r=e.get("player");if(!r||!e.get("embedType"))return"";var a=this.getCacheSt(),n={protocol:this.getEmbedProtocol(e,t),embedType:e.get("embedType"),uiConfId:r.id,width:r.width,height:r.height,entryMeta:e.get("entryMeta"),includeSeoMetadata:e.get("includeSeo"),playerId:"kaltura_player_"+a,cacheSt:a,flashVars:this.getEmbedFlashVars(e,t)};e.get("entryId")&&(n.entryId=e.get("entryId"));var i=this.getGenerator().getCode(n);return i},t.getPreviewUrl=function(t,r){var a=t.get("player");if(!a||!t.get("embedType"))return"";var n=this.getEmbedProtocol(t,r),i=n+"://"+e.vars.base_host+"/index.php/kmc/preview";return i+="/partner_id/"+e.vars.partner_id,i+="/uiconf_id/"+a.id,t.get("entryId")&&(i+="/entry_id/"+t.get("entryId")),i+="/embed/"+t.get("embedType"),i+="?"+e.functions.flashVarsToUrl(this.getEmbedFlashVars(t,r)),r===!0&&(i+="&framed=true"),i},t.generateQrCode=function(e){var t=$("#qrcode").empty();e&&($("html").hasClass("lt-ie9")||t.qrcode({width:80,height:80,text:e}))},t.generateShortUrl=function(t,r){t&&e.client.createShortURL(t,r)},e.Preview=t}(window.kmc);var kmcApp=angular.module("kmcApp",[]);kmcApp.factory("previewService",["$rootScope",function(e){var t={};return{get:function(e){return void 0===e?t:t[e]},set:function(r,a,n){"object"==typeof r?angular.extend(t,r):t[r]=a,n||e.$broadcast("previewChanged")},updatePlayers:function(t){e.$broadcast("playersUpdated",t)},changePlayer:function(t){e.$broadcast("changePlayer",t)},setDeliveryType:function(t){e.$broadcast("changeDelivery",t)}}}]),kmcApp.directive("showSlide",function(){return{restrict:"A",link:function(e,t,r){r.showSlide,e.$watch(r.showSlide,function(e){e&&!t.is(":visible")?t.slideDown():t.slideUp()})}}}),kmcApp.controller("PreviewCtrl",["$scope","previewService",function(e,t){var r=function(){e.$$phase||e.$apply()},a=kmc.Preview;a.playlistMode=!1,a.Service=t;var n=function(t){t=t||{};var r=t.uiConfId?t.uiConfId:void 0;kmc.vars.playlists_list&&kmc.vars.players_list&&(t.playlistId||t.playerOnly?(e.players=kmc.vars.playlists_list,a.playlistMode||(a.playlistMode=!0,e.$broadcast("changePlayer",r))):(e.players=kmc.vars.players_list,(a.playlistMode||!e.player)&&(a.playlistMode=!1,e.$broadcast("changePlayer",r))),r&&e.$broadcast("changePlayer",r))},i=function(r){var n=a.objectToArray(kmc.vars.delivery_types),i=e.deliveryType||a.getDefault("deliveryType"),o=[];$.each(n,function(){return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,r.swf_version)?(this.id==i&&(i=null),!0):(o.push(this),void 0)}),e.deliveryTypes=o,i||(i=e.deliveryTypes[0].id),t.setDeliveryType(i)},o=function(t){var r=a.objectToArray(kmc.vars.embed_code_types),n=e.embedType||a.getDefault("embedType"),i=[];$.each(r,function(){if(a.playlistMode&&this.entryOnly)return this.id==n&&(n=null),!0;var e=kmc.functions.getVersionFromPath(t.html5Url);return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,e)?(this.id==n&&(n=null),!0):(i.push(this),void 0)}),e.embedTypes=i,n||(n=e.embedTypes[0].id),e.embedType=n};e.players=[],e.player=null,e.deliveryTypes=[],e.deliveryType=null,e.embedTypes=[],e.embedType=null,e.secureEmbed=a.getDefault("secureEmbed"),e.includeSeo=a.getDefault("includeSeoMetadata"),e.previewOnly=!1,e.playerOnly=!1,e.liveBitrates=!1,e.showAdvancedOptionsStatus=a.getDefault("showAdvancedOptions"),e.shortLinkGenerated=!1,e.$on("playersUpdated",function(e,t){n(t)}),e.$on("changePlayer",function(t,a){a=a?a:e.players[0].id,e.player=a,r()}),e.$on("changeDelivery",function(t,a){e.deliveryType=a,r()}),e.showAdvancedOptions=function(r,a){r.preventDefault(),t.set("showAdvancedOptions",a,!0),e.showAdvancedOptionsStatus=a},e.$watch("showAdvancedOptionsStatus",function(){a.clipboard.reposition()}),e.$watch("player",function(){var r=a.getObjectById(e.player,e.players);r&&(i(r),o(r),t.set("player",r))}),e.$watch("deliveryType",function(){t.set("deliveryType",a.getObjectById(e.deliveryType,e.deliveryTypes))}),e.$watch("embedType",function(){t.set("embedType",e.embedType)}),e.$watch("secureEmbed",function(){t.set("secureEmbed",e.secureEmbed)}),e.$watch("includeSeo",function(){t.set("includeSeo",e.includeSeo)}),e.$watch("embedCodePreview",function(){a.generateIframe(e.embedCodePreview)}),e.$watch("previewOnly",function(){e.closeButtonText=e.previewOnly?"Close":"Copy Embed & Close",r()}),e.$on("previewChanged",function(){if(!a.ignoreChangeEvents){var n=a.getPreviewUrl(t);e.embedCode=a.getEmbedCode(t),e.embedCodePreview=a.getEmbedCode(t,!0),e.previewOnly=t.get("previewOnly"),e.playerOnly=t.get("playerOnly"),e.liveBitrates=t.get("liveBitrates"),r(),a.hasIframe()||a.generateIframe(e.embedCodePreview),e.previewUrl="Updating...",e.shortLinkGenerated=!1,a.generateShortUrl(n,function(t){t||(t=n),e.shortLinkGenerated=!0,e.previewUrl=t,a.generateQrCode(t),r()})}})}]),0==kmc.vars.allowFrame&&top!=window&&(top.location=window.location),kmc.vars.debug=!1,kmc.vars.quickstart_guide="/content/docs/pdf/KMC_User_Manual.pdf",kmc.vars.help_url=kmc.vars.service_url+"/kmc5help.html",kmc.vars.port=window.location.port?":"+window.location.port:"",kmc.vars.base_host=window.location.hostname+kmc.vars.port,kmc.vars.base_url=window.location.protocol+"//"+kmc.vars.base_host,kmc.vars.api_host=kmc.vars.host,kmc.vars.api_url=window.location.protocol+"//"+kmc.vars.api_host,kmc.vars.min_kdp_version_for_playlist_api_v3="3.6.15",kmc.vars.min_html5_version_for_playlist_api_v3="1.7.1.3",kmc.log=function(){if(kmc.vars.debug&&"undefined"!=typeof console&&console.log)if(1==arguments.length)console.log(arguments[0]);else{var e=Array.prototype.slice.call(arguments);console.log(e[0],e.slice(1))}},kmc.functions={loadSwf:function(){var e=window.location.protocol+"//"+kmc.vars.cdn_host+"/flash/kmc/"+kmc.vars.kmc_version+"/kmc.swf",t={kmc_uiconf:kmc.vars.kmc_general_uiconf,permission_uiconf:kmc.vars.kmc_permissions_uiconf,host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,srvurl:"api_v3/index.php",protocol:window.location.protocol+"//",partnerid:kmc.vars.partner_id,subpid:kmc.vars.partner_id+"00",ks:kmc.vars.ks,entryId:"-1",kshowId:"-1",debugmode:"true",widget_id:"_"+kmc.vars.partner_id,urchinNumber:kmc.vars.google_analytics_account,firstLogin:kmc.vars.first_login,openPlayer:"kmc.preview_embed.doPreviewEmbed",openPlaylist:"kmc.preview_embed.doPreviewEmbed",openCw:"kmc.functions.openKcw",language:kmc.vars.language||""};kmc.vars.disable_analytics&&(t.disableAnalytics=!0);var r={allowNetworking:"all",allowScriptAccess:"always"};swfobject.embedSWF(e,"kcms","100%","100%","10.0.0",!1,t,r),$("#kcms").attr("style","")},checkForOngoingProcess:function(){var e;try{e=$("#kcms")[0].hasOngoingProcess()}catch(t){e=null}return null!==e?e:void 0},expired:function(){kmc.user.logout()},openKcw:function(e,t){e=e||"";var r="uploadWebCam"==t?kmc.vars.kcw_webcam_uiconf:kmc.vars.kcw_import_uiconf,a={host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,protocol:window.location.protocol.slice(0,-1),partnerid:kmc.vars.partner_id,subPartnerId:kmc.vars.partner_id+"00",sessionId:kmc.vars.ks,devFlag:"true",entryId:"-1",kshow_id:"-1",terms_of_use:kmc.vars.terms_of_use,close:"kmc.functions.onCloseKcw",quick_edit:0,kvar_conversionQuality:e},n={allowscriptaccess:"always",allownetworking:"all",bgcolor:"#DBE3E9",quality:"high",movie:kmc.vars.service_url+"/kcw/ui_conf_id/"+r};kmc.layout.modal.open({width:700,height:420,content:'
    '}),swfobject.embedSWF(n.movie,"kcw","680","400","9.0.0",!1,a,n)},onCloseKcw:function(){kmc.layout.modal.close(),$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})},openChangePwd:function(){kmc.user.changeSetting("password")},openChangeEmail:function(){kmc.user.changeSetting("email")},openChangeName:function(){kmc.user.changeSetting("name")},getAddPanelPosition:function(){var e=$("#add").parent();return e.position().left+e.width()-10},openClipApp:function(e,t){var r=kmc.vars.base_url+"/apps/clipapp/"+kmc.vars.clipapp.version;r+="/?kdpUiconf="+kmc.vars.clipapp.kdp+"&kclipUiconf="+kmc.vars.clipapp.kclip,r+="&partnerId="+kmc.vars.partner_id+"&host="+kmc.vars.host+"&mode="+t+"&config=kmc&entryId="+e;var a="trim"==t?"Trimming Tool":"Clipping Tool";kmc.layout.modal.open({width:950,height:616,title:a,content:'',className:"iframe",closeCallback:function(){$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})}})},flashVarsToUrl:function(e){var t="";for(var r in e){var a="object"==typeof e[r]?JSON.stringify(e[r]):e[r];t+="&flashvars["+encodeURIComponent(r)+"]="+encodeURIComponent(a)}return t},versionIsAtLeast:function(e,t){if(!t)return!1;for(var r=e.split("."),a=t.split("."),n=0;r.length>n;n++){if(parseInt(a[n])>parseInt(r[n]))return!0;if(parseInt(a[n]) *").each(function(){e+=$(this).width()});var t=function(){kmc.vars.close_menu=!0;var t={width:0,visibility:"visible",top:"6px",right:"6px"},r={width:e+"px","padding-top":"2px","padding-bottom":"2px"};$("#user_links").css(t),$("#user_links").animate(r,500)};$("#user").hover(t).click(t),$("#user_links").mouseover(function(){kmc.vars.close_menu=!1}),$("#user_links").mouseleave(function(){kmc.vars.close_menu=!0,setTimeout(kmc.utils.closeMenu,650)}),$("#closeMenu").click(function(){kmc.vars.close_menu=!0,kmc.utils.closeMenu()})},closeMenu:function(){kmc.vars.close_menu&&$("#user_links").animate({width:0},500,function(){$("#user_links").css({width:"auto",visibility:"hidden"})})},activateHeader:function(){$("#user_links a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id");switch(t){case"Quickstart Guide":return this.href=kmc.vars.quickstart_guide,!0;case"Logout":return kmc.user.logout(),!1;case"Support":return kmc.user.openSupport(this),!1;case"ChangePartner":return kmc.user.changePartner(),!1;default:return!1}})},resize:function(){var e=$.browser.ie?640:590,t=$(document).height(),r=$.browser.mozilla?37:74;t-=r,t=e>t?e:t,$("#flash_wrap").height(t+"px"),$("#server_wrap iframe").height(t+"px"),$("#server_wrap").css("margin-top","-"+(t+2)+"px")},isModuleLoaded:function(){($("#flash_wrap object").length||$("#flash_wrap embed").length)&&(kmc.utils.resize(),clearInterval(kmc.vars.isLoadedInterval),kmc.vars.isLoadedInterval=null)},debug:function(){try{console.info(" ks: ",kmc.vars.ks),console.info(" partner_id: ",kmc.vars.partner_id)}catch(e){}},maskHeader:function(e){e?$("#mask").hide():$("#mask").show()},createTabs:function(e){if($("#closeMenu").trigger("click"),e){for(var t,r=kmc.vars.service_url+"/index.php/kmc/kmc4",a=e.length,n="",i=0;a>i;i++)t="action"==e[i].type?'class="menu" ':"",n+='
  • '+e[i].display_name+"
  • ";$("#hTabs").html(n);var o=$("body").width()-($("#logo").width()+$("#hTabs").width()+100);$("#user").width()+20>o&&$("#user").width(o),$("#hTabs a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id"),r="A"==e.target.tagName?$(e.target).attr("rel"):$(e.target).parent().attr("rel"),a={moduleName:t,subtab:r};return $("#kcms")[0].gotoPage(a),!1})}else alert("Error geting tabs")},setTab:function(e,t){t&&$("#kmcHeader ul li a").removeClass("active"),$("a#"+e).addClass("active")},resetTab:function(e){$("a#"+e).removeClass("active")},hideFlash:function(e){var t=$("html").hasClass("lt-ie8");e?t?$("#flash_wrap").css("margin-right","3333px"):($("#flash_wrap").css("visibility","hidden"),$("#flash_wrap object").css("visibility","hidden")):t?$("#flash_wrap").css("margin-right","0"):($("#flash_wrap").css("visibility","visible"),$("#flash_wrap object").css("visibility","visible"))},showFlash:function(){$("#server_wrap").hide(),$("#server_frame").removeAttr("src"),kmc.layout.modal.isOpen()||$("#flash_wrap").css("visibility","visible"),$("#server_wrap").css("margin-top",0)},openIframe:function(e){$("#flash_wrap").css("visibility","hidden"),$("#server_frame").attr("src",e),$("#server_wrap").css("margin-top","-"+($("#flash_wrap").height()+2)+"px"),$("#server_wrap").show() +},openHelp:function(e){$("#kcms")[0].doHelp(e)},setClientIP:function(){kmc.vars.clientIP="",kmc.vars.akamaiEdgeServerIpURL&&$.ajax({url:window.location.protocol+"//"+kmc.vars.akamaiEdgeServerIpURL,crossDomain:!0,success:function(e){kmc.vars.clientIP=$(e).find("serverip").text()}})},getClientIP:function(){return kmc.vars.clientIP}},kmc.mediator={writeUrlHash:function(e,t){location.hash=e+"|"+t,document.title="KMC > "+e+(t&&""!==t?" > "+t+" |":"")},readUrlHash:function(){var e,t,r="dashboard",a="",n={};try{e=location.hash.split("#")[1].split("|")}catch(i){t=!0}if(!t&&""!==e[0]){if(r=e[0],a=e[1],e[2])for(var o=e[2].split("&"),s=0;o.length>s;s++){var l=o[s].split(":");n[l[0]]=l[1]}switch(r){case"content":switch(a){case"Moderate":a="moderation";break;case"Syndicate":a="syndication"}a=a.toLowerCase();break;case"appstudio":r="studio",a="playersList";break;case"Settings":switch(r="account",a){case"Account_Settings":a="overview";break;case"Integration Settings":a="integration";break;case"Access Control":a="accessControl";break;case"Transcoding Settings":a="transcoding";break;case"Account Upgrade":a="upgrade"}break;case"reports":r="analytics","Bandwidth Usage Reports"==a&&(a="usageTabTitle")}}return{moduleName:r,subtab:a,extra:n}}},kmc.preview_embed={doPreviewEmbed:function(e,t,r,a,n,i,o){var s={previewOnly:a};i&&(s.uiConfId=parseInt(i)),n?"multitab_playlist"==e?(s.playerOnly=!0,s.name=t):(s.playlistId=e,s.playlistName=t):(s.entryId=e,s.entryMeta={name:t,description:r},o&&(s.liveBitrates=o)),kmc.Preview.openPreviewEmbed(s,kmc.Preview.Service)},doFlavorPreview:function(e,t,r){var a=kmc.vars.default_kdp,n=kmc.Preview.getGenerator().getCode({protocol:location.protocol.substring(0,location.protocol.length-1),embedType:"legacy",entryId:e,uiConfId:parseInt(a.id),width:a.width,height:a.height,includeSeoMetadata:!1,includeHtml5Library:!1,flashVars:{ks:kmc.vars.ks,flavorId:r.asset_id}}),i='
    '+n+"
    "+"
    Entry Name:
     "+t+"
    "+"
    Entry Id:
     "+e+"
    "+"
    Flavor Name:
     "+r.flavor_name+"
    "+"
    Flavor Asset Id:
     "+r.asset_id+"
    "+"
    Bitrate:
     "+r.bitrate+"
    "+"
    Codec:
     "+r.codec+"
    "+"
    Dimensions:
     "+r.dimensions.width+" x "+r.dimensions.height+"
    "+"
    Format:
     "+r.format+"
    "+"
    Size (KB):
     "+r.sizeKB+"
    "+"
    Status:
     "+r.status+"
    "+"
    ";kmc.layout.modal.open({width:parseInt(a.width)+120,height:parseInt(a.height)+300,title:"Flavor Preview",content:'
    '+i+"
    "})},updateList:function(e){var t=e?"playlist":"player";$.ajax({url:kmc.vars.base_url+kmc.vars.getuiconfs_url,type:"POST",data:{type:t,partner_id:kmc.vars.partner_id,ks:kmc.vars.ks},dataType:"json",success:function(t){t&&t.length&&(e?kmc.vars.playlists_list=t:kmc.vars.players_list=t,kmc.Preview.Service.updatePlayers())}})}},kmc.client={makeRequest:function(e,t,r,a){var n=kmc.vars.api_url+"/api_v3/index.php?service="+e+"&action="+t,i={ks:kmc.vars.ks,format:9};$.extend(r,i);var o=function(e){var t=[],r=[],a=0;for(var n in e)r[a++]=n+"|"+e[n];r=r.sort();for(var i=0;r.length>i;i++){var o=r[i].split("|");t[o[0]]=o[1]}return t},s=function(e){e=o(e);var t="";for(var r in e){var a=e[r];t+=a+r}return md5(t)},l=s(r);n+="&kalsig="+l,$.ajax({type:"GET",url:n,dataType:"jsonp",data:r,cache:!1,success:a})},createShortURL:function(e,t){kmc.log("createShortURL");var r={"shortLink:objectType":"KalturaShortLink","shortLink:systemName":"KMC-PREVIEW","shortLink:fullUrl":e};kmc.client.makeRequest("shortlink_shortlink","add",r,function(e){var r=!1;t?(e.id&&(r=kmc.vars.service_url+"/tiny/"+e.id),t(r)):kmc.preview_embed.setShortURL(e.id)})}},kmc.layout={init:function(){$("#kmcHeader").bind("click",function(){$("#hTabs a").each(function(e,t){var r=$(t);return r.hasClass("menu")&&r.hasClass("active")?($("#kcms")[0].gotoPage({moduleName:r.attr("id"),subtab:r.attr("rel")}),void 0):!0})}),$("body").append('
    ')},overlay:{show:function(){$("#overlay").show()},hide:function(){$("#overlay").hide()}},modal:{el:"#modal",create:function(e){var t={el:kmc.layout.modal.el,title:"",content:"",help:"",width:680,height:"auto",className:""};$.extend(t,e);var r=$(t.el),a=r.find(".title h2"),n=r.find(".content");return t.className="modal "+t.className,r.css({width:t.width,height:t.height}).attr("class",t.className),t.title?a.text(t.title).attr("title",t.title).parent().show():(a.parent().hide(),n.addClass("flash_only")),r.find(".help").remove(),a.parent().append(t.help),n[0].innerHTML=t.content,r.find(".close").click(function(){kmc.layout.modal.close(t.el),$.isFunction(e.closeCallback)&&e.closeCallback()}),r},show:function(e,t){t=void 0===t?!0:t,e=e||kmc.layout.modal.el;var r=$(e);kmc.utils.hideFlash(!0),kmc.layout.overlay.show(),r.fadeIn(600),$.browser.msie||r.css("display","table"),t&&this.position(e)},open:function(e){this.create(e);var t=e.el||kmc.layout.modal.el;this.show(t)},position:function(e){e=e||kmc.layout.modal.el;var t=$(e),r=($(window).height()-t.height())/2,a=($(window).width()-t.width())/(2+$(window).scrollLeft());r=40>r?40:r,t.css({top:r+"px",left:a+"px"})},close:function(e){e=e||kmc.layout.modal.el,$(e).fadeOut(300,function(){$(e).find(".content").html(""),kmc.layout.overlay.hide(),kmc.utils.hideFlash()})},isOpen:function(e){return e=e||kmc.layout.modal.el,$(e).is(":visible")}}},kmc.user={openSupport:function(e){var t=e.href;kmc.utils.hideFlash(!0),kmc.layout.overlay.show();var r='';kmc.layout.modal.create({width:550,title:"Support Request",content:r}),$("#support").load(function(){kmc.layout.modal.show(),kmc.vars.support_frame_height||(kmc.vars.support_frame_height=$("#support")[0].contentWindow.document.body.scrollHeight),$("#support").height(kmc.vars.support_frame_height),kmc.layout.modal.position()})},logout:function(){var e=kmc.functions.checkForOngoingProcess();if(e)return alert(e),!1;var t=kmc.mediator.readUrlHash();$.ajax({url:kmc.vars.base_url+"/index.php/kmc/logout",type:"POST",data:{ks:kmc.vars.ks},dataType:"json",complete:function(){window.location=kmc.vars.logoutUrl?kmc.vars.logoutUrl:kmc.vars.service_url+"/index.php/kmc/kmc#"+t.moduleName+"|"+t.subtab}})},changeSetting:function(e){var t,r;switch(e){case"password":t="Change Password",r=180;break;case"email":t="Change Email Address",r=160;break;case"name":t="Edit Name",r=200}var a=kmc.vars.kmc_secured||"https:"==location.protocol?"https":"http",n=a+"://"+window.location.hostname,i=n+kmc.vars.port+"/index.php/kmc/updateLoginData/type/"+e;i=i+"?parent="+encodeURIComponent(document.location.href);var o='';kmc.layout.modal.open({width:370,title:t,content:o}),XD.receiveMessage(function(e){kmc.layout.modal.close(),"reload"==e.data&&($.browser.msie&&8>$.browser.version&&(window.location.hash="account|user"),window.location.reload())},n)},changePartner:function(){var e,t,r,a=0,n=kmc.vars.allowed_partners.length,i='
    Please choose partner:
    ';for(e=0;n>e;e++)a=kmc.vars.allowed_partners[e].id,kmc.vars.partner_id==a?(t=' checked="checked"',r=' style="font-weight: bold"'):(t="",r=""),i+="  "+kmc.vars.allowed_partners[e].name+"";return i+='
    ',kmc.layout.modal.open({width:300,title:"Change Account",content:i}),$("#do_change_partner").click(function(){var e=kmc.vars.base_url+"/index.php/kmc/extlogin",t=$("").attr({type:"hidden",name:"ks",value:kmc.vars.ks}),r=$("").attr({type:"hidden",name:"partner_id",value:$("input[name=pid]:radio:checked").val()}),a=$("").attr({action:e,method:"post",style:"display: none"}).append(t,r);$("body").append(a),a[0].submit()}),!1}},$(function(){kmc.layout.init(),kmc.utils.handleMenu(),kmc.functions.loadSwf(),$(window).wresize(kmc.utils.resize),kmc.vars.isLoadedInterval=setInterval(kmc.utils.isModuleLoaded,200),kmc.preview_embed.updateList(),kmc.preview_embed.updateList(!0),kmc.utils.setClientIP()}),$(window).resize(function(){kmc.layout.modal.isOpen()&&kmc.layout.modal.position()}),window.onbeforeunload=kmc.functions.checkForOngoingProcess,function(e){e.fn.wresize=function(t){function r(){if(e.browser.msie)if(wresize.fired){var t=parseInt(e.browser.version,10);if(wresize.fired=!1,7>t)return!1;if(7==t){var r=e(window).width();if(r!=wresize.width)return wresize.width=r,!1}}else wresize.fired=!0;return!0}function a(e){return r()?t.apply(this,[e]):void 0}return version="1.1",wresize={fired:!1,width:0},this.each(function(){this==window?e(this).resize(a):e(this).resize(t)}),this}}(jQuery);var XD=function(){var e,t,r,a=1,n=this;return{postMessage:function(e,t,r){t&&(r=r||parent,n.postMessage?r.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(r.location=t.replace(/#.*$/,"")+"#"+ +new Date+a++ +"&"+e))},receiveMessage:function(a,i){n.postMessage?(a&&(r=function(e){return"string"==typeof i&&e.origin!==i||"[object Function]"===Object.prototype.toString.call(i)&&i(e.origin)===!1?!1:(a(e),void 0)}),n.addEventListener?n[a?"addEventListener":"removeEventListener"]("message",r,!1):n[a?"attachEvent":"detachEvent"]("onmessage",r)):(e&&clearInterval(e),e=null,a&&(e=setInterval(function(){var e=document.location.hash,r=/^#?\d+&/;e!==t&&r.test(e)&&(t=e,a({data:e.replace(r,"")}))},100)))}}}(); \ No newline at end of file From 804e14396cede33b93059b5a7709f01b02c7c9bc Mon Sep 17 00:00:00 2001 From: ranyefet Date: Sun, 14 Jul 2013 13:01:47 +0300 Subject: [PATCH 002/132] Set embed code textarea to read-only, updated view to use v6.0.6 JS --- alpha/apps/kaltura/modules/kmc/templates/kmc4Success.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/alpha/apps/kaltura/modules/kmc/templates/kmc4Success.php b/alpha/apps/kaltura/modules/kmc/templates/kmc4Success.php index 994fe2ee58f..a073baf405e 100644 --- a/alpha/apps/kaltura/modules/kmc/templates/kmc4Success.php +++ b/alpha/apps/kaltura/modules/kmc/templates/kmc4Success.php @@ -111,7 +111,7 @@
    - +
    @@ -123,7 +123,7 @@ - + From ae6d9937581c6cd449f905a45d1c970ff7a97d06 Mon Sep 17 00:00:00 2001 From: ranyefet Date: Sun, 14 Jul 2013 13:03:52 +0300 Subject: [PATCH 003/132] Do not add Kaltura SEO links for paying customers --- alpha/apps/kaltura/modules/kmc/actions/kmc4Action.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/modules/kmc/actions/kmc4Action.class.php b/alpha/apps/kaltura/modules/kmc/actions/kmc4Action.class.php index 3153ce7481e..43e6fd18500 100644 --- a/alpha/apps/kaltura/modules/kmc/actions/kmc4Action.class.php +++ b/alpha/apps/kaltura/modules/kmc/actions/kmc4Action.class.php @@ -69,7 +69,6 @@ public function execute ( ) kmcUtils::redirectPartnerToCorrectKmc($partner, $this->ks, null, null, null, self::CURRENT_KMC_VERSION); $this->templatePartnerId = $this->partner ? $this->partner->getTemplatePartnerId() : self::SYSTEM_DEFAULT_PARTNER; - $ignoreSeoLinks = $this->partner->getIgnoreSeoLinks(); $ignoreEntrySeoLinks = PermissionPeer::isValidForPartner(PermissionName::FEATURE_IGNORE_ENTRY_SEO_LINKS, $this->partner_id); $useEmbedCodeProtocolHttps = PermissionPeer::isValidForPartner(PermissionName::FEATURE_EMBED_CODE_DEFAULT_PROTOCOL_HTTPS, $this->partner_id); $deliveryTypes = $partner->getDeliveryTypes(); @@ -100,6 +99,9 @@ public function execute ( ) if($partner && $partner->getPartnerPackage() != PartnerPackages::PARTNER_PACKAGE_FREE) { $this->payingPartner = 'true'; + $ignoreSeoLinks = true; + } else { + $ignoreSeoLinks = $this->partner->getIgnoreSeoLinks(); } /** get partner languae **/ From d08dc6a73a57b51d0876561fc09b8f3e393e0afc Mon Sep 17 00:00:00 2001 From: ranyefet Date: Sun, 14 Jul 2013 14:29:36 +0300 Subject: [PATCH 004/132] Added notice for preview page --- alpha/apps/kaltura/modules/kmc/templates/previewSuccess.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/modules/kmc/templates/previewSuccess.php b/alpha/apps/kaltura/modules/kmc/templates/previewSuccess.php index 6ed21a7d734..44cf65aedf4 100644 --- a/alpha/apps/kaltura/modules/kmc/templates/previewSuccess.php +++ b/alpha/apps/kaltura/modules/kmc/templates/previewSuccess.php @@ -94,7 +94,7 @@ - +

    This page is for preview only. Not for production use.

    From d47eb5008c12766c391aa4ae745829240cf59ff7 Mon Sep 17 00:00:00 2001 From: ranyefet Date: Sun, 14 Jul 2013 15:27:01 +0300 Subject: [PATCH 005/132] Added v6.0.7 JS release files --- .../modules/kmc/templates/kmc4Success.php | 2 +- alpha/web/lib/js/kmc/6.0.7/kmc.js | 4247 +++++++++++++++++ alpha/web/lib/js/kmc/6.0.7/kmc.min.js | 6 + 3 files changed, 4254 insertions(+), 1 deletion(-) create mode 100644 alpha/web/lib/js/kmc/6.0.7/kmc.js create mode 100644 alpha/web/lib/js/kmc/6.0.7/kmc.min.js diff --git a/alpha/apps/kaltura/modules/kmc/templates/kmc4Success.php b/alpha/apps/kaltura/modules/kmc/templates/kmc4Success.php index a073baf405e..76456f172cc 100644 --- a/alpha/apps/kaltura/modules/kmc/templates/kmc4Success.php +++ b/alpha/apps/kaltura/modules/kmc/templates/kmc4Success.php @@ -123,7 +123,7 @@ - + diff --git a/alpha/web/lib/js/kmc/6.0.7/kmc.js b/alpha/web/lib/js/kmc/6.0.7/kmc.js new file mode 100644 index 00000000000..47d49699a2a --- /dev/null +++ b/alpha/web/lib/js/kmc/6.0.7/kmc.js @@ -0,0 +1,4247 @@ +/*! KMC - v6.0.7 - 2013-07-14 +* https://github.com/kaltura/KMC_V2 +* Copyright (c) 2013 Ran Yefet; Licensed GNU */ +/*! Kaltura Embed Code Generator - v1.0.6 - 2013-02-28 +* https://github.com/kaltura/EmbedCodeGenerator +* Copyright (c) 2013 Ran Yefet; Licensed MIT */ + +// lib/handlebars/base.js + +/*jshint eqnull:true*/ +this.Handlebars = {}; + +(function(Handlebars) { + +Handlebars.VERSION = "1.0.rc.2"; + +Handlebars.helpers = {}; +Handlebars.partials = {}; + +Handlebars.registerHelper = function(name, fn, inverse) { + if(inverse) { fn.not = inverse; } + this.helpers[name] = fn; +}; + +Handlebars.registerPartial = function(name, str) { + this.partials[name] = str; +}; + +Handlebars.registerHelper('helperMissing', function(arg) { + if(arguments.length === 2) { + return undefined; + } else { + throw new Error("Could not find property '" + arg + "'"); + } +}); + +var toString = Object.prototype.toString, functionType = "[object Function]"; + +Handlebars.registerHelper('blockHelperMissing', function(context, options) { + var inverse = options.inverse || function() {}, fn = options.fn; + + + var ret = ""; + var type = toString.call(context); + + if(type === functionType) { context = context.call(this); } + + if(context === true) { + return fn(this); + } else if(context === false || context == null) { + return inverse(this); + } else if(type === "[object Array]") { + if(context.length > 0) { + return Handlebars.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + return fn(context); + } +}); + +Handlebars.K = function() {}; + +Handlebars.createFrame = Object.create || function(object) { + Handlebars.K.prototype = object; + var obj = new Handlebars.K(); + Handlebars.K.prototype = null; + return obj; +}; + +Handlebars.logger = { + DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3, + + methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'}, + + // can be overridden in the host environment + log: function(level, obj) { + if (Handlebars.logger.level <= level) { + var method = Handlebars.logger.methodMap[level]; + if (typeof console !== 'undefined' && console[method]) { + console[method].call(console, obj); + } + } + } +}; + +Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); }; + +Handlebars.registerHelper('each', function(context, options) { + var fn = options.fn, inverse = options.inverse; + var i = 0, ret = "", data; + + if (options.data) { + data = Handlebars.createFrame(options.data); + } + + if(context && typeof context === 'object') { + if(context instanceof Array){ + for(var j = context.length; i": ">", + '"': """, + "'": "'", + "`": "`" + }; + + var badChars = /[&<>"'`]/g; + var possible = /[&<>"'`]/; + + var escapeChar = function(chr) { + return escape[chr] || "&"; + }; + + Handlebars.Utils = { + escapeExpression: function(string) { + // don't escape SafeStrings, since they're already safe + if (string instanceof Handlebars.SafeString) { + return string.toString(); + } else if (string == null || string === false) { + return ""; + } + + if(!possible.test(string)) { return string; } + return string.replace(badChars, escapeChar); + }, + + isEmpty: function(value) { + if (!value && value !== 0) { + return true; + } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) { + return true; + } else { + return false; + } + } + }; +})();; +// lib/handlebars/runtime.js +Handlebars.VM = { + template: function(templateSpec) { + // Just add water + var container = { + escapeExpression: Handlebars.Utils.escapeExpression, + invokePartial: Handlebars.VM.invokePartial, + programs: [], + program: function(i, fn, data) { + var programWrapper = this.programs[i]; + if(data) { + return Handlebars.VM.program(fn, data); + } else if(programWrapper) { + return programWrapper; + } else { + programWrapper = this.programs[i] = Handlebars.VM.program(fn); + return programWrapper; + } + }, + programWithDepth: Handlebars.VM.programWithDepth, + noop: Handlebars.VM.noop + }; + + return function(context, options) { + options = options || {}; + return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data); + }; + }, + + programWithDepth: function(fn, data, $depth) { + var args = Array.prototype.slice.call(arguments, 2); + + return function(context, options) { + options = options || {}; + + return fn.apply(this, [context, options.data || data].concat(args)); + }; + }, + program: function(fn, data) { + return function(context, options) { + options = options || {}; + + return fn(context, options.data || data); + }; + }, + noop: function() { return ""; }, + invokePartial: function(partial, name, context, helpers, partials, data) { + var options = { helpers: helpers, partials: partials, data: data }; + + if(partial === undefined) { + throw new Handlebars.Exception("The partial " + name + " could not be found"); + } else if(partial instanceof Function) { + return partial(context, options); + } else if (!Handlebars.compile) { + throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode"); + } else { + partials[name] = Handlebars.compile(partial, {data: data !== undefined}); + return partials[name](context, options); + } + } +}; + +Handlebars.template = Handlebars.VM.template; +; + +(function (window, Handlebars, undefined ) { +/** +* Transforms flashVars object into a string for Url or Flashvars string. +* +* @method flashVarsToUrl +* @param {Object} flashVarsObject A flashvars object +* @param {String} paramName The name parameter to add to url +* @return {String} Returns flashVars string like: &foo=bar or ¶m[foo]=bar +*/ +var flashVarsToUrl = function( flashVarsObject, paramName ) { + var params = ''; + + var paramPrefix = (paramName) ? paramName + '[' : ''; + var paramSuffix = (paramName) ? ']' : ''; + + for( var i in flashVarsObject ){ + // check for object representation of plugin config: + if( typeof flashVarsObject[i] == 'object' ){ + for( var j in flashVarsObject[i] ){ + params+= '&' + paramPrefix + encodeURIComponent( i ) + + '.' + encodeURIComponent( j ) + paramSuffix + + '=' + encodeURIComponent( flashVarsObject[i][j] ); + } + } else { + params+= '&' + paramPrefix + encodeURIComponent( i ) + paramSuffix + '=' + encodeURIComponent( flashVarsObject[i] ); + } + } + return params; +}; + +// Setup handlebars helpers +Handlebars.registerHelper('flashVarsUrl', function(flashVars) { + return flashVarsToUrl(flashVars, 'flashvars'); +}); +Handlebars.registerHelper('flashVarsString', function(flashVars) { + return flashVarsToUrl(flashVars); +}); +Handlebars.registerHelper('elAttributes', function( attributes ) { + var str = ''; + for( var i in attributes ) { + str += ' ' + i + '="' + attributes[i] + '"'; + } + return str; +}); +// Include kaltura links +Handlebars.registerHelper('kalturaLinks', function() { + if( ! this.includeKalturaLinks ) { + return ''; + } + var template = Handlebars.templates['kaltura_links']; + return template(); +}); + +Handlebars.registerHelper('seoMetadata', function() { + var template = Handlebars.templates['seo_metadata']; + return template(this); +}); + +})(this, this.Handlebars); +(function(){var a=Handlebars.template,b=Handlebars.templates=Handlebars.templates||{};b.auto=a(function(a,b,c,d,e){function p(a,b){var d="",e,f;d+='
    ",i=c.seoMetadata,e=i||a.seoMetadata,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"seoMetadata",{hash:{}}));if(e||e===0)d+=e;i=c.kalturaLinks,e=i||a.kalturaLinks,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"kalturaLinks",{hash:{}}));if(e||e===0)d+=e;return d+="
    \n",d}function q(a,b){var d="",e;return d+="&entry_id=",i=c.entryId,e=i||a.entryId,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"entryId",{hash:{}})),d+=o(e),d}function r(a,b){var d="",e;return d+="&cache_st=",i=c.cacheSt,e=i||a.cacheSt,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"cacheSt",{hash:{}})),d+=o(e),d}c=c||a.helpers;var f="",g,h,i,j,k=this,l="function",m=c.helperMissing,n=void 0,o=this.escapeExpression;i=c.includeSeoMetadata,g=i||b.includeSeoMetadata,h=c["if"],j=k.program(1,p,e),j.hash={},j.fn=j,j.inverse=k.noop,g=h.call(b,g,j);if(g||g===0)f+=g;f+='\n
    ",i=c.seoMetadata,g=i||b.seoMetadata,typeof g===k?g=g.call(b,{hash:{}}):g===m&&(g=l.call(b,"seoMetadata",{hash:{}}));if(g||g===0)f+=g;i=c.kalturaLinks,g=i||b.kalturaLinks,typeof g===k?g=g.call(b,{hash:{}}):g===m&&(g=l.call(b,"kalturaLinks",{hash:{}}));if(g||g===0)f+=g;f+="
    \n",f}),b.iframe=a(function(a,b,c,d,e){function p(a,b){var d="",e;return d+="&entry_id=",i=c.entryId,e=i||a.entryId,typeof e===l?e=e.call(a,{hash:{}}):e===n&&(e=m.call(a,"entryId",{hash:{}})),d+=o(e),d}c=c||a.helpers;var f="",g,h,i,j,k=this,l="function",m=c.helperMissing,n=void 0,o=this.escapeExpression;f+='",f}),b.kaltura_links=a(function(a,b,c,d,e){c=c||a.helpers;var f,g=this;return'Video Platform\nVideo Management \nVideo Solutions\nVideo Player'}),b.legacy=a(function(a,b,c,d,e){function p(a,b){var d="",e;return d+='\n',d}function q(a,b){var d="",e;return d+='\n \n \n \n \n \n \n ',d}c=c||a.helpers;var f="",g,h,i,j,k=this,l="function",m=c.helperMissing,n=void 0,o=this.escapeExpression;i=c.includeHtml5Library,g=i||b.includeHtml5Library,h=c["if"],j=k.program(1,p,e),j.hash={},j.fn=j,j.inverse=k.noop,g=h.call(b,g,j);if(g||g===0)f+=g;f+='\n \n \n \n \n \n \n ',i=c.includeSeoMetadata,g=i||b.includeSeoMetadata,h=c["if"],j=k.program(3,q,e),j.hash={},j.fn=j,j.inverse=k.noop,g=h.call(b,g,j);if(g||g===0)f+=g;i=c.kalturaLinks,g=i||b.kalturaLinks,typeof g===l?g=g.call(b,{hash:{}}):g===n&&(g=m.call(b,"kalturaLinks",{hash:{}}));if(g||g===0)f+=g;return f+="\n",f}),b.seo_metadata=a(function(a,b,c,d,e){function o(a,b){var d="",e;return d+='\n\n\n\n\n\n\n',d}c=c||a.helpers;var f,g,h,i,j=this,k="function",l=c.helperMissing,m=void 0,n=this.escapeExpression;return h=c.includeSeoMetadata,f=h||b.includeSeoMetadata,g=c["if"],i=j.program(1,o,e),i.hash={},i.fn=i,i.inverse=j.noop,f=g.call(b,f,i),f||f===0?f:""})})() +// Add indexOf to array object +if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = 0; + if (arguments.length > 1) { + n = Number(arguments[1]); + if (n !== n) { // shortcut for verifying if it's NaN + n = 0; + } else if (n !== 0 && n !== Infinity && n !== -Infinity) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + if (n >= len) { + return -1; + } + var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); + for (; k < len; k++) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + }; +} +// Add keys for Object +if (!Object.keys) { + Object.keys = (function () { + var hasOwnProperty = Object.prototype.hasOwnProperty, + hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'), + dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ], + dontEnumsLength = dontEnums.length; + + return function (obj) { + if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) { + throw new TypeError('Object.keys called on non-object'); + } + + var result = []; + + for (var prop in obj) { + if (hasOwnProperty.call(obj, prop)) { + result.push(prop); + } + } + + if (hasDontEnumBug) { + for (var i=0; i < dontEnumsLength; i++) { + if (hasOwnProperty.call(obj, dontEnums[i])) { + result.push(dontEnums[i]); + } + } + } + return result; + }; + })(); +} +(function( window, undefined ) { +/** +* Kaltura Embed Code Generator +* Used to generate different type of embed codes +* Depended on Handlebars ( http://handlebarsjs.com/ ) +* +* @class EmbedCodeGenerator +* @constructor +*/ +var EmbedCodeGenerator = function( options ) { + this.init( options ); +}; + +EmbedCodeGenerator.prototype = { + + types: ['auto', 'dynamic', 'thumb', 'iframe', 'legacy'], + required: ['widgetId', 'partnerId', 'uiConfId'], + + defaults: { + /** + * Embed code type to generate + * Can we one of: ['auto', 'dynamic', 'thumb', 'iframe', 'legacy'] + * + * @property embedType + * @type {String} + * @default "auto" + */ + embedType: 'auto', + /** + * The Player element Id / Name that will be used for embed code + * + * @property playerId + * @type {String} + * @default "kaltura_player" + */ + playerId: 'kaltura_player', + /** + * Embed HTTP protocol to use + * Can we one of: ['http', 'https'] + * + * @property protocol + * @type {String} + * @default "http" + */ + protocol: 'http', + /** + * Host for loading html5 library & kdp swf + * + * @property host + * @type {String} + * @default "www.kaltura.com" + */ + host: 'www.kaltura.com', + /** + * Secured host for loading html5 library & kdp swf + * Used if protocol is: 'https' + * + * @property securedHost + * @type {String} + * @default "www.kaltura.com" + */ + securedHost: 'www.kaltura.com', + /** + * Kaltura Widget Id + * + * @property widgetId + * @type {String} + * @default "_{partnerId}" + */ + widgetId: null, + /** + * Kaltura Partner Id + * + * @property partnerId + * @type {Number} + * @default null, + */ + partnerId: null, + /** + * Add cacheSt parameter to bust cache + * Should be unix timestamp of future time + * + * @property cacheSt + * @type {Number} + * @default null, + */ + cacheSt: null, + /** + * Kaltura UiConf Id + * + * @property uiConfId + * @type {Number} + * @default null, + */ + uiConfId: null, + /** + * Kaltura Entry Id + * + * @property entryId + * @type {String} + * @default null, + */ + entryId: null, + /** + * Entry Object similar to: + * { + * name: 'Foo', + * description: 'Bar', + * thumbUrl: 'http://cdnbakmi.kaltura.com/thumbnail/...' + * } + * + * @property entryMeta + * @type {Object} + * @default {}, + */ + entryMeta: {}, + /** + * Sets Player Width + * + * @property width + * @type {Number} + * @default 400, + */ + width: 400, + /** + * Sets Player Height + * + * @property height + * @type {Number} + * @default 330, + */ + height: 330, + /** + * Adds additonal attributes to embed code. + * Example: + * { + * "class": "player" + * } + * + * @property attributes + * @type {Object} + * @default {}, + */ + attributes: {}, + /** + * Adds flashVars to player + * Example: + * { + * "autoPlay": "true" + * } + * + * @property flashVars + * @type {Object} + * @default {}, + */ + flashVars: {}, + /** + * Include Kaltura SEO links to embed code + * + * @property includeKalturaLinks + * @type {Boolean} + * @default true, + */ + includeKalturaLinks: true, + /** + * Include Entry Seo Metadata + * Metadata is taken from {entryMeta} object + * + * @property includeSeoMetadata + * @type {Boolean} + * @default false, + */ + includeSeoMetadata: false, + /** + * Include HTML5 library script + * + * @property includeHtml5Library + * @type {Boolean} + * @default true, + */ + includeHtml5Library: true + }, + /** + * Merge two object together + * + * @method extend + * @param {Object} destination object to merge into + * @param {Object} sourece object to merge from + * @return {Object} Merged object + */ + extend: function(destination, source) { + for (var property in source) { + if (source.hasOwnProperty(property) && !destination.hasOwnProperty(property)) { + destination[property] = source[property]; + } + } + return destination; + }, + /** + * Check if property is null + * + * @method isNull + * @param {Any} property some var + * @return {Boolean} + */ + isNull: function( property ) { + if (property.length && property.length > 0) { + return false; + } + if (property.length && property.length === 0) { + return true; + } + if( typeof property === 'object' ) { + return (Object.keys(property).length > 0) ? false : true; + } + return !property; + }, + /** + * Set default options to EmbedCodeGenerator instance + * + * @method init + * @param {Object} options Configuration object based on defaults object + * @return {Object} Returns the current instance + */ + init: function( options ) { + + options = options || {}; + + var defaults = this.defaults; + + // Make sure Handlebars is available + if( typeof Handlebars === undefined ) { + throw 'Handlebars is not defined, please include Handlebars.js before this script'; + } + + // Merge options with defaults + if( typeof options === 'object' ) { + this.options = this.extend(options, this.defaults); + } + // Set widgetId to partnerId if not defined + if( ! this.config('widgetId') && this.config('partnerId') ) { + this.config('widgetId', '_' + this.config('partnerId')); + } + + return this; + }, + /** + * Get or Set default configuration + * + * @method config + * @param {String} key configuration property name + * @param {Any} value to set + * @return {Mixed} Return the value for the key, configuration object or null + */ + config: function( key, val ) { + // Used as getter + if( val === undefined && typeof key === 'string' && this.options.hasOwnProperty(key) ) { + return this.options[ key ]; + } + // Get all options + if( key === undefined && val === undefined ) { + return this.options; + } + // Used as setter + if( typeof key === 'string' && val !== undefined ) { + this.options[ key ] = val; + } + return null; + }, + /** + * Check if required parameters are missing + * + * @method checkRequiredParams + * @param {Object} Configuration object + * @return throws exception if missing parameters + */ + checkRequiredParams: function( params ) { + var requiredLength = this.required.length, + i = 0; + // Check for required configuration + for(i; i= 7) { + this.setupTypeNumber(test); + } + + if (this.dataCache == null) { + this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList); + } + + this.mapData(this.dataCache, maskPattern); + }, + + setupPositionProbePattern : function(row, col) { + + for (var r = -1; r <= 7; r++) { + + if (row + r <= -1 || this.moduleCount <= row + r) continue; + + for (var c = -1; c <= 7; c++) { + + if (col + c <= -1 || this.moduleCount <= col + c) continue; + + if ( (0 <= r && r <= 6 && (c == 0 || c == 6) ) + || (0 <= c && c <= 6 && (r == 0 || r == 6) ) + || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + }, + + getBestMaskPattern : function() { + + var minLostPoint = 0; + var pattern = 0; + + for (var i = 0; i < 8; i++) { + + this.makeImpl(true, i); + + var lostPoint = QRUtil.getLostPoint(this); + + if (i == 0 || minLostPoint > lostPoint) { + minLostPoint = lostPoint; + pattern = i; + } + } + + return pattern; + }, + + createMovieClip : function(target_mc, instance_name, depth) { + + var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth); + var cs = 1; + + this.make(); + + for (var row = 0; row < this.modules.length; row++) { + + var y = row * cs; + + for (var col = 0; col < this.modules[row].length; col++) { + + var x = col * cs; + var dark = this.modules[row][col]; + + if (dark) { + qr_mc.beginFill(0, 100); + qr_mc.moveTo(x, y); + qr_mc.lineTo(x + cs, y); + qr_mc.lineTo(x + cs, y + cs); + qr_mc.lineTo(x, y + cs); + qr_mc.endFill(); + } + } + } + + return qr_mc; + }, + + setupTimingPattern : function() { + + for (var r = 8; r < this.moduleCount - 8; r++) { + if (this.modules[r][6] != null) { + continue; + } + this.modules[r][6] = (r % 2 == 0); + } + + for (var c = 8; c < this.moduleCount - 8; c++) { + if (this.modules[6][c] != null) { + continue; + } + this.modules[6][c] = (c % 2 == 0); + } + }, + + setupPositionAdjustPattern : function() { + + var pos = QRUtil.getPatternPosition(this.typeNumber); + + for (var i = 0; i < pos.length; i++) { + + for (var j = 0; j < pos.length; j++) { + + var row = pos[i]; + var col = pos[j]; + + if (this.modules[row][col] != null) { + continue; + } + + for (var r = -2; r <= 2; r++) { + + for (var c = -2; c <= 2; c++) { + + if (r == -2 || r == 2 || c == -2 || c == 2 + || (r == 0 && c == 0) ) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + } + } + }, + + setupTypeNumber : function(test) { + + var bits = QRUtil.getBCHTypeNumber(this.typeNumber); + + for (var i = 0; i < 18; i++) { + var mod = (!test && ( (bits >> i) & 1) == 1); + this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod; + } + + for (var i = 0; i < 18; i++) { + var mod = (!test && ( (bits >> i) & 1) == 1); + this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod; + } + }, + + setupTypeInfo : function(test, maskPattern) { + + var data = (this.errorCorrectLevel << 3) | maskPattern; + var bits = QRUtil.getBCHTypeInfo(data); + + // vertical + for (var i = 0; i < 15; i++) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 6) { + this.modules[i][8] = mod; + } else if (i < 8) { + this.modules[i + 1][8] = mod; + } else { + this.modules[this.moduleCount - 15 + i][8] = mod; + } + } + + // horizontal + for (var i = 0; i < 15; i++) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 8) { + this.modules[8][this.moduleCount - i - 1] = mod; + } else if (i < 9) { + this.modules[8][15 - i - 1 + 1] = mod; + } else { + this.modules[8][15 - i - 1] = mod; + } + } + + // fixed module + this.modules[this.moduleCount - 8][8] = (!test); + + }, + + mapData : function(data, maskPattern) { + + var inc = -1; + var row = this.moduleCount - 1; + var bitIndex = 7; + var byteIndex = 0; + + for (var col = this.moduleCount - 1; col > 0; col -= 2) { + + if (col == 6) col--; + + while (true) { + + for (var c = 0; c < 2; c++) { + + if (this.modules[row][col - c] == null) { + + var dark = false; + + if (byteIndex < data.length) { + dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1); + } + + var mask = QRUtil.getMask(maskPattern, row, col - c); + + if (mask) { + dark = !dark; + } + + this.modules[row][col - c] = dark; + bitIndex--; + + if (bitIndex == -1) { + byteIndex++; + bitIndex = 7; + } + } + } + + row += inc; + + if (row < 0 || this.moduleCount <= row) { + row -= inc; + inc = -inc; + break; + } + } + } + + } + +}; + +QRCode.PAD0 = 0xEC; +QRCode.PAD1 = 0x11; + +QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) { + + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel); + + var buffer = new QRBitBuffer(); + + for (var i = 0; i < dataList.length; i++) { + var data = dataList[i]; + buffer.put(data.mode, 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) ); + data.write(buffer); + } + + // calc num max data. + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalDataCount += rsBlocks[i].dataCount; + } + + if (buffer.getLengthInBits() > totalDataCount * 8) { + throw new Error("code length overflow. (" + + buffer.getLengthInBits() + + ">" + + totalDataCount * 8 + + ")"); + } + + // end code + if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) { + buffer.put(0, 4); + } + + // padding + while (buffer.getLengthInBits() % 8 != 0) { + buffer.putBit(false); + } + + // padding + while (true) { + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD0, 8); + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD1, 8); + } + + return QRCode.createBytes(buffer, rsBlocks); +} + +QRCode.createBytes = function(buffer, rsBlocks) { + + var offset = 0; + + var maxDcCount = 0; + var maxEcCount = 0; + + var dcdata = new Array(rsBlocks.length); + var ecdata = new Array(rsBlocks.length); + + for (var r = 0; r < rsBlocks.length; r++) { + + var dcCount = rsBlocks[r].dataCount; + var ecCount = rsBlocks[r].totalCount - dcCount; + + maxDcCount = Math.max(maxDcCount, dcCount); + maxEcCount = Math.max(maxEcCount, ecCount); + + dcdata[r] = new Array(dcCount); + + for (var i = 0; i < dcdata[r].length; i++) { + dcdata[r][i] = 0xff & buffer.buffer[i + offset]; + } + offset += dcCount; + + var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); + var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1); + + var modPoly = rawPoly.mod(rsPoly); + ecdata[r] = new Array(rsPoly.getLength() - 1); + for (var i = 0; i < ecdata[r].length; i++) { + var modIndex = i + modPoly.getLength() - ecdata[r].length; + ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0; + } + + } + + var totalCodeCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalCodeCount += rsBlocks[i].totalCount; + } + + var data = new Array(totalCodeCount); + var index = 0; + + for (var i = 0; i < maxDcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < dcdata[r].length) { + data[index++] = dcdata[r][i]; + } + } + } + + for (var i = 0; i < maxEcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < ecdata[r].length) { + data[index++] = ecdata[r][i]; + } + } + } + + return data; + +} + +//--------------------------------------------------------------------- +// QRMode +//--------------------------------------------------------------------- + +var QRMode = { + MODE_NUMBER : 1 << 0, + MODE_ALPHA_NUM : 1 << 1, + MODE_8BIT_BYTE : 1 << 2, + MODE_KANJI : 1 << 3 +}; + +//--------------------------------------------------------------------- +// QRErrorCorrectLevel +//--------------------------------------------------------------------- + +var QRErrorCorrectLevel = { + L : 1, + M : 0, + Q : 3, + H : 2 +}; + +//--------------------------------------------------------------------- +// QRMaskPattern +//--------------------------------------------------------------------- + +var QRMaskPattern = { + PATTERN000 : 0, + PATTERN001 : 1, + PATTERN010 : 2, + PATTERN011 : 3, + PATTERN100 : 4, + PATTERN101 : 5, + PATTERN110 : 6, + PATTERN111 : 7 +}; + +//--------------------------------------------------------------------- +// QRUtil +//--------------------------------------------------------------------- + +var QRUtil = { + + PATTERN_POSITION_TABLE : [ + [], + [6, 18], + [6, 22], + [6, 26], + [6, 30], + [6, 34], + [6, 22, 38], + [6, 24, 42], + [6, 26, 46], + [6, 28, 50], + [6, 30, 54], + [6, 32, 58], + [6, 34, 62], + [6, 26, 46, 66], + [6, 26, 48, 70], + [6, 26, 50, 74], + [6, 30, 54, 78], + [6, 30, 56, 82], + [6, 30, 58, 86], + [6, 34, 62, 90], + [6, 28, 50, 72, 94], + [6, 26, 50, 74, 98], + [6, 30, 54, 78, 102], + [6, 28, 54, 80, 106], + [6, 32, 58, 84, 110], + [6, 30, 58, 86, 114], + [6, 34, 62, 90, 118], + [6, 26, 50, 74, 98, 122], + [6, 30, 54, 78, 102, 126], + [6, 26, 52, 78, 104, 130], + [6, 30, 56, 82, 108, 134], + [6, 34, 60, 86, 112, 138], + [6, 30, 58, 86, 114, 142], + [6, 34, 62, 90, 118, 146], + [6, 30, 54, 78, 102, 126, 150], + [6, 24, 50, 76, 102, 128, 154], + [6, 28, 54, 80, 106, 132, 158], + [6, 32, 58, 84, 110, 136, 162], + [6, 26, 54, 82, 110, 138, 166], + [6, 30, 58, 86, 114, 142, 170] + ], + + G15 : (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0), + G18 : (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0), + G15_MASK : (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1), + + getBCHTypeInfo : function(data) { + var d = data << 10; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) { + d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) ); + } + return ( (data << 10) | d) ^ QRUtil.G15_MASK; + }, + + getBCHTypeNumber : function(data) { + var d = data << 12; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) { + d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) ); + } + return (data << 12) | d; + }, + + getBCHDigit : function(data) { + + var digit = 0; + + while (data != 0) { + digit++; + data >>>= 1; + } + + return digit; + }, + + getPatternPosition : function(typeNumber) { + return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]; + }, + + getMask : function(maskPattern, i, j) { + + switch (maskPattern) { + + case QRMaskPattern.PATTERN000 : return (i + j) % 2 == 0; + case QRMaskPattern.PATTERN001 : return i % 2 == 0; + case QRMaskPattern.PATTERN010 : return j % 3 == 0; + case QRMaskPattern.PATTERN011 : return (i + j) % 3 == 0; + case QRMaskPattern.PATTERN100 : return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; + case QRMaskPattern.PATTERN101 : return (i * j) % 2 + (i * j) % 3 == 0; + case QRMaskPattern.PATTERN110 : return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; + case QRMaskPattern.PATTERN111 : return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; + + default : + throw new Error("bad maskPattern:" + maskPattern); + } + }, + + getErrorCorrectPolynomial : function(errorCorrectLength) { + + var a = new QRPolynomial([1], 0); + + for (var i = 0; i < errorCorrectLength; i++) { + a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0) ); + } + + return a; + }, + + getLengthInBits : function(mode, type) { + + if (1 <= type && type < 10) { + + // 1 - 9 + + switch(mode) { + case QRMode.MODE_NUMBER : return 10; + case QRMode.MODE_ALPHA_NUM : return 9; + case QRMode.MODE_8BIT_BYTE : return 8; + case QRMode.MODE_KANJI : return 8; + default : + throw new Error("mode:" + mode); + } + + } else if (type < 27) { + + // 10 - 26 + + switch(mode) { + case QRMode.MODE_NUMBER : return 12; + case QRMode.MODE_ALPHA_NUM : return 11; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 10; + default : + throw new Error("mode:" + mode); + } + + } else if (type < 41) { + + // 27 - 40 + + switch(mode) { + case QRMode.MODE_NUMBER : return 14; + case QRMode.MODE_ALPHA_NUM : return 13; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 12; + default : + throw new Error("mode:" + mode); + } + + } else { + throw new Error("type:" + type); + } + }, + + getLostPoint : function(qrCode) { + + var moduleCount = qrCode.getModuleCount(); + + var lostPoint = 0; + + // LEVEL1 + + for (var row = 0; row < moduleCount; row++) { + + for (var col = 0; col < moduleCount; col++) { + + var sameCount = 0; + var dark = qrCode.isDark(row, col); + + for (var r = -1; r <= 1; r++) { + + if (row + r < 0 || moduleCount <= row + r) { + continue; + } + + for (var c = -1; c <= 1; c++) { + + if (col + c < 0 || moduleCount <= col + c) { + continue; + } + + if (r == 0 && c == 0) { + continue; + } + + if (dark == qrCode.isDark(row + r, col + c) ) { + sameCount++; + } + } + } + + if (sameCount > 5) { + lostPoint += (3 + sameCount - 5); + } + } + } + + // LEVEL2 + + for (var row = 0; row < moduleCount - 1; row++) { + for (var col = 0; col < moduleCount - 1; col++) { + var count = 0; + if (qrCode.isDark(row, col ) ) count++; + if (qrCode.isDark(row + 1, col ) ) count++; + if (qrCode.isDark(row, col + 1) ) count++; + if (qrCode.isDark(row + 1, col + 1) ) count++; + if (count == 0 || count == 4) { + lostPoint += 3; + } + } + } + + // LEVEL3 + + for (var row = 0; row < moduleCount; row++) { + for (var col = 0; col < moduleCount - 6; col++) { + if (qrCode.isDark(row, col) + && !qrCode.isDark(row, col + 1) + && qrCode.isDark(row, col + 2) + && qrCode.isDark(row, col + 3) + && qrCode.isDark(row, col + 4) + && !qrCode.isDark(row, col + 5) + && qrCode.isDark(row, col + 6) ) { + lostPoint += 40; + } + } + } + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount - 6; row++) { + if (qrCode.isDark(row, col) + && !qrCode.isDark(row + 1, col) + && qrCode.isDark(row + 2, col) + && qrCode.isDark(row + 3, col) + && qrCode.isDark(row + 4, col) + && !qrCode.isDark(row + 5, col) + && qrCode.isDark(row + 6, col) ) { + lostPoint += 40; + } + } + } + + // LEVEL4 + + var darkCount = 0; + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount; row++) { + if (qrCode.isDark(row, col) ) { + darkCount++; + } + } + } + + var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; + lostPoint += ratio * 10; + + return lostPoint; + } + +}; + + +//--------------------------------------------------------------------- +// QRMath +//--------------------------------------------------------------------- + +var QRMath = { + + glog : function(n) { + + if (n < 1) { + throw new Error("glog(" + n + ")"); + } + + return QRMath.LOG_TABLE[n]; + }, + + gexp : function(n) { + + while (n < 0) { + n += 255; + } + + while (n >= 256) { + n -= 255; + } + + return QRMath.EXP_TABLE[n]; + }, + + EXP_TABLE : new Array(256), + + LOG_TABLE : new Array(256) + +}; + +for (var i = 0; i < 8; i++) { + QRMath.EXP_TABLE[i] = 1 << i; +} +for (var i = 8; i < 256; i++) { + QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] + ^ QRMath.EXP_TABLE[i - 5] + ^ QRMath.EXP_TABLE[i - 6] + ^ QRMath.EXP_TABLE[i - 8]; +} +for (var i = 0; i < 255; i++) { + QRMath.LOG_TABLE[QRMath.EXP_TABLE[i] ] = i; +} + +//--------------------------------------------------------------------- +// QRPolynomial +//--------------------------------------------------------------------- + +function QRPolynomial(num, shift) { + + if (num.length == undefined) { + throw new Error(num.length + "/" + shift); + } + + var offset = 0; + + while (offset < num.length && num[offset] == 0) { + offset++; + } + + this.num = new Array(num.length - offset + shift); + for (var i = 0; i < num.length - offset; i++) { + this.num[i] = num[i + offset]; + } +} + +QRPolynomial.prototype = { + + get : function(index) { + return this.num[index]; + }, + + getLength : function() { + return this.num.length; + }, + + multiply : function(e) { + + var num = new Array(this.getLength() + e.getLength() - 1); + + for (var i = 0; i < this.getLength(); i++) { + for (var j = 0; j < e.getLength(); j++) { + num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i) ) + QRMath.glog(e.get(j) ) ); + } + } + + return new QRPolynomial(num, 0); + }, + + mod : function(e) { + + if (this.getLength() - e.getLength() < 0) { + return this; + } + + var ratio = QRMath.glog(this.get(0) ) - QRMath.glog(e.get(0) ); + + var num = new Array(this.getLength() ); + + for (var i = 0; i < this.getLength(); i++) { + num[i] = this.get(i); + } + + for (var i = 0; i < e.getLength(); i++) { + num[i] ^= QRMath.gexp(QRMath.glog(e.get(i) ) + ratio); + } + + // recursive call + return new QRPolynomial(num, 0).mod(e); + } +}; + +//--------------------------------------------------------------------- +// QRRSBlock +//--------------------------------------------------------------------- + +function QRRSBlock(totalCount, dataCount) { + this.totalCount = totalCount; + this.dataCount = dataCount; +} + +QRRSBlock.RS_BLOCK_TABLE = [ + + // L + // M + // Q + // H + + // 1 + [1, 26, 19], + [1, 26, 16], + [1, 26, 13], + [1, 26, 9], + + // 2 + [1, 44, 34], + [1, 44, 28], + [1, 44, 22], + [1, 44, 16], + + // 3 + [1, 70, 55], + [1, 70, 44], + [2, 35, 17], + [2, 35, 13], + + // 4 + [1, 100, 80], + [2, 50, 32], + [2, 50, 24], + [4, 25, 9], + + // 5 + [1, 134, 108], + [2, 67, 43], + [2, 33, 15, 2, 34, 16], + [2, 33, 11, 2, 34, 12], + + // 6 + [2, 86, 68], + [4, 43, 27], + [4, 43, 19], + [4, 43, 15], + + // 7 + [2, 98, 78], + [4, 49, 31], + [2, 32, 14, 4, 33, 15], + [4, 39, 13, 1, 40, 14], + + // 8 + [2, 121, 97], + [2, 60, 38, 2, 61, 39], + [4, 40, 18, 2, 41, 19], + [4, 40, 14, 2, 41, 15], + + // 9 + [2, 146, 116], + [3, 58, 36, 2, 59, 37], + [4, 36, 16, 4, 37, 17], + [4, 36, 12, 4, 37, 13], + + // 10 + [2, 86, 68, 2, 87, 69], + [4, 69, 43, 1, 70, 44], + [6, 43, 19, 2, 44, 20], + [6, 43, 15, 2, 44, 16], + + // 11 + [4, 101, 81], + [1, 80, 50, 4, 81, 51], + [4, 50, 22, 4, 51, 23], + [3, 36, 12, 8, 37, 13], + + // 12 + [2, 116, 92, 2, 117, 93], + [6, 58, 36, 2, 59, 37], + [4, 46, 20, 6, 47, 21], + [7, 42, 14, 4, 43, 15], + + // 13 + [4, 133, 107], + [8, 59, 37, 1, 60, 38], + [8, 44, 20, 4, 45, 21], + [12, 33, 11, 4, 34, 12], + + // 14 + [3, 145, 115, 1, 146, 116], + [4, 64, 40, 5, 65, 41], + [11, 36, 16, 5, 37, 17], + [11, 36, 12, 5, 37, 13], + + // 15 + [5, 109, 87, 1, 110, 88], + [5, 65, 41, 5, 66, 42], + [5, 54, 24, 7, 55, 25], + [11, 36, 12], + + // 16 + [5, 122, 98, 1, 123, 99], + [7, 73, 45, 3, 74, 46], + [15, 43, 19, 2, 44, 20], + [3, 45, 15, 13, 46, 16], + + // 17 + [1, 135, 107, 5, 136, 108], + [10, 74, 46, 1, 75, 47], + [1, 50, 22, 15, 51, 23], + [2, 42, 14, 17, 43, 15], + + // 18 + [5, 150, 120, 1, 151, 121], + [9, 69, 43, 4, 70, 44], + [17, 50, 22, 1, 51, 23], + [2, 42, 14, 19, 43, 15], + + // 19 + [3, 141, 113, 4, 142, 114], + [3, 70, 44, 11, 71, 45], + [17, 47, 21, 4, 48, 22], + [9, 39, 13, 16, 40, 14], + + // 20 + [3, 135, 107, 5, 136, 108], + [3, 67, 41, 13, 68, 42], + [15, 54, 24, 5, 55, 25], + [15, 43, 15, 10, 44, 16], + + // 21 + [4, 144, 116, 4, 145, 117], + [17, 68, 42], + [17, 50, 22, 6, 51, 23], + [19, 46, 16, 6, 47, 17], + + // 22 + [2, 139, 111, 7, 140, 112], + [17, 74, 46], + [7, 54, 24, 16, 55, 25], + [34, 37, 13], + + // 23 + [4, 151, 121, 5, 152, 122], + [4, 75, 47, 14, 76, 48], + [11, 54, 24, 14, 55, 25], + [16, 45, 15, 14, 46, 16], + + // 24 + [6, 147, 117, 4, 148, 118], + [6, 73, 45, 14, 74, 46], + [11, 54, 24, 16, 55, 25], + [30, 46, 16, 2, 47, 17], + + // 25 + [8, 132, 106, 4, 133, 107], + [8, 75, 47, 13, 76, 48], + [7, 54, 24, 22, 55, 25], + [22, 45, 15, 13, 46, 16], + + // 26 + [10, 142, 114, 2, 143, 115], + [19, 74, 46, 4, 75, 47], + [28, 50, 22, 6, 51, 23], + [33, 46, 16, 4, 47, 17], + + // 27 + [8, 152, 122, 4, 153, 123], + [22, 73, 45, 3, 74, 46], + [8, 53, 23, 26, 54, 24], + [12, 45, 15, 28, 46, 16], + + // 28 + [3, 147, 117, 10, 148, 118], + [3, 73, 45, 23, 74, 46], + [4, 54, 24, 31, 55, 25], + [11, 45, 15, 31, 46, 16], + + // 29 + [7, 146, 116, 7, 147, 117], + [21, 73, 45, 7, 74, 46], + [1, 53, 23, 37, 54, 24], + [19, 45, 15, 26, 46, 16], + + // 30 + [5, 145, 115, 10, 146, 116], + [19, 75, 47, 10, 76, 48], + [15, 54, 24, 25, 55, 25], + [23, 45, 15, 25, 46, 16], + + // 31 + [13, 145, 115, 3, 146, 116], + [2, 74, 46, 29, 75, 47], + [42, 54, 24, 1, 55, 25], + [23, 45, 15, 28, 46, 16], + + // 32 + [17, 145, 115], + [10, 74, 46, 23, 75, 47], + [10, 54, 24, 35, 55, 25], + [19, 45, 15, 35, 46, 16], + + // 33 + [17, 145, 115, 1, 146, 116], + [14, 74, 46, 21, 75, 47], + [29, 54, 24, 19, 55, 25], + [11, 45, 15, 46, 46, 16], + + // 34 + [13, 145, 115, 6, 146, 116], + [14, 74, 46, 23, 75, 47], + [44, 54, 24, 7, 55, 25], + [59, 46, 16, 1, 47, 17], + + // 35 + [12, 151, 121, 7, 152, 122], + [12, 75, 47, 26, 76, 48], + [39, 54, 24, 14, 55, 25], + [22, 45, 15, 41, 46, 16], + + // 36 + [6, 151, 121, 14, 152, 122], + [6, 75, 47, 34, 76, 48], + [46, 54, 24, 10, 55, 25], + [2, 45, 15, 64, 46, 16], + + // 37 + [17, 152, 122, 4, 153, 123], + [29, 74, 46, 14, 75, 47], + [49, 54, 24, 10, 55, 25], + [24, 45, 15, 46, 46, 16], + + // 38 + [4, 152, 122, 18, 153, 123], + [13, 74, 46, 32, 75, 47], + [48, 54, 24, 14, 55, 25], + [42, 45, 15, 32, 46, 16], + + // 39 + [20, 147, 117, 4, 148, 118], + [40, 75, 47, 7, 76, 48], + [43, 54, 24, 22, 55, 25], + [10, 45, 15, 67, 46, 16], + + // 40 + [19, 148, 118, 6, 149, 119], + [18, 75, 47, 31, 76, 48], + [34, 54, 24, 34, 55, 25], + [20, 45, 15, 61, 46, 16] +]; + +QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) { + + var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel); + + if (rsBlock == undefined) { + throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel); + } + + var length = rsBlock.length / 3; + + var list = new Array(); + + for (var i = 0; i < length; i++) { + + var count = rsBlock[i * 3 + 0]; + var totalCount = rsBlock[i * 3 + 1]; + var dataCount = rsBlock[i * 3 + 2]; + + for (var j = 0; j < count; j++) { + list.push(new QRRSBlock(totalCount, dataCount) ); + } + } + + return list; +} + +QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) { + + switch(errorCorrectLevel) { + case QRErrorCorrectLevel.L : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; + case QRErrorCorrectLevel.M : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; + case QRErrorCorrectLevel.Q : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; + case QRErrorCorrectLevel.H : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; + default : + return undefined; + } +} + +//--------------------------------------------------------------------- +// QRBitBuffer +//--------------------------------------------------------------------- + +function QRBitBuffer() { + this.buffer = new Array(); + this.length = 0; +} + +QRBitBuffer.prototype = { + + get : function(index) { + var bufIndex = Math.floor(index / 8); + return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1; + }, + + put : function(num, length) { + for (var i = 0; i < length; i++) { + this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1); + } + }, + + getLengthInBits : function() { + return this.length; + }, + + putBit : function(bit) { + + var bufIndex = Math.floor(this.length / 8); + if (this.buffer.length <= bufIndex) { + this.buffer.push(0); + } + + if (bit) { + this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) ); + } + + this.length++; + } +}; + // if options is string, + if( typeof options === 'string' ){ + options = { text: options }; + } + + // set default values + // typeNumber < 1 for automatic calculation + options = $.extend( {}, { + render : "canvas", + width : 256, + height : 256, + typeNumber : -1, + correctLevel : QRErrorCorrectLevel.H, + background : "#ffffff", + foreground : "#000000" + }, options); + + var createCanvas = function(){ + // create the qrcode itself + var qrcode = new QRCode(options.typeNumber, options.correctLevel); + qrcode.addData(options.text); + qrcode.make(); + + // create canvas element + var canvas = document.createElement('canvas'); + canvas.width = options.width; + canvas.height = options.height; + var ctx = canvas.getContext('2d'); + + // compute tileW/tileH based on options.width/options.height + var tileW = options.width / qrcode.getModuleCount(); + var tileH = options.height / qrcode.getModuleCount(); + + // draw in the canvas + for( var row = 0; row < qrcode.getModuleCount(); row++ ){ + for( var col = 0; col < qrcode.getModuleCount(); col++ ){ + ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background; + var w = (Math.ceil((col+1)*tileW) - Math.floor(col*tileW)); + var h = (Math.ceil((row+1)*tileW) - Math.floor(row*tileW)); + ctx.fillRect(Math.round(col*tileW),Math.round(row*tileH), w, h); + } + } + // return just built canvas + return canvas; + } + + // from Jon-Carlos Rivera (https://github.com/imbcmdth) + var createTable = function(){ + // create the qrcode itself + var qrcode = new QRCode(options.typeNumber, options.correctLevel); + qrcode.addData(options.text); + qrcode.make(); + + // create table element + var $table = $('
    ') + .css("width", options.width+"px") + .css("height", options.height+"px") + .css("border", "0px") + .css("border-collapse", "collapse") + .css('background-color', options.background); + + // compute tileS percentage + var tileW = options.width / qrcode.getModuleCount(); + var tileH = options.height / qrcode.getModuleCount(); + + // draw in the table + for(var row = 0; row < qrcode.getModuleCount(); row++ ){ + var $row = $('').css('height', tileH+"px").appendTo($table); + + for(var col = 0; col < qrcode.getModuleCount(); col++ ){ + $('') + .css('width', tileW+"px") + .css('background-color', qrcode.isDark(row, col) ? options.foreground : options.background) + .appendTo($row); + } + } + // return just built canvas + return $table; + } + + + return this.each(function(){ + var element = options.render == "canvas" ? createCanvas() : createTable(); + $(element).appendTo(this); + }); + }; +})( jQuery ); + +// jQuery.XDomainRequest.js +// Author: Jason Moon - @JSONMOON +// IE8+ +if ( window.XDomainRequest ) { + jQuery.ajaxTransport(function( s ) { + if ( s.crossDomain && s.async ) { + if ( s.timeout ) { + s.xdrTimeout = s.timeout; + delete s.timeout; + } + var xdr; + return { + send: function( _, complete ) { + function callback( status, statusText, responses, responseHeaders ) { + xdr.onload = xdr.onerror = xdr.ontimeout = jQuery.noop; + xdr = undefined; + complete( status, statusText, responses, responseHeaders ); + } + xdr = new XDomainRequest(); + xdr.onload = function() { + callback( 200, "OK", { text: xdr.responseText }, "Content-Type: " + xdr.contentType ); + }; + xdr.onerror = function() { + callback( 404, "Not Found" ); + }; + xdr.onprogress = jQuery.noop; + xdr.ontimeout = function() { + callback( 0, "timeout" ); + }; + xdr.timeout = s.xdrTimeout || Number.MAX_VALUE; + xdr.open( s.type, s.url ); + xdr.send( ( s.hasContent && s.data ) || null ); + }, + abort: function() { + if ( xdr ) { + xdr.onerror = jQuery.noop; + xdr.abort(); + } + } + }; + } + }); +} +/*! + * zeroclipboard + * The Zero Clipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie, and a JavaScript interface. + * Copyright 2012 Jon Rohan, James M. Greene, . + * Released under the MIT license + * http://jonrohan.github.com/ZeroClipboard/ + * v1.1.7 + */(function() { + "use strict"; + var _getStyle = function(el, prop) { + var y = el.style[prop]; + if (el.currentStyle) y = el.currentStyle[prop]; else if (window.getComputedStyle) y = document.defaultView.getComputedStyle(el, null).getPropertyValue(prop); + if (y == "auto" && prop == "cursor") { + var possiblePointers = [ "a" ]; + for (var i = 0; i < possiblePointers.length; i++) { + if (el.tagName.toLowerCase() == possiblePointers[i]) { + return "pointer"; + } + } + } + return y; + }; + var _elementMouseOver = function(event) { + if (!ZeroClipboard.prototype._singleton) return; + if (!event) { + event = window.event; + } + var target; + if (this !== window) { + target = this; + } else if (event.target) { + target = event.target; + } else if (event.srcElement) { + target = event.srcElement; + } + ZeroClipboard.prototype._singleton.setCurrent(target); + }; + var _addEventHandler = function(element, method, func) { + if (element.addEventListener) { + element.addEventListener(method, func, false); + } else if (element.attachEvent) { + element.attachEvent("on" + method, func); + } + }; + var _removeEventHandler = function(element, method, func) { + if (element.removeEventListener) { + element.removeEventListener(method, func, false); + } else if (element.detachEvent) { + element.detachEvent("on" + method, func); + } + }; + var _addClass = function(element, value) { + if (element.addClass) { + element.addClass(value); + return element; + } + if (value && typeof value === "string") { + var classNames = (value || "").split(/\s+/); + if (element.nodeType === 1) { + if (!element.className) { + element.className = value; + } else { + var className = " " + element.className + " ", setClass = element.className; + for (var c = 0, cl = classNames.length; c < cl; c++) { + if (className.indexOf(" " + classNames[c] + " ") < 0) { + setClass += " " + classNames[c]; + } + } + element.className = setClass.replace(/^\s+|\s+$/g, ""); + } + } + } + return element; + }; + var _removeClass = function(element, value) { + if (element.removeClass) { + element.removeClass(value); + return element; + } + if (value && typeof value === "string" || value === undefined) { + var classNames = (value || "").split(/\s+/); + if (element.nodeType === 1 && element.className) { + if (value) { + var className = (" " + element.className + " ").replace(/[\n\t]/g, " "); + for (var c = 0, cl = classNames.length; c < cl; c++) { + className = className.replace(" " + classNames[c] + " ", " "); + } + element.className = className.replace(/^\s+|\s+$/g, ""); + } else { + element.className = ""; + } + } + } + return element; + }; + var _getDOMObjectPosition = function(obj) { + var info = { + left: 0, + top: 0, + width: obj.width || obj.offsetWidth || 0, + height: obj.height || obj.offsetHeight || 0, + zIndex: 9999 + }; + var zi = _getStyle(obj, "zIndex"); + if (zi && zi != "auto") { + info.zIndex = parseInt(zi, 10); + } + while (obj) { + var borderLeftWidth = parseInt(_getStyle(obj, "borderLeftWidth"), 10); + var borderTopWidth = parseInt(_getStyle(obj, "borderTopWidth"), 10); + info.left += isNaN(obj.offsetLeft) ? 0 : obj.offsetLeft; + info.left += isNaN(borderLeftWidth) ? 0 : borderLeftWidth; + info.top += isNaN(obj.offsetTop) ? 0 : obj.offsetTop; + info.top += isNaN(borderTopWidth) ? 0 : borderTopWidth; + obj = obj.offsetParent; + } + return info; + }; + var _noCache = function(path) { + return (path.indexOf("?") >= 0 ? "&" : "?") + "nocache=" + (new Date).getTime(); + }; + var _vars = function(options) { + var str = []; + if (options.trustedDomains) { + if (typeof options.trustedDomains === "string") { + str.push("trustedDomain=" + options.trustedDomains); + } else { + str.push("trustedDomain=" + options.trustedDomains.join(",")); + } + } + return str.join("&"); + }; + var _inArray = function(elem, array) { + if (array.indexOf) { + return array.indexOf(elem); + } + for (var i = 0, length = array.length; i < length; i++) { + if (array[i] === elem) { + return i; + } + } + return -1; + }; + var _prepGlue = function(elements) { + if (typeof elements === "string") throw new TypeError("ZeroClipboard doesn't accept query strings."); + if (!elements.length) return [ elements ]; + return elements; + }; + var ZeroClipboard = function(elements, options) { + if (elements) (ZeroClipboard.prototype._singleton || this).glue(elements); + if (ZeroClipboard.prototype._singleton) return ZeroClipboard.prototype._singleton; + ZeroClipboard.prototype._singleton = this; + this.options = {}; + for (var kd in _defaults) this.options[kd] = _defaults[kd]; + for (var ko in options) this.options[ko] = options[ko]; + this.handlers = {}; + if (ZeroClipboard.detectFlashSupport()) _bridge(); + }; + var currentElement, gluedElements = []; + ZeroClipboard.prototype.setCurrent = function(element) { + currentElement = element; + this.reposition(); + if (element.getAttribute("title")) { + this.setTitle(element.getAttribute("title")); + } + this.setHandCursor(_getStyle(element, "cursor") == "pointer"); + }; + ZeroClipboard.prototype.setText = function(newText) { + if (newText && newText !== "") { + this.options.text = newText; + if (this.ready()) this.flashBridge.setText(newText); + } + }; + ZeroClipboard.prototype.setTitle = function(newTitle) { + if (newTitle && newTitle !== "") this.htmlBridge.setAttribute("title", newTitle); + }; + ZeroClipboard.prototype.setSize = function(width, height) { + if (this.ready()) this.flashBridge.setSize(width, height); + }; + ZeroClipboard.prototype.setHandCursor = function(enabled) { + if (this.ready()) this.flashBridge.setHandCursor(enabled); + }; + ZeroClipboard.version = "1.1.7"; + var _defaults = { + moviePath: "ZeroClipboard.swf", + trustedDomains: null, + text: null, + hoverClass: "zeroclipboard-is-hover", + activeClass: "zeroclipboard-is-active", + allowScriptAccess: "sameDomain" + }; + ZeroClipboard.setDefaults = function(options) { + for (var ko in options) _defaults[ko] = options[ko]; + }; + ZeroClipboard.destroy = function() { + ZeroClipboard.prototype._singleton.unglue(gluedElements); + var bridge = ZeroClipboard.prototype._singleton.htmlBridge; + bridge.parentNode.removeChild(bridge); + delete ZeroClipboard.prototype._singleton; + }; + ZeroClipboard.detectFlashSupport = function() { + var hasFlash = false; + try { + if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) { + hasFlash = true; + } + } catch (error) { + if (navigator.mimeTypes["application/x-shockwave-flash"]) { + hasFlash = true; + } + } + return hasFlash; + }; + var _bridge = function() { + var client = ZeroClipboard.prototype._singleton; + var container = document.getElementById("global-zeroclipboard-html-bridge"); + if (!container) { + var html = ' '; + container = document.createElement("div"); + container.id = "global-zeroclipboard-html-bridge"; + container.setAttribute("class", "global-zeroclipboard-container"); + container.setAttribute("data-clipboard-ready", false); + container.style.position = "absolute"; + container.style.left = "-9999px"; + container.style.top = "-9999px"; + container.style.width = "15px"; + container.style.height = "15px"; + container.style.zIndex = "9999"; + container.innerHTML = html; + document.body.appendChild(container); + } + client.htmlBridge = container; + client.flashBridge = document["global-zeroclipboard-flash-bridge"] || container.children[0].lastElementChild; + }; + ZeroClipboard.prototype.resetBridge = function() { + this.htmlBridge.style.left = "-9999px"; + this.htmlBridge.style.top = "-9999px"; + this.htmlBridge.removeAttribute("title"); + this.htmlBridge.removeAttribute("data-clipboard-text"); + _removeClass(currentElement, this.options.activeClass); + currentElement = null; + this.options.text = null; + }; + ZeroClipboard.prototype.ready = function() { + var ready = this.htmlBridge.getAttribute("data-clipboard-ready"); + return ready === "true" || ready === true; + }; + ZeroClipboard.prototype.reposition = function() { + if (!currentElement) return false; + var pos = _getDOMObjectPosition(currentElement); + this.htmlBridge.style.top = pos.top + "px"; + this.htmlBridge.style.left = pos.left + "px"; + this.htmlBridge.style.width = pos.width + "px"; + this.htmlBridge.style.height = pos.height + "px"; + this.htmlBridge.style.zIndex = pos.zIndex + 1; + this.setSize(pos.width, pos.height); + }; + ZeroClipboard.dispatch = function(eventName, args) { + ZeroClipboard.prototype._singleton.receiveEvent(eventName, args); + }; + ZeroClipboard.prototype.on = function(eventName, func) { + var events = eventName.toString().split(/\s/g); + for (var i = 0; i < events.length; i++) { + eventName = events[i].toLowerCase().replace(/^on/, ""); + if (!this.handlers[eventName]) this.handlers[eventName] = func; + } + if (this.handlers.noflash && !ZeroClipboard.detectFlashSupport()) { + this.receiveEvent("onNoFlash", null); + } + }; + ZeroClipboard.prototype.addEventListener = ZeroClipboard.prototype.on; + ZeroClipboard.prototype.off = function(eventName, func) { + var events = eventName.toString().split(/\s/g); + for (var i = 0; i < events.length; i++) { + eventName = events[i].toLowerCase().replace(/^on/, ""); + for (var event in this.handlers) { + if (event === eventName && this.handlers[event] === func) { + delete this.handlers[event]; + } + } + } + }; + ZeroClipboard.prototype.removeEventListener = ZeroClipboard.prototype.off; + ZeroClipboard.prototype.receiveEvent = function(eventName, args) { + eventName = eventName.toString().toLowerCase().replace(/^on/, ""); + var element = currentElement; + switch (eventName) { + case "load": + if (args && parseFloat(args.flashVersion.replace(",", ".").replace(/[^0-9\.]/gi, "")) < 10) { + this.receiveEvent("onWrongFlash", { + flashVersion: args.flashVersion + }); + return; + } + this.htmlBridge.setAttribute("data-clipboard-ready", true); + break; + case "mouseover": + _addClass(element, this.options.hoverClass); + break; + case "mouseout": + _removeClass(element, this.options.hoverClass); + this.resetBridge(); + break; + case "mousedown": + _addClass(element, this.options.activeClass); + break; + case "mouseup": + _removeClass(element, this.options.activeClass); + break; + case "datarequested": + var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId ? null : document.getElementById(targetId); + if (targetEl) { + var textContent = targetEl.value || targetEl.textContent || targetEl.innerText; + if (textContent) this.setText(textContent); + } else { + var defaultText = element.getAttribute("data-clipboard-text"); + if (defaultText) this.setText(defaultText); + } + break; + case "complete": + this.options.text = null; + break; + } + if (this.handlers[eventName]) { + var func = this.handlers[eventName]; + if (typeof func == "function") { + func.call(element, this, args); + } else if (typeof func == "string") { + window[func].call(element, this, args); + } + } + }; + ZeroClipboard.prototype.glue = function(elements) { + elements = _prepGlue(elements); + for (var i = 0; i < elements.length; i++) { + if (_inArray(elements[i], gluedElements) == -1) { + gluedElements.push(elements[i]); + _addEventHandler(elements[i], "mouseover", _elementMouseOver); + } + } + }; + ZeroClipboard.prototype.unglue = function(elements) { + elements = _prepGlue(elements); + for (var i = 0; i < elements.length; i++) { + _removeEventHandler(elements[i], "mouseover", _elementMouseOver); + var arrayIndex = _inArray(elements[i], gluedElements); + if (arrayIndex != -1) gluedElements.splice(arrayIndex, 1); + } + }; + if (typeof module !== "undefined") { + module.exports = ZeroClipboard; + } else if (typeof define === "function" && define.amd) { + define(function() { + return ZeroClipboard; + }); + } else { + window.ZeroClipboard = ZeroClipboard; + } +})(); +(function(kmc) { + + /* + * TODO: + * Use ng-view for preview template + * Use filters for delivery + */ + + var Preview = kmc.Preview || {}; + + // Preview Partner Defaults + kmc.vars.previewDefaults = { + showAdvancedOptions: false, + includeKalturaLinks: (!kmc.vars.ignore_seo_links), + includeSeoMetadata: (!kmc.vars.ignore_entry_seo), + deliveryType: kmc.vars.default_delivery_type, + embedType: kmc.vars.default_embed_code_type, + secureEmbed: kmc.vars.embed_code_protocol_https + }; + + // Check for current protocol and update secureEmbed + if(window.location.protocol == 'https:') { + kmc.vars.previewDefaults.secureEmbed = true; + } + + Preview.storageName = 'previewDefaults'; + Preview.el = '#previewModal'; + Preview.iframeContainer = 'previewIframe'; + + // We use this flag to ignore all change evnets when we initilize the preview ( on page start up ) + // We will set that to true once Preview is opened. + Preview.ignoreChangeEvents = true; + + // Set generator + Preview.getGenerator = function() { + if(!this.generator) { + this.generator = new kEmbedCodeGenerator({ + host: kmc.vars.embed_host, + securedHost: kmc.vars.embed_host_https, + partnerId: kmc.vars.partner_id, + includeKalturaLinks: kmc.vars.previewDefaults.includeKalturaLinks + }); + } + return this.generator; + }; + + Preview.clipboard = new ZeroClipboard($('.copy-code'), { + moviePath: "/lib/flash/ZeroClipboard.swf", + trustedDomains: ['*'], + allowScriptAccess: "always" + }); + + Preview.clipboard.on('complete', function() { + var $this = $(this); + // Mark embed code as selected + $('#' + $this.data('clipboard-target')).select(); + // Close preview + if($this.data('close') === true) { + Preview.closeModal(Preview.el); + } + }); + + Preview.objectToArray = function(obj) { + var arr = []; + for(var key in obj) { + obj[key].id = key; + arr.push(obj[key]); + } + return arr; + }; + + Preview.getObjectById = function(id, arr) { + var result = $.grep(arr, function(e) { + return e.id == id; + }); + return(result.length) ? result[0] : false; + }; + + Preview.getDefault = function(setting) { + var defaults = localStorage.getItem(Preview.storageName); + if(defaults) { + defaults = JSON.parse(defaults); + } else { + defaults = kmc.vars.previewDefaults; + } + if(defaults[setting] !== undefined) { + return defaults[setting]; + } + return null; + }; + + Preview.savePreviewState = function() { + var previewService = this.Service; + var defaults = { + embedType: previewService.get('embedType'), + secureEmbed: previewService.get('secureEmbed'), + includeSeoMetadata: previewService.get('includeSeo'), + deliveryType: previewService.get('deliveryType').id, + showAdvancedOptions: previewService.get('showAdvancedOptions') + }; + // Save defaults to localStorage + localStorage.setItem(Preview.storageName, JSON.stringify(defaults)); + }; + + Preview.getDeliveryTypeFlashVars = function(deliveryType) { + // Not delivery type, exit + if(!deliveryType) return {}; + + // Get original delivery type flashvars + var originalFlashVars = (deliveryType.flashvars) ? deliveryType.flashvars : {}; + + // Clone flashVars object + var newFlashVars = $.extend({}, originalFlashVars); + + // Add streamerType and mediaProtocol flashVars + if(deliveryType.streamerType) + newFlashVars.streamerType = deliveryType.streamerType; + + if(deliveryType.mediaProtocol) + newFlashVars.mediaProtocol = deliveryType.mediaProtocol; + + // Return the new Flashvars object + return newFlashVars; + }; + + Preview.getPreviewTitle = function(options) { + if(options.entryMeta && options.entryMeta.name) { + return 'Embedding: ' + options.entryMeta.name; + } + if(options.playlistName) { + return 'Playlist: ' + options.playlistName; + } + if(options.playerOnly) { + return 'Player Name:' + options.name; + } + }; + + Preview.openPreviewEmbed = function(options, previewService) { + + var _this = this; + var el = _this.el; + + // Enable preview events + this.ignoreChangeEvents = false; + + var defaults = { + entryId: null, + entryMeta: {}, + playlistId: null, + playlistName: null, + previewOnly: false, + liveBitrates: null, + playerOnly: false, + uiConfId: null, + name: null + }; + + options = $.extend({}, defaults, options); + // In case of live entry preview, set delivery type to auto + if( options.liveBitrates ) { + previewService.setDeliveryType('auto'); + } + // Update our players + previewService.updatePlayers(options); + // Set options + previewService.set(options); + + var title = this.getPreviewTitle(options); + + var $previewModal = $(el); + $previewModal.find(".title h2").text(title).attr('title', title); + $previewModal.find(".close").unbind('click').click(function() { + _this.closeModal(el); + }); + + // Show our preview modal + var modalHeight = $('body').height() - 173; + $previewModal.find('.content').height(modalHeight); + kmc.layout.modal.show(el, false); + }; + + Preview.closeModal = function(el) { + this.savePreviewState(); + this.emptyDiv(this.iframeContainer); + $(el).fadeOut(300, function() { + kmc.layout.overlay.hide(); + kmc.utils.hideFlash(); + }); + }; + + Preview.emptyDiv = function(divId) { + var $targetDiv = $('#' + divId); + var $previewIframe = $('#previewIframe iframe'); + if( $previewIframe.length ) { + try { + var $iframeDoc = $($previewIframe[0].contentWindow.document); + $iframeDoc.find('#framePlayerContainer').empty(); + } catch (e) {} + } + + if( $targetDiv.length ) { + $targetDiv.empty(); + return $targetDiv[0]; + } + return false; + }; + + Preview.hasIframe = function() { + return $('#' + this.iframeContainer + ' iframe').length; + }; + + Preview.getCacheSt = function() { + var d = new Date(); + return Math.floor(d.getTime() / 1000) + (15 * 60); // start caching in 15 minutes + }; + + Preview.generateIframe = function(embedCode) { + + var ltIE10 = $('html').hasClass('lt-ie10'); + var style = ''; + var container = this.emptyDiv(this.iframeContainer); + var iframe = document.createElement('iframe'); + // Reset iframe style + iframe.frameborder = "0"; + iframe.frameBorder = "0"; + iframe.marginheight="0"; + iframe.marginwidth="0"; + iframe.frameborder="0"; + + container.appendChild(iframe); + + if(ltIE10) { + iframe.src = this.getPreviewUrl(this.Service, true); + } else { + var newDoc = iframe.contentDocument; + newDoc.open(); + newDoc.write('' + style + '
    ' + embedCode + '
    '); + newDoc.close(); + } + }; + + Preview.getEmbedProtocol = function(previewService, previewPlayer) { + if(previewPlayer === true) { + return location.protocol.substring(0, location.protocol.length - 1); // Get host protocol + } + return (previewService.get('secureEmbed')) ? 'https' : 'http'; + }; + + Preview.getEmbedFlashVars = function(previewService, addKs) { + var protocol = this.getEmbedProtocol(previewService, addKs); + var player = previewService.get('player'); + var flashVars = this.getDeliveryTypeFlashVars(previewService.get('deliveryType')); + if(addKs === true) { + flashVars.ks = kmc.vars.ks; + } + + var playlistId = previewService.get('playlistId'); + if(playlistId) { + // Use new kpl0Id flashvar for new players only + var html5_version = kmc.functions.getVersionFromPath(player.html5Url); + var kdpVersionCheck = kmc.functions.versionIsAtLeast(kmc.vars.min_kdp_version_for_playlist_api_v3, player.swf_version); + var html5VersionCheck = kmc.functions.versionIsAtLeast(kmc.vars.min_html5_version_for_playlist_api_v3, html5_version); + if( kdpVersionCheck && html5VersionCheck ) { + flashVars['playlistAPI.kpl0Id'] = playlistId; + } else { + flashVars['playlistAPI.autoInsert'] = 'true'; + flashVars['playlistAPI.kpl0Name'] = previewService.get('playlistName'); + flashVars['playlistAPI.kpl0Url'] = protocol + '://' + kmc.vars.api_host + '/index.php/partnerservices2/executeplaylist?' + 'partner_id=' + kmc.vars.partner_id + '&subp_id=' + kmc.vars.partner_id + '00' + '&format=8&ks={ks}&playlist_id=' + playlistId; + } + } + return flashVars; + }; + + Preview.getEmbedCode = function(previewService, previewPlayer) { + var player = previewService.get('player'); + if(!player || !previewService.get('embedType')) { + return ''; + } + var cacheSt = this.getCacheSt(); + var params = { + protocol: this.getEmbedProtocol(previewService, previewPlayer), + embedType: previewService.get('embedType'), + uiConfId: player.id, + width: player.width, + height: player.height, + entryMeta: previewService.get('entryMeta'), + includeSeoMetadata: previewService.get('includeSeo'), + playerId: 'kaltura_player_' + cacheSt, + cacheSt: cacheSt, + flashVars: this.getEmbedFlashVars(previewService, previewPlayer) + }; + + if(previewService.get('entryId')) { + params.entryId = previewService.get('entryId'); + } + + var code = this.getGenerator().getCode(params); + return code; + }; + + Preview.getPreviewUrl = function(previewService, framed) { + var player = previewService.get('player'); + if(!player || !previewService.get('embedType')) { + return ''; + } + + var protocol = this.getEmbedProtocol(previewService, framed); + var url = protocol + '://' + kmc.vars.api_host + '/index.php/kmc/preview'; + //var url = protocol + '://' + window.location.host + '/KMC_V2/preview.php'; + url += '/partner_id/' + kmc.vars.partner_id; + url += '/uiconf_id/' + player.id; + // Add entry Id + if(previewService.get('entryId')) { + url += '/entry_id/' + previewService.get('entryId'); + } + url += '/embed/' + previewService.get('embedType'); + url += '?' + kmc.functions.flashVarsToUrl(this.getEmbedFlashVars(previewService, framed)); + if( framed === true ) { + url += '&framed=true'; + } + return url; + }; + + Preview.generateQrCode = function(url) { + var $qrCode = $('#qrcode').empty(); + if(!url) return ; + if($('html').hasClass('lt-ie9')) return; + $qrCode.qrcode({ + width: 80, + height: 80, + text: url + }); + }; + + Preview.generateShortUrl = function(url, callback) { + if(!url) return ; + kmc.client.createShortURL(url, callback); + }; + + kmc.Preview = Preview; + +})(window.kmc); + +var kmcApp = angular.module('kmcApp', []); +kmcApp.factory('previewService', ['$rootScope', function($rootScope) { + var previewProps = {}; + return { + get: function(key) { + if(key === undefined) return previewProps; + return previewProps[key]; + }, + set: function(key, value, quiet) { + if(typeof key == 'object') { + angular.extend(previewProps, key); + } else { + previewProps[key] = value; + } + if(!quiet) { + $rootScope.$broadcast('previewChanged'); + } + }, + updatePlayers: function(options) { + $rootScope.$broadcast('playersUpdated', options); + }, + changePlayer: function(playerId) { + $rootScope.$broadcast('changePlayer', playerId); + }, + setDeliveryType: function( deliveryTypeId ) { + $rootScope.$broadcast('changeDelivery', deliveryTypeId); + } + }; +}]); +kmcApp.directive('showSlide', function() { + return { + //restrict it's use to attribute only. + restrict: 'A', + + //set up the directive. + link: function(scope, elem, attr) { + + //get the field to watch from the directive attribute. + var watchField = attr.showSlide; + + //set up the watch to toggle the element. + scope.$watch(attr.showSlide, function(v) { + if(v && !elem.is(':visible')) { + elem.slideDown(); + } else { + elem.slideUp(); + } + }); + } + }; +}); + +kmcApp.controller('PreviewCtrl', ['$scope', 'previewService', function($scope, previewService) { + + var draw = function() { + if(!$scope.$$phase) { + $scope.$apply(); + } + }; + + var Preview = kmc.Preview; + Preview.playlistMode = false; + + Preview.Service = previewService; + + var updatePlayers = function(options) { + options = options || {}; + var playerId = (options.uiConfId) ? options.uiConfId : undefined; + // Exit if player not loaded + if(!kmc.vars.playlists_list || !kmc.vars.players_list) { + return ; + } + // List of players + if(options.playlistId || options.playerOnly) { + $scope.players = kmc.vars.playlists_list; + if(!Preview.playlistMode) { + Preview.playlistMode = true; + $scope.$broadcast('changePlayer', playerId); + } + } else { + $scope.players = kmc.vars.players_list; + if(Preview.playlistMode || !$scope.player) { + Preview.playlistMode = false; + $scope.$broadcast('changePlayer', playerId); + } + } + if(playerId){ + $scope.$broadcast('changePlayer', playerId); + } + }; + + var setDeliveryTypes = function(player) { + var deliveryTypes = Preview.objectToArray(kmc.vars.delivery_types); + var defaultType = $scope.deliveryType || Preview.getDefault('deliveryType'); + var validDeliveryTypes = []; + $.each(deliveryTypes, function() { + if(this.minVersion && !kmc.functions.versionIsAtLeast(this.minVersion, player.swf_version)) { + if(this.id == defaultType) { + defaultType = null; + } + return true; + } + validDeliveryTypes.push(this); + }); + // List of delivery types + $scope.deliveryTypes = validDeliveryTypes; + // Set default delivery type + if(!defaultType) { + defaultType = $scope.deliveryTypes[0].id; + } + previewService.setDeliveryType(defaultType); + }; + + var setEmbedTypes = function(player) { + var embedTypes = Preview.objectToArray(kmc.vars.embed_code_types); + var defaultType = $scope.embedType || Preview.getDefault('embedType'); + var validEmbedTypes = []; + $.each(embedTypes, function() { + // Don't add embed code that are entry only for playlists + if(Preview.playlistMode && this.entryOnly) { + if(this.id == defaultType) { + defaultType = null; + } + return true; + } + // Check for library minimum version to eanble embed type + var libVersion = kmc.functions.getVersionFromPath(player.html5Url); + if(this.minVersion && !kmc.functions.versionIsAtLeast(this.minVersion, libVersion)) { + if(this.id == defaultType) { + defaultType = null; + } + return true; + } + validEmbedTypes.push(this); + }); + // List of embed types + $scope.embedTypes = validEmbedTypes; + // Set default embed type + if(!defaultType) { + defaultType = $scope.embedTypes[0].id; + } + $scope.embedType = defaultType; + }; + + // Set defaults + $scope.players = []; + $scope.player = null; + $scope.deliveryTypes = []; + $scope.deliveryType = null; + $scope.embedTypes = []; + $scope.embedType = null; + $scope.secureEmbed = Preview.getDefault('secureEmbed'); + $scope.includeSeo = Preview.getDefault('includeSeoMetadata'); + $scope.previewOnly = false; + $scope.playerOnly = false; + $scope.liveBitrates = false; + $scope.showAdvancedOptionsStatus = Preview.getDefault('showAdvancedOptions'); + $scope.shortLinkGenerated = false; + + // Set players on update + $scope.$on('playersUpdated', function(e, options) { + updatePlayers(options); + }); + + $scope.$on('changePlayer', function(e, playerId) { + playerId = ( playerId ) ? playerId : $scope.players[0].id; + $scope.player = playerId; + draw(); + }); + + $scope.$on('changeDelivery', function(e, deliveryTypeId) { + $scope.deliveryType = deliveryTypeId; + draw(); + }); + + $scope.showAdvancedOptions = function($event, show) { + $event.preventDefault(); + previewService.set('showAdvancedOptions', show, true); + $scope.showAdvancedOptionsStatus = show; + }; + + $scope.$watch('showAdvancedOptionsStatus', function() { + Preview.clipboard.reposition(); + }); + + // Listen to player change + $scope.$watch('player', function() { + var player = Preview.getObjectById($scope.player, $scope.players); + if(!player) { return ; } + setDeliveryTypes(player); + setEmbedTypes(player); + previewService.set('player', player); + }); + $scope.$watch('deliveryType', function() { + previewService.set('deliveryType', Preview.getObjectById($scope.deliveryType, $scope.deliveryTypes)); + }); + $scope.$watch('embedType', function() { + previewService.set('embedType', $scope.embedType); + }); + $scope.$watch('secureEmbed', function() { + previewService.set('secureEmbed', $scope.secureEmbed); + }); + $scope.$watch('includeSeo', function() { + previewService.set('includeSeo', $scope.includeSeo); + }); + $scope.$watch('embedCodePreview', function() { + Preview.generateIframe($scope.embedCodePreview); + }); + $scope.$watch('previewOnly', function() { + if($scope.previewOnly) { + $scope.closeButtonText = 'Close'; + } else { + $scope.closeButtonText = 'Copy Embed & Close'; + } + draw(); + }); + $scope.$on('previewChanged', function() { + if(Preview.ignoreChangeEvents) return; + var previewUrl = Preview.getPreviewUrl(previewService); + $scope.embedCode = Preview.getEmbedCode(previewService); + $scope.embedCodePreview = Preview.getEmbedCode(previewService, true); + $scope.previewOnly = previewService.get('previewOnly'); + $scope.playerOnly = previewService.get('playerOnly'); + $scope.liveBitrates = previewService.get('liveBitrates'); + draw(); + // Generate Iframe if not exist + if(!Preview.hasIframe()) { + Preview.generateIframe($scope.embedCodePreview); + } + // Update Short url + $scope.previewUrl = 'Updating...'; + $scope.shortLinkGenerated = false; + Preview.generateShortUrl(previewUrl, function(tinyUrl) { + if(!tinyUrl) { + // Set tinyUrl to fullUrl + tinyUrl = previewUrl; + } + $scope.shortLinkGenerated = true; + $scope.previewUrl = tinyUrl; + // Generate QR Code + Preview.generateQrCode(tinyUrl); + draw(); + }); + }); + +}]); +// Prevent the page to be framed +if(kmc.vars.allowFrame == false && top != window) { top.location = window.location; } + +/* kmc and kmc.vars defined in script block in kmc4success.php */ + +// For debug enable to true. Debug will show information in the browser console +kmc.vars.debug = false; + +// Quickstart guide (should be moved to kmc4success.php) +kmc.vars.quickstart_guide = "/content/docs/pdf/KMC_User_Manual.pdf"; +kmc.vars.help_url = kmc.vars.service_url + '/kmc5help.html'; + +// Set base URL +kmc.vars.port = (window.location.port) ? ":" + window.location.port : ""; +kmc.vars.base_host = window.location.hostname + kmc.vars.port; +kmc.vars.base_url = window.location.protocol + '//' + kmc.vars.base_host; +kmc.vars.api_host = kmc.vars.host; +kmc.vars.api_url = window.location.protocol + '//' + kmc.vars.api_host; + +// Holds the minimum version for html5 & kdp with the api_v3 for playlists +kmc.vars.min_kdp_version_for_playlist_api_v3 = '3.6.15'; +kmc.vars.min_html5_version_for_playlist_api_v3 = '1.7.1.3'; + +// Log function +kmc.log = function() { + if( kmc.vars.debug && typeof console !='undefined' && console.log ){ + if (arguments.length == 1) { + console.log( arguments[0] ); + } else { + var args = Array.prototype.slice.call(arguments); + console.log( args[0], args.slice( 1 ) ); + } + } +}; + +kmc.functions = { + + loadSwf : function() { + + var kmc_swf_url = window.location.protocol + '//' + kmc.vars.cdn_host + '/flash/kmc/' + kmc.vars.kmc_version + '/kmc.swf'; + var flashvars = { + // kmc configuration + kmc_uiconf : kmc.vars.kmc_general_uiconf, + + //permission uiconf id: + permission_uiconf : kmc.vars.kmc_permissions_uiconf, + + host : kmc.vars.host, + cdnhost : kmc.vars.cdn_host, + srvurl : "api_v3/index.php", + protocol : window.location.protocol + '//', + partnerid : kmc.vars.partner_id, + subpid : kmc.vars.partner_id + '00', + ks : kmc.vars.ks, + entryId : "-1", + kshowId : "-1", + debugmode : "true", + widget_id : "_" + kmc.vars.partner_id, + urchinNumber : kmc.vars.google_analytics_account, // "UA-12055206-1"" + firstLogin : kmc.vars.first_login, + openPlayer : "kmc.preview_embed.doPreviewEmbed", // @todo: remove for 2.0.9 ? + openPlaylist : "kmc.preview_embed.doPreviewEmbed", + openCw : "kmc.functions.openKcw", + language : (kmc.vars.language || "") + }; + // Disable analytics + if( kmc.vars.disable_analytics ) { + flashvars.disableAnalytics = true; + } + var params = { + allowNetworking: "all", + allowScriptAccess: "always" + }; + + swfobject.embedSWF(kmc_swf_url, "kcms", "100%", "100%", "10.0.0", false, flashvars, params); + $("#kcms").attr('style', ''); // Reset the object style + }, + + checkForOngoingProcess : function() { + var warning_message; + try { + warning_message = $("#kcms")[0].hasOngoingProcess(); + } + catch(e) { + warning_message = null; + } + + if(warning_message !== null) { + return warning_message; + } + return; + }, + + expired : function() { + kmc.user.logout(); + }, + + openKcw : function(conversion_profile, uiconf_tag) { + + conversion_profile = conversion_profile || ""; + + // uiconf_tag - uploadWebCam or uploadImport + var kcw_uiconf = (uiconf_tag == "uploadWebCam") ? kmc.vars.kcw_webcam_uiconf : kmc.vars.kcw_import_uiconf; + + var flashvars = { + host : kmc.vars.host, + cdnhost : kmc.vars.cdn_host, + protocol : window.location.protocol.slice(0, -1), + partnerid : kmc.vars.partner_id, + subPartnerId : kmc.vars.partner_id + '00', + sessionId : kmc.vars.ks, + devFlag : "true", + entryId : "-1", + kshow_id : "-1", + terms_of_use : kmc.vars.terms_of_use, + close : "kmc.functions.onCloseKcw", + quick_edit : 0, + kvar_conversionQuality : conversion_profile + }; + + var params = { + allowscriptaccess: "always", + allownetworking: "all", + bgcolor: "#DBE3E9", + quality: "high", + movie: kmc.vars.service_url + "/kcw/ui_conf_id/" + kcw_uiconf + }; + + kmc.layout.modal.open( { + 'width' : 700, + 'height' : 420, + 'content' : '
    ' + } ); + + swfobject.embedSWF(params.movie, "kcw", "680", "400" , "9.0.0", false, flashvars , params); + }, + onCloseKcw : function() { + kmc.layout.modal.close(); + $("#kcms")[0].gotoPage({ + moduleName: "content", + subtab: "manage" + }); + }, + // Should be moved into user object + openChangePwd : function(email) { + kmc.user.changeSetting('password'); + }, + openChangeEmail : function(email) { + kmc.user.changeSetting('email'); + }, + openChangeName : function(fname, lname, email) { + kmc.user.changeSetting('name'); + }, + getAddPanelPosition : function() { + var el = $("#add").parent(); + return (el.position().left + el.width() - 10); + }, + openClipApp : function( entry_id, mode ) { + + var iframe_url = kmc.vars.base_url + '/apps/clipapp/' + kmc.vars.clipapp.version; + iframe_url += '/?kdpUiconf=' + kmc.vars.clipapp.kdp + '&kclipUiconf=' + kmc.vars.clipapp.kclip; + iframe_url += '&partnerId=' + kmc.vars.partner_id + '&host=' + kmc.vars.host + '&mode=' + mode + '&config=kmc&entryId=' + entry_id; + + var title = ( mode == 'trim' ) ? 'Trimming Tool' : 'Clipping Tool'; + + kmc.layout.modal.open( { + 'width' : 950, + 'height' : 616, + 'title' : title, + 'content' : '', + 'className' : 'iframe', + 'closeCallback': function() { + $("#kcms")[0].gotoPage({ + moduleName: "content", + subtab: "manage" + }); + } + } ); + }, + flashVarsToUrl: function( flashVarsObject ){ + var params = ''; + for( var i in flashVarsObject ){ + var curVal = typeof flashVarsObject[i] == 'object'? + JSON.stringify( flashVarsObject[i] ): + flashVarsObject[i]; + params+= '&' + 'flashvars[' + encodeURIComponent( i ) + ']=' + + encodeURIComponent( curVal ); + } + return params; + }, + versionIsAtLeast: function( minVersion, clientVersion ) { + if( ! clientVersion ){ + return false; + } + var minVersionParts = minVersion.split('.'); + var clientVersionParts = clientVersion.split('.'); + for( var i =0; i < minVersionParts.length; i++ ) { + if( parseInt( clientVersionParts[i] ) > parseInt( minVersionParts[i] ) ) { + return true; + } + if( parseInt( clientVersionParts[i] ) < parseInt( minVersionParts[i] ) ) { + return false; + } + } + // Same version: + return true; + }, + getVersionFromPath: function( path ) { + return (typeof path == 'string') ? path.split("/v")[1].split("/")[0] : false; + } +}; + +kmc.utils = { + // Backward compatability + closeModal : function() {kmc.layout.modal.close();}, + + handleMenu : function() { + + // Activate menu links + kmc.utils.activateHeader(); + + // Calculate menu width + var menu_width = 10; + $("#user_links > *").each( function() { + menu_width += $(this).width(); + }); + + var openMenu = function() { + + // Set close menu to true + kmc.vars.close_menu = true; + + var menu_default_css = { + "width": 0, + "visibility": 'visible', + "top": '6px', + "right": '6px' + }; + + var menu_animation_css = { + "width": menu_width + 'px', + "padding-top": '2px', + "padding-bottom": '2px' + }; + + $("#user_links").css( menu_default_css ); + $("#user_links").animate( menu_animation_css , 500); + }; + + $("#user").hover( openMenu ).click( openMenu ); + $("#user_links").mouseover( function(){ + kmc.vars.close_menu = false; + } ); + $("#user_links").mouseleave( function() { + kmc.vars.close_menu = true; + setTimeout( kmc.utils.closeMenu , 650 ); + } ); + $("#closeMenu").click( function() { + kmc.vars.close_menu = true; + kmc.utils.closeMenu(); + } ); + }, + + closeMenu : function() { + if( kmc.vars.close_menu ) { + $("#user_links").animate( { + width: 0 + } , 500, function() { + $("#user_links").css( { + width: 'auto', + visibility: 'hidden' + } ); + }); + } + }, + + activateHeader : function() { + $("#user_links a").click(function(e) { + var tab = (e.target.tagName == "A") ? e.target.id : $(e.target).parent().attr("id"); + + switch(tab) { + case "Quickstart Guide" : + this.href = kmc.vars.quickstart_guide; + return true; + case "Logout" : + kmc.user.logout(); + return false; + case "Support" : + kmc.user.openSupport(this); + return false; + case "ChangePartner" : + kmc.user.changePartner(); + return false; + default : + return false; + } + }); + }, + + resize : function() { + var min_height = ($.browser.ie) ? 640 : 590; + var doc_height = $(document).height(), + offset = $.browser.mozilla ? 37 : 74; + doc_height = (doc_height-offset); + doc_height = (doc_height < min_height) ? min_height : doc_height; // Flash minimum height is 590 px + $("#flash_wrap").height(doc_height + "px"); + $("#server_wrap iframe").height(doc_height + "px"); + $("#server_wrap").css("margin-top", "-"+ (doc_height + 2) +"px"); + }, + isModuleLoaded : function() { + if($("#flash_wrap object").length || $("#flash_wrap embed").length) { + kmc.utils.resize(); + clearInterval(kmc.vars.isLoadedInterval); + kmc.vars.isLoadedInterval = null; + } + }, + debug : function() { + try{ + console.info(" ks: ",kmc.vars.ks); + console.info(" partner_id: ",kmc.vars.partner_id); + } + catch(err) {} + }, + + // we should have only one overlay for both flash & html modals + maskHeader : function(hide) { + if(hide) { + $("#mask").hide(); + } + else { + $("#mask").show(); + } + }, + + // Create dynamic tabs + createTabs : function(arr) { + // Close the user link menu + $("#closeMenu").trigger('click'); + + if(arr) { + var module_url = kmc.vars.service_url + '/index.php/kmc/kmc4', + arr_len = arr.length, + tabs_html = '', + tab_class; + for( var i = 0; i < arr_len; i++ ) { + tab_class = (arr[i].type == "action") ? 'class="menu" ' : ''; + tabs_html += '
  • ' + arr[i].display_name + '
  • '; + } + + $('#hTabs').html(tabs_html); + + // Get maximum width for user name + var max_user_width = ( $("body").width() - ($("#logo").width() + $("#hTabs").width() + 100) ); + if( ($("#user").width()+ 20) > max_user_width ) { + $("#user").width(max_user_width); + } + + $('#hTabs a').click(function(e) { + var tab = (e.target.tagName == "A") ? e.target.id : $(e.target).parent().attr("id"); + var subtab = (e.target.tagName == "A") ? $(e.target).attr("rel") : $(e.target).parent().attr("rel"); + + var go_to = { + moduleName : tab, + subtab : subtab + }; + $("#kcms")[0].gotoPage(go_to); + return false; + + }); + } else { + alert('Error geting tabs'); + } + }, + + setTab : function(module, resetAll){ + if( resetAll ) {$("#kmcHeader ul li a").removeClass("active");} + $("a#" + module).addClass("active"); + }, + + // Reset active tab + resetTab : function(module) { + $("a#" + module).removeClass("active"); + }, + + // we should combine the two following functions into one + hideFlash : function(hide) { + var ltIE8 = $('html').hasClass('lt-ie8'); + if(hide) { + if( ltIE8 ) { + // For IE only we're positioning outside of the screen + $("#flash_wrap").css("margin-right","3333px"); + } else { + // For other browsers we're just make it + $("#flash_wrap").css("visibility","hidden"); + $("#flash_wrap object").css("visibility","hidden"); + } + } else { + if( ltIE8 ) { + $("#flash_wrap").css("margin-right","0"); + } else { + $("#flash_wrap").css("visibility","visible"); + $("#flash_wrap object").css("visibility","visible"); + } + } + }, + showFlash : function() { + $("#server_wrap").hide(); + $("#server_frame").removeAttr('src'); + if( !kmc.layout.modal.isOpen() ) { + $("#flash_wrap").css("visibility","visible"); + } + $("#server_wrap").css("margin-top", 0); + }, + + // HTML Tab iframe + openIframe : function(url) { + $("#flash_wrap").css("visibility","hidden"); + $("#server_frame").attr("src", url); + $("#server_wrap").css("margin-top", "-"+ ($("#flash_wrap").height() + 2) +"px"); + $("#server_wrap").show(); + }, + + openHelp: function( key ) { + $("#kcms")[0].doHelp( key ); + }, + + setClientIP: function() { + kmc.vars.clientIP = ""; + if( kmc.vars.akamaiEdgeServerIpURL ) { + $.ajax({ + url: window.location.protocol + '//' + kmc.vars.akamaiEdgeServerIpURL, + crossDomain: true, + success: function( data ) { + kmc.vars.clientIP = $(data).find('serverip').text(); + } + }); + } + }, + getClientIP: function() { + return kmc.vars.clientIP; + } + +}; + +kmc.mediator = { + + writeUrlHash : function(module,subtab){ + location.hash = module + "|" + subtab; + document.title = "KMC > " + module + ((subtab && subtab !== "") ? " > " + subtab + " |" : ""); + }, + readUrlHash : function() { + var module = "dashboard", + subtab = "", + extra = {}, + hash, nohash; + + try { + hash = location.hash.split("#")[1].split("|"); + } + catch(err) { + nohash=true; + } + if(!nohash && hash[0]!=="") { + module = hash[0]; + subtab = hash[1]; + + if (hash[2]) + { + var tmp = hash[2].split("&"); + for (var i = 0; idrilldown->flavors->preview + doFlavorPreview : function(entryId, entryName, flavorDetails) { + + var player = kmc.vars.default_kdp; + var code = kmc.Preview.getGenerator().getCode({ + protocol: location.protocol.substring(0, location.protocol.length - 1), + embedType: 'legacy', + entryId: entryId, + uiConfId: parseInt(player.id), + width: player.width, + height: player.height, + includeSeoMetadata: false, + includeHtml5Library: false, + flashVars: { + 'ks': kmc.vars.ks, + 'flavorId': flavorDetails.asset_id + } + }); + + var modal_content = '
    ' + code + '
    ' + + '
    Entry Name:
     ' + entryName + '
    ' + + '
    Entry Id:
     ' + entryId + '
    ' + + '
    Flavor Name:
     ' + flavorDetails.flavor_name + '
    ' + + '
    Flavor Asset Id:
     ' + flavorDetails.asset_id + '
    ' + + '
    Bitrate:
     ' + flavorDetails.bitrate + '
    ' + + '
    Codec:
     ' + flavorDetails.codec + '
    ' + + '
    Dimensions:
     ' + flavorDetails.dimensions.width + ' x ' + flavorDetails.dimensions.height + '
    ' + + '
    Format:
     ' + flavorDetails.format + '
    ' + + '
    Size (KB):
     ' + flavorDetails.sizeKB + '
    ' + + '
    Status:
     ' + flavorDetails.status + '
    ' + + '
    '; + + kmc.layout.modal.open( { + 'width' : parseInt(player.width) + 120, + 'height' : parseInt(player.height) + 300, + 'title' : 'Flavor Preview', + 'content' : '
    ' + modal_content + '
    ' + } ); + + }, + updateList : function(is_playlist) { + var type = is_playlist ? "playlist" : "player"; + $.ajax({ + url: kmc.vars.base_url + kmc.vars.getuiconfs_url, + type: "POST", + data: { + "type": type, + "partner_id": kmc.vars.partner_id, + "ks": kmc.vars.ks + }, + dataType: "json", + success: function(data) { + if (data && data.length) { + if(is_playlist) { + kmc.vars.playlists_list = data; + } + else { + kmc.vars.players_list = data; + } + kmc.Preview.Service.updatePlayers(); + } + } + }); + } +}; + +kmc.client = { + makeRequest: function( service, action, params, callback ) { + var serviceUrl = kmc.vars.api_url + '/api_v3/index.php?service='+service+'&action='+action; + var defaultParams = { + "ks" : kmc.vars.ks, + "format" : 9 + }; + // Merge params and defaults + $.extend( params, defaultParams); + + var ksort = function ( arr ) { + var sArr = []; + var tArr = []; + var n = 0; + for ( var k in arr ){ + tArr[n++] = k+"|"+arr[k]; + } + tArr = tArr.sort(); + for (var i=0; i
    '); + }, + overlay: { + show: function() {$("#overlay").show();}, + hide: function() {$("#overlay").hide();} + }, + modal: { + el: '#modal', + + create: function(data) { + var options = { + 'el': kmc.layout.modal.el, + 'title': '', + 'content': '', + 'help': '', + 'width': 680, + 'height': 'auto', + 'className': '' + }; + // Overwrite defaults with data + $.extend(options, data); + // Set defaults + var $modal = $(options.el), + $modal_title = $modal.find(".title h2"), + $modal_content = $modal.find(".content"); + + // Add default ".modal" class + options.className = 'modal ' + options.className; + + // Set width & height + $modal.css( { + 'width' : options.width, + 'height' : options.height + }).attr('class', options.className); + + // Insert data into modal + if( options.title ) { + $modal_title.text(options.title).attr('title', options.title).parent().show(); + } else { + $modal_title.parent().hide(); + $modal_content.addClass('flash_only'); + } + $modal.find(".help").remove(); + $modal_title.parent().append( options.help ); + $modal_content[0].innerHTML = options.content; + + // Activate close button + $modal.find(".close").click( function() { + kmc.layout.modal.close(options.el); + if( $.isFunction( data.closeCallback ) ) { + data.closeCallback(); + } + }); + + return $modal; + }, + + show: function(el, position) { + position = (position === undefined) ? true : position; + el = el || kmc.layout.modal.el; + var $modal = $(el); + + kmc.utils.hideFlash(true); + kmc.layout.overlay.show(); + $modal.fadeIn(600); + + if( ! $.browser.msie ) { + $modal.css('display', 'table'); + } + + if( position ) { + this.position(el); + } + }, + + open: function(data) { + this.create(data); + var el = data.el || kmc.layout.modal.el; + this.show(el); + }, + + position: function(el) { + el = el || kmc.layout.modal.el; + var $modal = $(el); + // Calculate Modal Position + var mTop = ( ($(window).height() - $modal.height()) / 2 ), + mLeft = ( ($(window).width() - $modal.width()) / (2+$(window).scrollLeft()) ); + mTop = (mTop < 40) ? 40 : mTop; + // Apply style + $modal.css( { + 'top' : mTop + "px", + 'left' : mLeft + "px" + }); + + }, + close: function(el) { + el = el || kmc.layout.modal.el; + $(el).fadeOut(300, function() { + $(el).find(".content").html(''); + kmc.layout.overlay.hide(); + kmc.utils.hideFlash(); + }); + }, + isOpen: function(el) { + el = el || kmc.layout.modal.el; + return $(el).is(":visible"); + } + } +}; + +kmc.user = { + + openSupport: function(el) { + var href = el.href; + // Show overlay + kmc.utils.hideFlash(true); + kmc.layout.overlay.show(); + + // We want the show the modal only after the iframe is loaded so we use "create" instead of "open" + var modal_content = ''; + kmc.layout.modal.create( { + 'width' : 550, + 'title' : 'Support Request', + 'content' : modal_content + } ); + + // Wait until iframe loads and then show the modal + $("#support").load(function() { + // In order to get the iframe content height the modal must be visible + kmc.layout.modal.show(); + // Get iframe content height & update iframe + if( ! kmc.vars.support_frame_height ) { + kmc.vars.support_frame_height = $("#support")[0].contentWindow.document.body.scrollHeight; + } + $("#support").height( kmc.vars.support_frame_height ); + // Re-position the modal box + kmc.layout.modal.position(); + }); + }, + + logout: function() { + var message = kmc.functions.checkForOngoingProcess(); + if( message ) {alert( message );return false;} + var state = kmc.mediator.readUrlHash(); + // Cookies are HTTP only, we delete them using logoutAction + $.ajax({ + url: kmc.vars.base_url + "/index.php/kmc/logout", + type: "POST", + data: { + "ks": kmc.vars.ks + }, + dataType: "json", + complete: function() { + if (kmc.vars.logoutUrl) + window.location = kmc.vars.logoutUrl; + else + window.location = kmc.vars.service_url + "/index.php/kmc/kmc#" + state.moduleName + "|" + state.subtab; + } + }); + }, + + changeSetting: function(action) { + // Set title + var title, iframe_height; + switch(action) { + case "password": + title = "Change Password"; + iframe_height = 180; + break; + case "email": + title = "Change Email Address"; + iframe_height = 160; + break; + case "name": + title = "Edit Name"; + iframe_height = 200; + break; + } + + // setup url + var http_protocol = (kmc.vars.kmc_secured || location.protocol == 'https:') ? 'https' : 'http'; + var from_domain = http_protocol + '://' + window.location.hostname; + var url = from_domain + kmc.vars.port + "/index.php/kmc/updateLoginData/type/" + action; + // pass the parent url for the postMessage to work + url = url + '?parent=' + encodeURIComponent(document.location.href); + + var modal_content = ''; + + kmc.layout.modal.open( { + 'width' : 370, + 'title' : title, + 'content' : modal_content + } ); + + // setup a callback to handle the dispatched MessageEvent. if window.postMessage is supported the passed + // event will have .data, .origin and .source properties. otherwise, it will only have the .data property. + XD.receiveMessage(function(message){ + kmc.layout.modal.close(); + if(message.data == "reload") { + if( ($.browser.msie) && ($.browser.version < 8) ) { + window.location.hash = "account|user"; + } + window.location.reload(); + } + }, from_domain); + }, + + changePartner: function() { + + var i, pid = 0, selected, bolded, + total = kmc.vars.allowed_partners.length; + + var modal_content = '
    Please choose partner:
    '; + + for( i=0; i < total; i++ ) { + pid = kmc.vars.allowed_partners[i].id; + if( kmc.vars.partner_id == pid ) { + selected = ' checked="checked"'; + bolded = ' style="font-weight: bold"'; + } else { + selected = ''; + bolded = ''; + } + modal_content += '  ' + kmc.vars.allowed_partners[i].name + ''; + } + modal_content += '
    '; + + kmc.layout.modal.open( { + 'width' : 300, + 'title' : 'Change Account', + 'content' : modal_content + } ); + + $("#do_change_partner").click(function() { + + var url = kmc.vars.base_url + '/index.php/kmc/extlogin'; + + // Setup input fields + var ks_input = $('').attr({ + 'type': 'hidden', + 'name': 'ks', + 'value': kmc.vars.ks + }); + var partner_id_input = $('').attr({ + 'type': 'hidden', + 'name': 'partner_id', + 'value': $('input[name=pid]:radio:checked').val() // grab the selected partner id + }); + + var $form = $('') + .attr({ + 'action': url, + 'method': 'post', + 'style': 'display: none' + }) + .append( ks_input, partner_id_input ); + + // Submit the form + $('body').append( $form ); + $form[0].submit(); + }); + + return false; + } +}; + +// Maintain support for old kmc2 functions: +function openPlayer(title, width, height, uiconf_id, previewOnly) { + if (previewOnly===true) $("#kcms")[0].alert('previewOnly from studio'); + kmc.preview_embed.doPreviewEmbed("multitab_playlist", title, null, previewOnly, true, uiconf_id, false, false, false); +} +function playlistAdded() {kmc.preview_embed.updateList(true);} +function playerAdded() {kmc.preview_embed.updateList(false);} +/*** end old functions ***/ + +// When page ready initilize KMC +$(function() { + kmc.layout.init(); + kmc.utils.handleMenu(); + kmc.functions.loadSwf(); + + // Set resize event to update the flash object size + $(window).wresize(kmc.utils.resize); + kmc.vars.isLoadedInterval = setInterval(kmc.utils.isModuleLoaded,200); + + // Load kdp player & playlists for preview & embed + kmc.preview_embed.updateList(); // Load players + kmc.preview_embed.updateList(true); // Load playlists + + // Set client IP + kmc.utils.setClientIP(); +}); + +// Auto resize modal windows +$(window).resize(function() { + // Exit if not open + if( kmc.layout.modal.isOpen() ) { + kmc.layout.modal.position(); + } +}); + +// If we have ongoing process, we show a warning message when the user try to leaves the page +window.onbeforeunload = kmc.functions.checkForOngoingProcess; + +/* WResize: plugin for fixing the IE window resize bug (http://noteslog.com/) */ +(function($){$.fn.wresize=function(f){version='1.1';wresize={fired:false,width:0};function resizeOnce(){if($.browser.msie){if(!wresize.fired){wresize.fired=true}else{var version=parseInt($.browser.version,10);wresize.fired=false;if(version<7){return false}else if(version==7){var width=$(window).width();if(width!=wresize.width){wresize.width=width;return false}}}}return true}function handleWResize(e){if(resizeOnce()){return f.apply(this,[e])}}this.each(function(){if(this==window){$(this).resize(handleWResize)}else{$(this).resize(f)}});return this}})(jQuery); + +/* XD: a backwards compatable implementation of postMessage (http://www.onlineaspect.com/2010/01/15/backwards-compatible-postmessage/) */ +var XD=function(){var e,g,h=1,f,d=this;return{postMessage:function(c,b,a){if(b)if(a=a||parent,d.postMessage)a.postMessage(c,b.replace(/([^:]+:\/\/[^\/]+).*/,"$1"));else if(b)a.location=b.replace(/#.*$/,"")+"#"+ +new Date+h++ +"&"+c},receiveMessage:function(c,b){if(d.postMessage)if(c&&(f=function(a){if(typeof b==="string"&&a.origin!==b||Object.prototype.toString.call(b)==="[object Function]"&&b(a.origin)===!1)return!1;c(a)}),d.addEventListener)d[c?"addEventListener":"removeEventListener"]("message", +f,!1);else d[c?"attachEvent":"detachEvent"]("onmessage",f);else e&&clearInterval(e),e=null,c&&(e=setInterval(function(){var a=document.location.hash,b=/^#?\d+&/;a!==g&&b.test(a)&&(g=a,c({data:a.replace(b,"")}))},100))}}}(); + +/* md5 and utf8_encode from phpjs.org */ +function md5(str){var xl;var rotateLeft=function(lValue,iShiftBits){return(lValue<>>(32-iShiftBits));};var addUnsigned=function(lX,lY){var lX4,lY4,lX8,lY8,lResult;lX8=(lX&0x80000000);lY8=(lY&0x80000000);lX4=(lX&0x40000000);lY4=(lY&0x40000000);lResult=(lX&0x3FFFFFFF)+(lY&0x3FFFFFFF);if(lX4&lY4){return(lResult^0x80000000^lX8^lY8);} +if(lX4|lY4){if(lResult&0x40000000){return(lResult^0xC0000000^lX8^lY8);}else{return(lResult^0x40000000^lX8^lY8);}}else{return(lResult^lX8^lY8);}};var _F=function(x,y,z){return(x&y)|((~x)&z);};var _G=function(x,y,z){return(x&z)|(y&(~z));};var _H=function(x,y,z){return(x^y^z);};var _I=function(x,y,z){return(y^(x|(~z)));};var _FF=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(_F(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var _GG=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(_G(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var _HH=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(_H(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var _II=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(_I(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var convertToWordArray=function(str){var lWordCount;var lMessageLength=str.length;var lNumberOfWords_temp1=lMessageLength+8;var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1%64))/64;var lNumberOfWords=(lNumberOfWords_temp2+1)*16;var lWordArray=new Array(lNumberOfWords-1);var lBytePosition=0;var lByteCount=0;while(lByteCount>>29;return lWordArray;};var wordToHex=function(lValue){var wordToHexValue="",wordToHexValue_temp="",lByte,lCount;for(lCount=0;lCount<=3;lCount++){lByte=(lValue>>>(lCount*8))&255;wordToHexValue_temp="0"+lByte.toString(16);wordToHexValue=wordToHexValue+wordToHexValue_temp.substr(wordToHexValue_temp.length-2,2);} +return wordToHexValue;};var x=[],k,AA,BB,CC,DD,a,b,c,d,S11=7,S12=12,S13=17,S14=22,S21=5,S22=9,S23=14,S24=20,S31=4,S32=11,S33=16,S34=23,S41=6,S42=10,S43=15,S44=21;str=this.utf8_encode(str);x=convertToWordArray(str);a=0x67452301;b=0xEFCDAB89;c=0x98BADCFE;d=0x10325476;xl=x.length;for(k=0;k127&&c1<2048){enc=String.fromCharCode((c1>>6)|192)+String.fromCharCode((c1&63)|128);}else{enc=String.fromCharCode((c1>>12)|224)+String.fromCharCode(((c1>>6)&63)|128)+String.fromCharCode((c1&63)|128);} +if(enc!==null){if(end>start){utftext+=string.slice(start,end);} +utftext+=enc;start=end=n+1;}} +if(end>start){utftext+=string.slice(start,stringl);} +return utftext;} \ No newline at end of file diff --git a/alpha/web/lib/js/kmc/6.0.7/kmc.min.js b/alpha/web/lib/js/kmc/6.0.7/kmc.min.js new file mode 100644 index 00000000000..9fdc286b524 --- /dev/null +++ b/alpha/web/lib/js/kmc/6.0.7/kmc.min.js @@ -0,0 +1,6 @@ +/*! KMC - v6.0.7 - 2013-07-14 +* https://github.com/kaltura/KMC_V2 +* Copyright (c) 2013 Ran Yefet; Licensed GNU */ +function openPlayer(e,t,r,a,n){n===!0&&$("#kcms")[0].alert("previewOnly from studio"),kmc.preview_embed.doPreviewEmbed("multitab_playlist",e,null,n,!0,a,!1,!1,!1)}function playlistAdded(){kmc.preview_embed.updateList(!0)}function playerAdded(){kmc.preview_embed.updateList(!1)}function md5(e){var t,r,a,n,i,o,s,l,c,d,h=function(e,t){return e<>>32-t},u=function(e,t){var r,a,n,i,o;return n=2147483648&e,i=2147483648&t,r=1073741824&e,a=1073741824&t,o=(1073741823&e)+(1073741823&t),r&a?2147483648^o^n^i:r|a?1073741824&o?3221225472^o^n^i:1073741824^o^n^i:o^n^i},p=function(e,t,r){return e&t|~e&r},f=function(e,t,r){return e&r|t&~r},m=function(e,t,r){return e^t^r},v=function(e,t,r){return t^(e|~r)},g=function(e,t,r,a,n,i,o){return e=u(e,u(u(p(t,r,a),n),o)),u(h(e,i),t)},y=function(e,t,r,a,n,i,o){return e=u(e,u(u(f(t,r,a),n),o)),u(h(e,i),t)},b=function(e,t,r,a,n,i,o){return e=u(e,u(u(m(t,r,a),n),o)),u(h(e,i),t)},w=function(e,t,r,a,n,i,o){return e=u(e,u(u(v(t,r,a),n),o)),u(h(e,i),t)},k=function(e){for(var t,r=e.length,a=r+8,n=(a-a%64)/64,i=16*(n+1),o=Array(i-1),s=0,l=0;r>l;)t=(l-l%4)/4,s=8*(l%4),o[t]=o[t]|e.charCodeAt(l)<>>29,o},_=function(e){var t,r,a="",n="";for(r=0;3>=r;r++)t=255&e>>>8*r,n="0"+t.toString(16),a+=n.substr(n.length-2,2);return a},C=[],I=7,T=12,E=17,P=22,M=5,A=9,S=14,L=20,$=4,x=11,N=16,B=23,D=6,O=10,H=15,U=21;for(e=this.utf8_encode(e),C=k(e),s=1732584193,l=4023233417,c=2562383102,d=271733878,t=C.length,r=0;t>r;r+=16)a=s,n=l,i=c,o=d,s=g(s,l,c,d,C[r+0],I,3614090360),d=g(d,s,l,c,C[r+1],T,3905402710),c=g(c,d,s,l,C[r+2],E,606105819),l=g(l,c,d,s,C[r+3],P,3250441966),s=g(s,l,c,d,C[r+4],I,4118548399),d=g(d,s,l,c,C[r+5],T,1200080426),c=g(c,d,s,l,C[r+6],E,2821735955),l=g(l,c,d,s,C[r+7],P,4249261313),s=g(s,l,c,d,C[r+8],I,1770035416),d=g(d,s,l,c,C[r+9],T,2336552879),c=g(c,d,s,l,C[r+10],E,4294925233),l=g(l,c,d,s,C[r+11],P,2304563134),s=g(s,l,c,d,C[r+12],I,1804603682),d=g(d,s,l,c,C[r+13],T,4254626195),c=g(c,d,s,l,C[r+14],E,2792965006),l=g(l,c,d,s,C[r+15],P,1236535329),s=y(s,l,c,d,C[r+1],M,4129170786),d=y(d,s,l,c,C[r+6],A,3225465664),c=y(c,d,s,l,C[r+11],S,643717713),l=y(l,c,d,s,C[r+0],L,3921069994),s=y(s,l,c,d,C[r+5],M,3593408605),d=y(d,s,l,c,C[r+10],A,38016083),c=y(c,d,s,l,C[r+15],S,3634488961),l=y(l,c,d,s,C[r+4],L,3889429448),s=y(s,l,c,d,C[r+9],M,568446438),d=y(d,s,l,c,C[r+14],A,3275163606),c=y(c,d,s,l,C[r+3],S,4107603335),l=y(l,c,d,s,C[r+8],L,1163531501),s=y(s,l,c,d,C[r+13],M,2850285829),d=y(d,s,l,c,C[r+2],A,4243563512),c=y(c,d,s,l,C[r+7],S,1735328473),l=y(l,c,d,s,C[r+12],L,2368359562),s=b(s,l,c,d,C[r+5],$,4294588738),d=b(d,s,l,c,C[r+8],x,2272392833),c=b(c,d,s,l,C[r+11],N,1839030562),l=b(l,c,d,s,C[r+14],B,4259657740),s=b(s,l,c,d,C[r+1],$,2763975236),d=b(d,s,l,c,C[r+4],x,1272893353),c=b(c,d,s,l,C[r+7],N,4139469664),l=b(l,c,d,s,C[r+10],B,3200236656),s=b(s,l,c,d,C[r+13],$,681279174),d=b(d,s,l,c,C[r+0],x,3936430074),c=b(c,d,s,l,C[r+3],N,3572445317),l=b(l,c,d,s,C[r+6],B,76029189),s=b(s,l,c,d,C[r+9],$,3654602809),d=b(d,s,l,c,C[r+12],x,3873151461),c=b(c,d,s,l,C[r+15],N,530742520),l=b(l,c,d,s,C[r+2],B,3299628645),s=w(s,l,c,d,C[r+0],D,4096336452),d=w(d,s,l,c,C[r+7],O,1126891415),c=w(c,d,s,l,C[r+14],H,2878612391),l=w(l,c,d,s,C[r+5],U,4237533241),s=w(s,l,c,d,C[r+12],D,1700485571),d=w(d,s,l,c,C[r+3],O,2399980690),c=w(c,d,s,l,C[r+10],H,4293915773),l=w(l,c,d,s,C[r+1],U,2240044497),s=w(s,l,c,d,C[r+8],D,1873313359),d=w(d,s,l,c,C[r+15],O,4264355552),c=w(c,d,s,l,C[r+6],H,2734768916),l=w(l,c,d,s,C[r+13],U,1309151649),s=w(s,l,c,d,C[r+4],D,4149444226),d=w(d,s,l,c,C[r+11],O,3174756917),c=w(c,d,s,l,C[r+2],H,718787259),l=w(l,c,d,s,C[r+9],U,3951481745),s=u(s,a),l=u(l,n),c=u(c,i),d=u(d,o);var j=_(s)+_(l)+_(c)+_(d);return j.toLowerCase()}function utf8_encode(e){if(null===e||e===void 0)return"";var t,r,a=e+"",n="",i=0;t=r=0,i=a.length;for(var o=0;i>o;o++){var s=a.charCodeAt(o),l=null;128>s?r++:l=s>127&&2048>s?String.fromCharCode(192|s>>6)+String.fromCharCode(128|63&s):String.fromCharCode(224|s>>12)+String.fromCharCode(128|63&s>>6)+String.fromCharCode(128|63&s),null!==l&&(r>t&&(n+=a.slice(t,r)),n+=l,t=r=o+1)}return r>t&&(n+=a.slice(t,i)),n}this.Handlebars={},function(e){e.VERSION="1.0.rc.2",e.helpers={},e.partials={},e.registerHelper=function(e,t,r){r&&(t.not=r),this.helpers[e]=t},e.registerPartial=function(e,t){this.partials[e]=t},e.registerHelper("helperMissing",function(e){if(2===arguments.length)return void 0;throw Error("Could not find property '"+e+"'")});var t=Object.prototype.toString,r="[object Function]";e.registerHelper("blockHelperMissing",function(a,n){var i=n.inverse||function(){},o=n.fn,s=t.call(a);return s===r&&(a=a.call(this)),a===!0?o(this):a===!1||null==a?i(this):"[object Array]"===s?a.length>0?e.helpers.each(a,n):i(this):o(a)}),e.K=function(){},e.createFrame=Object.create||function(t){e.K.prototype=t;var r=new e.K;return e.K.prototype=null,r},e.logger={DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,methodMap:{0:"debug",1:"info",2:"warn",3:"error"},log:function(t,r){if(t>=e.logger.level){var a=e.logger.methodMap[t];"undefined"!=typeof console&&console[a]&&console[a].call(console,r)}}},e.log=function(t,r){e.logger.log(t,r)},e.registerHelper("each",function(t,r){var a,n=r.fn,i=r.inverse,o=0,s="";if(r.data&&(a=e.createFrame(r.data)),t&&"object"==typeof t)if(t instanceof Array)for(var l=t.length;l>o;o++)a&&(a.index=o),s+=n(t[o],{data:a});else for(var c in t)t.hasOwnProperty(c)&&(a&&(a.key=c),s+=n(t[c],{data:a}),o++);return 0===o&&(s=i(this)),s}),e.registerHelper("if",function(a,n){var i=t.call(a);return i===r&&(a=a.call(this)),!a||e.Utils.isEmpty(a)?n.inverse(this):n.fn(this)}),e.registerHelper("unless",function(t,r){var a=r.fn,n=r.inverse;return r.fn=n,r.inverse=a,e.helpers["if"].call(this,t,r)}),e.registerHelper("with",function(e,t){return t.fn(e)}),e.registerHelper("log",function(t,r){var a=r.data&&null!=r.data.level?parseInt(r.data.level,10):1;e.log(a,t)})}(this.Handlebars);var errorProps=["description","fileName","lineNumber","message","name","number","stack"];Handlebars.Exception=function(){for(var e=Error.prototype.constructor.apply(this,arguments),t=0;errorProps.length>t;t++)this[errorProps[t]]=e[errorProps[t]]},Handlebars.Exception.prototype=Error(),Handlebars.SafeString=function(e){this.string=e},Handlebars.SafeString.prototype.toString=function(){return""+this.string},function(){var e={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},t=/[&<>"'`]/g,r=/[&<>"'`]/,a=function(t){return e[t]||"&"};Handlebars.Utils={escapeExpression:function(e){return e instanceof Handlebars.SafeString?""+e:null==e||e===!1?"":r.test(e)?e.replace(t,a):e},isEmpty:function(e){return e||0===e?"[object Array]"===Object.prototype.toString.call(e)&&0===e.length?!0:!1:!0}}}(),Handlebars.VM={template:function(e){var t={escapeExpression:Handlebars.Utils.escapeExpression,invokePartial:Handlebars.VM.invokePartial,programs:[],program:function(e,t,r){var a=this.programs[e];return r?Handlebars.VM.program(t,r):a?a:a=this.programs[e]=Handlebars.VM.program(t)},programWithDepth:Handlebars.VM.programWithDepth,noop:Handlebars.VM.noop};return function(r,a){return a=a||{},e.call(t,Handlebars,r,a.helpers,a.partials,a.data)}},programWithDepth:function(e,t){var r=Array.prototype.slice.call(arguments,2);return function(a,n){return n=n||{},e.apply(this,[a,n.data||t].concat(r))}},program:function(e,t){return function(r,a){return a=a||{},e(r,a.data||t)}},noop:function(){return""},invokePartial:function(e,t,r,a,n,i){var o={helpers:a,partials:n,data:i};if(void 0===e)throw new Handlebars.Exception("The partial "+t+" could not be found");if(e instanceof Function)return e(r,o);if(Handlebars.compile)return n[t]=Handlebars.compile(e,{data:void 0!==i}),n[t](r,o);throw new Handlebars.Exception("The partial "+t+" could not be compiled when running in runtime-only mode")}},Handlebars.template=Handlebars.VM.template,function(e,t){var r=function(e,t){var r="",a=t?t+"[":"",n=t?"]":"";for(var i in e)if("object"==typeof e[i])for(var o in e[i])r+="&"+a+encodeURIComponent(i)+"."+encodeURIComponent(o)+n+"="+encodeURIComponent(e[i][o]);else r+="&"+a+encodeURIComponent(i)+n+"="+encodeURIComponent(e[i]);return r};t.registerHelper("flashVarsUrl",function(e){return r(e,"flashvars")}),t.registerHelper("flashVarsString",function(e){return r(e)}),t.registerHelper("elAttributes",function(e){var t="";for(var r in e)t+=" "+r+'="'+e[r]+'"';return t}),t.registerHelper("kalturaLinks",function(){if(!this.includeKalturaLinks)return"";var e=t.templates.kaltura_links;return e()}),t.registerHelper("seoMetadata",function(){var e=t.templates.seo_metadata;return e(this)})}(this,this.Handlebars),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.auto=e(function(e,t,r,a,n){function i(e){var t,a,n="";return n+='
    ",d=r.seoMetadata,t=d||e.seoMetadata,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"seoMetadata",{hash:{}})),(t||0===t)&&(n+=t),d=r.kalturaLinks,t=d||e.kalturaLinks,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"kalturaLinks",{hash:{}})),(t||0===t)&&(n+=t),n+="
    \n"}function o(e){var t,a="";return a+="&entry_id=",d=r.entryId,t=d||e.entryId,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"entryId",{hash:{}})),a+=g(t)}function s(e){var t,a="";return a+="&cache_st=",d=r.cacheSt,t=d||e.cacheSt,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"cacheSt",{hash:{}})),a+=g(t)}r=r||e.helpers;var l,c,d,h,u="",p=this,f="function",m=r.helperMissing,v=void 0,g=this.escapeExpression;return d=r.includeSeoMetadata,l=d||t.includeSeoMetadata,c=r["if"],h=p.program(1,i,n),h.hash={},h.fn=h,h.inverse=p.noop,l=c.call(t,l,h),(l||0===l)&&(u+=l),u+=''}),t.dynamic=e(function(e,t,r){r=r||e.helpers;var a,n,i,o="",s="function",l=r.helperMissing,c=void 0,d=this.escapeExpression;return o+='\n
    ",i=r.seoMetadata,a=i||t.seoMetadata,typeof a===s?a=a.call(t,{hash:{}}):a===c&&(a=l.call(t,"seoMetadata",{hash:{}})),(a||0===a)&&(o+=a),i=r.kalturaLinks,a=i||t.kalturaLinks,typeof a===s?a=a.call(t,{hash:{}}):a===c&&(a=l.call(t,"kalturaLinks",{hash:{}})),(a||0===a)&&(o+=a),o+="
    \n"}),t.iframe=e(function(e,t,r,a,n){function i(e){var t,a="";return a+="&entry_id=",l=r.entryId,t=l||e.entryId,typeof t===u?t=t.call(e,{hash:{}}):t===f&&(t=p.call(e,"entryId",{hash:{}})),a+=m(t)}r=r||e.helpers;var o,s,l,c,d="",h=this,u="function",p=r.helperMissing,f=void 0,m=this.escapeExpression;return d+='"}),t.kaltura_links=e(function(e,t,r){return r=r||e.helpers,'Video Platform\nVideo Management \nVideo Solutions\nVideo Player'}),t.legacy=e(function(e,t,r,a,n){function i(e){var t,a="";return a+='\n'}function o(e){var t,a="";return a+='\n \n \n \n \n \n \n '}r=r||e.helpers;var s,l,c,d,h="",u=this,p="function",f=r.helperMissing,m=void 0,v=this.escapeExpression;return c=r.includeHtml5Library,s=c||t.includeHtml5Library,l=r["if"],d=u.program(1,i,n),d.hash={},d.fn=d,d.inverse=u.noop,s=l.call(t,s,d),(s||0===s)&&(h+=s),h+='\n \n \n \n \n \n \n ',c=r.includeSeoMetadata,s=c||t.includeSeoMetadata,l=r["if"],d=u.program(3,o,n),d.hash={},d.fn=d,d.inverse=u.noop,s=l.call(t,s,d),(s||0===s)&&(h+=s),c=r.kalturaLinks,s=c||t.kalturaLinks,typeof s===p?s=s.call(t,{hash:{}}):s===m&&(s=f.call(t,"kalturaLinks",{hash:{}})),(s||0===s)&&(h+=s),h+="\n"}),t.seo_metadata=e(function(e,t,r,a,n){function i(e){var t,a="";return a+='\n\n\n\n\n\n\n'}r=r||e.helpers;var o,s,l,c,d=this,h="function",u=r.helperMissing,p=void 0,f=this.escapeExpression;return l=r.includeSeoMetadata,o=l||t.includeSeoMetadata,s=r["if"],c=d.program(1,i,n),c.hash={},c.fn=c,c.inverse=d.noop,o=s.call(t,o,c),o||0===o?o:""})}(),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){"use strict";if(null==this)throw new TypeError;var t=Object(this),r=t.length>>>0;if(0===r)return-1;var a=0;if(arguments.length>1&&(a=Number(arguments[1]),a!==a?a=0:0!==a&&1/0!==a&&a!==-1/0&&(a=(a>0||-1)*Math.floor(Math.abs(a)))),a>=r)return-1;for(var n=a>=0?a:Math.max(r-Math.abs(a),0);r>n;n++)if(n in t&&t[n]===e)return n;return-1}),Object.keys||(Object.keys=function(){var e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=r.length;return function(n){if("object"!=typeof n&&"function"!=typeof n||null===n)throw new TypeError("Object.keys called on non-object");var i=[];for(var o in n)e.call(n,o)&&i.push(o);if(t)for(var s=0;a>s;s++)e.call(n,r[s])&&i.push(r[s]);return i}}()),function(e,t){var r=function(e){this.init(e)};r.prototype={types:["auto","dynamic","thumb","iframe","legacy"],required:["widgetId","partnerId","uiConfId"],defaults:{embedType:"auto",playerId:"kaltura_player",protocol:"http",host:"www.kaltura.com",securedHost:"www.kaltura.com",widgetId:null,partnerId:null,cacheSt:null,uiConfId:null,entryId:null,entryMeta:{},width:400,height:330,attributes:{},flashVars:{},includeKalturaLinks:!0,includeSeoMetadata:!1,includeHtml5Library:!0},extend:function(e,t){for(var r in t)t.hasOwnProperty(r)&&!e.hasOwnProperty(r)&&(e[r]=t[r]);return e},isNull:function(e){return e.length&&e.length>0?!1:e.length&&0===e.length?!0:"object"==typeof e?Object.keys(e).length>0?!1:!0:!e},init:function(e){if(e=e||{},this.defaults,typeof Handlebars===t)throw"Handlebars is not defined, please include Handlebars.js before this script";return"object"==typeof e&&(this.options=this.extend(e,this.defaults)),!this.config("widgetId")&&this.config("partnerId")&&this.config("widgetId","_"+this.config("partnerId")),this},config:function(e,r){return r===t&&"string"==typeof e&&this.options.hasOwnProperty(e)?this.options[e]:e===t&&r===t?this.options:("string"==typeof e&&r!==t&&(this.options[e]=r),null)},checkRequiredParams:function(e){var t=this.required.length,r=0;for(r;t>r;r++)if(this.isNull(e[this.required[r]]))throw"Missing required parameter: "+this.required[r]},checkValidType:function(e){var t=-1!==this.types.indexOf(e)?!0:!1;if(!t)throw"Embed type: "+e+" is not valid. Available types: "+this.types.join(",")},getTemplate:function(e){return e="thumb"==e?"dynamic":e,e&&Handlebars.templates&&Handlebars.templates[e]?Handlebars.templates[e]:null},isKWidgetEmbed:function(e){return"dynamic"==e||"thumb"==e?!0:!1},getHost:function(e){return"http"===e.protocol?e.host:e.securedHost},getScriptUrl:function(e){return e.protocol+"://"+this.getHost(e)+"/p/"+e.partnerId+"/sp/"+e.partnerId+"00/embedIframeJs/uiconf_id/"+e.uiConfId+"/partner_id/"+e.partnerId},getSwfUrl:function(e){var t=e.cacheSt?"/cache_st/"+e.cacheSt:"",r=e.entryId?"/entry_id/"+e.entryId:"";return e.protocol+"://"+this.getHost(e)+"/index.php/kwidget"+t+"/wid/"+e.widgetId+"/uiconf_id/"+e.uiConfId+r},getAttributes:function(e){var t={};return(this.isKWidgetEmbed(e.embedType)||e.includeSeoMetadata)&&(t.style="width: "+e.width+"px; height: "+e.height+"px;"),e.includeSeoMetadata&&("legacy"==e.embedType?(t["xmlns:dc"]="http://purl.org/dc/terms/",t["xmlns:media"]="http://search.yahoo.com/searchmonkey/media/",t.rel="media:video",t.resource=this.getSwfUrl(e)):(t.itemprop="video",t["itemscope itemtype"]="http://schema.org/VideoObject")),t},getEmbedObject:function(e){var t={targetId:e.playerId,wid:e.widgetId,uiconf_id:e.uiConfId,flashvars:e.flashVars};return e.cacheSt&&(t.cache_st=e.cacheSt),e.entryId&&(t.entry_id=e.entryId),JSON.stringify(t,null,2)},getCode:function(e){var r=e===t?{}:this.extend({},e);r=this.extend(r,this.config()),!r.widgetId&&r.partnerId&&(r.widgetId="_"+r.partnerId),this.checkRequiredParams(r),this.checkValidType(r.embedType);var a=this.getTemplate(r.embedType);if(!a)throw"Template: "+r.embedType+" is not defined as Handlebars template";var n={host:this.getHost(r),scriptUrl:this.getScriptUrl(r),attributes:this.getAttributes(r)};return"legacy"===r.embedType&&(n.swfUrl=this.getSwfUrl(r)),this.isKWidgetEmbed(r.embedType)&&(n.embedMethod="dynamic"==r.embedType?"embed":"thumbEmbed",n.kWidgetObject=this.getEmbedObject(r)),n=this.extend(n,r),a(n)}},e.kEmbedCodeGenerator=r}(this),function(e){e.fn.qrcode=function(t){function r(e){this.mode=s.MODE_8BIT_BYTE,this.data=e}function a(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function n(e,t){if(void 0==e.length)throw Error(e.length+"/"+t);for(var r=0;e.length>r&&0==e[r];)r++;this.num=Array(e.length-r+t);for(var a=0;e.length-r>a;a++)this.num[a]=e[a+r]}function i(e,t){this.totalCount=e,this.dataCount=t}function o(){this.buffer=[],this.length=0}r.prototype={getLength:function(){return this.data.length},write:function(e){for(var t=0;this.data.length>t;t++)e.put(this.data.charCodeAt(t),8)}},a.prototype={addData:function(e){var t=new r(e);this.dataList.push(t),this.dataCache=null},isDark:function(e,t){if(0>e||e>=this.moduleCount||0>t||t>=this.moduleCount)throw Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){var e=1;for(e=1;40>e;e++){for(var t=i.getRSBlocks(e,this.errorCorrectLevel),r=new o,a=0,n=0;t.length>n;n++)a+=t[n].dataCount;for(var n=0;this.dataList.length>n;n++){var s=this.dataList[n];r.put(s.mode,4),r.put(s.getLength(),d.getLengthInBits(s.mode,e)),s.write(r)}if(8*a>=r.getLengthInBits())break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,t){this.moduleCount=4*this.typeNumber+17,this.modules=Array(this.moduleCount);for(var r=0;this.moduleCount>r;r++){this.modules[r]=Array(this.moduleCount);for(var n=0;this.moduleCount>n;n++)this.modules[r][n]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,t),this.typeNumber>=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=a.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;7>=r;r++)if(!(-1>=e+r||e+r>=this.moduleCount))for(var a=-1;7>=a;a++)-1>=t+a||t+a>=this.moduleCount||(this.modules[e+r][t+a]=r>=0&&6>=r&&(0==a||6==a)||a>=0&&6>=a&&(0==r||6==r)||r>=2&&4>=r&&a>=2&&4>=a?!0:!1)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;8>r;r++){this.makeImpl(!0,r);var a=d.getLostPoint(this);(0==r||e>a)&&(e=a,t=r)}return t},createMovieClip:function(e,t,r){var a=e.createEmptyMovieClip(t,r),n=1;this.make();for(var i=0;this.modules.length>i;i++)for(var o=i*n,s=0;this.modules[i].length>s;s++){var l=s*n,c=this.modules[i][s];c&&(a.beginFill(0,100),a.moveTo(l,o),a.lineTo(l+n,o),a.lineTo(l+n,o+n),a.lineTo(l,o+n),a.endFill())}return a},setupTimingPattern:function(){for(var e=8;this.moduleCount-8>e;e++)null==this.modules[e][6]&&(this.modules[e][6]=0==e%2);for(var t=8;this.moduleCount-8>t;t++)null==this.modules[6][t]&&(this.modules[6][t]=0==t%2)},setupPositionAdjustPattern:function(){for(var e=d.getPatternPosition(this.typeNumber),t=0;e.length>t;t++)for(var r=0;e.length>r;r++){var a=e[t],n=e[r];if(null==this.modules[a][n])for(var i=-2;2>=i;i++)for(var o=-2;2>=o;o++)this.modules[a+i][n+o]=-2==i||2==i||-2==o||2==o||0==i&&0==o?!0:!1}},setupTypeNumber:function(e){for(var t=d.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var a=!e&&1==(1&t>>r);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=a}for(var r=0;18>r;r++){var a=!e&&1==(1&t>>r);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=a}},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,a=d.getBCHTypeInfo(r),n=0;15>n;n++){var i=!e&&1==(1&a>>n);6>n?this.modules[n][8]=i:8>n?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(var n=0;15>n;n++){var i=!e&&1==(1&a>>n);8>n?this.modules[8][this.moduleCount-n-1]=i:9>n?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,a=this.moduleCount-1,n=7,i=0,o=this.moduleCount-1;o>0;o-=2)for(6==o&&o--;;){for(var s=0;2>s;s++)if(null==this.modules[a][o-s]){var l=!1;e.length>i&&(l=1==(1&e[i]>>>n));var c=d.getMask(t,a,o-s);c&&(l=!l),this.modules[a][o-s]=l,n--,-1==n&&(i++,n=7)}if(a+=r,0>a||a>=this.moduleCount){a-=r,r=-r;break}}}},a.PAD0=236,a.PAD1=17,a.createData=function(e,t,r){for(var n=i.getRSBlocks(e,t),s=new o,l=0;r.length>l;l++){var c=r[l];s.put(c.mode,4),s.put(c.getLength(),d.getLengthInBits(c.mode,e)),c.write(s)}for(var h=0,l=0;n.length>l;l++)h+=n[l].dataCount;if(s.getLengthInBits()>8*h)throw Error("code length overflow. ("+s.getLengthInBits()+">"+8*h+")");for(8*h>=s.getLengthInBits()+4&&s.put(0,4);0!=s.getLengthInBits()%8;)s.putBit(!1);for(;;){if(s.getLengthInBits()>=8*h)break;if(s.put(a.PAD0,8),s.getLengthInBits()>=8*h)break;s.put(a.PAD1,8)}return a.createBytes(s,n)},a.createBytes=function(e,t){for(var r=0,a=0,i=0,o=Array(t.length),s=Array(t.length),l=0;t.length>l;l++){var c=t[l].dataCount,h=t[l].totalCount-c;a=Math.max(a,c),i=Math.max(i,h),o[l]=Array(c);for(var u=0;o[l].length>u;u++)o[l][u]=255&e.buffer[u+r];r+=c;var p=d.getErrorCorrectPolynomial(h),f=new n(o[l],p.getLength()-1),m=f.mod(p);s[l]=Array(p.getLength()-1);for(var u=0;s[l].length>u;u++){var v=u+m.getLength()-s[l].length;s[l][u]=v>=0?m.get(v):0}}for(var g=0,u=0;t.length>u;u++)g+=t[u].totalCount;for(var y=Array(g),b=0,u=0;a>u;u++)for(var l=0;t.length>l;l++)o[l].length>u&&(y[b++]=o[l][u]);for(var u=0;i>u;u++)for(var l=0;t.length>l;l++)s[l].length>u&&(y[b++]=s[l][u]);return y};for(var s={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},l={L:1,M:0,Q:3,H:2},c={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},d={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var t=e<<10;d.getBCHDigit(t)-d.getBCHDigit(d.G15)>=0;)t^=d.G15<=0;)t^=d.G18<>>=1;return t},getPatternPosition:function(e){return d.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case c.PATTERN000:return 0==(t+r)%2;case c.PATTERN001:return 0==t%2;case c.PATTERN010:return 0==r%3;case c.PATTERN011:return 0==(t+r)%3;case c.PATTERN100:return 0==(Math.floor(t/2)+Math.floor(r/3))%2;case c.PATTERN101:return 0==t*r%2+t*r%3;case c.PATTERN110:return 0==(t*r%2+t*r%3)%2;case c.PATTERN111:return 0==(t*r%3+(t+r)%2)%2;default:throw Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new n([1],0),r=0;e>r;r++)t=t.multiply(new n([1,h.gexp(r)],0));return t},getLengthInBits:function(e,t){if(t>=1&&10>t)switch(e){case s.MODE_NUMBER:return 10;case s.MODE_ALPHA_NUM:return 9;case s.MODE_8BIT_BYTE:return 8;case s.MODE_KANJI:return 8;default:throw Error("mode:"+e)}else if(27>t)switch(e){case s.MODE_NUMBER:return 12;case s.MODE_ALPHA_NUM:return 11;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 10;default:throw Error("mode:"+e)}else{if(!(41>t))throw Error("type:"+t);switch(e){case s.MODE_NUMBER:return 14;case s.MODE_ALPHA_NUM:return 13;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 12;default:throw Error("mode:"+e)}}},getLostPoint:function(e){for(var t=e.getModuleCount(),r=0,a=0;t>a;a++)for(var n=0;t>n;n++){for(var i=0,o=e.isDark(a,n),s=-1;1>=s;s++)if(!(0>a+s||a+s>=t))for(var l=-1;1>=l;l++)0>n+l||n+l>=t||(0!=s||0!=l)&&o==e.isDark(a+s,n+l)&&i++; +i>5&&(r+=3+i-5)}for(var a=0;t-1>a;a++)for(var n=0;t-1>n;n++){var c=0;e.isDark(a,n)&&c++,e.isDark(a+1,n)&&c++,e.isDark(a,n+1)&&c++,e.isDark(a+1,n+1)&&c++,(0==c||4==c)&&(r+=3)}for(var a=0;t>a;a++)for(var n=0;t-6>n;n++)e.isDark(a,n)&&!e.isDark(a,n+1)&&e.isDark(a,n+2)&&e.isDark(a,n+3)&&e.isDark(a,n+4)&&!e.isDark(a,n+5)&&e.isDark(a,n+6)&&(r+=40);for(var n=0;t>n;n++)for(var a=0;t-6>a;a++)e.isDark(a,n)&&!e.isDark(a+1,n)&&e.isDark(a+2,n)&&e.isDark(a+3,n)&&e.isDark(a+4,n)&&!e.isDark(a+5,n)&&e.isDark(a+6,n)&&(r+=40);for(var d=0,n=0;t>n;n++)for(var a=0;t>a;a++)e.isDark(a,n)&&d++;var h=Math.abs(100*d/t/t-50)/5;return r+=10*h}},h={glog:function(e){if(1>e)throw Error("glog("+e+")");return h.LOG_TABLE[e]},gexp:function(e){for(;0>e;)e+=255;for(;e>=256;)e-=255;return h.EXP_TABLE[e]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},u=0;8>u;u++)h.EXP_TABLE[u]=1<u;u++)h.EXP_TABLE[u]=h.EXP_TABLE[u-4]^h.EXP_TABLE[u-5]^h.EXP_TABLE[u-6]^h.EXP_TABLE[u-8];for(var u=0;255>u;u++)h.LOG_TABLE[h.EXP_TABLE[u]]=u;n.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=Array(this.getLength()+e.getLength()-1),r=0;this.getLength()>r;r++)for(var a=0;e.getLength()>a;a++)t[r+a]^=h.gexp(h.glog(this.get(r))+h.glog(e.get(a)));return new n(t,0)},mod:function(e){if(0>this.getLength()-e.getLength())return this;for(var t=h.glog(this.get(0))-h.glog(e.get(0)),r=Array(this.getLength()),a=0;this.getLength()>a;a++)r[a]=this.get(a);for(var a=0;e.getLength()>a;a++)r[a]^=h.gexp(h.glog(e.get(a))+t);return new n(r,0).mod(e)}},i.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],i.getRSBlocks=function(e,t){var r=i.getRsBlockTable(e,t);if(void 0==r)throw Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+t);for(var a=r.length/3,n=[],o=0;a>o;o++)for(var s=r[3*o+0],l=r[3*o+1],c=r[3*o+2],d=0;s>d;d++)n.push(new i(l,c));return n},i.getRsBlockTable=function(e,t){switch(t){case l.L:return i.RS_BLOCK_TABLE[4*(e-1)+0];case l.M:return i.RS_BLOCK_TABLE[4*(e-1)+1];case l.Q:return i.RS_BLOCK_TABLE[4*(e-1)+2];case l.H:return i.RS_BLOCK_TABLE[4*(e-1)+3];default:return void 0}},o.prototype={get:function(e){var t=Math.floor(e/8);return 1==(1&this.buffer[t]>>>7-e%8)},put:function(e,t){for(var r=0;t>r;r++)this.putBit(1==(1&e>>>t-r-1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);t>=this.buffer.length&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},"string"==typeof t&&(t={text:t}),t=e.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,correctLevel:l.H,background:"#ffffff",foreground:"#000000"},t);var p=function(){var e=new a(t.typeNumber,t.correctLevel);e.addData(t.text),e.make();var r=document.createElement("canvas");r.width=t.width,r.height=t.height;for(var n=r.getContext("2d"),i=t.width/e.getModuleCount(),o=t.height/e.getModuleCount(),s=0;e.getModuleCount()>s;s++)for(var l=0;e.getModuleCount()>l;l++){n.fillStyle=e.isDark(s,l)?t.foreground:t.background;var c=Math.ceil((l+1)*i)-Math.floor(l*i),d=Math.ceil((s+1)*i)-Math.floor(s*i);n.fillRect(Math.round(l*i),Math.round(s*o),c,d)}return r},f=function(){var r=new a(t.typeNumber,t.correctLevel);r.addData(t.text),r.make();for(var n=e("
    ").css("width",t.width+"px").css("height",t.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",t.background),i=t.width/r.getModuleCount(),o=t.height/r.getModuleCount(),s=0;r.getModuleCount()>s;s++)for(var l=e("").css("height",o+"px").appendTo(n),c=0;r.getModuleCount()>c;c++)e("").css("width",i+"px").css("background-color",r.isDark(s,c)?t.foreground:t.background).appendTo(l);return n};return this.each(function(){var r="canvas"==t.render?p():f();e(r).appendTo(this)})}}(jQuery),window.XDomainRequest&&jQuery.ajaxTransport(function(e){if(e.crossDomain&&e.async){e.timeout&&(e.xdrTimeout=e.timeout,delete e.timeout);var t;return{send:function(r,a){function n(e,r,n,i){t.onload=t.onerror=t.ontimeout=jQuery.noop,t=void 0,a(e,r,n,i)}t=new XDomainRequest,t.onload=function(){n(200,"OK",{text:t.responseText},"Content-Type: "+t.contentType)},t.onerror=function(){n(404,"Not Found")},t.onprogress=jQuery.noop,t.ontimeout=function(){n(0,"timeout")},t.timeout=e.xdrTimeout||Number.MAX_VALUE,t.open(e.type,e.url),t.send(e.hasContent&&e.data||null)},abort:function(){t&&(t.onerror=jQuery.noop,t.abort())}}}}),function(){"use strict";var e,t=function(e,t){var r=e.style[t];if(e.currentStyle?r=e.currentStyle[t]:window.getComputedStyle&&(r=document.defaultView.getComputedStyle(e,null).getPropertyValue(t)),"auto"==r&&"cursor"==t)for(var a=["a"],n=0;a.length>n;n++)if(e.tagName.toLowerCase()==a[n])return"pointer";return r},r=function(e){if(u.prototype._singleton){e||(e=window.event);var t;this!==window?t=this:e.target?t=e.target:e.srcElement&&(t=e.srcElement),u.prototype._singleton.setCurrent(t)}},a=function(e,t,r){e.addEventListener?e.addEventListener(t,r,!1):e.attachEvent&&e.attachEvent("on"+t,r)},n=function(e,t,r){e.removeEventListener?e.removeEventListener(t,r,!1):e.detachEvent&&e.detachEvent("on"+t,r)},i=function(e,t){if(e.addClass)return e.addClass(t),e;if(t&&"string"==typeof t){var r=(t||"").split(/\s+/);if(1===e.nodeType)if(e.className){for(var a=" "+e.className+" ",n=e.className,i=0,o=r.length;o>i;i++)0>a.indexOf(" "+r[i]+" ")&&(n+=" "+r[i]);e.className=n.replace(/^\s+|\s+$/g,"")}else e.className=t}return e},o=function(e,t){if(e.removeClass)return e.removeClass(t),e;if(t&&"string"==typeof t||void 0===t){var r=(t||"").split(/\s+/);if(1===e.nodeType&&e.className)if(t){for(var a=(" "+e.className+" ").replace(/[\n\t]/g," "),n=0,i=r.length;i>n;n++)a=a.replace(" "+r[n]+" "," ");e.className=a.replace(/^\s+|\s+$/g,"")}else e.className=""}return e},s=function(e){var r={left:0,top:0,width:e.width||e.offsetWidth||0,height:e.height||e.offsetHeight||0,zIndex:9999},a=t(e,"zIndex");for(a&&"auto"!=a&&(r.zIndex=parseInt(a,10));e;){var n=parseInt(t(e,"borderLeftWidth"),10),i=parseInt(t(e,"borderTopWidth"),10);r.left+=isNaN(e.offsetLeft)?0:e.offsetLeft,r.left+=isNaN(n)?0:n,r.top+=isNaN(e.offsetTop)?0:e.offsetTop,r.top+=isNaN(i)?0:i,e=e.offsetParent}return r},l=function(e){return(e.indexOf("?")>=0?"&":"?")+"nocache="+(new Date).getTime()},c=function(e){var t=[];return e.trustedDomains&&("string"==typeof e.trustedDomains?t.push("trustedDomain="+e.trustedDomains):t.push("trustedDomain="+e.trustedDomains.join(","))),t.join("&")},d=function(e,t){if(t.indexOf)return t.indexOf(e);for(var r=0,a=t.length;a>r;r++)if(t[r]===e)return r;return-1},h=function(e){if("string"==typeof e)throw new TypeError("ZeroClipboard doesn't accept query strings.");return e.length?e:[e]},u=function(e,t){if(e&&(u.prototype._singleton||this).glue(e),u.prototype._singleton)return u.prototype._singleton;u.prototype._singleton=this,this.options={};for(var r in f)this.options[r]=f[r];for(var a in t)this.options[a]=t[a];this.handlers={},u.detectFlashSupport()&&m()},p=[];u.prototype.setCurrent=function(r){e=r,this.reposition(),r.getAttribute("title")&&this.setTitle(r.getAttribute("title")),this.setHandCursor("pointer"==t(r,"cursor"))},u.prototype.setText=function(e){e&&""!==e&&(this.options.text=e,this.ready()&&this.flashBridge.setText(e))},u.prototype.setTitle=function(e){e&&""!==e&&this.htmlBridge.setAttribute("title",e)},u.prototype.setSize=function(e,t){this.ready()&&this.flashBridge.setSize(e,t)},u.prototype.setHandCursor=function(e){this.ready()&&this.flashBridge.setHandCursor(e)},u.version="1.1.7";var f={moviePath:"ZeroClipboard.swf",trustedDomains:null,text:null,hoverClass:"zeroclipboard-is-hover",activeClass:"zeroclipboard-is-active",allowScriptAccess:"sameDomain"};u.setDefaults=function(e){for(var t in e)f[t]=e[t]},u.destroy=function(){u.prototype._singleton.unglue(p);var e=u.prototype._singleton.htmlBridge;e.parentNode.removeChild(e),delete u.prototype._singleton},u.detectFlashSupport=function(){var e=!1;try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(e=!0)}catch(t){navigator.mimeTypes["application/x-shockwave-flash"]&&(e=!0)}return e};var m=function(){var e=u.prototype._singleton,t=document.getElementById("global-zeroclipboard-html-bridge");if(!t){var r=' ';t=document.createElement("div"),t.id="global-zeroclipboard-html-bridge",t.setAttribute("class","global-zeroclipboard-container"),t.setAttribute("data-clipboard-ready",!1),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="15px",t.style.height="15px",t.style.zIndex="9999",t.innerHTML=r,document.body.appendChild(t)}e.htmlBridge=t,e.flashBridge=document["global-zeroclipboard-flash-bridge"]||t.children[0].lastElementChild};u.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),o(e,this.options.activeClass),e=null,this.options.text=null},u.prototype.ready=function(){var e=this.htmlBridge.getAttribute("data-clipboard-ready");return"true"===e||e===!0},u.prototype.reposition=function(){if(!e)return!1;var t=s(e);this.htmlBridge.style.top=t.top+"px",this.htmlBridge.style.left=t.left+"px",this.htmlBridge.style.width=t.width+"px",this.htmlBridge.style.height=t.height+"px",this.htmlBridge.style.zIndex=t.zIndex+1,this.setSize(t.width,t.height)},u.dispatch=function(e,t){u.prototype._singleton.receiveEvent(e,t)},u.prototype.on=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++)e=r[a].toLowerCase().replace(/^on/,""),this.handlers[e]||(this.handlers[e]=t);this.handlers.noflash&&!u.detectFlashSupport()&&this.receiveEvent("onNoFlash",null)},u.prototype.addEventListener=u.prototype.on,u.prototype.off=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++){e=r[a].toLowerCase().replace(/^on/,"");for(var n in this.handlers)n===e&&this.handlers[n]===t&&delete this.handlers[n]}},u.prototype.removeEventListener=u.prototype.off,u.prototype.receiveEvent=function(t,r){t=(""+t).toLowerCase().replace(/^on/,"");var a=e;switch(t){case"load":if(r&&10>parseFloat(r.flashVersion.replace(",",".").replace(/[^0-9\.]/gi,"")))return this.receiveEvent("onWrongFlash",{flashVersion:r.flashVersion}),void 0;this.htmlBridge.setAttribute("data-clipboard-ready",!0);break;case"mouseover":i(a,this.options.hoverClass);break;case"mouseout":o(a,this.options.hoverClass),this.resetBridge();break;case"mousedown":i(a,this.options.activeClass);break;case"mouseup":o(a,this.options.activeClass);break;case"datarequested":var n=a.getAttribute("data-clipboard-target"),s=n?document.getElementById(n):null;if(s){var l=s.value||s.textContent||s.innerText;l&&this.setText(l)}else{var c=a.getAttribute("data-clipboard-text");c&&this.setText(c)}break;case"complete":this.options.text=null}if(this.handlers[t]){var d=this.handlers[t];"function"==typeof d?d.call(a,this,r):"string"==typeof d&&window[d].call(a,this,r)}},u.prototype.glue=function(e){e=h(e);for(var t=0;e.length>t;t++)-1==d(e[t],p)&&(p.push(e[t]),a(e[t],"mouseover",r))},u.prototype.unglue=function(e){e=h(e);for(var t=0;e.length>t;t++){n(e[t],"mouseover",r);var a=d(e[t],p);-1!=a&&p.splice(a,1)}},"undefined"!=typeof module?module.exports=u:"function"==typeof define&&define.amd?define(function(){return u}):window.ZeroClipboard=u}(),function(e){var t=e.Preview||{};e.vars.previewDefaults={showAdvancedOptions:!1,includeKalturaLinks:!e.vars.ignore_seo_links,includeSeoMetadata:!e.vars.ignore_entry_seo,deliveryType:e.vars.default_delivery_type,embedType:e.vars.default_embed_code_type,secureEmbed:e.vars.embed_code_protocol_https},"https:"==window.location.protocol&&(e.vars.previewDefaults.secureEmbed=!0),t.storageName="previewDefaults",t.el="#previewModal",t.iframeContainer="previewIframe",t.ignoreChangeEvents=!0,t.getGenerator=function(){return this.generator||(this.generator=new kEmbedCodeGenerator({host:e.vars.embed_host,securedHost:e.vars.embed_host_https,partnerId:e.vars.partner_id,includeKalturaLinks:e.vars.previewDefaults.includeKalturaLinks})),this.generator},t.clipboard=new ZeroClipboard($(".copy-code"),{moviePath:"/lib/flash/ZeroClipboard.swf",trustedDomains:["*"],allowScriptAccess:"always"}),t.clipboard.on("complete",function(){var e=$(this);$("#"+e.data("clipboard-target")).select(),e.data("close")===!0&&t.closeModal(t.el)}),t.objectToArray=function(e){var t=[];for(var r in e)e[r].id=r,t.push(e[r]);return t},t.getObjectById=function(e,t){var r=$.grep(t,function(t){return t.id==e});return r.length?r[0]:!1},t.getDefault=function(r){var a=localStorage.getItem(t.storageName);return a=a?JSON.parse(a):e.vars.previewDefaults,void 0!==a[r]?a[r]:null},t.savePreviewState=function(){var e=this.Service,r={embedType:e.get("embedType"),secureEmbed:e.get("secureEmbed"),includeSeoMetadata:e.get("includeSeo"),deliveryType:e.get("deliveryType").id,showAdvancedOptions:e.get("showAdvancedOptions")};localStorage.setItem(t.storageName,JSON.stringify(r))},t.getDeliveryTypeFlashVars=function(e){if(!e)return{};var t=e.flashvars?e.flashvars:{},r=$.extend({},t);return e.streamerType&&(r.streamerType=e.streamerType),e.mediaProtocol&&(r.mediaProtocol=e.mediaProtocol),r},t.getPreviewTitle=function(e){return e.entryMeta&&e.entryMeta.name?"Embedding: "+e.entryMeta.name:e.playlistName?"Playlist: "+e.playlistName:e.playerOnly?"Player Name:"+e.name:void 0},t.openPreviewEmbed=function(t,r){var a=this,n=a.el;this.ignoreChangeEvents=!1;var i={entryId:null,entryMeta:{},playlistId:null,playlistName:null,previewOnly:!1,liveBitrates:null,playerOnly:!1,uiConfId:null,name:null};t=$.extend({},i,t),t.liveBitrates&&r.setDeliveryType("auto"),r.updatePlayers(t),r.set(t);var o=this.getPreviewTitle(t),s=$(n);s.find(".title h2").text(o).attr("title",o),s.find(".close").unbind("click").click(function(){a.closeModal(n)});var l=$("body").height()-173;s.find(".content").height(l),e.layout.modal.show(n,!1)},t.closeModal=function(t){this.savePreviewState(),this.emptyDiv(this.iframeContainer),$(t).fadeOut(300,function(){e.layout.overlay.hide(),e.utils.hideFlash()})},t.emptyDiv=function(e){var t=$("#"+e),r=$("#previewIframe iframe");if(r.length)try{var a=$(r[0].contentWindow.document);a.find("#framePlayerContainer").empty()}catch(n){}return t.length?(t.empty(),t[0]):!1},t.hasIframe=function(){return $("#"+this.iframeContainer+" iframe").length},t.getCacheSt=function(){var e=new Date;return Math.floor(e.getTime()/1e3)+900},t.generateIframe=function(e){var t=$("html").hasClass("lt-ie10"),r="",a=this.emptyDiv(this.iframeContainer),n=document.createElement("iframe");if(n.frameborder="0",n.frameBorder="0",n.marginheight="0",n.marginwidth="0",n.frameborder="0",a.appendChild(n),t)n.src=this.getPreviewUrl(this.Service,!0);else{var i=n.contentDocument;i.open(),i.write(""+r+'
    '+e+"
    "),i.close()}},t.getEmbedProtocol=function(e,t){return t===!0?location.protocol.substring(0,location.protocol.length-1):e.get("secureEmbed")?"https":"http"},t.getEmbedFlashVars=function(t,r){var a=this.getEmbedProtocol(t,r),n=t.get("player"),i=this.getDeliveryTypeFlashVars(t.get("deliveryType"));r===!0&&(i.ks=e.vars.ks);var o=t.get("playlistId");if(o){var s=e.functions.getVersionFromPath(n.html5Url),l=e.functions.versionIsAtLeast(e.vars.min_kdp_version_for_playlist_api_v3,n.swf_version),c=e.functions.versionIsAtLeast(e.vars.min_html5_version_for_playlist_api_v3,s);l&&c?i["playlistAPI.kpl0Id"]=o:(i["playlistAPI.autoInsert"]="true",i["playlistAPI.kpl0Name"]=t.get("playlistName"),i["playlistAPI.kpl0Url"]=a+"://"+e.vars.api_host+"/index.php/partnerservices2/executeplaylist?"+"partner_id="+e.vars.partner_id+"&subp_id="+e.vars.partner_id+"00"+"&format=8&ks={ks}&playlist_id="+o)}return i},t.getEmbedCode=function(e,t){var r=e.get("player");if(!r||!e.get("embedType"))return"";var a=this.getCacheSt(),n={protocol:this.getEmbedProtocol(e,t),embedType:e.get("embedType"),uiConfId:r.id,width:r.width,height:r.height,entryMeta:e.get("entryMeta"),includeSeoMetadata:e.get("includeSeo"),playerId:"kaltura_player_"+a,cacheSt:a,flashVars:this.getEmbedFlashVars(e,t)};e.get("entryId")&&(n.entryId=e.get("entryId"));var i=this.getGenerator().getCode(n);return i},t.getPreviewUrl=function(t,r){var a=t.get("player");if(!a||!t.get("embedType"))return"";var n=this.getEmbedProtocol(t,r),i=n+"://"+e.vars.api_host+"/index.php/kmc/preview";return i+="/partner_id/"+e.vars.partner_id,i+="/uiconf_id/"+a.id,t.get("entryId")&&(i+="/entry_id/"+t.get("entryId")),i+="/embed/"+t.get("embedType"),i+="?"+e.functions.flashVarsToUrl(this.getEmbedFlashVars(t,r)),r===!0&&(i+="&framed=true"),i},t.generateQrCode=function(e){var t=$("#qrcode").empty();e&&($("html").hasClass("lt-ie9")||t.qrcode({width:80,height:80,text:e}))},t.generateShortUrl=function(t,r){t&&e.client.createShortURL(t,r)},e.Preview=t}(window.kmc);var kmcApp=angular.module("kmcApp",[]);kmcApp.factory("previewService",["$rootScope",function(e){var t={};return{get:function(e){return void 0===e?t:t[e]},set:function(r,a,n){"object"==typeof r?angular.extend(t,r):t[r]=a,n||e.$broadcast("previewChanged")},updatePlayers:function(t){e.$broadcast("playersUpdated",t)},changePlayer:function(t){e.$broadcast("changePlayer",t)},setDeliveryType:function(t){e.$broadcast("changeDelivery",t)}}}]),kmcApp.directive("showSlide",function(){return{restrict:"A",link:function(e,t,r){r.showSlide,e.$watch(r.showSlide,function(e){e&&!t.is(":visible")?t.slideDown():t.slideUp()})}}}),kmcApp.controller("PreviewCtrl",["$scope","previewService",function(e,t){var r=function(){e.$$phase||e.$apply()},a=kmc.Preview;a.playlistMode=!1,a.Service=t;var n=function(t){t=t||{};var r=t.uiConfId?t.uiConfId:void 0;kmc.vars.playlists_list&&kmc.vars.players_list&&(t.playlistId||t.playerOnly?(e.players=kmc.vars.playlists_list,a.playlistMode||(a.playlistMode=!0,e.$broadcast("changePlayer",r))):(e.players=kmc.vars.players_list,(a.playlistMode||!e.player)&&(a.playlistMode=!1,e.$broadcast("changePlayer",r))),r&&e.$broadcast("changePlayer",r))},i=function(r){var n=a.objectToArray(kmc.vars.delivery_types),i=e.deliveryType||a.getDefault("deliveryType"),o=[];$.each(n,function(){return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,r.swf_version)?(this.id==i&&(i=null),!0):(o.push(this),void 0)}),e.deliveryTypes=o,i||(i=e.deliveryTypes[0].id),t.setDeliveryType(i)},o=function(t){var r=a.objectToArray(kmc.vars.embed_code_types),n=e.embedType||a.getDefault("embedType"),i=[];$.each(r,function(){if(a.playlistMode&&this.entryOnly)return this.id==n&&(n=null),!0;var e=kmc.functions.getVersionFromPath(t.html5Url);return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,e)?(this.id==n&&(n=null),!0):(i.push(this),void 0)}),e.embedTypes=i,n||(n=e.embedTypes[0].id),e.embedType=n};e.players=[],e.player=null,e.deliveryTypes=[],e.deliveryType=null,e.embedTypes=[],e.embedType=null,e.secureEmbed=a.getDefault("secureEmbed"),e.includeSeo=a.getDefault("includeSeoMetadata"),e.previewOnly=!1,e.playerOnly=!1,e.liveBitrates=!1,e.showAdvancedOptionsStatus=a.getDefault("showAdvancedOptions"),e.shortLinkGenerated=!1,e.$on("playersUpdated",function(e,t){n(t)}),e.$on("changePlayer",function(t,a){a=a?a:e.players[0].id,e.player=a,r()}),e.$on("changeDelivery",function(t,a){e.deliveryType=a,r()}),e.showAdvancedOptions=function(r,a){r.preventDefault(),t.set("showAdvancedOptions",a,!0),e.showAdvancedOptionsStatus=a},e.$watch("showAdvancedOptionsStatus",function(){a.clipboard.reposition()}),e.$watch("player",function(){var r=a.getObjectById(e.player,e.players);r&&(i(r),o(r),t.set("player",r))}),e.$watch("deliveryType",function(){t.set("deliveryType",a.getObjectById(e.deliveryType,e.deliveryTypes))}),e.$watch("embedType",function(){t.set("embedType",e.embedType)}),e.$watch("secureEmbed",function(){t.set("secureEmbed",e.secureEmbed)}),e.$watch("includeSeo",function(){t.set("includeSeo",e.includeSeo)}),e.$watch("embedCodePreview",function(){a.generateIframe(e.embedCodePreview)}),e.$watch("previewOnly",function(){e.closeButtonText=e.previewOnly?"Close":"Copy Embed & Close",r()}),e.$on("previewChanged",function(){if(!a.ignoreChangeEvents){var n=a.getPreviewUrl(t);e.embedCode=a.getEmbedCode(t),e.embedCodePreview=a.getEmbedCode(t,!0),e.previewOnly=t.get("previewOnly"),e.playerOnly=t.get("playerOnly"),e.liveBitrates=t.get("liveBitrates"),r(),a.hasIframe()||a.generateIframe(e.embedCodePreview),e.previewUrl="Updating...",e.shortLinkGenerated=!1,a.generateShortUrl(n,function(t){t||(t=n),e.shortLinkGenerated=!0,e.previewUrl=t,a.generateQrCode(t),r()})}})}]),0==kmc.vars.allowFrame&&top!=window&&(top.location=window.location),kmc.vars.debug=!1,kmc.vars.quickstart_guide="/content/docs/pdf/KMC_User_Manual.pdf",kmc.vars.help_url=kmc.vars.service_url+"/kmc5help.html",kmc.vars.port=window.location.port?":"+window.location.port:"",kmc.vars.base_host=window.location.hostname+kmc.vars.port,kmc.vars.base_url=window.location.protocol+"//"+kmc.vars.base_host,kmc.vars.api_host=kmc.vars.host,kmc.vars.api_url=window.location.protocol+"//"+kmc.vars.api_host,kmc.vars.min_kdp_version_for_playlist_api_v3="3.6.15",kmc.vars.min_html5_version_for_playlist_api_v3="1.7.1.3",kmc.log=function(){if(kmc.vars.debug&&"undefined"!=typeof console&&console.log)if(1==arguments.length)console.log(arguments[0]);else{var e=Array.prototype.slice.call(arguments);console.log(e[0],e.slice(1))}},kmc.functions={loadSwf:function(){var e=window.location.protocol+"//"+kmc.vars.cdn_host+"/flash/kmc/"+kmc.vars.kmc_version+"/kmc.swf",t={kmc_uiconf:kmc.vars.kmc_general_uiconf,permission_uiconf:kmc.vars.kmc_permissions_uiconf,host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,srvurl:"api_v3/index.php",protocol:window.location.protocol+"//",partnerid:kmc.vars.partner_id,subpid:kmc.vars.partner_id+"00",ks:kmc.vars.ks,entryId:"-1",kshowId:"-1",debugmode:"true",widget_id:"_"+kmc.vars.partner_id,urchinNumber:kmc.vars.google_analytics_account,firstLogin:kmc.vars.first_login,openPlayer:"kmc.preview_embed.doPreviewEmbed",openPlaylist:"kmc.preview_embed.doPreviewEmbed",openCw:"kmc.functions.openKcw",language:kmc.vars.language||""};kmc.vars.disable_analytics&&(t.disableAnalytics=!0);var r={allowNetworking:"all",allowScriptAccess:"always"};swfobject.embedSWF(e,"kcms","100%","100%","10.0.0",!1,t,r),$("#kcms").attr("style","")},checkForOngoingProcess:function(){var e;try{e=$("#kcms")[0].hasOngoingProcess()}catch(t){e=null}return null!==e?e:void 0},expired:function(){kmc.user.logout()},openKcw:function(e,t){e=e||"";var r="uploadWebCam"==t?kmc.vars.kcw_webcam_uiconf:kmc.vars.kcw_import_uiconf,a={host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,protocol:window.location.protocol.slice(0,-1),partnerid:kmc.vars.partner_id,subPartnerId:kmc.vars.partner_id+"00",sessionId:kmc.vars.ks,devFlag:"true",entryId:"-1",kshow_id:"-1",terms_of_use:kmc.vars.terms_of_use,close:"kmc.functions.onCloseKcw",quick_edit:0,kvar_conversionQuality:e},n={allowscriptaccess:"always",allownetworking:"all",bgcolor:"#DBE3E9",quality:"high",movie:kmc.vars.service_url+"/kcw/ui_conf_id/"+r};kmc.layout.modal.open({width:700,height:420,content:'
    '}),swfobject.embedSWF(n.movie,"kcw","680","400","9.0.0",!1,a,n)},onCloseKcw:function(){kmc.layout.modal.close(),$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})},openChangePwd:function(){kmc.user.changeSetting("password")},openChangeEmail:function(){kmc.user.changeSetting("email")},openChangeName:function(){kmc.user.changeSetting("name")},getAddPanelPosition:function(){var e=$("#add").parent();return e.position().left+e.width()-10},openClipApp:function(e,t){var r=kmc.vars.base_url+"/apps/clipapp/"+kmc.vars.clipapp.version;r+="/?kdpUiconf="+kmc.vars.clipapp.kdp+"&kclipUiconf="+kmc.vars.clipapp.kclip,r+="&partnerId="+kmc.vars.partner_id+"&host="+kmc.vars.host+"&mode="+t+"&config=kmc&entryId="+e;var a="trim"==t?"Trimming Tool":"Clipping Tool";kmc.layout.modal.open({width:950,height:616,title:a,content:'',className:"iframe",closeCallback:function(){$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})}})},flashVarsToUrl:function(e){var t="";for(var r in e){var a="object"==typeof e[r]?JSON.stringify(e[r]):e[r];t+="&flashvars["+encodeURIComponent(r)+"]="+encodeURIComponent(a)}return t},versionIsAtLeast:function(e,t){if(!t)return!1;for(var r=e.split("."),a=t.split("."),n=0;r.length>n;n++){if(parseInt(a[n])>parseInt(r[n]))return!0;if(parseInt(a[n]) *").each(function(){e+=$(this).width()});var t=function(){kmc.vars.close_menu=!0;var t={width:0,visibility:"visible",top:"6px",right:"6px"},r={width:e+"px","padding-top":"2px","padding-bottom":"2px"};$("#user_links").css(t),$("#user_links").animate(r,500)};$("#user").hover(t).click(t),$("#user_links").mouseover(function(){kmc.vars.close_menu=!1}),$("#user_links").mouseleave(function(){kmc.vars.close_menu=!0,setTimeout(kmc.utils.closeMenu,650)}),$("#closeMenu").click(function(){kmc.vars.close_menu=!0,kmc.utils.closeMenu()})},closeMenu:function(){kmc.vars.close_menu&&$("#user_links").animate({width:0},500,function(){$("#user_links").css({width:"auto",visibility:"hidden"})})},activateHeader:function(){$("#user_links a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id");switch(t){case"Quickstart Guide":return this.href=kmc.vars.quickstart_guide,!0;case"Logout":return kmc.user.logout(),!1;case"Support":return kmc.user.openSupport(this),!1;case"ChangePartner":return kmc.user.changePartner(),!1;default:return!1}})},resize:function(){var e=$.browser.ie?640:590,t=$(document).height(),r=$.browser.mozilla?37:74;t-=r,t=e>t?e:t,$("#flash_wrap").height(t+"px"),$("#server_wrap iframe").height(t+"px"),$("#server_wrap").css("margin-top","-"+(t+2)+"px")},isModuleLoaded:function(){($("#flash_wrap object").length||$("#flash_wrap embed").length)&&(kmc.utils.resize(),clearInterval(kmc.vars.isLoadedInterval),kmc.vars.isLoadedInterval=null)},debug:function(){try{console.info(" ks: ",kmc.vars.ks),console.info(" partner_id: ",kmc.vars.partner_id)}catch(e){}},maskHeader:function(e){e?$("#mask").hide():$("#mask").show()},createTabs:function(e){if($("#closeMenu").trigger("click"),e){for(var t,r=kmc.vars.service_url+"/index.php/kmc/kmc4",a=e.length,n="",i=0;a>i;i++)t="action"==e[i].type?'class="menu" ':"",n+='
  • '+e[i].display_name+"
  • ";$("#hTabs").html(n);var o=$("body").width()-($("#logo").width()+$("#hTabs").width()+100);$("#user").width()+20>o&&$("#user").width(o),$("#hTabs a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id"),r="A"==e.target.tagName?$(e.target).attr("rel"):$(e.target).parent().attr("rel"),a={moduleName:t,subtab:r};return $("#kcms")[0].gotoPage(a),!1})}else alert("Error geting tabs")},setTab:function(e,t){t&&$("#kmcHeader ul li a").removeClass("active"),$("a#"+e).addClass("active")},resetTab:function(e){$("a#"+e).removeClass("active")},hideFlash:function(e){var t=$("html").hasClass("lt-ie8");e?t?$("#flash_wrap").css("margin-right","3333px"):($("#flash_wrap").css("visibility","hidden"),$("#flash_wrap object").css("visibility","hidden")):t?$("#flash_wrap").css("margin-right","0"):($("#flash_wrap").css("visibility","visible"),$("#flash_wrap object").css("visibility","visible"))},showFlash:function(){$("#server_wrap").hide(),$("#server_frame").removeAttr("src"),kmc.layout.modal.isOpen()||$("#flash_wrap").css("visibility","visible"),$("#server_wrap").css("margin-top",0)},openIframe:function(e){$("#flash_wrap").css("visibility","hidden"),$("#server_frame").attr("src",e),$("#server_wrap").css("margin-top","-"+($("#flash_wrap").height()+2)+"px"),$("#server_wrap").show() +},openHelp:function(e){$("#kcms")[0].doHelp(e)},setClientIP:function(){kmc.vars.clientIP="",kmc.vars.akamaiEdgeServerIpURL&&$.ajax({url:window.location.protocol+"//"+kmc.vars.akamaiEdgeServerIpURL,crossDomain:!0,success:function(e){kmc.vars.clientIP=$(e).find("serverip").text()}})},getClientIP:function(){return kmc.vars.clientIP}},kmc.mediator={writeUrlHash:function(e,t){location.hash=e+"|"+t,document.title="KMC > "+e+(t&&""!==t?" > "+t+" |":"")},readUrlHash:function(){var e,t,r="dashboard",a="",n={};try{e=location.hash.split("#")[1].split("|")}catch(i){t=!0}if(!t&&""!==e[0]){if(r=e[0],a=e[1],e[2])for(var o=e[2].split("&"),s=0;o.length>s;s++){var l=o[s].split(":");n[l[0]]=l[1]}switch(r){case"content":switch(a){case"Moderate":a="moderation";break;case"Syndicate":a="syndication"}a=a.toLowerCase();break;case"appstudio":r="studio",a="playersList";break;case"Settings":switch(r="account",a){case"Account_Settings":a="overview";break;case"Integration Settings":a="integration";break;case"Access Control":a="accessControl";break;case"Transcoding Settings":a="transcoding";break;case"Account Upgrade":a="upgrade"}break;case"reports":r="analytics","Bandwidth Usage Reports"==a&&(a="usageTabTitle")}}return{moduleName:r,subtab:a,extra:n}}},kmc.preview_embed={doPreviewEmbed:function(e,t,r,a,n,i,o){var s={previewOnly:a};i&&(s.uiConfId=parseInt(i)),n?"multitab_playlist"==e?(s.playerOnly=!0,s.name=t):(s.playlistId=e,s.playlistName=t):(s.entryId=e,s.entryMeta={name:t,description:r},o&&(s.liveBitrates=o)),kmc.Preview.openPreviewEmbed(s,kmc.Preview.Service)},doFlavorPreview:function(e,t,r){var a=kmc.vars.default_kdp,n=kmc.Preview.getGenerator().getCode({protocol:location.protocol.substring(0,location.protocol.length-1),embedType:"legacy",entryId:e,uiConfId:parseInt(a.id),width:a.width,height:a.height,includeSeoMetadata:!1,includeHtml5Library:!1,flashVars:{ks:kmc.vars.ks,flavorId:r.asset_id}}),i='
    '+n+"
    "+"
    Entry Name:
     "+t+"
    "+"
    Entry Id:
     "+e+"
    "+"
    Flavor Name:
     "+r.flavor_name+"
    "+"
    Flavor Asset Id:
     "+r.asset_id+"
    "+"
    Bitrate:
     "+r.bitrate+"
    "+"
    Codec:
     "+r.codec+"
    "+"
    Dimensions:
     "+r.dimensions.width+" x "+r.dimensions.height+"
    "+"
    Format:
     "+r.format+"
    "+"
    Size (KB):
     "+r.sizeKB+"
    "+"
    Status:
     "+r.status+"
    "+"
    ";kmc.layout.modal.open({width:parseInt(a.width)+120,height:parseInt(a.height)+300,title:"Flavor Preview",content:'
    '+i+"
    "})},updateList:function(e){var t=e?"playlist":"player";$.ajax({url:kmc.vars.base_url+kmc.vars.getuiconfs_url,type:"POST",data:{type:t,partner_id:kmc.vars.partner_id,ks:kmc.vars.ks},dataType:"json",success:function(t){t&&t.length&&(e?kmc.vars.playlists_list=t:kmc.vars.players_list=t,kmc.Preview.Service.updatePlayers())}})}},kmc.client={makeRequest:function(e,t,r,a){var n=kmc.vars.api_url+"/api_v3/index.php?service="+e+"&action="+t,i={ks:kmc.vars.ks,format:9};$.extend(r,i);var o=function(e){var t=[],r=[],a=0;for(var n in e)r[a++]=n+"|"+e[n];r=r.sort();for(var i=0;r.length>i;i++){var o=r[i].split("|");t[o[0]]=o[1]}return t},s=function(e){e=o(e);var t="";for(var r in e){var a=e[r];t+=a+r}return md5(t)},l=s(r);n+="&kalsig="+l,$.ajax({type:"GET",url:n,dataType:"jsonp",data:r,cache:!1,success:a})},createShortURL:function(e,t){kmc.log("createShortURL");var r={"shortLink:objectType":"KalturaShortLink","shortLink:systemName":"KMC-PREVIEW","shortLink:fullUrl":e};kmc.client.makeRequest("shortlink_shortlink","add",r,function(e){var r=!1;t?(e.id&&(r=kmc.vars.service_url+"/tiny/"+e.id),t(r)):kmc.preview_embed.setShortURL(e.id)})}},kmc.layout={init:function(){$("#kmcHeader").bind("click",function(){$("#hTabs a").each(function(e,t){var r=$(t);return r.hasClass("menu")&&r.hasClass("active")?($("#kcms")[0].gotoPage({moduleName:r.attr("id"),subtab:r.attr("rel")}),void 0):!0})}),$("body").append('
    ')},overlay:{show:function(){$("#overlay").show()},hide:function(){$("#overlay").hide()}},modal:{el:"#modal",create:function(e){var t={el:kmc.layout.modal.el,title:"",content:"",help:"",width:680,height:"auto",className:""};$.extend(t,e);var r=$(t.el),a=r.find(".title h2"),n=r.find(".content");return t.className="modal "+t.className,r.css({width:t.width,height:t.height}).attr("class",t.className),t.title?a.text(t.title).attr("title",t.title).parent().show():(a.parent().hide(),n.addClass("flash_only")),r.find(".help").remove(),a.parent().append(t.help),n[0].innerHTML=t.content,r.find(".close").click(function(){kmc.layout.modal.close(t.el),$.isFunction(e.closeCallback)&&e.closeCallback()}),r},show:function(e,t){t=void 0===t?!0:t,e=e||kmc.layout.modal.el;var r=$(e);kmc.utils.hideFlash(!0),kmc.layout.overlay.show(),r.fadeIn(600),$.browser.msie||r.css("display","table"),t&&this.position(e)},open:function(e){this.create(e);var t=e.el||kmc.layout.modal.el;this.show(t)},position:function(e){e=e||kmc.layout.modal.el;var t=$(e),r=($(window).height()-t.height())/2,a=($(window).width()-t.width())/(2+$(window).scrollLeft());r=40>r?40:r,t.css({top:r+"px",left:a+"px"})},close:function(e){e=e||kmc.layout.modal.el,$(e).fadeOut(300,function(){$(e).find(".content").html(""),kmc.layout.overlay.hide(),kmc.utils.hideFlash()})},isOpen:function(e){return e=e||kmc.layout.modal.el,$(e).is(":visible")}}},kmc.user={openSupport:function(e){var t=e.href;kmc.utils.hideFlash(!0),kmc.layout.overlay.show();var r='';kmc.layout.modal.create({width:550,title:"Support Request",content:r}),$("#support").load(function(){kmc.layout.modal.show(),kmc.vars.support_frame_height||(kmc.vars.support_frame_height=$("#support")[0].contentWindow.document.body.scrollHeight),$("#support").height(kmc.vars.support_frame_height),kmc.layout.modal.position()})},logout:function(){var e=kmc.functions.checkForOngoingProcess();if(e)return alert(e),!1;var t=kmc.mediator.readUrlHash();$.ajax({url:kmc.vars.base_url+"/index.php/kmc/logout",type:"POST",data:{ks:kmc.vars.ks},dataType:"json",complete:function(){window.location=kmc.vars.logoutUrl?kmc.vars.logoutUrl:kmc.vars.service_url+"/index.php/kmc/kmc#"+t.moduleName+"|"+t.subtab}})},changeSetting:function(e){var t,r;switch(e){case"password":t="Change Password",r=180;break;case"email":t="Change Email Address",r=160;break;case"name":t="Edit Name",r=200}var a=kmc.vars.kmc_secured||"https:"==location.protocol?"https":"http",n=a+"://"+window.location.hostname,i=n+kmc.vars.port+"/index.php/kmc/updateLoginData/type/"+e;i=i+"?parent="+encodeURIComponent(document.location.href);var o='';kmc.layout.modal.open({width:370,title:t,content:o}),XD.receiveMessage(function(e){kmc.layout.modal.close(),"reload"==e.data&&($.browser.msie&&8>$.browser.version&&(window.location.hash="account|user"),window.location.reload())},n)},changePartner:function(){var e,t,r,a=0,n=kmc.vars.allowed_partners.length,i='
    Please choose partner:
    ';for(e=0;n>e;e++)a=kmc.vars.allowed_partners[e].id,kmc.vars.partner_id==a?(t=' checked="checked"',r=' style="font-weight: bold"'):(t="",r=""),i+="  "+kmc.vars.allowed_partners[e].name+"";return i+='
    ',kmc.layout.modal.open({width:300,title:"Change Account",content:i}),$("#do_change_partner").click(function(){var e=kmc.vars.base_url+"/index.php/kmc/extlogin",t=$("").attr({type:"hidden",name:"ks",value:kmc.vars.ks}),r=$("").attr({type:"hidden",name:"partner_id",value:$("input[name=pid]:radio:checked").val()}),a=$("").attr({action:e,method:"post",style:"display: none"}).append(t,r);$("body").append(a),a[0].submit()}),!1}},$(function(){kmc.layout.init(),kmc.utils.handleMenu(),kmc.functions.loadSwf(),$(window).wresize(kmc.utils.resize),kmc.vars.isLoadedInterval=setInterval(kmc.utils.isModuleLoaded,200),kmc.preview_embed.updateList(),kmc.preview_embed.updateList(!0),kmc.utils.setClientIP()}),$(window).resize(function(){kmc.layout.modal.isOpen()&&kmc.layout.modal.position()}),window.onbeforeunload=kmc.functions.checkForOngoingProcess,function(e){e.fn.wresize=function(t){function r(){if(e.browser.msie)if(wresize.fired){var t=parseInt(e.browser.version,10);if(wresize.fired=!1,7>t)return!1;if(7==t){var r=e(window).width();if(r!=wresize.width)return wresize.width=r,!1}}else wresize.fired=!0;return!0}function a(e){return r()?t.apply(this,[e]):void 0}return version="1.1",wresize={fired:!1,width:0},this.each(function(){this==window?e(this).resize(a):e(this).resize(t)}),this}}(jQuery);var XD=function(){var e,t,r,a=1,n=this;return{postMessage:function(e,t,r){t&&(r=r||parent,n.postMessage?r.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(r.location=t.replace(/#.*$/,"")+"#"+ +new Date+a++ +"&"+e))},receiveMessage:function(a,i){n.postMessage?(a&&(r=function(e){return"string"==typeof i&&e.origin!==i||"[object Function]"===Object.prototype.toString.call(i)&&i(e.origin)===!1?!1:(a(e),void 0)}),n.addEventListener?n[a?"addEventListener":"removeEventListener"]("message",r,!1):n[a?"attachEvent":"detachEvent"]("onmessage",r)):(e&&clearInterval(e),e=null,a&&(e=setInterval(function(){var e=document.location.hash,r=/^#?\d+&/;e!==t&&r.test(e)&&(t=e,a({data:e.replace(r,"")}))},100)))}}}(); \ No newline at end of file From dc2eb5e2413da1977644adcb0177ca50e80aeca7 Mon Sep 17 00:00:00 2001 From: ranyefet Date: Sun, 14 Jul 2013 16:49:48 +0300 Subject: [PATCH 006/132] moved kmc js files into directories --- alpha/web/lib/js/{kmc-full-6.0.0.js => kmc/6.0.0/kmc.js} | 0 alpha/web/lib/js/{kmc-full-6.0.0.min.js => kmc/6.0.0/kmc.min.js} | 0 alpha/web/lib/js/{kmc-full-6.0.1.js => kmc/6.0.1/kmc.js} | 0 alpha/web/lib/js/{kmc-full-6.0.1.min.js => kmc/6.0.1/kmc.min.js} | 0 alpha/web/lib/js/{kmc-full-6.0.2.js => kmc/6.0.2/kmc.js} | 0 alpha/web/lib/js/{kmc-full-6.0.2.min.js => kmc/6.0.2/kmc.min.js} | 0 alpha/web/lib/js/{kmc-full-6.0.3.js => kmc/6.0.3/kmc.js} | 0 alpha/web/lib/js/{kmc-full-6.0.3.min.js => kmc/6.0.3/kmc.min.js} | 0 alpha/web/lib/js/{kmc-full-6.0.4.js => kmc/6.0.4/kmc.js} | 0 alpha/web/lib/js/{kmc-full-6.0.4.min.js => kmc/6.0.4/kmc.min.js} | 0 alpha/web/lib/js/{kmc-full-6.0.5.js => kmc/6.0.5/kmc.js} | 0 alpha/web/lib/js/{kmc-full-6.0.5.min.js => kmc/6.0.5/kmc.min.js} | 0 alpha/web/lib/js/{kmc-full-6.0.6.js => kmc/6.0.6/kmc.js} | 0 alpha/web/lib/js/{kmc-full-6.0.6.min.js => kmc/6.0.6/kmc.min.js} | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename alpha/web/lib/js/{kmc-full-6.0.0.js => kmc/6.0.0/kmc.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.0.min.js => kmc/6.0.0/kmc.min.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.1.js => kmc/6.0.1/kmc.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.1.min.js => kmc/6.0.1/kmc.min.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.2.js => kmc/6.0.2/kmc.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.2.min.js => kmc/6.0.2/kmc.min.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.3.js => kmc/6.0.3/kmc.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.3.min.js => kmc/6.0.3/kmc.min.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.4.js => kmc/6.0.4/kmc.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.4.min.js => kmc/6.0.4/kmc.min.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.5.js => kmc/6.0.5/kmc.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.5.min.js => kmc/6.0.5/kmc.min.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.6.js => kmc/6.0.6/kmc.js} (100%) rename alpha/web/lib/js/{kmc-full-6.0.6.min.js => kmc/6.0.6/kmc.min.js} (100%) diff --git a/alpha/web/lib/js/kmc-full-6.0.0.js b/alpha/web/lib/js/kmc/6.0.0/kmc.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.0.js rename to alpha/web/lib/js/kmc/6.0.0/kmc.js diff --git a/alpha/web/lib/js/kmc-full-6.0.0.min.js b/alpha/web/lib/js/kmc/6.0.0/kmc.min.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.0.min.js rename to alpha/web/lib/js/kmc/6.0.0/kmc.min.js diff --git a/alpha/web/lib/js/kmc-full-6.0.1.js b/alpha/web/lib/js/kmc/6.0.1/kmc.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.1.js rename to alpha/web/lib/js/kmc/6.0.1/kmc.js diff --git a/alpha/web/lib/js/kmc-full-6.0.1.min.js b/alpha/web/lib/js/kmc/6.0.1/kmc.min.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.1.min.js rename to alpha/web/lib/js/kmc/6.0.1/kmc.min.js diff --git a/alpha/web/lib/js/kmc-full-6.0.2.js b/alpha/web/lib/js/kmc/6.0.2/kmc.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.2.js rename to alpha/web/lib/js/kmc/6.0.2/kmc.js diff --git a/alpha/web/lib/js/kmc-full-6.0.2.min.js b/alpha/web/lib/js/kmc/6.0.2/kmc.min.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.2.min.js rename to alpha/web/lib/js/kmc/6.0.2/kmc.min.js diff --git a/alpha/web/lib/js/kmc-full-6.0.3.js b/alpha/web/lib/js/kmc/6.0.3/kmc.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.3.js rename to alpha/web/lib/js/kmc/6.0.3/kmc.js diff --git a/alpha/web/lib/js/kmc-full-6.0.3.min.js b/alpha/web/lib/js/kmc/6.0.3/kmc.min.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.3.min.js rename to alpha/web/lib/js/kmc/6.0.3/kmc.min.js diff --git a/alpha/web/lib/js/kmc-full-6.0.4.js b/alpha/web/lib/js/kmc/6.0.4/kmc.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.4.js rename to alpha/web/lib/js/kmc/6.0.4/kmc.js diff --git a/alpha/web/lib/js/kmc-full-6.0.4.min.js b/alpha/web/lib/js/kmc/6.0.4/kmc.min.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.4.min.js rename to alpha/web/lib/js/kmc/6.0.4/kmc.min.js diff --git a/alpha/web/lib/js/kmc-full-6.0.5.js b/alpha/web/lib/js/kmc/6.0.5/kmc.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.5.js rename to alpha/web/lib/js/kmc/6.0.5/kmc.js diff --git a/alpha/web/lib/js/kmc-full-6.0.5.min.js b/alpha/web/lib/js/kmc/6.0.5/kmc.min.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.5.min.js rename to alpha/web/lib/js/kmc/6.0.5/kmc.min.js diff --git a/alpha/web/lib/js/kmc-full-6.0.6.js b/alpha/web/lib/js/kmc/6.0.6/kmc.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.6.js rename to alpha/web/lib/js/kmc/6.0.6/kmc.js diff --git a/alpha/web/lib/js/kmc-full-6.0.6.min.js b/alpha/web/lib/js/kmc/6.0.6/kmc.min.js similarity index 100% rename from alpha/web/lib/js/kmc-full-6.0.6.min.js rename to alpha/web/lib/js/kmc/6.0.6/kmc.min.js From 5a24e282763b2f021a7c2ed3ed2c0c2b517762ea Mon Sep 17 00:00:00 2001 From: hilak Date: Tue, 16 Jul 2013 13:29:05 +0300 Subject: [PATCH 007/132] test commit to branch --- api_v3/lib/types/entry/KalturaBaseEntry.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api_v3/lib/types/entry/KalturaBaseEntry.php b/api_v3/lib/types/entry/KalturaBaseEntry.php index fe753e1c7a0..603676500bc 100644 --- a/api_v3/lib/types/entry/KalturaBaseEntry.php +++ b/api_v3/lib/types/entry/KalturaBaseEntry.php @@ -5,6 +5,8 @@ */ class KalturaBaseEntry extends KalturaObject implements IFilterable { + //test commit to branch + /** * Auto generated 10 characters alphanumeric string * From 69138747da7bebc70e956bc8d6e3c0fbcb71ca42 Mon Sep 17 00:00:00 2001 From: sharonadar Date: Mon, 15 Jul 2013 19:51:02 +0300 Subject: [PATCH 008/132] Changed to move from using exec file, to use php code. --- infra/storage/kFile.class.php | 96 ++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 24 deletions(-) diff --git a/infra/storage/kFile.class.php b/infra/storage/kFile.class.php index 51aa9863808..b01b84ebf7a 100644 --- a/infra/storage/kFile.class.php +++ b/infra/storage/kFile.class.php @@ -338,30 +338,66 @@ public static function fullMkdir($path, $rights = 0755, $recursive = true) return self::fullMkfileDir(dirname($path), $rights, $recursive); } - private static function rename_wrap($src, $trg) - { - if(!file_exists($src)) - { - KalturaLog::err("Source file doesn't exist [$src]"); + /** + * copies src to destination. + * Doesn't support non-flat directories! + * One can't use rename because rename isn't supported between partitions. + */ + private static function copyRecursively($src, $dest, $deleteSrc = false) { + if (is_dir($src)) { + + // Generate target directory + if (file_exists ($dest)) { + if (! is_dir($dest)) { + KalturaLog::err("Can't override a file with a directory [$dest]"); + return false; + } + } else { + if (! mkdir($dest)) { + KalturaLog::err("Failed to create directory [$dest]"); + return false; + } + } + + // Copy files + $dir = dir($src); + while ( false !== $entry = $dir->read () ) { + if ($entry == '.' || $entry == '..') { + continue; + } + + $newSrc = $src . DIRECTORY_SEPARATOR . $entry; + if(is_dir($newSrc)) { + KalturaLog::err("Copying of non-flat directroeis is illegal"); + return false; + } + + $res = self::copySingleFile ($newSrc, $dest . DIRECTORY_SEPARATOR . $entry , $deleteSrc); + if (! $res) + return false; + } + + // Delete source + if ($deleteSrc && (! rmdir($src))) { + KalturaLog::err("Failed to delete source directory : [$src]"); + return false; + } + } else { + self::copySingleFile($src, $dest, $deleteSrc); + } + return true; + } + + private static function copySingleFile($src, $dest, $deleteSrc) { + if (!copy($src,$dest)) { + KalturaLog::err("Failed to copy file : [$src]"); return false; } - - if(strpos($trg,'\"') !== false) - { - KalturaLog::err("Illegal destination file [$trg]"); + if ($deleteSrc && (!unlink($src))) { + KalturaLog::err("Failed to delete source file : [$src]"); return false; } - - if(rename($src, $trg)) - return true; - - $out_arr = array(); - $rv = 0; - - // We use this case for folders - exec("mv \"$src\" \"$trg\"", $out_arr, $rv); - - return ($rv==0); + return true; } public static function moveFile($from, $to, $override_if_exists = false, $copy = false) @@ -369,6 +405,20 @@ public static function moveFile($from, $to, $override_if_exists = false, $copy = $from = str_replace("\\", "/", $from); $to = str_replace("\\", "/", $to); + // Validation + if(!file_exists($from)) + { + KalturaLog::err("Source doesn't exist [$from]"); + return false; + } + + if(strpos($to,'\"') !== false) + { + KalturaLog::err("Illegal destination file [$to]"); + return false; + } + + // Preperation if($override_if_exists && is_file($to)) { self::deleteFile($to); @@ -379,10 +429,8 @@ public static function moveFile($from, $to, $override_if_exists = false, $copy = self::fullMkdir($to); } - if($copy) - return copy($from, $to); - else - return self::rename_wrap($from, $to); + // Copy + return self::copyRecursively($from,$to, !$copy); } public static function linkFile($from, $to, $overrideIfExists = false, $copyIfLinkFailed = true) From 13ce17e4297133bce464b0f8373821a954ffb47e Mon Sep 17 00:00:00 2001 From: hilak Date: Tue, 16 Jul 2013 15:37:01 +0300 Subject: [PATCH 009/132] change storage_profile tinyint parameters to integers --- alpha/config/schema.xml | 10 +++++----- alpha/data/sql/schema.sql | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/alpha/config/schema.xml b/alpha/config/schema.xml index 7d4f1480722..f41f83c9c95 100644 --- a/alpha/config/schema.xml +++ b/alpha/config/schema.xml @@ -1505,7 +1505,7 @@ - +
    @@ -1635,13 +1635,13 @@ - - + + - + @@ -1653,7 +1653,7 @@ - +
    diff --git a/alpha/data/sql/schema.sql b/alpha/data/sql/schema.sql index e8ea8834d8e..b7c7842d25b 100644 --- a/alpha/data/sql/schema.sql +++ b/alpha/data/sql/schema.sql @@ -1837,13 +1837,13 @@ CREATE TABLE `storage_profile` `name` VARCHAR(31), `system_name` VARCHAR(128), `desciption` VARCHAR(127), - `status` TINYINT, - `protocol` TINYINT, + `status` INTEGER, + `protocol` INTEGER, `storage_url` VARCHAR(127), `storage_base_dir` VARCHAR(127), `storage_username` VARCHAR(31), `storage_password` VARCHAR(31), - `storage_ftp_passive_mode` TINYINT, + `storage_ftp_passive_mode` INTEGER, `delivery_http_base_url` VARCHAR(127), `delivery_rmp_base_url` VARCHAR(127), `delivery_iis_base_url` VARCHAR(127), @@ -1855,7 +1855,7 @@ CREATE TABLE `storage_profile` `path_manager_class` VARCHAR(127), `url_manager_class` VARCHAR(127), `delivery_priority` INTEGER, - `delivery_status` TINYINT, + `delivery_status` INTEGER, PRIMARY KEY (`id`) )Type=InnoDB; From 7063344c0c7b163246174395eb0d0dcb5f3d5cc5 Mon Sep 17 00:00:00 2001 From: sharonadar Date: Tue, 16 Jul 2013 16:15:39 +0300 Subject: [PATCH 010/132] revert the FETCH_ASSOC change --- plugins/sphinx_search/lib/SphinxCriteria.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/plugins/sphinx_search/lib/SphinxCriteria.php b/plugins/sphinx_search/lib/SphinxCriteria.php index ae1689f3176..b3b8acf5670 100644 --- a/plugins/sphinx_search/lib/SphinxCriteria.php +++ b/plugins/sphinx_search/lib/SphinxCriteria.php @@ -204,11 +204,7 @@ protected function executeSphinx($index, $wheres, $orderBy, $limit, $maxMatches, } //debug query - $rows = $pdo->queryAndFetchAll($sql, PDO::FETCH_ASSOC); - $ids = false; - if(is_array($rows)) - $ids = array_map(array($this, "fetchIds"), $rows); - + $ids = $pdo->queryAndFetchAll($sql, PDO::FETCH_COLUMN, 0); if($ids === false) { list($sqlState, $errCode, $errDescription) = $pdo->errorInfo(); @@ -263,11 +259,6 @@ protected function executeSphinx($index, $wheres, $orderBy, $limit, $maxMatches, } } - protected function fetchIds($row) { - $idField = $this->selectColumn ? $this->selectColumn: $this->getSphinxIdField(); - return $row[$idField]; - } - /** * This function is responsible to sort the fields by their priority. * Fields that cut more results, should be first so the query will be faster. From b20c6b92d601cd65ee1819ef0a28221d14f0e4cf Mon Sep 17 00:00:00 2001 From: rotema Date: Tue, 16 Jul 2013 16:29:25 +0300 Subject: [PATCH 011/132] checked featureStatus is not null as well --- alpha/lib/model/Partner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alpha/lib/model/Partner.php b/alpha/lib/model/Partner.php index d4fdd19a683..aee63090798 100644 --- a/alpha/lib/model/Partner.php +++ b/alpha/lib/model/Partner.php @@ -455,7 +455,7 @@ public function setEnforceHttpsApi( $v ) { return $this->putInCustomData( "enfo public function getFeaturesStatus() { $featuresStatus = $this->getFromCustomData(null, "featuresStatus"); - if (!is_array($featuresStatus)){ + if (!is_null($featuresStatus) && (!is_array($featuresStatus))){ $featuresStatus = unserialize($featuresStatus); } return $featuresStatus; From cecc385e46daf8298eeee005930748f65f17f960 Mon Sep 17 00:00:00 2001 From: yossipapi Date: Tue, 16 Jul 2013 17:26:31 +0300 Subject: [PATCH 012/132] SUP 412 added missing part of the code fix --- api_v3/services/LiveStreamService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_v3/services/LiveStreamService.php b/api_v3/services/LiveStreamService.php index 3358f8ba064..eba662a7075 100644 --- a/api_v3/services/LiveStreamService.php +++ b/api_v3/services/LiveStreamService.php @@ -293,7 +293,7 @@ private function urlExists ($url, $contentTypeToReturn) curl_close($ch); if($data && $httpcode>=200 && $httpcode<300) { - return $contentType == $contentTypeToReturn ? $data : true; + return in_array($contentType, $contentTypeToReturn) ? $data : true; } else return false; From 292d57f31898e68d5bde0b04e5325c8ce6b9b6c5 Mon Sep 17 00:00:00 2001 From: hilak Date: Tue, 16 Jul 2013 18:45:10 +0300 Subject: [PATCH 013/132] changed function signature --- .../batch/Distribute/KAsyncDistributeCloser.class.php | 2 +- .../batch/Distribute/KAsyncDistributeDelete.class.php | 2 +- .../batch/Distribute/KAsyncDistributeDeleteCloser.class.php | 2 +- .../batch/Distribute/KAsyncDistributeDisable.class.php | 2 +- .../batch/Distribute/KAsyncDistributeDisableCloser.class.php | 2 +- .../batch/Distribute/KAsyncDistributeEnable.class.php | 2 +- .../batch/Distribute/KAsyncDistributeEnableCloser.class.php | 2 +- .../batch/Distribute/KAsyncDistributeFetchReport.class.php | 2 +- .../Distribute/KAsyncDistributeFetchReportCloser.class.php | 2 +- .../batch/Distribute/KAsyncDistributeSubmit.class.php | 2 +- .../batch/Distribute/KAsyncDistributeSubmitCloser.class.php | 2 +- .../batch/Distribute/KAsyncDistributeUpdate.class.php | 2 +- .../batch/Distribute/KAsyncDistributeUpdateCloser.class.php | 2 +- .../batch/Distribute/KAsyncSynchronizeDistribution.class.php | 4 ++-- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeCloser.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeCloser.class.php index 1bf637d412f..72584c4786a 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeCloser.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeCloser.class.php @@ -34,7 +34,7 @@ abstract protected function execute(KalturaDistributionJobData $data); protected function distribute(KalturaBatchJob $job, KalturaDistributionJobData $data) { - if(($job->queueTime + $this->taskConfig->params->maxTimeBeforeFail) < time()) + if(($job->queueTime + self::$taskConfig->params->maxTimeBeforeFail) < time()) return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::CLOSER_TIMEOUT, 'Timed out', KalturaBatchJobStatus::FAILED); try diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeDelete.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeDelete.class.php index 617e06e0863..139affbd131 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeDelete.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeDelete.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineDelete', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineDelete', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeDeleteCloser.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeDeleteCloser.class.php index 808cf5ea235..ea13e6c476a 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeDeleteCloser.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeDeleteCloser.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineCloseDelete', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineCloseDelete', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeDisable.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeDisable.class.php index 77680b4effd..d61a083aa8f 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeDisable.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeDisable.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineDisable', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineDisable', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeDisableCloser.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeDisableCloser.class.php index 464f59d1719..993323a2021 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeDisableCloser.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeDisableCloser.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineCloseUpdate', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineCloseUpdate', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeEnable.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeEnable.class.php index 4f0fbd19635..c34a7f80d95 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeEnable.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeEnable.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineEnable', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineEnable', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeEnableCloser.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeEnableCloser.class.php index 3e4bd9ff920..d703596e4f1 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeEnableCloser.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeEnableCloser.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineCloseUpdate', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineCloseUpdate', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeFetchReport.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeFetchReport.class.php index 91b41bbd0f7..67cdde88f5d 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeFetchReport.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeFetchReport.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineFetchReport', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineFetchReport', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeFetchReportCloser.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeFetchReportCloser.class.php index dbb6b06c89b..df150cbeebb 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeFetchReportCloser.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeFetchReportCloser.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineCloseReport', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineCloseReport', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeSubmit.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeSubmit.class.php index 0fd67de1ef0..579ad43ec4c 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeSubmit.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeSubmit.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineSubmit', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineSubmit', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeSubmitCloser.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeSubmitCloser.class.php index 5501e7bef39..ac1feadcd44 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeSubmitCloser.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeSubmitCloser.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineCloseSubmit', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineCloseSubmit', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeUpdate.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeUpdate.class.php index f022489ad16..f5522a636ae 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeUpdate.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeUpdate.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineUpdate', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineUpdate', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncDistributeUpdateCloser.class.php b/plugins/content_distribution/batch/Distribute/KAsyncDistributeUpdateCloser.class.php index 3696fd10c00..68dadf35303 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncDistributeUpdateCloser.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncDistributeUpdateCloser.class.php @@ -28,7 +28,7 @@ public function getJobType() */ protected function getDistributionEngine($providerType, KalturaDistributionJobData $data) { - return DistributionEngine::getEngine('IDistributionEngineCloseUpdate', $providerType, $this->getClient(), $this->taskConfig, $data); + return DistributionEngine::getEngine('IDistributionEngineCloseUpdate', $providerType, $data); } /* (non-PHPdoc) diff --git a/plugins/content_distribution/batch/Distribute/KAsyncSynchronizeDistribution.class.php b/plugins/content_distribution/batch/Distribute/KAsyncSynchronizeDistribution.class.php index acfecb9838a..32629e5953b 100644 --- a/plugins/content_distribution/batch/Distribute/KAsyncSynchronizeDistribution.class.php +++ b/plugins/content_distribution/batch/Distribute/KAsyncSynchronizeDistribution.class.php @@ -31,7 +31,7 @@ public function run($jobs = null) { KalturaLog::info("Synchronize distribution batch is running"); - $this->kClient->contentDistributionBatch->updateSunStatus(); - $this->kClient->contentDistributionBatch->createRequiredJobs(); + self::$kClient->contentDistributionBatch->updateSunStatus(); + self::$kClient->contentDistributionBatch->createRequiredJobs(); } } From 2b040a8e077ff41cbb6d73baa340975912456ce2 Mon Sep 17 00:00:00 2001 From: hilak Date: Tue, 16 Jul 2013 20:07:38 +0300 Subject: [PATCH 014/132] merge sql scripts for storage_profile and tag tables --- .../updates/sql/2013_06_24_tag_add_updated_at_column.sql | 3 +++ .../2013_07_08_alter_storage_profile_tinyint_columns.sql | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 deployment/updates/sql/2013_06_24_tag_add_updated_at_column.sql create mode 100644 deployment/updates/sql/2013_07_08_alter_storage_profile_tinyint_columns.sql diff --git a/deployment/updates/sql/2013_06_24_tag_add_updated_at_column.sql b/deployment/updates/sql/2013_06_24_tag_add_updated_at_column.sql new file mode 100644 index 00000000000..7846320f255 --- /dev/null +++ b/deployment/updates/sql/2013_06_24_tag_add_updated_at_column.sql @@ -0,0 +1,3 @@ +ALTER TABLE `tag` +ADD `updated_at` DATETIME +AFTER `created_at`; diff --git a/deployment/updates/sql/2013_07_08_alter_storage_profile_tinyint_columns.sql b/deployment/updates/sql/2013_07_08_alter_storage_profile_tinyint_columns.sql new file mode 100644 index 00000000000..46fd1585f41 --- /dev/null +++ b/deployment/updates/sql/2013_07_08_alter_storage_profile_tinyint_columns.sql @@ -0,0 +1,6 @@ +ALTER TABLE storage_profile + MODIFY `status` INTEGER, + MODIFY `protocol` INTEGER, + MODIFY `storage_ftp_passive_mode` INTEGER, + MODIFY `delivery_status` INTEGER; + \ No newline at end of file From 3d3019d569a0fc9172ccde038f339beaf61ac54b Mon Sep 17 00:00:00 2001 From: hilak Date: Tue, 16 Jul 2013 20:07:58 +0300 Subject: [PATCH 015/132] merge sql scripts for storage_profile and tag tables --- .../batches/Storage/Engine/KExportEngine.php | 56 +++++++++ .../Engine/KFileTransferExportEngine.php | 115 ++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 batch/batches/Storage/Engine/KExportEngine.php create mode 100644 batch/batches/Storage/Engine/KFileTransferExportEngine.php diff --git a/batch/batches/Storage/Engine/KExportEngine.php b/batch/batches/Storage/Engine/KExportEngine.php new file mode 100644 index 00000000000..adebb28cb69 --- /dev/null +++ b/batch/batches/Storage/Engine/KExportEngine.php @@ -0,0 +1,56 @@ +data = $data; + } + + /** + * @return bool + */ + abstract function export (); + + + /** + * @return bool + */ + abstract function verifyExportedResource (); + + /** + * @return bool + */ + abstract function delete(); + + /** + * @param int $protocol + * @param KalturaStorageExportJobData $data + * @return KExportEngine + */ + public static function getInstance ($protocol, $partnerId, KalturaStorageExportJobData $data) + { + switch ($protocol) + { + case KalturaStorageProfileProtocol::FTP: + case KalturaStorageProfileProtocol::KALTURA_DC: + case KalturaStorageProfileProtocol::S3: + case KalturaStorageProfileProtocol::SCP: + case KalturaStorageProfileProtocol::SFTP: + return new KFileTransferExportEngine($data, $protocol); + default: + return KalturaPluginManager::loadObject('KExportEngine', $protocol, array($partnerId, $data)); + } + } +} \ No newline at end of file diff --git a/batch/batches/Storage/Engine/KFileTransferExportEngine.php b/batch/batches/Storage/Engine/KFileTransferExportEngine.php new file mode 100644 index 00000000000..1c119f29acb --- /dev/null +++ b/batch/batches/Storage/Engine/KFileTransferExportEngine.php @@ -0,0 +1,115 @@ +protocol = $jobSubType; + $this->srcFile = str_replace('//', '/', trim($this->data->srcFileSyncLocalPath)); + + if(!KBatchBase::pollingFileExists($this->srcFile)) + throw new kTemporaryException("Source file {$this->srcFile} does not exist"); + + $this->destFile = str_replace('//', '/', trim($this->data->destFileSyncStoredPath)); + } + + /* (non-PHPdoc) + * @see KExportEngine::export() + */ + function export() { + + KalturaLog::debug("starting export process"); + $engineOptions = isset(KBatchBase::$taskConfig->engineOptions) ? KBatchBase::$taskConfig->engineOptions->toArray() : array(); + $engineOptions['passiveMode'] = $this->data->ftpPassiveMode; + if($this->data instanceof KalturaAmazonS3StorageExportJobData) + $engineOptions['filesAcl'] = $this->data->filesPermissionInS3; + + $engine = kFileTransferMgr::getInstance($this->protocol, $engineOptions); + + try{ + $engine->login($this->data->serverUrl, $this->data->serverUsername, $this->data->serverPassword); + } + catch(Exception $e) + { + throw new kTemporaryException($e->getMessage()); + } + + try{ + if (is_file($this->srcFile)){ + $engine->putFile($this->destFile, $this->srcFile, $this->data->force); + } + else if (is_dir($this->srcFile)){ + $filesPaths = kFile::dirList($this->srcFile); + $destDir = $this->destFile; + foreach ($filesPaths as $filePath){ + $destFile = $destDir.DIRECTORY_SEPARATOR.basename($filePath); + $engine->putFile($this->destFile, $filePath, $this->data->force); + } + } + } + + catch(kFileTransferMgrException $e){ + if($e->getCode() == kFileTransferMgrException::remoteFileExists) + throw new kApplicativeException(KalturaBatchJobAppErrors::FILE_ALREADY_EXISTS, $e->getMessage()); + + throw new Exception($e->getMessage(), $e->getCode()); + } + catch(Exception $e) + { + throw new Exception($e->getMessage(), $e->getCode()); + } + + if(KBatchBase::$taskConfig->params->chmod) + { + try{ + $engine->chmod($destFile, KBatchBase::$taskConfig->params->chmod); + } + catch(Exception $e){} + } + + return true; + } + + /* (non-PHPdoc) + * @see KExportEngine::verifyExportedResource() + */ + function verifyExportedResource() { + // TODO Auto-generated method stub + + } + + /* (non-PHPdoc) + * @see KExportEngine::delete() + */ + function delete() + { + $srcFile = str_replace('//', '/', trim($this->data->srcFileSyncLocalPath)); + $destFile = str_replace('//', '/', trim($this->data->destFileSyncStoredPath)); + + + $engineOptions = isset(KBatchBase::$taskConfig->engineOptions) ? KBatchBase::$taskConfig->engineOptions->toArray() : array(); + $engineOptions['passiveMode'] = $this->data->ftpPassiveMode; + $engine = kFileTransferMgr::getInstance($this->protocol, $engineOptions); + + try{ + $engine->login($this->data->serverUrl, $this->data->serverUsername, $this->data->serverPassword); + $engine->delFile($destFile); + } + catch(kFileTransferMgrException $ke) + { + throw new kApplicativeException($ke->getCode(), $ke->getMessage()); + } + + return true; + } +} \ No newline at end of file From 4deed854f1cacd6e0d07661c596c38c61bf76238 Mon Sep 17 00:00:00 2001 From: hilak Date: Wed, 17 Jul 2013 11:05:31 +0300 Subject: [PATCH 016/132] revert commit comment --- api_v3/lib/types/entry/KalturaBaseEntry.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/api_v3/lib/types/entry/KalturaBaseEntry.php b/api_v3/lib/types/entry/KalturaBaseEntry.php index 603676500bc..fe753e1c7a0 100644 --- a/api_v3/lib/types/entry/KalturaBaseEntry.php +++ b/api_v3/lib/types/entry/KalturaBaseEntry.php @@ -5,8 +5,6 @@ */ class KalturaBaseEntry extends KalturaObject implements IFilterable { - //test commit to branch - /** * Auto generated 10 characters alphanumeric string * From 500613e28344c1808985ad0fce3fddc595e4c215 Mon Sep 17 00:00:00 2001 From: hilak Date: Wed, 17 Jul 2013 11:09:25 +0300 Subject: [PATCH 017/132] remove referencews to taskConfig --- batch/batches/Provision/Engines/KProvisionEngine.php | 4 ++-- batch/batches/Provision/Engines/KProvisionEngineAkamai.php | 2 +- .../Provision/Engines/KProvisionEngineUniversalAkamai.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/batch/batches/Provision/Engines/KProvisionEngine.php b/batch/batches/Provision/Engines/KProvisionEngine.php index fb6f5417e1a..6ab23e0dfa1 100644 --- a/batch/batches/Provision/Engines/KProvisionEngine.php +++ b/batch/batches/Provision/Engines/KProvisionEngine.php @@ -23,10 +23,10 @@ public static function getInstance ( $provider , KalturaProvisionJobData $data = switch ($provider ) { case KalturaSourceType::AKAMAI_LIVE: - $engine = new KProvisionEngineAkamai( $taskConfig , $data); + $engine = new KProvisionEngineAkamai($data); break; case KalturaSourceType::AKAMAI_UNIVERSAL_LIVE: - $engine = new KProvisionEngineUniversalAkamai($taskConfig, $data); + $engine = new KProvisionEngineUniversalAkamai($data); break; default: $engine = KalturaPluginManager::loadObject('KProvisionEngine', $provider); diff --git a/batch/batches/Provision/Engines/KProvisionEngineAkamai.php b/batch/batches/Provision/Engines/KProvisionEngineAkamai.php index 133538a0f70..fd03ecbca7b 100644 --- a/batch/batches/Provision/Engines/KProvisionEngineAkamai.php +++ b/batch/batches/Provision/Engines/KProvisionEngineAkamai.php @@ -25,7 +25,7 @@ public function getName() */ protected function __construct(KalturaProvisionJobData $data = null) { - parent::__construct($taskConfig); + parent::__construct(); $username = null; $password = null; diff --git a/batch/batches/Provision/Engines/KProvisionEngineUniversalAkamai.php b/batch/batches/Provision/Engines/KProvisionEngineUniversalAkamai.php index d90a21b9a3f..6f24ef02980 100644 --- a/batch/batches/Provision/Engines/KProvisionEngineUniversalAkamai.php +++ b/batch/batches/Provision/Engines/KProvisionEngineUniversalAkamai.php @@ -30,7 +30,7 @@ protected function __construct(KalturaAkamaiUniversalProvisionJobData $data) return new KProvisionEngineResult(KalturaBatchJobStatus::FAILED, "Error: akamaiRestApiBaseServiceUrl is missing from worker configuration. Cannot provision stream"); self::$baseServiceUrl = KBatchBase::$taskConfig->params->restapi->akamaiRestApiBaseServiceUrl; - parent::__construct(KBatchBase::$taskConfig); + parent::__construct(); $username = null; $password = null; From 830e189ac063b29c8c3003234d5e8e8dbbec9dab Mon Sep 17 00:00:00 2001 From: hilak Date: Wed, 17 Jul 2013 11:42:25 +0300 Subject: [PATCH 018/132] remove constants and add implementation of IKalturaDynamicEnum --- .../storageProfile/KalturaStorageProfileProtocol.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/api_v3/lib/types/storageProfile/KalturaStorageProfileProtocol.php b/api_v3/lib/types/storageProfile/KalturaStorageProfileProtocol.php index 722d5b8612f..2fcb8e114d4 100644 --- a/api_v3/lib/types/storageProfile/KalturaStorageProfileProtocol.php +++ b/api_v3/lib/types/storageProfile/KalturaStorageProfileProtocol.php @@ -5,9 +5,8 @@ */ class KalturaStorageProfileProtocol extends KalturaDynamicEnum implements StorageProfileProtocol { - const KALTURA_DC = 0; - const FTP = 1; - const SCP = 2; - const SFTP = 3; - const S3 = 6; + public static function getEnumClass() + { + return 'StorageProfileProtocol'; + } } From ee39c4a0365068fcb9f9f83da692eef38efec1ed Mon Sep 17 00:00:00 2001 From: sharonadar Date: Wed, 17 Jul 2013 12:06:26 +0300 Subject: [PATCH 019/132] Removing support in dc:external_url and replacing it with dc:url --- alpha/apps/kaltura/lib/requestUtils.class.php | 24 ------------------- .../lib/storage/kDataCenterMgr.class.php | 15 +++++++----- .../extwidget/actions/rawAction.class.php | 10 ++------ .../actions/serveFlavorAction.class.php | 3 --- configurations/dc_config.template.ini | 1 - 5 files changed, 11 insertions(+), 42 deletions(-) diff --git a/alpha/apps/kaltura/lib/requestUtils.class.php b/alpha/apps/kaltura/lib/requestUtils.class.php index ae276f70c17..1bcc7097048 100755 --- a/alpha/apps/kaltura/lib/requestUtils.class.php +++ b/alpha/apps/kaltura/lib/requestUtils.class.php @@ -280,28 +280,4 @@ public static function matchIpCountry ( $ip_country_list_str , &$current_country return ( in_array ( $current_country , $ip_country_list ) ); } - // - // allow access only via cdn or via proxy from secondary datacenter - // - public static function enforceCdnDelivery($partnerId) - { - $host = requestUtils::getHost(); - $cdnHost = myPartnerUtils::getCdnHost($partnerId); - - $dc = kDataCenterMgr::getCurrentDc(); - $external_url = $dc["external_url"]; - - // allow access only via cdn or via proxy from secondary datacenter - if ($host != $cdnHost && $host != $external_url) - { - $uri = $_SERVER["REQUEST_URI"]; - if (strpos($uri, "/forceproxy/true") === false) - $uri .= "/forceproxy/true/"; - - header('Location:'.$cdnHost.$uri); - header("X-Kaltura:enforce-cdn"); - - die; - } - } } diff --git a/alpha/apps/kaltura/lib/storage/kDataCenterMgr.class.php b/alpha/apps/kaltura/lib/storage/kDataCenterMgr.class.php index 58401a1bef8..f29b17ace87 100644 --- a/alpha/apps/kaltura/lib/storage/kDataCenterMgr.class.php +++ b/alpha/apps/kaltura/lib/storage/kDataCenterMgr.class.php @@ -102,22 +102,25 @@ public static function getRemoteDcExternalUrl ( FileSync $file_sync ) KalturaLog::log("File Sync [{$file_sync->getId()}]"); $dc_id = $file_sync->getDc(); $dc = self::getDcById ( $dc_id ); - $external_url = $dc["external_url"]; - return $external_url; + $url = $dc["url"]; + return $url; } public static function getRemoteDcExternalUrlByDcId ( $dc_id ) { KalturaLog::log("DC id [{$dc_id}]"); $dc = self::getDcById ( $dc_id ); - $external_url = $dc["external_url"]; - return $external_url; + $url = $dc["url"]; + return $url; } public static function getRedirectExternalUrl ( FileSync $file_sync , $additional_url = null ) { - $remote_external_url = self::getRemoteDcExternalUrl ( $file_sync ); - $remote_url = $remote_external_url . $_SERVER['REQUEST_URI']; + $remote_url = self::getRemoteDcExternalUrl ( $file_sync ); + $remote_url = $remote_url . $_SERVER['REQUEST_URI']; + $remote_url = preg_replace('/^https?:\/\//', '', $remote_url); + $remote_url = infraRequestUtils::getProtocol() . '://' . $remote_url; + KalturaLog::log ("URL to redirect to [$remote_url]" ); return $remote_url; diff --git a/alpha/apps/kaltura/modules/extwidget/actions/rawAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/rawAction.class.php index 6b4ec7d04ac..60f65788e0f 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/rawAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/rawAction.class.php @@ -67,13 +67,6 @@ public function execute() $securyEntryHelper = new KSecureEntryHelper($entry, $ks, $referrer, accessControlContextType::DOWNLOAD); $securyEntryHelper->validateForDownload(); -// Rmoved by Tan-Tan - asked by Eran -// // allow access only via cdn unless these are documents (due to the current implementation of convert ppt2swf) -// if ($entry->getType() != entryType::DOCUMENT && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_IMAGE) -// { -// requestUtils::enforceCdnDelivery($entry->getPartnerId()); -// } - // relocate = did we use the redirect and added the extension to the name $relocate = $this->getRequestParameter ( "relocate" ); @@ -182,7 +175,8 @@ public function execute() else { $path = kDataCenterMgr::getRedirectExternalUrl($fileSync); - KalturaLog::info("Redirecting to [$path]"); + header("Location: $path"); + KExternalErrors::dieGracefully(); } if (!$path) { diff --git a/alpha/apps/kaltura/modules/extwidget/actions/serveFlavorAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/serveFlavorAction.class.php index 5107cd951f7..75e2b4af88b 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/serveFlavorAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/serveFlavorAction.class.php @@ -45,9 +45,6 @@ public function execute() myPartnerUtils::blockInactivePartner($flavorAsset->getPartnerId()); myPartnerUtils::enforceDelivery($flavorAsset->getPartnerId()); - //disabled enforce cdn because of rtmp delivery - //requestUtils::enforceCdnDelivery($flavorAsset->getPartnerId()); - $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (!kFileSyncUtils::file_exists($syncKey, false)) { diff --git a/configurations/dc_config.template.ini b/configurations/dc_config.template.ini index 41b99b1e4d2..3ebefc4cd55 100644 --- a/configurations/dc_config.template.ini +++ b/configurations/dc_config.template.ini @@ -10,7 +10,6 @@ current = 0 0.id = 0 0.name = DC_0 0.url = @SERVICE_URL@ -0.external_url = @SERVICE_URL@ 0.secret = @DC0_SECRET@ 0.root = @WEB_DIR@/ From 8de076613cf5aeeac54e91efe9e9b7cde47954b0 Mon Sep 17 00:00:00 2001 From: ranyefet Date: Wed, 17 Jul 2013 12:34:38 +0300 Subject: [PATCH 020/132] Moved preview page from kmc to extwidget --- .../modules/{kmc => extwidget}/actions/previewAction.class.php | 2 +- .../modules/{kmc => extwidget}/templates/previewSuccess.php | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename alpha/apps/kaltura/modules/{kmc => extwidget}/actions/previewAction.class.php (99%) rename alpha/apps/kaltura/modules/{kmc => extwidget}/templates/previewSuccess.php (100%) diff --git a/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/previewAction.class.php similarity index 99% rename from alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php rename to alpha/apps/kaltura/modules/extwidget/actions/previewAction.class.php index 785118735c3..133e6f190cc 100644 --- a/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/previewAction.class.php @@ -1,7 +1,7 @@ Date: Wed, 17 Jul 2013 12:40:50 +0300 Subject: [PATCH 021/132] Updated preview to use extwidget instead of kmc --- alpha/web/lib/js/kmc/6.0.7/kmc.js | 4 ++-- alpha/web/lib/js/kmc/6.0.7/kmc.min.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/alpha/web/lib/js/kmc/6.0.7/kmc.js b/alpha/web/lib/js/kmc/6.0.7/kmc.js index 47d49699a2a..9eee74124c4 100644 --- a/alpha/web/lib/js/kmc/6.0.7/kmc.js +++ b/alpha/web/lib/js/kmc/6.0.7/kmc.js @@ -1,4 +1,4 @@ -/*! KMC - v6.0.7 - 2013-07-14 +/*! KMC - v6.0.7 - 2013-07-17 * https://github.com/kaltura/KMC_V2 * Copyright (c) 2013 Ran Yefet; Licensed GNU */ /*! Kaltura Embed Code Generator - v1.0.6 - 2013-02-28 @@ -2909,7 +2909,7 @@ if ( window.XDomainRequest ) { } var protocol = this.getEmbedProtocol(previewService, framed); - var url = protocol + '://' + kmc.vars.api_host + '/index.php/kmc/preview'; + var url = protocol + '://' + kmc.vars.api_host + '/index.php/extwidget/preview'; //var url = protocol + '://' + window.location.host + '/KMC_V2/preview.php'; url += '/partner_id/' + kmc.vars.partner_id; url += '/uiconf_id/' + player.id; diff --git a/alpha/web/lib/js/kmc/6.0.7/kmc.min.js b/alpha/web/lib/js/kmc/6.0.7/kmc.min.js index 9fdc286b524..15b7b3f6770 100644 --- a/alpha/web/lib/js/kmc/6.0.7/kmc.min.js +++ b/alpha/web/lib/js/kmc/6.0.7/kmc.min.js @@ -1,6 +1,6 @@ -/*! KMC - v6.0.7 - 2013-07-14 +/*! KMC - v6.0.7 - 2013-07-17 * https://github.com/kaltura/KMC_V2 * Copyright (c) 2013 Ran Yefet; Licensed GNU */ function openPlayer(e,t,r,a,n){n===!0&&$("#kcms")[0].alert("previewOnly from studio"),kmc.preview_embed.doPreviewEmbed("multitab_playlist",e,null,n,!0,a,!1,!1,!1)}function playlistAdded(){kmc.preview_embed.updateList(!0)}function playerAdded(){kmc.preview_embed.updateList(!1)}function md5(e){var t,r,a,n,i,o,s,l,c,d,h=function(e,t){return e<>>32-t},u=function(e,t){var r,a,n,i,o;return n=2147483648&e,i=2147483648&t,r=1073741824&e,a=1073741824&t,o=(1073741823&e)+(1073741823&t),r&a?2147483648^o^n^i:r|a?1073741824&o?3221225472^o^n^i:1073741824^o^n^i:o^n^i},p=function(e,t,r){return e&t|~e&r},f=function(e,t,r){return e&r|t&~r},m=function(e,t,r){return e^t^r},v=function(e,t,r){return t^(e|~r)},g=function(e,t,r,a,n,i,o){return e=u(e,u(u(p(t,r,a),n),o)),u(h(e,i),t)},y=function(e,t,r,a,n,i,o){return e=u(e,u(u(f(t,r,a),n),o)),u(h(e,i),t)},b=function(e,t,r,a,n,i,o){return e=u(e,u(u(m(t,r,a),n),o)),u(h(e,i),t)},w=function(e,t,r,a,n,i,o){return e=u(e,u(u(v(t,r,a),n),o)),u(h(e,i),t)},k=function(e){for(var t,r=e.length,a=r+8,n=(a-a%64)/64,i=16*(n+1),o=Array(i-1),s=0,l=0;r>l;)t=(l-l%4)/4,s=8*(l%4),o[t]=o[t]|e.charCodeAt(l)<>>29,o},_=function(e){var t,r,a="",n="";for(r=0;3>=r;r++)t=255&e>>>8*r,n="0"+t.toString(16),a+=n.substr(n.length-2,2);return a},C=[],I=7,T=12,E=17,P=22,M=5,A=9,S=14,L=20,$=4,x=11,N=16,B=23,D=6,O=10,H=15,U=21;for(e=this.utf8_encode(e),C=k(e),s=1732584193,l=4023233417,c=2562383102,d=271733878,t=C.length,r=0;t>r;r+=16)a=s,n=l,i=c,o=d,s=g(s,l,c,d,C[r+0],I,3614090360),d=g(d,s,l,c,C[r+1],T,3905402710),c=g(c,d,s,l,C[r+2],E,606105819),l=g(l,c,d,s,C[r+3],P,3250441966),s=g(s,l,c,d,C[r+4],I,4118548399),d=g(d,s,l,c,C[r+5],T,1200080426),c=g(c,d,s,l,C[r+6],E,2821735955),l=g(l,c,d,s,C[r+7],P,4249261313),s=g(s,l,c,d,C[r+8],I,1770035416),d=g(d,s,l,c,C[r+9],T,2336552879),c=g(c,d,s,l,C[r+10],E,4294925233),l=g(l,c,d,s,C[r+11],P,2304563134),s=g(s,l,c,d,C[r+12],I,1804603682),d=g(d,s,l,c,C[r+13],T,4254626195),c=g(c,d,s,l,C[r+14],E,2792965006),l=g(l,c,d,s,C[r+15],P,1236535329),s=y(s,l,c,d,C[r+1],M,4129170786),d=y(d,s,l,c,C[r+6],A,3225465664),c=y(c,d,s,l,C[r+11],S,643717713),l=y(l,c,d,s,C[r+0],L,3921069994),s=y(s,l,c,d,C[r+5],M,3593408605),d=y(d,s,l,c,C[r+10],A,38016083),c=y(c,d,s,l,C[r+15],S,3634488961),l=y(l,c,d,s,C[r+4],L,3889429448),s=y(s,l,c,d,C[r+9],M,568446438),d=y(d,s,l,c,C[r+14],A,3275163606),c=y(c,d,s,l,C[r+3],S,4107603335),l=y(l,c,d,s,C[r+8],L,1163531501),s=y(s,l,c,d,C[r+13],M,2850285829),d=y(d,s,l,c,C[r+2],A,4243563512),c=y(c,d,s,l,C[r+7],S,1735328473),l=y(l,c,d,s,C[r+12],L,2368359562),s=b(s,l,c,d,C[r+5],$,4294588738),d=b(d,s,l,c,C[r+8],x,2272392833),c=b(c,d,s,l,C[r+11],N,1839030562),l=b(l,c,d,s,C[r+14],B,4259657740),s=b(s,l,c,d,C[r+1],$,2763975236),d=b(d,s,l,c,C[r+4],x,1272893353),c=b(c,d,s,l,C[r+7],N,4139469664),l=b(l,c,d,s,C[r+10],B,3200236656),s=b(s,l,c,d,C[r+13],$,681279174),d=b(d,s,l,c,C[r+0],x,3936430074),c=b(c,d,s,l,C[r+3],N,3572445317),l=b(l,c,d,s,C[r+6],B,76029189),s=b(s,l,c,d,C[r+9],$,3654602809),d=b(d,s,l,c,C[r+12],x,3873151461),c=b(c,d,s,l,C[r+15],N,530742520),l=b(l,c,d,s,C[r+2],B,3299628645),s=w(s,l,c,d,C[r+0],D,4096336452),d=w(d,s,l,c,C[r+7],O,1126891415),c=w(c,d,s,l,C[r+14],H,2878612391),l=w(l,c,d,s,C[r+5],U,4237533241),s=w(s,l,c,d,C[r+12],D,1700485571),d=w(d,s,l,c,C[r+3],O,2399980690),c=w(c,d,s,l,C[r+10],H,4293915773),l=w(l,c,d,s,C[r+1],U,2240044497),s=w(s,l,c,d,C[r+8],D,1873313359),d=w(d,s,l,c,C[r+15],O,4264355552),c=w(c,d,s,l,C[r+6],H,2734768916),l=w(l,c,d,s,C[r+13],U,1309151649),s=w(s,l,c,d,C[r+4],D,4149444226),d=w(d,s,l,c,C[r+11],O,3174756917),c=w(c,d,s,l,C[r+2],H,718787259),l=w(l,c,d,s,C[r+9],U,3951481745),s=u(s,a),l=u(l,n),c=u(c,i),d=u(d,o);var j=_(s)+_(l)+_(c)+_(d);return j.toLowerCase()}function utf8_encode(e){if(null===e||e===void 0)return"";var t,r,a=e+"",n="",i=0;t=r=0,i=a.length;for(var o=0;i>o;o++){var s=a.charCodeAt(o),l=null;128>s?r++:l=s>127&&2048>s?String.fromCharCode(192|s>>6)+String.fromCharCode(128|63&s):String.fromCharCode(224|s>>12)+String.fromCharCode(128|63&s>>6)+String.fromCharCode(128|63&s),null!==l&&(r>t&&(n+=a.slice(t,r)),n+=l,t=r=o+1)}return r>t&&(n+=a.slice(t,i)),n}this.Handlebars={},function(e){e.VERSION="1.0.rc.2",e.helpers={},e.partials={},e.registerHelper=function(e,t,r){r&&(t.not=r),this.helpers[e]=t},e.registerPartial=function(e,t){this.partials[e]=t},e.registerHelper("helperMissing",function(e){if(2===arguments.length)return void 0;throw Error("Could not find property '"+e+"'")});var t=Object.prototype.toString,r="[object Function]";e.registerHelper("blockHelperMissing",function(a,n){var i=n.inverse||function(){},o=n.fn,s=t.call(a);return s===r&&(a=a.call(this)),a===!0?o(this):a===!1||null==a?i(this):"[object Array]"===s?a.length>0?e.helpers.each(a,n):i(this):o(a)}),e.K=function(){},e.createFrame=Object.create||function(t){e.K.prototype=t;var r=new e.K;return e.K.prototype=null,r},e.logger={DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,methodMap:{0:"debug",1:"info",2:"warn",3:"error"},log:function(t,r){if(t>=e.logger.level){var a=e.logger.methodMap[t];"undefined"!=typeof console&&console[a]&&console[a].call(console,r)}}},e.log=function(t,r){e.logger.log(t,r)},e.registerHelper("each",function(t,r){var a,n=r.fn,i=r.inverse,o=0,s="";if(r.data&&(a=e.createFrame(r.data)),t&&"object"==typeof t)if(t instanceof Array)for(var l=t.length;l>o;o++)a&&(a.index=o),s+=n(t[o],{data:a});else for(var c in t)t.hasOwnProperty(c)&&(a&&(a.key=c),s+=n(t[c],{data:a}),o++);return 0===o&&(s=i(this)),s}),e.registerHelper("if",function(a,n){var i=t.call(a);return i===r&&(a=a.call(this)),!a||e.Utils.isEmpty(a)?n.inverse(this):n.fn(this)}),e.registerHelper("unless",function(t,r){var a=r.fn,n=r.inverse;return r.fn=n,r.inverse=a,e.helpers["if"].call(this,t,r)}),e.registerHelper("with",function(e,t){return t.fn(e)}),e.registerHelper("log",function(t,r){var a=r.data&&null!=r.data.level?parseInt(r.data.level,10):1;e.log(a,t)})}(this.Handlebars);var errorProps=["description","fileName","lineNumber","message","name","number","stack"];Handlebars.Exception=function(){for(var e=Error.prototype.constructor.apply(this,arguments),t=0;errorProps.length>t;t++)this[errorProps[t]]=e[errorProps[t]]},Handlebars.Exception.prototype=Error(),Handlebars.SafeString=function(e){this.string=e},Handlebars.SafeString.prototype.toString=function(){return""+this.string},function(){var e={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},t=/[&<>"'`]/g,r=/[&<>"'`]/,a=function(t){return e[t]||"&"};Handlebars.Utils={escapeExpression:function(e){return e instanceof Handlebars.SafeString?""+e:null==e||e===!1?"":r.test(e)?e.replace(t,a):e},isEmpty:function(e){return e||0===e?"[object Array]"===Object.prototype.toString.call(e)&&0===e.length?!0:!1:!0}}}(),Handlebars.VM={template:function(e){var t={escapeExpression:Handlebars.Utils.escapeExpression,invokePartial:Handlebars.VM.invokePartial,programs:[],program:function(e,t,r){var a=this.programs[e];return r?Handlebars.VM.program(t,r):a?a:a=this.programs[e]=Handlebars.VM.program(t)},programWithDepth:Handlebars.VM.programWithDepth,noop:Handlebars.VM.noop};return function(r,a){return a=a||{},e.call(t,Handlebars,r,a.helpers,a.partials,a.data)}},programWithDepth:function(e,t){var r=Array.prototype.slice.call(arguments,2);return function(a,n){return n=n||{},e.apply(this,[a,n.data||t].concat(r))}},program:function(e,t){return function(r,a){return a=a||{},e(r,a.data||t)}},noop:function(){return""},invokePartial:function(e,t,r,a,n,i){var o={helpers:a,partials:n,data:i};if(void 0===e)throw new Handlebars.Exception("The partial "+t+" could not be found");if(e instanceof Function)return e(r,o);if(Handlebars.compile)return n[t]=Handlebars.compile(e,{data:void 0!==i}),n[t](r,o);throw new Handlebars.Exception("The partial "+t+" could not be compiled when running in runtime-only mode")}},Handlebars.template=Handlebars.VM.template,function(e,t){var r=function(e,t){var r="",a=t?t+"[":"",n=t?"]":"";for(var i in e)if("object"==typeof e[i])for(var o in e[i])r+="&"+a+encodeURIComponent(i)+"."+encodeURIComponent(o)+n+"="+encodeURIComponent(e[i][o]);else r+="&"+a+encodeURIComponent(i)+n+"="+encodeURIComponent(e[i]);return r};t.registerHelper("flashVarsUrl",function(e){return r(e,"flashvars")}),t.registerHelper("flashVarsString",function(e){return r(e)}),t.registerHelper("elAttributes",function(e){var t="";for(var r in e)t+=" "+r+'="'+e[r]+'"';return t}),t.registerHelper("kalturaLinks",function(){if(!this.includeKalturaLinks)return"";var e=t.templates.kaltura_links;return e()}),t.registerHelper("seoMetadata",function(){var e=t.templates.seo_metadata;return e(this)})}(this,this.Handlebars),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.auto=e(function(e,t,r,a,n){function i(e){var t,a,n="";return n+='
    ",d=r.seoMetadata,t=d||e.seoMetadata,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"seoMetadata",{hash:{}})),(t||0===t)&&(n+=t),d=r.kalturaLinks,t=d||e.kalturaLinks,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"kalturaLinks",{hash:{}})),(t||0===t)&&(n+=t),n+="
    \n"}function o(e){var t,a="";return a+="&entry_id=",d=r.entryId,t=d||e.entryId,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"entryId",{hash:{}})),a+=g(t)}function s(e){var t,a="";return a+="&cache_st=",d=r.cacheSt,t=d||e.cacheSt,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"cacheSt",{hash:{}})),a+=g(t)}r=r||e.helpers;var l,c,d,h,u="",p=this,f="function",m=r.helperMissing,v=void 0,g=this.escapeExpression;return d=r.includeSeoMetadata,l=d||t.includeSeoMetadata,c=r["if"],h=p.program(1,i,n),h.hash={},h.fn=h,h.inverse=p.noop,l=c.call(t,l,h),(l||0===l)&&(u+=l),u+=''}),t.dynamic=e(function(e,t,r){r=r||e.helpers;var a,n,i,o="",s="function",l=r.helperMissing,c=void 0,d=this.escapeExpression;return o+='\n
    ",i=r.seoMetadata,a=i||t.seoMetadata,typeof a===s?a=a.call(t,{hash:{}}):a===c&&(a=l.call(t,"seoMetadata",{hash:{}})),(a||0===a)&&(o+=a),i=r.kalturaLinks,a=i||t.kalturaLinks,typeof a===s?a=a.call(t,{hash:{}}):a===c&&(a=l.call(t,"kalturaLinks",{hash:{}})),(a||0===a)&&(o+=a),o+="
    \n"}),t.iframe=e(function(e,t,r,a,n){function i(e){var t,a="";return a+="&entry_id=",l=r.entryId,t=l||e.entryId,typeof t===u?t=t.call(e,{hash:{}}):t===f&&(t=p.call(e,"entryId",{hash:{}})),a+=m(t)}r=r||e.helpers;var o,s,l,c,d="",h=this,u="function",p=r.helperMissing,f=void 0,m=this.escapeExpression;return d+='"}),t.kaltura_links=e(function(e,t,r){return r=r||e.helpers,'Video Platform\nVideo Management \nVideo Solutions\nVideo Player'}),t.legacy=e(function(e,t,r,a,n){function i(e){var t,a="";return a+='\n'}function o(e){var t,a="";return a+='\n \n \n \n \n \n \n '}r=r||e.helpers;var s,l,c,d,h="",u=this,p="function",f=r.helperMissing,m=void 0,v=this.escapeExpression;return c=r.includeHtml5Library,s=c||t.includeHtml5Library,l=r["if"],d=u.program(1,i,n),d.hash={},d.fn=d,d.inverse=u.noop,s=l.call(t,s,d),(s||0===s)&&(h+=s),h+='\n \n \n \n \n \n \n ',c=r.includeSeoMetadata,s=c||t.includeSeoMetadata,l=r["if"],d=u.program(3,o,n),d.hash={},d.fn=d,d.inverse=u.noop,s=l.call(t,s,d),(s||0===s)&&(h+=s),c=r.kalturaLinks,s=c||t.kalturaLinks,typeof s===p?s=s.call(t,{hash:{}}):s===m&&(s=f.call(t,"kalturaLinks",{hash:{}})),(s||0===s)&&(h+=s),h+="\n"}),t.seo_metadata=e(function(e,t,r,a,n){function i(e){var t,a="";return a+='\n\n\n\n\n\n\n'}r=r||e.helpers;var o,s,l,c,d=this,h="function",u=r.helperMissing,p=void 0,f=this.escapeExpression;return l=r.includeSeoMetadata,o=l||t.includeSeoMetadata,s=r["if"],c=d.program(1,i,n),c.hash={},c.fn=c,c.inverse=d.noop,o=s.call(t,o,c),o||0===o?o:""})}(),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){"use strict";if(null==this)throw new TypeError;var t=Object(this),r=t.length>>>0;if(0===r)return-1;var a=0;if(arguments.length>1&&(a=Number(arguments[1]),a!==a?a=0:0!==a&&1/0!==a&&a!==-1/0&&(a=(a>0||-1)*Math.floor(Math.abs(a)))),a>=r)return-1;for(var n=a>=0?a:Math.max(r-Math.abs(a),0);r>n;n++)if(n in t&&t[n]===e)return n;return-1}),Object.keys||(Object.keys=function(){var e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=r.length;return function(n){if("object"!=typeof n&&"function"!=typeof n||null===n)throw new TypeError("Object.keys called on non-object");var i=[];for(var o in n)e.call(n,o)&&i.push(o);if(t)for(var s=0;a>s;s++)e.call(n,r[s])&&i.push(r[s]);return i}}()),function(e,t){var r=function(e){this.init(e)};r.prototype={types:["auto","dynamic","thumb","iframe","legacy"],required:["widgetId","partnerId","uiConfId"],defaults:{embedType:"auto",playerId:"kaltura_player",protocol:"http",host:"www.kaltura.com",securedHost:"www.kaltura.com",widgetId:null,partnerId:null,cacheSt:null,uiConfId:null,entryId:null,entryMeta:{},width:400,height:330,attributes:{},flashVars:{},includeKalturaLinks:!0,includeSeoMetadata:!1,includeHtml5Library:!0},extend:function(e,t){for(var r in t)t.hasOwnProperty(r)&&!e.hasOwnProperty(r)&&(e[r]=t[r]);return e},isNull:function(e){return e.length&&e.length>0?!1:e.length&&0===e.length?!0:"object"==typeof e?Object.keys(e).length>0?!1:!0:!e},init:function(e){if(e=e||{},this.defaults,typeof Handlebars===t)throw"Handlebars is not defined, please include Handlebars.js before this script";return"object"==typeof e&&(this.options=this.extend(e,this.defaults)),!this.config("widgetId")&&this.config("partnerId")&&this.config("widgetId","_"+this.config("partnerId")),this},config:function(e,r){return r===t&&"string"==typeof e&&this.options.hasOwnProperty(e)?this.options[e]:e===t&&r===t?this.options:("string"==typeof e&&r!==t&&(this.options[e]=r),null)},checkRequiredParams:function(e){var t=this.required.length,r=0;for(r;t>r;r++)if(this.isNull(e[this.required[r]]))throw"Missing required parameter: "+this.required[r]},checkValidType:function(e){var t=-1!==this.types.indexOf(e)?!0:!1;if(!t)throw"Embed type: "+e+" is not valid. Available types: "+this.types.join(",")},getTemplate:function(e){return e="thumb"==e?"dynamic":e,e&&Handlebars.templates&&Handlebars.templates[e]?Handlebars.templates[e]:null},isKWidgetEmbed:function(e){return"dynamic"==e||"thumb"==e?!0:!1},getHost:function(e){return"http"===e.protocol?e.host:e.securedHost},getScriptUrl:function(e){return e.protocol+"://"+this.getHost(e)+"/p/"+e.partnerId+"/sp/"+e.partnerId+"00/embedIframeJs/uiconf_id/"+e.uiConfId+"/partner_id/"+e.partnerId},getSwfUrl:function(e){var t=e.cacheSt?"/cache_st/"+e.cacheSt:"",r=e.entryId?"/entry_id/"+e.entryId:"";return e.protocol+"://"+this.getHost(e)+"/index.php/kwidget"+t+"/wid/"+e.widgetId+"/uiconf_id/"+e.uiConfId+r},getAttributes:function(e){var t={};return(this.isKWidgetEmbed(e.embedType)||e.includeSeoMetadata)&&(t.style="width: "+e.width+"px; height: "+e.height+"px;"),e.includeSeoMetadata&&("legacy"==e.embedType?(t["xmlns:dc"]="http://purl.org/dc/terms/",t["xmlns:media"]="http://search.yahoo.com/searchmonkey/media/",t.rel="media:video",t.resource=this.getSwfUrl(e)):(t.itemprop="video",t["itemscope itemtype"]="http://schema.org/VideoObject")),t},getEmbedObject:function(e){var t={targetId:e.playerId,wid:e.widgetId,uiconf_id:e.uiConfId,flashvars:e.flashVars};return e.cacheSt&&(t.cache_st=e.cacheSt),e.entryId&&(t.entry_id=e.entryId),JSON.stringify(t,null,2)},getCode:function(e){var r=e===t?{}:this.extend({},e);r=this.extend(r,this.config()),!r.widgetId&&r.partnerId&&(r.widgetId="_"+r.partnerId),this.checkRequiredParams(r),this.checkValidType(r.embedType);var a=this.getTemplate(r.embedType);if(!a)throw"Template: "+r.embedType+" is not defined as Handlebars template";var n={host:this.getHost(r),scriptUrl:this.getScriptUrl(r),attributes:this.getAttributes(r)};return"legacy"===r.embedType&&(n.swfUrl=this.getSwfUrl(r)),this.isKWidgetEmbed(r.embedType)&&(n.embedMethod="dynamic"==r.embedType?"embed":"thumbEmbed",n.kWidgetObject=this.getEmbedObject(r)),n=this.extend(n,r),a(n)}},e.kEmbedCodeGenerator=r}(this),function(e){e.fn.qrcode=function(t){function r(e){this.mode=s.MODE_8BIT_BYTE,this.data=e}function a(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function n(e,t){if(void 0==e.length)throw Error(e.length+"/"+t);for(var r=0;e.length>r&&0==e[r];)r++;this.num=Array(e.length-r+t);for(var a=0;e.length-r>a;a++)this.num[a]=e[a+r]}function i(e,t){this.totalCount=e,this.dataCount=t}function o(){this.buffer=[],this.length=0}r.prototype={getLength:function(){return this.data.length},write:function(e){for(var t=0;this.data.length>t;t++)e.put(this.data.charCodeAt(t),8)}},a.prototype={addData:function(e){var t=new r(e);this.dataList.push(t),this.dataCache=null},isDark:function(e,t){if(0>e||e>=this.moduleCount||0>t||t>=this.moduleCount)throw Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){var e=1;for(e=1;40>e;e++){for(var t=i.getRSBlocks(e,this.errorCorrectLevel),r=new o,a=0,n=0;t.length>n;n++)a+=t[n].dataCount;for(var n=0;this.dataList.length>n;n++){var s=this.dataList[n];r.put(s.mode,4),r.put(s.getLength(),d.getLengthInBits(s.mode,e)),s.write(r)}if(8*a>=r.getLengthInBits())break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,t){this.moduleCount=4*this.typeNumber+17,this.modules=Array(this.moduleCount);for(var r=0;this.moduleCount>r;r++){this.modules[r]=Array(this.moduleCount);for(var n=0;this.moduleCount>n;n++)this.modules[r][n]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,t),this.typeNumber>=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=a.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;7>=r;r++)if(!(-1>=e+r||e+r>=this.moduleCount))for(var a=-1;7>=a;a++)-1>=t+a||t+a>=this.moduleCount||(this.modules[e+r][t+a]=r>=0&&6>=r&&(0==a||6==a)||a>=0&&6>=a&&(0==r||6==r)||r>=2&&4>=r&&a>=2&&4>=a?!0:!1)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;8>r;r++){this.makeImpl(!0,r);var a=d.getLostPoint(this);(0==r||e>a)&&(e=a,t=r)}return t},createMovieClip:function(e,t,r){var a=e.createEmptyMovieClip(t,r),n=1;this.make();for(var i=0;this.modules.length>i;i++)for(var o=i*n,s=0;this.modules[i].length>s;s++){var l=s*n,c=this.modules[i][s];c&&(a.beginFill(0,100),a.moveTo(l,o),a.lineTo(l+n,o),a.lineTo(l+n,o+n),a.lineTo(l,o+n),a.endFill())}return a},setupTimingPattern:function(){for(var e=8;this.moduleCount-8>e;e++)null==this.modules[e][6]&&(this.modules[e][6]=0==e%2);for(var t=8;this.moduleCount-8>t;t++)null==this.modules[6][t]&&(this.modules[6][t]=0==t%2)},setupPositionAdjustPattern:function(){for(var e=d.getPatternPosition(this.typeNumber),t=0;e.length>t;t++)for(var r=0;e.length>r;r++){var a=e[t],n=e[r];if(null==this.modules[a][n])for(var i=-2;2>=i;i++)for(var o=-2;2>=o;o++)this.modules[a+i][n+o]=-2==i||2==i||-2==o||2==o||0==i&&0==o?!0:!1}},setupTypeNumber:function(e){for(var t=d.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var a=!e&&1==(1&t>>r);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=a}for(var r=0;18>r;r++){var a=!e&&1==(1&t>>r);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=a}},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,a=d.getBCHTypeInfo(r),n=0;15>n;n++){var i=!e&&1==(1&a>>n);6>n?this.modules[n][8]=i:8>n?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(var n=0;15>n;n++){var i=!e&&1==(1&a>>n);8>n?this.modules[8][this.moduleCount-n-1]=i:9>n?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,a=this.moduleCount-1,n=7,i=0,o=this.moduleCount-1;o>0;o-=2)for(6==o&&o--;;){for(var s=0;2>s;s++)if(null==this.modules[a][o-s]){var l=!1;e.length>i&&(l=1==(1&e[i]>>>n));var c=d.getMask(t,a,o-s);c&&(l=!l),this.modules[a][o-s]=l,n--,-1==n&&(i++,n=7)}if(a+=r,0>a||a>=this.moduleCount){a-=r,r=-r;break}}}},a.PAD0=236,a.PAD1=17,a.createData=function(e,t,r){for(var n=i.getRSBlocks(e,t),s=new o,l=0;r.length>l;l++){var c=r[l];s.put(c.mode,4),s.put(c.getLength(),d.getLengthInBits(c.mode,e)),c.write(s)}for(var h=0,l=0;n.length>l;l++)h+=n[l].dataCount;if(s.getLengthInBits()>8*h)throw Error("code length overflow. ("+s.getLengthInBits()+">"+8*h+")");for(8*h>=s.getLengthInBits()+4&&s.put(0,4);0!=s.getLengthInBits()%8;)s.putBit(!1);for(;;){if(s.getLengthInBits()>=8*h)break;if(s.put(a.PAD0,8),s.getLengthInBits()>=8*h)break;s.put(a.PAD1,8)}return a.createBytes(s,n)},a.createBytes=function(e,t){for(var r=0,a=0,i=0,o=Array(t.length),s=Array(t.length),l=0;t.length>l;l++){var c=t[l].dataCount,h=t[l].totalCount-c;a=Math.max(a,c),i=Math.max(i,h),o[l]=Array(c);for(var u=0;o[l].length>u;u++)o[l][u]=255&e.buffer[u+r];r+=c;var p=d.getErrorCorrectPolynomial(h),f=new n(o[l],p.getLength()-1),m=f.mod(p);s[l]=Array(p.getLength()-1);for(var u=0;s[l].length>u;u++){var v=u+m.getLength()-s[l].length;s[l][u]=v>=0?m.get(v):0}}for(var g=0,u=0;t.length>u;u++)g+=t[u].totalCount;for(var y=Array(g),b=0,u=0;a>u;u++)for(var l=0;t.length>l;l++)o[l].length>u&&(y[b++]=o[l][u]);for(var u=0;i>u;u++)for(var l=0;t.length>l;l++)s[l].length>u&&(y[b++]=s[l][u]);return y};for(var s={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},l={L:1,M:0,Q:3,H:2},c={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},d={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var t=e<<10;d.getBCHDigit(t)-d.getBCHDigit(d.G15)>=0;)t^=d.G15<=0;)t^=d.G18<>>=1;return t},getPatternPosition:function(e){return d.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case c.PATTERN000:return 0==(t+r)%2;case c.PATTERN001:return 0==t%2;case c.PATTERN010:return 0==r%3;case c.PATTERN011:return 0==(t+r)%3;case c.PATTERN100:return 0==(Math.floor(t/2)+Math.floor(r/3))%2;case c.PATTERN101:return 0==t*r%2+t*r%3;case c.PATTERN110:return 0==(t*r%2+t*r%3)%2;case c.PATTERN111:return 0==(t*r%3+(t+r)%2)%2;default:throw Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new n([1],0),r=0;e>r;r++)t=t.multiply(new n([1,h.gexp(r)],0));return t},getLengthInBits:function(e,t){if(t>=1&&10>t)switch(e){case s.MODE_NUMBER:return 10;case s.MODE_ALPHA_NUM:return 9;case s.MODE_8BIT_BYTE:return 8;case s.MODE_KANJI:return 8;default:throw Error("mode:"+e)}else if(27>t)switch(e){case s.MODE_NUMBER:return 12;case s.MODE_ALPHA_NUM:return 11;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 10;default:throw Error("mode:"+e)}else{if(!(41>t))throw Error("type:"+t);switch(e){case s.MODE_NUMBER:return 14;case s.MODE_ALPHA_NUM:return 13;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 12;default:throw Error("mode:"+e)}}},getLostPoint:function(e){for(var t=e.getModuleCount(),r=0,a=0;t>a;a++)for(var n=0;t>n;n++){for(var i=0,o=e.isDark(a,n),s=-1;1>=s;s++)if(!(0>a+s||a+s>=t))for(var l=-1;1>=l;l++)0>n+l||n+l>=t||(0!=s||0!=l)&&o==e.isDark(a+s,n+l)&&i++; -i>5&&(r+=3+i-5)}for(var a=0;t-1>a;a++)for(var n=0;t-1>n;n++){var c=0;e.isDark(a,n)&&c++,e.isDark(a+1,n)&&c++,e.isDark(a,n+1)&&c++,e.isDark(a+1,n+1)&&c++,(0==c||4==c)&&(r+=3)}for(var a=0;t>a;a++)for(var n=0;t-6>n;n++)e.isDark(a,n)&&!e.isDark(a,n+1)&&e.isDark(a,n+2)&&e.isDark(a,n+3)&&e.isDark(a,n+4)&&!e.isDark(a,n+5)&&e.isDark(a,n+6)&&(r+=40);for(var n=0;t>n;n++)for(var a=0;t-6>a;a++)e.isDark(a,n)&&!e.isDark(a+1,n)&&e.isDark(a+2,n)&&e.isDark(a+3,n)&&e.isDark(a+4,n)&&!e.isDark(a+5,n)&&e.isDark(a+6,n)&&(r+=40);for(var d=0,n=0;t>n;n++)for(var a=0;t>a;a++)e.isDark(a,n)&&d++;var h=Math.abs(100*d/t/t-50)/5;return r+=10*h}},h={glog:function(e){if(1>e)throw Error("glog("+e+")");return h.LOG_TABLE[e]},gexp:function(e){for(;0>e;)e+=255;for(;e>=256;)e-=255;return h.EXP_TABLE[e]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},u=0;8>u;u++)h.EXP_TABLE[u]=1<u;u++)h.EXP_TABLE[u]=h.EXP_TABLE[u-4]^h.EXP_TABLE[u-5]^h.EXP_TABLE[u-6]^h.EXP_TABLE[u-8];for(var u=0;255>u;u++)h.LOG_TABLE[h.EXP_TABLE[u]]=u;n.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=Array(this.getLength()+e.getLength()-1),r=0;this.getLength()>r;r++)for(var a=0;e.getLength()>a;a++)t[r+a]^=h.gexp(h.glog(this.get(r))+h.glog(e.get(a)));return new n(t,0)},mod:function(e){if(0>this.getLength()-e.getLength())return this;for(var t=h.glog(this.get(0))-h.glog(e.get(0)),r=Array(this.getLength()),a=0;this.getLength()>a;a++)r[a]=this.get(a);for(var a=0;e.getLength()>a;a++)r[a]^=h.gexp(h.glog(e.get(a))+t);return new n(r,0).mod(e)}},i.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],i.getRSBlocks=function(e,t){var r=i.getRsBlockTable(e,t);if(void 0==r)throw Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+t);for(var a=r.length/3,n=[],o=0;a>o;o++)for(var s=r[3*o+0],l=r[3*o+1],c=r[3*o+2],d=0;s>d;d++)n.push(new i(l,c));return n},i.getRsBlockTable=function(e,t){switch(t){case l.L:return i.RS_BLOCK_TABLE[4*(e-1)+0];case l.M:return i.RS_BLOCK_TABLE[4*(e-1)+1];case l.Q:return i.RS_BLOCK_TABLE[4*(e-1)+2];case l.H:return i.RS_BLOCK_TABLE[4*(e-1)+3];default:return void 0}},o.prototype={get:function(e){var t=Math.floor(e/8);return 1==(1&this.buffer[t]>>>7-e%8)},put:function(e,t){for(var r=0;t>r;r++)this.putBit(1==(1&e>>>t-r-1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);t>=this.buffer.length&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},"string"==typeof t&&(t={text:t}),t=e.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,correctLevel:l.H,background:"#ffffff",foreground:"#000000"},t);var p=function(){var e=new a(t.typeNumber,t.correctLevel);e.addData(t.text),e.make();var r=document.createElement("canvas");r.width=t.width,r.height=t.height;for(var n=r.getContext("2d"),i=t.width/e.getModuleCount(),o=t.height/e.getModuleCount(),s=0;e.getModuleCount()>s;s++)for(var l=0;e.getModuleCount()>l;l++){n.fillStyle=e.isDark(s,l)?t.foreground:t.background;var c=Math.ceil((l+1)*i)-Math.floor(l*i),d=Math.ceil((s+1)*i)-Math.floor(s*i);n.fillRect(Math.round(l*i),Math.round(s*o),c,d)}return r},f=function(){var r=new a(t.typeNumber,t.correctLevel);r.addData(t.text),r.make();for(var n=e("
    ").css("width",t.width+"px").css("height",t.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",t.background),i=t.width/r.getModuleCount(),o=t.height/r.getModuleCount(),s=0;r.getModuleCount()>s;s++)for(var l=e("").css("height",o+"px").appendTo(n),c=0;r.getModuleCount()>c;c++)e("").css("width",i+"px").css("background-color",r.isDark(s,c)?t.foreground:t.background).appendTo(l);return n};return this.each(function(){var r="canvas"==t.render?p():f();e(r).appendTo(this)})}}(jQuery),window.XDomainRequest&&jQuery.ajaxTransport(function(e){if(e.crossDomain&&e.async){e.timeout&&(e.xdrTimeout=e.timeout,delete e.timeout);var t;return{send:function(r,a){function n(e,r,n,i){t.onload=t.onerror=t.ontimeout=jQuery.noop,t=void 0,a(e,r,n,i)}t=new XDomainRequest,t.onload=function(){n(200,"OK",{text:t.responseText},"Content-Type: "+t.contentType)},t.onerror=function(){n(404,"Not Found")},t.onprogress=jQuery.noop,t.ontimeout=function(){n(0,"timeout")},t.timeout=e.xdrTimeout||Number.MAX_VALUE,t.open(e.type,e.url),t.send(e.hasContent&&e.data||null)},abort:function(){t&&(t.onerror=jQuery.noop,t.abort())}}}}),function(){"use strict";var e,t=function(e,t){var r=e.style[t];if(e.currentStyle?r=e.currentStyle[t]:window.getComputedStyle&&(r=document.defaultView.getComputedStyle(e,null).getPropertyValue(t)),"auto"==r&&"cursor"==t)for(var a=["a"],n=0;a.length>n;n++)if(e.tagName.toLowerCase()==a[n])return"pointer";return r},r=function(e){if(u.prototype._singleton){e||(e=window.event);var t;this!==window?t=this:e.target?t=e.target:e.srcElement&&(t=e.srcElement),u.prototype._singleton.setCurrent(t)}},a=function(e,t,r){e.addEventListener?e.addEventListener(t,r,!1):e.attachEvent&&e.attachEvent("on"+t,r)},n=function(e,t,r){e.removeEventListener?e.removeEventListener(t,r,!1):e.detachEvent&&e.detachEvent("on"+t,r)},i=function(e,t){if(e.addClass)return e.addClass(t),e;if(t&&"string"==typeof t){var r=(t||"").split(/\s+/);if(1===e.nodeType)if(e.className){for(var a=" "+e.className+" ",n=e.className,i=0,o=r.length;o>i;i++)0>a.indexOf(" "+r[i]+" ")&&(n+=" "+r[i]);e.className=n.replace(/^\s+|\s+$/g,"")}else e.className=t}return e},o=function(e,t){if(e.removeClass)return e.removeClass(t),e;if(t&&"string"==typeof t||void 0===t){var r=(t||"").split(/\s+/);if(1===e.nodeType&&e.className)if(t){for(var a=(" "+e.className+" ").replace(/[\n\t]/g," "),n=0,i=r.length;i>n;n++)a=a.replace(" "+r[n]+" "," ");e.className=a.replace(/^\s+|\s+$/g,"")}else e.className=""}return e},s=function(e){var r={left:0,top:0,width:e.width||e.offsetWidth||0,height:e.height||e.offsetHeight||0,zIndex:9999},a=t(e,"zIndex");for(a&&"auto"!=a&&(r.zIndex=parseInt(a,10));e;){var n=parseInt(t(e,"borderLeftWidth"),10),i=parseInt(t(e,"borderTopWidth"),10);r.left+=isNaN(e.offsetLeft)?0:e.offsetLeft,r.left+=isNaN(n)?0:n,r.top+=isNaN(e.offsetTop)?0:e.offsetTop,r.top+=isNaN(i)?0:i,e=e.offsetParent}return r},l=function(e){return(e.indexOf("?")>=0?"&":"?")+"nocache="+(new Date).getTime()},c=function(e){var t=[];return e.trustedDomains&&("string"==typeof e.trustedDomains?t.push("trustedDomain="+e.trustedDomains):t.push("trustedDomain="+e.trustedDomains.join(","))),t.join("&")},d=function(e,t){if(t.indexOf)return t.indexOf(e);for(var r=0,a=t.length;a>r;r++)if(t[r]===e)return r;return-1},h=function(e){if("string"==typeof e)throw new TypeError("ZeroClipboard doesn't accept query strings.");return e.length?e:[e]},u=function(e,t){if(e&&(u.prototype._singleton||this).glue(e),u.prototype._singleton)return u.prototype._singleton;u.prototype._singleton=this,this.options={};for(var r in f)this.options[r]=f[r];for(var a in t)this.options[a]=t[a];this.handlers={},u.detectFlashSupport()&&m()},p=[];u.prototype.setCurrent=function(r){e=r,this.reposition(),r.getAttribute("title")&&this.setTitle(r.getAttribute("title")),this.setHandCursor("pointer"==t(r,"cursor"))},u.prototype.setText=function(e){e&&""!==e&&(this.options.text=e,this.ready()&&this.flashBridge.setText(e))},u.prototype.setTitle=function(e){e&&""!==e&&this.htmlBridge.setAttribute("title",e)},u.prototype.setSize=function(e,t){this.ready()&&this.flashBridge.setSize(e,t)},u.prototype.setHandCursor=function(e){this.ready()&&this.flashBridge.setHandCursor(e)},u.version="1.1.7";var f={moviePath:"ZeroClipboard.swf",trustedDomains:null,text:null,hoverClass:"zeroclipboard-is-hover",activeClass:"zeroclipboard-is-active",allowScriptAccess:"sameDomain"};u.setDefaults=function(e){for(var t in e)f[t]=e[t]},u.destroy=function(){u.prototype._singleton.unglue(p);var e=u.prototype._singleton.htmlBridge;e.parentNode.removeChild(e),delete u.prototype._singleton},u.detectFlashSupport=function(){var e=!1;try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(e=!0)}catch(t){navigator.mimeTypes["application/x-shockwave-flash"]&&(e=!0)}return e};var m=function(){var e=u.prototype._singleton,t=document.getElementById("global-zeroclipboard-html-bridge");if(!t){var r=' ';t=document.createElement("div"),t.id="global-zeroclipboard-html-bridge",t.setAttribute("class","global-zeroclipboard-container"),t.setAttribute("data-clipboard-ready",!1),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="15px",t.style.height="15px",t.style.zIndex="9999",t.innerHTML=r,document.body.appendChild(t)}e.htmlBridge=t,e.flashBridge=document["global-zeroclipboard-flash-bridge"]||t.children[0].lastElementChild};u.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),o(e,this.options.activeClass),e=null,this.options.text=null},u.prototype.ready=function(){var e=this.htmlBridge.getAttribute("data-clipboard-ready");return"true"===e||e===!0},u.prototype.reposition=function(){if(!e)return!1;var t=s(e);this.htmlBridge.style.top=t.top+"px",this.htmlBridge.style.left=t.left+"px",this.htmlBridge.style.width=t.width+"px",this.htmlBridge.style.height=t.height+"px",this.htmlBridge.style.zIndex=t.zIndex+1,this.setSize(t.width,t.height)},u.dispatch=function(e,t){u.prototype._singleton.receiveEvent(e,t)},u.prototype.on=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++)e=r[a].toLowerCase().replace(/^on/,""),this.handlers[e]||(this.handlers[e]=t);this.handlers.noflash&&!u.detectFlashSupport()&&this.receiveEvent("onNoFlash",null)},u.prototype.addEventListener=u.prototype.on,u.prototype.off=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++){e=r[a].toLowerCase().replace(/^on/,"");for(var n in this.handlers)n===e&&this.handlers[n]===t&&delete this.handlers[n]}},u.prototype.removeEventListener=u.prototype.off,u.prototype.receiveEvent=function(t,r){t=(""+t).toLowerCase().replace(/^on/,"");var a=e;switch(t){case"load":if(r&&10>parseFloat(r.flashVersion.replace(",",".").replace(/[^0-9\.]/gi,"")))return this.receiveEvent("onWrongFlash",{flashVersion:r.flashVersion}),void 0;this.htmlBridge.setAttribute("data-clipboard-ready",!0);break;case"mouseover":i(a,this.options.hoverClass);break;case"mouseout":o(a,this.options.hoverClass),this.resetBridge();break;case"mousedown":i(a,this.options.activeClass);break;case"mouseup":o(a,this.options.activeClass);break;case"datarequested":var n=a.getAttribute("data-clipboard-target"),s=n?document.getElementById(n):null;if(s){var l=s.value||s.textContent||s.innerText;l&&this.setText(l)}else{var c=a.getAttribute("data-clipboard-text");c&&this.setText(c)}break;case"complete":this.options.text=null}if(this.handlers[t]){var d=this.handlers[t];"function"==typeof d?d.call(a,this,r):"string"==typeof d&&window[d].call(a,this,r)}},u.prototype.glue=function(e){e=h(e);for(var t=0;e.length>t;t++)-1==d(e[t],p)&&(p.push(e[t]),a(e[t],"mouseover",r))},u.prototype.unglue=function(e){e=h(e);for(var t=0;e.length>t;t++){n(e[t],"mouseover",r);var a=d(e[t],p);-1!=a&&p.splice(a,1)}},"undefined"!=typeof module?module.exports=u:"function"==typeof define&&define.amd?define(function(){return u}):window.ZeroClipboard=u}(),function(e){var t=e.Preview||{};e.vars.previewDefaults={showAdvancedOptions:!1,includeKalturaLinks:!e.vars.ignore_seo_links,includeSeoMetadata:!e.vars.ignore_entry_seo,deliveryType:e.vars.default_delivery_type,embedType:e.vars.default_embed_code_type,secureEmbed:e.vars.embed_code_protocol_https},"https:"==window.location.protocol&&(e.vars.previewDefaults.secureEmbed=!0),t.storageName="previewDefaults",t.el="#previewModal",t.iframeContainer="previewIframe",t.ignoreChangeEvents=!0,t.getGenerator=function(){return this.generator||(this.generator=new kEmbedCodeGenerator({host:e.vars.embed_host,securedHost:e.vars.embed_host_https,partnerId:e.vars.partner_id,includeKalturaLinks:e.vars.previewDefaults.includeKalturaLinks})),this.generator},t.clipboard=new ZeroClipboard($(".copy-code"),{moviePath:"/lib/flash/ZeroClipboard.swf",trustedDomains:["*"],allowScriptAccess:"always"}),t.clipboard.on("complete",function(){var e=$(this);$("#"+e.data("clipboard-target")).select(),e.data("close")===!0&&t.closeModal(t.el)}),t.objectToArray=function(e){var t=[];for(var r in e)e[r].id=r,t.push(e[r]);return t},t.getObjectById=function(e,t){var r=$.grep(t,function(t){return t.id==e});return r.length?r[0]:!1},t.getDefault=function(r){var a=localStorage.getItem(t.storageName);return a=a?JSON.parse(a):e.vars.previewDefaults,void 0!==a[r]?a[r]:null},t.savePreviewState=function(){var e=this.Service,r={embedType:e.get("embedType"),secureEmbed:e.get("secureEmbed"),includeSeoMetadata:e.get("includeSeo"),deliveryType:e.get("deliveryType").id,showAdvancedOptions:e.get("showAdvancedOptions")};localStorage.setItem(t.storageName,JSON.stringify(r))},t.getDeliveryTypeFlashVars=function(e){if(!e)return{};var t=e.flashvars?e.flashvars:{},r=$.extend({},t);return e.streamerType&&(r.streamerType=e.streamerType),e.mediaProtocol&&(r.mediaProtocol=e.mediaProtocol),r},t.getPreviewTitle=function(e){return e.entryMeta&&e.entryMeta.name?"Embedding: "+e.entryMeta.name:e.playlistName?"Playlist: "+e.playlistName:e.playerOnly?"Player Name:"+e.name:void 0},t.openPreviewEmbed=function(t,r){var a=this,n=a.el;this.ignoreChangeEvents=!1;var i={entryId:null,entryMeta:{},playlistId:null,playlistName:null,previewOnly:!1,liveBitrates:null,playerOnly:!1,uiConfId:null,name:null};t=$.extend({},i,t),t.liveBitrates&&r.setDeliveryType("auto"),r.updatePlayers(t),r.set(t);var o=this.getPreviewTitle(t),s=$(n);s.find(".title h2").text(o).attr("title",o),s.find(".close").unbind("click").click(function(){a.closeModal(n)});var l=$("body").height()-173;s.find(".content").height(l),e.layout.modal.show(n,!1)},t.closeModal=function(t){this.savePreviewState(),this.emptyDiv(this.iframeContainer),$(t).fadeOut(300,function(){e.layout.overlay.hide(),e.utils.hideFlash()})},t.emptyDiv=function(e){var t=$("#"+e),r=$("#previewIframe iframe");if(r.length)try{var a=$(r[0].contentWindow.document);a.find("#framePlayerContainer").empty()}catch(n){}return t.length?(t.empty(),t[0]):!1},t.hasIframe=function(){return $("#"+this.iframeContainer+" iframe").length},t.getCacheSt=function(){var e=new Date;return Math.floor(e.getTime()/1e3)+900},t.generateIframe=function(e){var t=$("html").hasClass("lt-ie10"),r="",a=this.emptyDiv(this.iframeContainer),n=document.createElement("iframe");if(n.frameborder="0",n.frameBorder="0",n.marginheight="0",n.marginwidth="0",n.frameborder="0",a.appendChild(n),t)n.src=this.getPreviewUrl(this.Service,!0);else{var i=n.contentDocument;i.open(),i.write(""+r+'
    '+e+"
    "),i.close()}},t.getEmbedProtocol=function(e,t){return t===!0?location.protocol.substring(0,location.protocol.length-1):e.get("secureEmbed")?"https":"http"},t.getEmbedFlashVars=function(t,r){var a=this.getEmbedProtocol(t,r),n=t.get("player"),i=this.getDeliveryTypeFlashVars(t.get("deliveryType"));r===!0&&(i.ks=e.vars.ks);var o=t.get("playlistId");if(o){var s=e.functions.getVersionFromPath(n.html5Url),l=e.functions.versionIsAtLeast(e.vars.min_kdp_version_for_playlist_api_v3,n.swf_version),c=e.functions.versionIsAtLeast(e.vars.min_html5_version_for_playlist_api_v3,s);l&&c?i["playlistAPI.kpl0Id"]=o:(i["playlistAPI.autoInsert"]="true",i["playlistAPI.kpl0Name"]=t.get("playlistName"),i["playlistAPI.kpl0Url"]=a+"://"+e.vars.api_host+"/index.php/partnerservices2/executeplaylist?"+"partner_id="+e.vars.partner_id+"&subp_id="+e.vars.partner_id+"00"+"&format=8&ks={ks}&playlist_id="+o)}return i},t.getEmbedCode=function(e,t){var r=e.get("player");if(!r||!e.get("embedType"))return"";var a=this.getCacheSt(),n={protocol:this.getEmbedProtocol(e,t),embedType:e.get("embedType"),uiConfId:r.id,width:r.width,height:r.height,entryMeta:e.get("entryMeta"),includeSeoMetadata:e.get("includeSeo"),playerId:"kaltura_player_"+a,cacheSt:a,flashVars:this.getEmbedFlashVars(e,t)};e.get("entryId")&&(n.entryId=e.get("entryId"));var i=this.getGenerator().getCode(n);return i},t.getPreviewUrl=function(t,r){var a=t.get("player");if(!a||!t.get("embedType"))return"";var n=this.getEmbedProtocol(t,r),i=n+"://"+e.vars.api_host+"/index.php/kmc/preview";return i+="/partner_id/"+e.vars.partner_id,i+="/uiconf_id/"+a.id,t.get("entryId")&&(i+="/entry_id/"+t.get("entryId")),i+="/embed/"+t.get("embedType"),i+="?"+e.functions.flashVarsToUrl(this.getEmbedFlashVars(t,r)),r===!0&&(i+="&framed=true"),i},t.generateQrCode=function(e){var t=$("#qrcode").empty();e&&($("html").hasClass("lt-ie9")||t.qrcode({width:80,height:80,text:e}))},t.generateShortUrl=function(t,r){t&&e.client.createShortURL(t,r)},e.Preview=t}(window.kmc);var kmcApp=angular.module("kmcApp",[]);kmcApp.factory("previewService",["$rootScope",function(e){var t={};return{get:function(e){return void 0===e?t:t[e]},set:function(r,a,n){"object"==typeof r?angular.extend(t,r):t[r]=a,n||e.$broadcast("previewChanged")},updatePlayers:function(t){e.$broadcast("playersUpdated",t)},changePlayer:function(t){e.$broadcast("changePlayer",t)},setDeliveryType:function(t){e.$broadcast("changeDelivery",t)}}}]),kmcApp.directive("showSlide",function(){return{restrict:"A",link:function(e,t,r){r.showSlide,e.$watch(r.showSlide,function(e){e&&!t.is(":visible")?t.slideDown():t.slideUp()})}}}),kmcApp.controller("PreviewCtrl",["$scope","previewService",function(e,t){var r=function(){e.$$phase||e.$apply()},a=kmc.Preview;a.playlistMode=!1,a.Service=t;var n=function(t){t=t||{};var r=t.uiConfId?t.uiConfId:void 0;kmc.vars.playlists_list&&kmc.vars.players_list&&(t.playlistId||t.playerOnly?(e.players=kmc.vars.playlists_list,a.playlistMode||(a.playlistMode=!0,e.$broadcast("changePlayer",r))):(e.players=kmc.vars.players_list,(a.playlistMode||!e.player)&&(a.playlistMode=!1,e.$broadcast("changePlayer",r))),r&&e.$broadcast("changePlayer",r))},i=function(r){var n=a.objectToArray(kmc.vars.delivery_types),i=e.deliveryType||a.getDefault("deliveryType"),o=[];$.each(n,function(){return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,r.swf_version)?(this.id==i&&(i=null),!0):(o.push(this),void 0)}),e.deliveryTypes=o,i||(i=e.deliveryTypes[0].id),t.setDeliveryType(i)},o=function(t){var r=a.objectToArray(kmc.vars.embed_code_types),n=e.embedType||a.getDefault("embedType"),i=[];$.each(r,function(){if(a.playlistMode&&this.entryOnly)return this.id==n&&(n=null),!0;var e=kmc.functions.getVersionFromPath(t.html5Url);return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,e)?(this.id==n&&(n=null),!0):(i.push(this),void 0)}),e.embedTypes=i,n||(n=e.embedTypes[0].id),e.embedType=n};e.players=[],e.player=null,e.deliveryTypes=[],e.deliveryType=null,e.embedTypes=[],e.embedType=null,e.secureEmbed=a.getDefault("secureEmbed"),e.includeSeo=a.getDefault("includeSeoMetadata"),e.previewOnly=!1,e.playerOnly=!1,e.liveBitrates=!1,e.showAdvancedOptionsStatus=a.getDefault("showAdvancedOptions"),e.shortLinkGenerated=!1,e.$on("playersUpdated",function(e,t){n(t)}),e.$on("changePlayer",function(t,a){a=a?a:e.players[0].id,e.player=a,r()}),e.$on("changeDelivery",function(t,a){e.deliveryType=a,r()}),e.showAdvancedOptions=function(r,a){r.preventDefault(),t.set("showAdvancedOptions",a,!0),e.showAdvancedOptionsStatus=a},e.$watch("showAdvancedOptionsStatus",function(){a.clipboard.reposition()}),e.$watch("player",function(){var r=a.getObjectById(e.player,e.players);r&&(i(r),o(r),t.set("player",r))}),e.$watch("deliveryType",function(){t.set("deliveryType",a.getObjectById(e.deliveryType,e.deliveryTypes))}),e.$watch("embedType",function(){t.set("embedType",e.embedType)}),e.$watch("secureEmbed",function(){t.set("secureEmbed",e.secureEmbed)}),e.$watch("includeSeo",function(){t.set("includeSeo",e.includeSeo)}),e.$watch("embedCodePreview",function(){a.generateIframe(e.embedCodePreview)}),e.$watch("previewOnly",function(){e.closeButtonText=e.previewOnly?"Close":"Copy Embed & Close",r()}),e.$on("previewChanged",function(){if(!a.ignoreChangeEvents){var n=a.getPreviewUrl(t);e.embedCode=a.getEmbedCode(t),e.embedCodePreview=a.getEmbedCode(t,!0),e.previewOnly=t.get("previewOnly"),e.playerOnly=t.get("playerOnly"),e.liveBitrates=t.get("liveBitrates"),r(),a.hasIframe()||a.generateIframe(e.embedCodePreview),e.previewUrl="Updating...",e.shortLinkGenerated=!1,a.generateShortUrl(n,function(t){t||(t=n),e.shortLinkGenerated=!0,e.previewUrl=t,a.generateQrCode(t),r()})}})}]),0==kmc.vars.allowFrame&&top!=window&&(top.location=window.location),kmc.vars.debug=!1,kmc.vars.quickstart_guide="/content/docs/pdf/KMC_User_Manual.pdf",kmc.vars.help_url=kmc.vars.service_url+"/kmc5help.html",kmc.vars.port=window.location.port?":"+window.location.port:"",kmc.vars.base_host=window.location.hostname+kmc.vars.port,kmc.vars.base_url=window.location.protocol+"//"+kmc.vars.base_host,kmc.vars.api_host=kmc.vars.host,kmc.vars.api_url=window.location.protocol+"//"+kmc.vars.api_host,kmc.vars.min_kdp_version_for_playlist_api_v3="3.6.15",kmc.vars.min_html5_version_for_playlist_api_v3="1.7.1.3",kmc.log=function(){if(kmc.vars.debug&&"undefined"!=typeof console&&console.log)if(1==arguments.length)console.log(arguments[0]);else{var e=Array.prototype.slice.call(arguments);console.log(e[0],e.slice(1))}},kmc.functions={loadSwf:function(){var e=window.location.protocol+"//"+kmc.vars.cdn_host+"/flash/kmc/"+kmc.vars.kmc_version+"/kmc.swf",t={kmc_uiconf:kmc.vars.kmc_general_uiconf,permission_uiconf:kmc.vars.kmc_permissions_uiconf,host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,srvurl:"api_v3/index.php",protocol:window.location.protocol+"//",partnerid:kmc.vars.partner_id,subpid:kmc.vars.partner_id+"00",ks:kmc.vars.ks,entryId:"-1",kshowId:"-1",debugmode:"true",widget_id:"_"+kmc.vars.partner_id,urchinNumber:kmc.vars.google_analytics_account,firstLogin:kmc.vars.first_login,openPlayer:"kmc.preview_embed.doPreviewEmbed",openPlaylist:"kmc.preview_embed.doPreviewEmbed",openCw:"kmc.functions.openKcw",language:kmc.vars.language||""};kmc.vars.disable_analytics&&(t.disableAnalytics=!0);var r={allowNetworking:"all",allowScriptAccess:"always"};swfobject.embedSWF(e,"kcms","100%","100%","10.0.0",!1,t,r),$("#kcms").attr("style","")},checkForOngoingProcess:function(){var e;try{e=$("#kcms")[0].hasOngoingProcess()}catch(t){e=null}return null!==e?e:void 0},expired:function(){kmc.user.logout()},openKcw:function(e,t){e=e||"";var r="uploadWebCam"==t?kmc.vars.kcw_webcam_uiconf:kmc.vars.kcw_import_uiconf,a={host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,protocol:window.location.protocol.slice(0,-1),partnerid:kmc.vars.partner_id,subPartnerId:kmc.vars.partner_id+"00",sessionId:kmc.vars.ks,devFlag:"true",entryId:"-1",kshow_id:"-1",terms_of_use:kmc.vars.terms_of_use,close:"kmc.functions.onCloseKcw",quick_edit:0,kvar_conversionQuality:e},n={allowscriptaccess:"always",allownetworking:"all",bgcolor:"#DBE3E9",quality:"high",movie:kmc.vars.service_url+"/kcw/ui_conf_id/"+r};kmc.layout.modal.open({width:700,height:420,content:'
    '}),swfobject.embedSWF(n.movie,"kcw","680","400","9.0.0",!1,a,n)},onCloseKcw:function(){kmc.layout.modal.close(),$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})},openChangePwd:function(){kmc.user.changeSetting("password")},openChangeEmail:function(){kmc.user.changeSetting("email")},openChangeName:function(){kmc.user.changeSetting("name")},getAddPanelPosition:function(){var e=$("#add").parent();return e.position().left+e.width()-10},openClipApp:function(e,t){var r=kmc.vars.base_url+"/apps/clipapp/"+kmc.vars.clipapp.version;r+="/?kdpUiconf="+kmc.vars.clipapp.kdp+"&kclipUiconf="+kmc.vars.clipapp.kclip,r+="&partnerId="+kmc.vars.partner_id+"&host="+kmc.vars.host+"&mode="+t+"&config=kmc&entryId="+e;var a="trim"==t?"Trimming Tool":"Clipping Tool";kmc.layout.modal.open({width:950,height:616,title:a,content:'',className:"iframe",closeCallback:function(){$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})}})},flashVarsToUrl:function(e){var t="";for(var r in e){var a="object"==typeof e[r]?JSON.stringify(e[r]):e[r];t+="&flashvars["+encodeURIComponent(r)+"]="+encodeURIComponent(a)}return t},versionIsAtLeast:function(e,t){if(!t)return!1;for(var r=e.split("."),a=t.split("."),n=0;r.length>n;n++){if(parseInt(a[n])>parseInt(r[n]))return!0;if(parseInt(a[n]) *").each(function(){e+=$(this).width()});var t=function(){kmc.vars.close_menu=!0;var t={width:0,visibility:"visible",top:"6px",right:"6px"},r={width:e+"px","padding-top":"2px","padding-bottom":"2px"};$("#user_links").css(t),$("#user_links").animate(r,500)};$("#user").hover(t).click(t),$("#user_links").mouseover(function(){kmc.vars.close_menu=!1}),$("#user_links").mouseleave(function(){kmc.vars.close_menu=!0,setTimeout(kmc.utils.closeMenu,650)}),$("#closeMenu").click(function(){kmc.vars.close_menu=!0,kmc.utils.closeMenu()})},closeMenu:function(){kmc.vars.close_menu&&$("#user_links").animate({width:0},500,function(){$("#user_links").css({width:"auto",visibility:"hidden"})})},activateHeader:function(){$("#user_links a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id");switch(t){case"Quickstart Guide":return this.href=kmc.vars.quickstart_guide,!0;case"Logout":return kmc.user.logout(),!1;case"Support":return kmc.user.openSupport(this),!1;case"ChangePartner":return kmc.user.changePartner(),!1;default:return!1}})},resize:function(){var e=$.browser.ie?640:590,t=$(document).height(),r=$.browser.mozilla?37:74;t-=r,t=e>t?e:t,$("#flash_wrap").height(t+"px"),$("#server_wrap iframe").height(t+"px"),$("#server_wrap").css("margin-top","-"+(t+2)+"px")},isModuleLoaded:function(){($("#flash_wrap object").length||$("#flash_wrap embed").length)&&(kmc.utils.resize(),clearInterval(kmc.vars.isLoadedInterval),kmc.vars.isLoadedInterval=null)},debug:function(){try{console.info(" ks: ",kmc.vars.ks),console.info(" partner_id: ",kmc.vars.partner_id)}catch(e){}},maskHeader:function(e){e?$("#mask").hide():$("#mask").show()},createTabs:function(e){if($("#closeMenu").trigger("click"),e){for(var t,r=kmc.vars.service_url+"/index.php/kmc/kmc4",a=e.length,n="",i=0;a>i;i++)t="action"==e[i].type?'class="menu" ':"",n+='
  • '+e[i].display_name+"
  • ";$("#hTabs").html(n);var o=$("body").width()-($("#logo").width()+$("#hTabs").width()+100);$("#user").width()+20>o&&$("#user").width(o),$("#hTabs a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id"),r="A"==e.target.tagName?$(e.target).attr("rel"):$(e.target).parent().attr("rel"),a={moduleName:t,subtab:r};return $("#kcms")[0].gotoPage(a),!1})}else alert("Error geting tabs")},setTab:function(e,t){t&&$("#kmcHeader ul li a").removeClass("active"),$("a#"+e).addClass("active")},resetTab:function(e){$("a#"+e).removeClass("active")},hideFlash:function(e){var t=$("html").hasClass("lt-ie8");e?t?$("#flash_wrap").css("margin-right","3333px"):($("#flash_wrap").css("visibility","hidden"),$("#flash_wrap object").css("visibility","hidden")):t?$("#flash_wrap").css("margin-right","0"):($("#flash_wrap").css("visibility","visible"),$("#flash_wrap object").css("visibility","visible"))},showFlash:function(){$("#server_wrap").hide(),$("#server_frame").removeAttr("src"),kmc.layout.modal.isOpen()||$("#flash_wrap").css("visibility","visible"),$("#server_wrap").css("margin-top",0)},openIframe:function(e){$("#flash_wrap").css("visibility","hidden"),$("#server_frame").attr("src",e),$("#server_wrap").css("margin-top","-"+($("#flash_wrap").height()+2)+"px"),$("#server_wrap").show() +i>5&&(r+=3+i-5)}for(var a=0;t-1>a;a++)for(var n=0;t-1>n;n++){var c=0;e.isDark(a,n)&&c++,e.isDark(a+1,n)&&c++,e.isDark(a,n+1)&&c++,e.isDark(a+1,n+1)&&c++,(0==c||4==c)&&(r+=3)}for(var a=0;t>a;a++)for(var n=0;t-6>n;n++)e.isDark(a,n)&&!e.isDark(a,n+1)&&e.isDark(a,n+2)&&e.isDark(a,n+3)&&e.isDark(a,n+4)&&!e.isDark(a,n+5)&&e.isDark(a,n+6)&&(r+=40);for(var n=0;t>n;n++)for(var a=0;t-6>a;a++)e.isDark(a,n)&&!e.isDark(a+1,n)&&e.isDark(a+2,n)&&e.isDark(a+3,n)&&e.isDark(a+4,n)&&!e.isDark(a+5,n)&&e.isDark(a+6,n)&&(r+=40);for(var d=0,n=0;t>n;n++)for(var a=0;t>a;a++)e.isDark(a,n)&&d++;var h=Math.abs(100*d/t/t-50)/5;return r+=10*h}},h={glog:function(e){if(1>e)throw Error("glog("+e+")");return h.LOG_TABLE[e]},gexp:function(e){for(;0>e;)e+=255;for(;e>=256;)e-=255;return h.EXP_TABLE[e]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},u=0;8>u;u++)h.EXP_TABLE[u]=1<u;u++)h.EXP_TABLE[u]=h.EXP_TABLE[u-4]^h.EXP_TABLE[u-5]^h.EXP_TABLE[u-6]^h.EXP_TABLE[u-8];for(var u=0;255>u;u++)h.LOG_TABLE[h.EXP_TABLE[u]]=u;n.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=Array(this.getLength()+e.getLength()-1),r=0;this.getLength()>r;r++)for(var a=0;e.getLength()>a;a++)t[r+a]^=h.gexp(h.glog(this.get(r))+h.glog(e.get(a)));return new n(t,0)},mod:function(e){if(0>this.getLength()-e.getLength())return this;for(var t=h.glog(this.get(0))-h.glog(e.get(0)),r=Array(this.getLength()),a=0;this.getLength()>a;a++)r[a]=this.get(a);for(var a=0;e.getLength()>a;a++)r[a]^=h.gexp(h.glog(e.get(a))+t);return new n(r,0).mod(e)}},i.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],i.getRSBlocks=function(e,t){var r=i.getRsBlockTable(e,t);if(void 0==r)throw Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+t);for(var a=r.length/3,n=[],o=0;a>o;o++)for(var s=r[3*o+0],l=r[3*o+1],c=r[3*o+2],d=0;s>d;d++)n.push(new i(l,c));return n},i.getRsBlockTable=function(e,t){switch(t){case l.L:return i.RS_BLOCK_TABLE[4*(e-1)+0];case l.M:return i.RS_BLOCK_TABLE[4*(e-1)+1];case l.Q:return i.RS_BLOCK_TABLE[4*(e-1)+2];case l.H:return i.RS_BLOCK_TABLE[4*(e-1)+3];default:return void 0}},o.prototype={get:function(e){var t=Math.floor(e/8);return 1==(1&this.buffer[t]>>>7-e%8)},put:function(e,t){for(var r=0;t>r;r++)this.putBit(1==(1&e>>>t-r-1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);t>=this.buffer.length&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},"string"==typeof t&&(t={text:t}),t=e.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,correctLevel:l.H,background:"#ffffff",foreground:"#000000"},t);var p=function(){var e=new a(t.typeNumber,t.correctLevel);e.addData(t.text),e.make();var r=document.createElement("canvas");r.width=t.width,r.height=t.height;for(var n=r.getContext("2d"),i=t.width/e.getModuleCount(),o=t.height/e.getModuleCount(),s=0;e.getModuleCount()>s;s++)for(var l=0;e.getModuleCount()>l;l++){n.fillStyle=e.isDark(s,l)?t.foreground:t.background;var c=Math.ceil((l+1)*i)-Math.floor(l*i),d=Math.ceil((s+1)*i)-Math.floor(s*i);n.fillRect(Math.round(l*i),Math.round(s*o),c,d)}return r},f=function(){var r=new a(t.typeNumber,t.correctLevel);r.addData(t.text),r.make();for(var n=e("
    ").css("width",t.width+"px").css("height",t.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",t.background),i=t.width/r.getModuleCount(),o=t.height/r.getModuleCount(),s=0;r.getModuleCount()>s;s++)for(var l=e("").css("height",o+"px").appendTo(n),c=0;r.getModuleCount()>c;c++)e("").css("width",i+"px").css("background-color",r.isDark(s,c)?t.foreground:t.background).appendTo(l);return n};return this.each(function(){var r="canvas"==t.render?p():f();e(r).appendTo(this)})}}(jQuery),window.XDomainRequest&&jQuery.ajaxTransport(function(e){if(e.crossDomain&&e.async){e.timeout&&(e.xdrTimeout=e.timeout,delete e.timeout);var t;return{send:function(r,a){function n(e,r,n,i){t.onload=t.onerror=t.ontimeout=jQuery.noop,t=void 0,a(e,r,n,i)}t=new XDomainRequest,t.onload=function(){n(200,"OK",{text:t.responseText},"Content-Type: "+t.contentType)},t.onerror=function(){n(404,"Not Found")},t.onprogress=jQuery.noop,t.ontimeout=function(){n(0,"timeout")},t.timeout=e.xdrTimeout||Number.MAX_VALUE,t.open(e.type,e.url),t.send(e.hasContent&&e.data||null)},abort:function(){t&&(t.onerror=jQuery.noop,t.abort())}}}}),function(){"use strict";var e,t=function(e,t){var r=e.style[t];if(e.currentStyle?r=e.currentStyle[t]:window.getComputedStyle&&(r=document.defaultView.getComputedStyle(e,null).getPropertyValue(t)),"auto"==r&&"cursor"==t)for(var a=["a"],n=0;a.length>n;n++)if(e.tagName.toLowerCase()==a[n])return"pointer";return r},r=function(e){if(u.prototype._singleton){e||(e=window.event);var t;this!==window?t=this:e.target?t=e.target:e.srcElement&&(t=e.srcElement),u.prototype._singleton.setCurrent(t)}},a=function(e,t,r){e.addEventListener?e.addEventListener(t,r,!1):e.attachEvent&&e.attachEvent("on"+t,r)},n=function(e,t,r){e.removeEventListener?e.removeEventListener(t,r,!1):e.detachEvent&&e.detachEvent("on"+t,r)},i=function(e,t){if(e.addClass)return e.addClass(t),e;if(t&&"string"==typeof t){var r=(t||"").split(/\s+/);if(1===e.nodeType)if(e.className){for(var a=" "+e.className+" ",n=e.className,i=0,o=r.length;o>i;i++)0>a.indexOf(" "+r[i]+" ")&&(n+=" "+r[i]);e.className=n.replace(/^\s+|\s+$/g,"")}else e.className=t}return e},o=function(e,t){if(e.removeClass)return e.removeClass(t),e;if(t&&"string"==typeof t||void 0===t){var r=(t||"").split(/\s+/);if(1===e.nodeType&&e.className)if(t){for(var a=(" "+e.className+" ").replace(/[\n\t]/g," "),n=0,i=r.length;i>n;n++)a=a.replace(" "+r[n]+" "," ");e.className=a.replace(/^\s+|\s+$/g,"")}else e.className=""}return e},s=function(e){var r={left:0,top:0,width:e.width||e.offsetWidth||0,height:e.height||e.offsetHeight||0,zIndex:9999},a=t(e,"zIndex");for(a&&"auto"!=a&&(r.zIndex=parseInt(a,10));e;){var n=parseInt(t(e,"borderLeftWidth"),10),i=parseInt(t(e,"borderTopWidth"),10);r.left+=isNaN(e.offsetLeft)?0:e.offsetLeft,r.left+=isNaN(n)?0:n,r.top+=isNaN(e.offsetTop)?0:e.offsetTop,r.top+=isNaN(i)?0:i,e=e.offsetParent}return r},l=function(e){return(e.indexOf("?")>=0?"&":"?")+"nocache="+(new Date).getTime()},c=function(e){var t=[];return e.trustedDomains&&("string"==typeof e.trustedDomains?t.push("trustedDomain="+e.trustedDomains):t.push("trustedDomain="+e.trustedDomains.join(","))),t.join("&")},d=function(e,t){if(t.indexOf)return t.indexOf(e);for(var r=0,a=t.length;a>r;r++)if(t[r]===e)return r;return-1},h=function(e){if("string"==typeof e)throw new TypeError("ZeroClipboard doesn't accept query strings.");return e.length?e:[e]},u=function(e,t){if(e&&(u.prototype._singleton||this).glue(e),u.prototype._singleton)return u.prototype._singleton;u.prototype._singleton=this,this.options={};for(var r in f)this.options[r]=f[r];for(var a in t)this.options[a]=t[a];this.handlers={},u.detectFlashSupport()&&m()},p=[];u.prototype.setCurrent=function(r){e=r,this.reposition(),r.getAttribute("title")&&this.setTitle(r.getAttribute("title")),this.setHandCursor("pointer"==t(r,"cursor"))},u.prototype.setText=function(e){e&&""!==e&&(this.options.text=e,this.ready()&&this.flashBridge.setText(e))},u.prototype.setTitle=function(e){e&&""!==e&&this.htmlBridge.setAttribute("title",e)},u.prototype.setSize=function(e,t){this.ready()&&this.flashBridge.setSize(e,t)},u.prototype.setHandCursor=function(e){this.ready()&&this.flashBridge.setHandCursor(e)},u.version="1.1.7";var f={moviePath:"ZeroClipboard.swf",trustedDomains:null,text:null,hoverClass:"zeroclipboard-is-hover",activeClass:"zeroclipboard-is-active",allowScriptAccess:"sameDomain"};u.setDefaults=function(e){for(var t in e)f[t]=e[t]},u.destroy=function(){u.prototype._singleton.unglue(p);var e=u.prototype._singleton.htmlBridge;e.parentNode.removeChild(e),delete u.prototype._singleton},u.detectFlashSupport=function(){var e=!1;try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(e=!0)}catch(t){navigator.mimeTypes["application/x-shockwave-flash"]&&(e=!0)}return e};var m=function(){var e=u.prototype._singleton,t=document.getElementById("global-zeroclipboard-html-bridge");if(!t){var r=' ';t=document.createElement("div"),t.id="global-zeroclipboard-html-bridge",t.setAttribute("class","global-zeroclipboard-container"),t.setAttribute("data-clipboard-ready",!1),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="15px",t.style.height="15px",t.style.zIndex="9999",t.innerHTML=r,document.body.appendChild(t)}e.htmlBridge=t,e.flashBridge=document["global-zeroclipboard-flash-bridge"]||t.children[0].lastElementChild};u.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),o(e,this.options.activeClass),e=null,this.options.text=null},u.prototype.ready=function(){var e=this.htmlBridge.getAttribute("data-clipboard-ready");return"true"===e||e===!0},u.prototype.reposition=function(){if(!e)return!1;var t=s(e);this.htmlBridge.style.top=t.top+"px",this.htmlBridge.style.left=t.left+"px",this.htmlBridge.style.width=t.width+"px",this.htmlBridge.style.height=t.height+"px",this.htmlBridge.style.zIndex=t.zIndex+1,this.setSize(t.width,t.height)},u.dispatch=function(e,t){u.prototype._singleton.receiveEvent(e,t)},u.prototype.on=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++)e=r[a].toLowerCase().replace(/^on/,""),this.handlers[e]||(this.handlers[e]=t);this.handlers.noflash&&!u.detectFlashSupport()&&this.receiveEvent("onNoFlash",null)},u.prototype.addEventListener=u.prototype.on,u.prototype.off=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++){e=r[a].toLowerCase().replace(/^on/,"");for(var n in this.handlers)n===e&&this.handlers[n]===t&&delete this.handlers[n]}},u.prototype.removeEventListener=u.prototype.off,u.prototype.receiveEvent=function(t,r){t=(""+t).toLowerCase().replace(/^on/,"");var a=e;switch(t){case"load":if(r&&10>parseFloat(r.flashVersion.replace(",",".").replace(/[^0-9\.]/gi,"")))return this.receiveEvent("onWrongFlash",{flashVersion:r.flashVersion}),void 0;this.htmlBridge.setAttribute("data-clipboard-ready",!0);break;case"mouseover":i(a,this.options.hoverClass);break;case"mouseout":o(a,this.options.hoverClass),this.resetBridge();break;case"mousedown":i(a,this.options.activeClass);break;case"mouseup":o(a,this.options.activeClass);break;case"datarequested":var n=a.getAttribute("data-clipboard-target"),s=n?document.getElementById(n):null;if(s){var l=s.value||s.textContent||s.innerText;l&&this.setText(l)}else{var c=a.getAttribute("data-clipboard-text");c&&this.setText(c)}break;case"complete":this.options.text=null}if(this.handlers[t]){var d=this.handlers[t];"function"==typeof d?d.call(a,this,r):"string"==typeof d&&window[d].call(a,this,r)}},u.prototype.glue=function(e){e=h(e);for(var t=0;e.length>t;t++)-1==d(e[t],p)&&(p.push(e[t]),a(e[t],"mouseover",r))},u.prototype.unglue=function(e){e=h(e);for(var t=0;e.length>t;t++){n(e[t],"mouseover",r);var a=d(e[t],p);-1!=a&&p.splice(a,1)}},"undefined"!=typeof module?module.exports=u:"function"==typeof define&&define.amd?define(function(){return u}):window.ZeroClipboard=u}(),function(e){var t=e.Preview||{};e.vars.previewDefaults={showAdvancedOptions:!1,includeKalturaLinks:!e.vars.ignore_seo_links,includeSeoMetadata:!e.vars.ignore_entry_seo,deliveryType:e.vars.default_delivery_type,embedType:e.vars.default_embed_code_type,secureEmbed:e.vars.embed_code_protocol_https},"https:"==window.location.protocol&&(e.vars.previewDefaults.secureEmbed=!0),t.storageName="previewDefaults",t.el="#previewModal",t.iframeContainer="previewIframe",t.ignoreChangeEvents=!0,t.getGenerator=function(){return this.generator||(this.generator=new kEmbedCodeGenerator({host:e.vars.embed_host,securedHost:e.vars.embed_host_https,partnerId:e.vars.partner_id,includeKalturaLinks:e.vars.previewDefaults.includeKalturaLinks})),this.generator},t.clipboard=new ZeroClipboard($(".copy-code"),{moviePath:"/lib/flash/ZeroClipboard.swf",trustedDomains:["*"],allowScriptAccess:"always"}),t.clipboard.on("complete",function(){var e=$(this);$("#"+e.data("clipboard-target")).select(),e.data("close")===!0&&t.closeModal(t.el)}),t.objectToArray=function(e){var t=[];for(var r in e)e[r].id=r,t.push(e[r]);return t},t.getObjectById=function(e,t){var r=$.grep(t,function(t){return t.id==e});return r.length?r[0]:!1},t.getDefault=function(r){var a=localStorage.getItem(t.storageName);return a=a?JSON.parse(a):e.vars.previewDefaults,void 0!==a[r]?a[r]:null},t.savePreviewState=function(){var e=this.Service,r={embedType:e.get("embedType"),secureEmbed:e.get("secureEmbed"),includeSeoMetadata:e.get("includeSeo"),deliveryType:e.get("deliveryType").id,showAdvancedOptions:e.get("showAdvancedOptions")};localStorage.setItem(t.storageName,JSON.stringify(r))},t.getDeliveryTypeFlashVars=function(e){if(!e)return{};var t=e.flashvars?e.flashvars:{},r=$.extend({},t);return e.streamerType&&(r.streamerType=e.streamerType),e.mediaProtocol&&(r.mediaProtocol=e.mediaProtocol),r},t.getPreviewTitle=function(e){return e.entryMeta&&e.entryMeta.name?"Embedding: "+e.entryMeta.name:e.playlistName?"Playlist: "+e.playlistName:e.playerOnly?"Player Name:"+e.name:void 0},t.openPreviewEmbed=function(t,r){var a=this,n=a.el;this.ignoreChangeEvents=!1;var i={entryId:null,entryMeta:{},playlistId:null,playlistName:null,previewOnly:!1,liveBitrates:null,playerOnly:!1,uiConfId:null,name:null};t=$.extend({},i,t),t.liveBitrates&&r.setDeliveryType("auto"),r.updatePlayers(t),r.set(t);var o=this.getPreviewTitle(t),s=$(n);s.find(".title h2").text(o).attr("title",o),s.find(".close").unbind("click").click(function(){a.closeModal(n)});var l=$("body").height()-173;s.find(".content").height(l),e.layout.modal.show(n,!1)},t.closeModal=function(t){this.savePreviewState(),this.emptyDiv(this.iframeContainer),$(t).fadeOut(300,function(){e.layout.overlay.hide(),e.utils.hideFlash()})},t.emptyDiv=function(e){var t=$("#"+e),r=$("#previewIframe iframe");if(r.length)try{var a=$(r[0].contentWindow.document);a.find("#framePlayerContainer").empty()}catch(n){}return t.length?(t.empty(),t[0]):!1},t.hasIframe=function(){return $("#"+this.iframeContainer+" iframe").length},t.getCacheSt=function(){var e=new Date;return Math.floor(e.getTime()/1e3)+900},t.generateIframe=function(e){var t=$("html").hasClass("lt-ie10"),r="",a=this.emptyDiv(this.iframeContainer),n=document.createElement("iframe");if(n.frameborder="0",n.frameBorder="0",n.marginheight="0",n.marginwidth="0",n.frameborder="0",a.appendChild(n),t)n.src=this.getPreviewUrl(this.Service,!0);else{var i=n.contentDocument;i.open(),i.write(""+r+'
    '+e+"
    "),i.close()}},t.getEmbedProtocol=function(e,t){return t===!0?location.protocol.substring(0,location.protocol.length-1):e.get("secureEmbed")?"https":"http"},t.getEmbedFlashVars=function(t,r){var a=this.getEmbedProtocol(t,r),n=t.get("player"),i=this.getDeliveryTypeFlashVars(t.get("deliveryType"));r===!0&&(i.ks=e.vars.ks);var o=t.get("playlistId");if(o){var s=e.functions.getVersionFromPath(n.html5Url),l=e.functions.versionIsAtLeast(e.vars.min_kdp_version_for_playlist_api_v3,n.swf_version),c=e.functions.versionIsAtLeast(e.vars.min_html5_version_for_playlist_api_v3,s);l&&c?i["playlistAPI.kpl0Id"]=o:(i["playlistAPI.autoInsert"]="true",i["playlistAPI.kpl0Name"]=t.get("playlistName"),i["playlistAPI.kpl0Url"]=a+"://"+e.vars.api_host+"/index.php/partnerservices2/executeplaylist?"+"partner_id="+e.vars.partner_id+"&subp_id="+e.vars.partner_id+"00"+"&format=8&ks={ks}&playlist_id="+o)}return i},t.getEmbedCode=function(e,t){var r=e.get("player");if(!r||!e.get("embedType"))return"";var a=this.getCacheSt(),n={protocol:this.getEmbedProtocol(e,t),embedType:e.get("embedType"),uiConfId:r.id,width:r.width,height:r.height,entryMeta:e.get("entryMeta"),includeSeoMetadata:e.get("includeSeo"),playerId:"kaltura_player_"+a,cacheSt:a,flashVars:this.getEmbedFlashVars(e,t)};e.get("entryId")&&(n.entryId=e.get("entryId"));var i=this.getGenerator().getCode(n);return i},t.getPreviewUrl=function(t,r){var a=t.get("player");if(!a||!t.get("embedType"))return"";var n=this.getEmbedProtocol(t,r),i=n+"://"+e.vars.api_host+"/index.php/extwidget/preview";return i+="/partner_id/"+e.vars.partner_id,i+="/uiconf_id/"+a.id,t.get("entryId")&&(i+="/entry_id/"+t.get("entryId")),i+="/embed/"+t.get("embedType"),i+="?"+e.functions.flashVarsToUrl(this.getEmbedFlashVars(t,r)),r===!0&&(i+="&framed=true"),i},t.generateQrCode=function(e){var t=$("#qrcode").empty();e&&($("html").hasClass("lt-ie9")||t.qrcode({width:80,height:80,text:e}))},t.generateShortUrl=function(t,r){t&&e.client.createShortURL(t,r)},e.Preview=t}(window.kmc);var kmcApp=angular.module("kmcApp",[]);kmcApp.factory("previewService",["$rootScope",function(e){var t={};return{get:function(e){return void 0===e?t:t[e]},set:function(r,a,n){"object"==typeof r?angular.extend(t,r):t[r]=a,n||e.$broadcast("previewChanged")},updatePlayers:function(t){e.$broadcast("playersUpdated",t)},changePlayer:function(t){e.$broadcast("changePlayer",t)},setDeliveryType:function(t){e.$broadcast("changeDelivery",t)}}}]),kmcApp.directive("showSlide",function(){return{restrict:"A",link:function(e,t,r){r.showSlide,e.$watch(r.showSlide,function(e){e&&!t.is(":visible")?t.slideDown():t.slideUp()})}}}),kmcApp.controller("PreviewCtrl",["$scope","previewService",function(e,t){var r=function(){e.$$phase||e.$apply()},a=kmc.Preview;a.playlistMode=!1,a.Service=t;var n=function(t){t=t||{};var r=t.uiConfId?t.uiConfId:void 0;kmc.vars.playlists_list&&kmc.vars.players_list&&(t.playlistId||t.playerOnly?(e.players=kmc.vars.playlists_list,a.playlistMode||(a.playlistMode=!0,e.$broadcast("changePlayer",r))):(e.players=kmc.vars.players_list,(a.playlistMode||!e.player)&&(a.playlistMode=!1,e.$broadcast("changePlayer",r))),r&&e.$broadcast("changePlayer",r))},i=function(r){var n=a.objectToArray(kmc.vars.delivery_types),i=e.deliveryType||a.getDefault("deliveryType"),o=[];$.each(n,function(){return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,r.swf_version)?(this.id==i&&(i=null),!0):(o.push(this),void 0)}),e.deliveryTypes=o,i||(i=e.deliveryTypes[0].id),t.setDeliveryType(i)},o=function(t){var r=a.objectToArray(kmc.vars.embed_code_types),n=e.embedType||a.getDefault("embedType"),i=[];$.each(r,function(){if(a.playlistMode&&this.entryOnly)return this.id==n&&(n=null),!0;var e=kmc.functions.getVersionFromPath(t.html5Url);return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,e)?(this.id==n&&(n=null),!0):(i.push(this),void 0)}),e.embedTypes=i,n||(n=e.embedTypes[0].id),e.embedType=n};e.players=[],e.player=null,e.deliveryTypes=[],e.deliveryType=null,e.embedTypes=[],e.embedType=null,e.secureEmbed=a.getDefault("secureEmbed"),e.includeSeo=a.getDefault("includeSeoMetadata"),e.previewOnly=!1,e.playerOnly=!1,e.liveBitrates=!1,e.showAdvancedOptionsStatus=a.getDefault("showAdvancedOptions"),e.shortLinkGenerated=!1,e.$on("playersUpdated",function(e,t){n(t)}),e.$on("changePlayer",function(t,a){a=a?a:e.players[0].id,e.player=a,r()}),e.$on("changeDelivery",function(t,a){e.deliveryType=a,r()}),e.showAdvancedOptions=function(r,a){r.preventDefault(),t.set("showAdvancedOptions",a,!0),e.showAdvancedOptionsStatus=a},e.$watch("showAdvancedOptionsStatus",function(){a.clipboard.reposition()}),e.$watch("player",function(){var r=a.getObjectById(e.player,e.players);r&&(i(r),o(r),t.set("player",r))}),e.$watch("deliveryType",function(){t.set("deliveryType",a.getObjectById(e.deliveryType,e.deliveryTypes))}),e.$watch("embedType",function(){t.set("embedType",e.embedType)}),e.$watch("secureEmbed",function(){t.set("secureEmbed",e.secureEmbed)}),e.$watch("includeSeo",function(){t.set("includeSeo",e.includeSeo)}),e.$watch("embedCodePreview",function(){a.generateIframe(e.embedCodePreview)}),e.$watch("previewOnly",function(){e.closeButtonText=e.previewOnly?"Close":"Copy Embed & Close",r()}),e.$on("previewChanged",function(){if(!a.ignoreChangeEvents){var n=a.getPreviewUrl(t);e.embedCode=a.getEmbedCode(t),e.embedCodePreview=a.getEmbedCode(t,!0),e.previewOnly=t.get("previewOnly"),e.playerOnly=t.get("playerOnly"),e.liveBitrates=t.get("liveBitrates"),r(),a.hasIframe()||a.generateIframe(e.embedCodePreview),e.previewUrl="Updating...",e.shortLinkGenerated=!1,a.generateShortUrl(n,function(t){t||(t=n),e.shortLinkGenerated=!0,e.previewUrl=t,a.generateQrCode(t),r()})}})}]),0==kmc.vars.allowFrame&&top!=window&&(top.location=window.location),kmc.vars.debug=!1,kmc.vars.quickstart_guide="/content/docs/pdf/KMC_User_Manual.pdf",kmc.vars.help_url=kmc.vars.service_url+"/kmc5help.html",kmc.vars.port=window.location.port?":"+window.location.port:"",kmc.vars.base_host=window.location.hostname+kmc.vars.port,kmc.vars.base_url=window.location.protocol+"//"+kmc.vars.base_host,kmc.vars.api_host=kmc.vars.host,kmc.vars.api_url=window.location.protocol+"//"+kmc.vars.api_host,kmc.vars.min_kdp_version_for_playlist_api_v3="3.6.15",kmc.vars.min_html5_version_for_playlist_api_v3="1.7.1.3",kmc.log=function(){if(kmc.vars.debug&&"undefined"!=typeof console&&console.log)if(1==arguments.length)console.log(arguments[0]);else{var e=Array.prototype.slice.call(arguments);console.log(e[0],e.slice(1))}},kmc.functions={loadSwf:function(){var e=window.location.protocol+"//"+kmc.vars.cdn_host+"/flash/kmc/"+kmc.vars.kmc_version+"/kmc.swf",t={kmc_uiconf:kmc.vars.kmc_general_uiconf,permission_uiconf:kmc.vars.kmc_permissions_uiconf,host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,srvurl:"api_v3/index.php",protocol:window.location.protocol+"//",partnerid:kmc.vars.partner_id,subpid:kmc.vars.partner_id+"00",ks:kmc.vars.ks,entryId:"-1",kshowId:"-1",debugmode:"true",widget_id:"_"+kmc.vars.partner_id,urchinNumber:kmc.vars.google_analytics_account,firstLogin:kmc.vars.first_login,openPlayer:"kmc.preview_embed.doPreviewEmbed",openPlaylist:"kmc.preview_embed.doPreviewEmbed",openCw:"kmc.functions.openKcw",language:kmc.vars.language||""};kmc.vars.disable_analytics&&(t.disableAnalytics=!0);var r={allowNetworking:"all",allowScriptAccess:"always"};swfobject.embedSWF(e,"kcms","100%","100%","10.0.0",!1,t,r),$("#kcms").attr("style","")},checkForOngoingProcess:function(){var e;try{e=$("#kcms")[0].hasOngoingProcess()}catch(t){e=null}return null!==e?e:void 0},expired:function(){kmc.user.logout()},openKcw:function(e,t){e=e||"";var r="uploadWebCam"==t?kmc.vars.kcw_webcam_uiconf:kmc.vars.kcw_import_uiconf,a={host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,protocol:window.location.protocol.slice(0,-1),partnerid:kmc.vars.partner_id,subPartnerId:kmc.vars.partner_id+"00",sessionId:kmc.vars.ks,devFlag:"true",entryId:"-1",kshow_id:"-1",terms_of_use:kmc.vars.terms_of_use,close:"kmc.functions.onCloseKcw",quick_edit:0,kvar_conversionQuality:e},n={allowscriptaccess:"always",allownetworking:"all",bgcolor:"#DBE3E9",quality:"high",movie:kmc.vars.service_url+"/kcw/ui_conf_id/"+r};kmc.layout.modal.open({width:700,height:420,content:'
    '}),swfobject.embedSWF(n.movie,"kcw","680","400","9.0.0",!1,a,n)},onCloseKcw:function(){kmc.layout.modal.close(),$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})},openChangePwd:function(){kmc.user.changeSetting("password")},openChangeEmail:function(){kmc.user.changeSetting("email")},openChangeName:function(){kmc.user.changeSetting("name")},getAddPanelPosition:function(){var e=$("#add").parent();return e.position().left+e.width()-10},openClipApp:function(e,t){var r=kmc.vars.base_url+"/apps/clipapp/"+kmc.vars.clipapp.version;r+="/?kdpUiconf="+kmc.vars.clipapp.kdp+"&kclipUiconf="+kmc.vars.clipapp.kclip,r+="&partnerId="+kmc.vars.partner_id+"&host="+kmc.vars.host+"&mode="+t+"&config=kmc&entryId="+e;var a="trim"==t?"Trimming Tool":"Clipping Tool";kmc.layout.modal.open({width:950,height:616,title:a,content:'',className:"iframe",closeCallback:function(){$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})}})},flashVarsToUrl:function(e){var t="";for(var r in e){var a="object"==typeof e[r]?JSON.stringify(e[r]):e[r];t+="&flashvars["+encodeURIComponent(r)+"]="+encodeURIComponent(a)}return t},versionIsAtLeast:function(e,t){if(!t)return!1;for(var r=e.split("."),a=t.split("."),n=0;r.length>n;n++){if(parseInt(a[n])>parseInt(r[n]))return!0;if(parseInt(a[n]) *").each(function(){e+=$(this).width()});var t=function(){kmc.vars.close_menu=!0;var t={width:0,visibility:"visible",top:"6px",right:"6px"},r={width:e+"px","padding-top":"2px","padding-bottom":"2px"};$("#user_links").css(t),$("#user_links").animate(r,500)};$("#user").hover(t).click(t),$("#user_links").mouseover(function(){kmc.vars.close_menu=!1}),$("#user_links").mouseleave(function(){kmc.vars.close_menu=!0,setTimeout(kmc.utils.closeMenu,650)}),$("#closeMenu").click(function(){kmc.vars.close_menu=!0,kmc.utils.closeMenu()})},closeMenu:function(){kmc.vars.close_menu&&$("#user_links").animate({width:0},500,function(){$("#user_links").css({width:"auto",visibility:"hidden"})})},activateHeader:function(){$("#user_links a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id");switch(t){case"Quickstart Guide":return this.href=kmc.vars.quickstart_guide,!0;case"Logout":return kmc.user.logout(),!1;case"Support":return kmc.user.openSupport(this),!1;case"ChangePartner":return kmc.user.changePartner(),!1;default:return!1}})},resize:function(){var e=$.browser.ie?640:590,t=$(document).height(),r=$.browser.mozilla?37:74;t-=r,t=e>t?e:t,$("#flash_wrap").height(t+"px"),$("#server_wrap iframe").height(t+"px"),$("#server_wrap").css("margin-top","-"+(t+2)+"px")},isModuleLoaded:function(){($("#flash_wrap object").length||$("#flash_wrap embed").length)&&(kmc.utils.resize(),clearInterval(kmc.vars.isLoadedInterval),kmc.vars.isLoadedInterval=null)},debug:function(){try{console.info(" ks: ",kmc.vars.ks),console.info(" partner_id: ",kmc.vars.partner_id)}catch(e){}},maskHeader:function(e){e?$("#mask").hide():$("#mask").show()},createTabs:function(e){if($("#closeMenu").trigger("click"),e){for(var t,r=kmc.vars.service_url+"/index.php/kmc/kmc4",a=e.length,n="",i=0;a>i;i++)t="action"==e[i].type?'class="menu" ':"",n+='
  • '+e[i].display_name+"
  • ";$("#hTabs").html(n);var o=$("body").width()-($("#logo").width()+$("#hTabs").width()+100);$("#user").width()+20>o&&$("#user").width(o),$("#hTabs a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id"),r="A"==e.target.tagName?$(e.target).attr("rel"):$(e.target).parent().attr("rel"),a={moduleName:t,subtab:r};return $("#kcms")[0].gotoPage(a),!1})}else alert("Error geting tabs")},setTab:function(e,t){t&&$("#kmcHeader ul li a").removeClass("active"),$("a#"+e).addClass("active")},resetTab:function(e){$("a#"+e).removeClass("active")},hideFlash:function(e){var t=$("html").hasClass("lt-ie8");e?t?$("#flash_wrap").css("margin-right","3333px"):($("#flash_wrap").css("visibility","hidden"),$("#flash_wrap object").css("visibility","hidden")):t?$("#flash_wrap").css("margin-right","0"):($("#flash_wrap").css("visibility","visible"),$("#flash_wrap object").css("visibility","visible"))},showFlash:function(){$("#server_wrap").hide(),$("#server_frame").removeAttr("src"),kmc.layout.modal.isOpen()||$("#flash_wrap").css("visibility","visible"),$("#server_wrap").css("margin-top",0)},openIframe:function(e){$("#flash_wrap").css("visibility","hidden"),$("#server_frame").attr("src",e),$("#server_wrap").css("margin-top","-"+($("#flash_wrap").height()+2)+"px"),$("#server_wrap").show() },openHelp:function(e){$("#kcms")[0].doHelp(e)},setClientIP:function(){kmc.vars.clientIP="",kmc.vars.akamaiEdgeServerIpURL&&$.ajax({url:window.location.protocol+"//"+kmc.vars.akamaiEdgeServerIpURL,crossDomain:!0,success:function(e){kmc.vars.clientIP=$(e).find("serverip").text()}})},getClientIP:function(){return kmc.vars.clientIP}},kmc.mediator={writeUrlHash:function(e,t){location.hash=e+"|"+t,document.title="KMC > "+e+(t&&""!==t?" > "+t+" |":"")},readUrlHash:function(){var e,t,r="dashboard",a="",n={};try{e=location.hash.split("#")[1].split("|")}catch(i){t=!0}if(!t&&""!==e[0]){if(r=e[0],a=e[1],e[2])for(var o=e[2].split("&"),s=0;o.length>s;s++){var l=o[s].split(":");n[l[0]]=l[1]}switch(r){case"content":switch(a){case"Moderate":a="moderation";break;case"Syndicate":a="syndication"}a=a.toLowerCase();break;case"appstudio":r="studio",a="playersList";break;case"Settings":switch(r="account",a){case"Account_Settings":a="overview";break;case"Integration Settings":a="integration";break;case"Access Control":a="accessControl";break;case"Transcoding Settings":a="transcoding";break;case"Account Upgrade":a="upgrade"}break;case"reports":r="analytics","Bandwidth Usage Reports"==a&&(a="usageTabTitle")}}return{moduleName:r,subtab:a,extra:n}}},kmc.preview_embed={doPreviewEmbed:function(e,t,r,a,n,i,o){var s={previewOnly:a};i&&(s.uiConfId=parseInt(i)),n?"multitab_playlist"==e?(s.playerOnly=!0,s.name=t):(s.playlistId=e,s.playlistName=t):(s.entryId=e,s.entryMeta={name:t,description:r},o&&(s.liveBitrates=o)),kmc.Preview.openPreviewEmbed(s,kmc.Preview.Service)},doFlavorPreview:function(e,t,r){var a=kmc.vars.default_kdp,n=kmc.Preview.getGenerator().getCode({protocol:location.protocol.substring(0,location.protocol.length-1),embedType:"legacy",entryId:e,uiConfId:parseInt(a.id),width:a.width,height:a.height,includeSeoMetadata:!1,includeHtml5Library:!1,flashVars:{ks:kmc.vars.ks,flavorId:r.asset_id}}),i='
    '+n+"
    "+"
    Entry Name:
     "+t+"
    "+"
    Entry Id:
     "+e+"
    "+"
    Flavor Name:
     "+r.flavor_name+"
    "+"
    Flavor Asset Id:
     "+r.asset_id+"
    "+"
    Bitrate:
     "+r.bitrate+"
    "+"
    Codec:
     "+r.codec+"
    "+"
    Dimensions:
     "+r.dimensions.width+" x "+r.dimensions.height+"
    "+"
    Format:
     "+r.format+"
    "+"
    Size (KB):
     "+r.sizeKB+"
    "+"
    Status:
     "+r.status+"
    "+"
    ";kmc.layout.modal.open({width:parseInt(a.width)+120,height:parseInt(a.height)+300,title:"Flavor Preview",content:'
    '+i+"
    "})},updateList:function(e){var t=e?"playlist":"player";$.ajax({url:kmc.vars.base_url+kmc.vars.getuiconfs_url,type:"POST",data:{type:t,partner_id:kmc.vars.partner_id,ks:kmc.vars.ks},dataType:"json",success:function(t){t&&t.length&&(e?kmc.vars.playlists_list=t:kmc.vars.players_list=t,kmc.Preview.Service.updatePlayers())}})}},kmc.client={makeRequest:function(e,t,r,a){var n=kmc.vars.api_url+"/api_v3/index.php?service="+e+"&action="+t,i={ks:kmc.vars.ks,format:9};$.extend(r,i);var o=function(e){var t=[],r=[],a=0;for(var n in e)r[a++]=n+"|"+e[n];r=r.sort();for(var i=0;r.length>i;i++){var o=r[i].split("|");t[o[0]]=o[1]}return t},s=function(e){e=o(e);var t="";for(var r in e){var a=e[r];t+=a+r}return md5(t)},l=s(r);n+="&kalsig="+l,$.ajax({type:"GET",url:n,dataType:"jsonp",data:r,cache:!1,success:a})},createShortURL:function(e,t){kmc.log("createShortURL");var r={"shortLink:objectType":"KalturaShortLink","shortLink:systemName":"KMC-PREVIEW","shortLink:fullUrl":e};kmc.client.makeRequest("shortlink_shortlink","add",r,function(e){var r=!1;t?(e.id&&(r=kmc.vars.service_url+"/tiny/"+e.id),t(r)):kmc.preview_embed.setShortURL(e.id)})}},kmc.layout={init:function(){$("#kmcHeader").bind("click",function(){$("#hTabs a").each(function(e,t){var r=$(t);return r.hasClass("menu")&&r.hasClass("active")?($("#kcms")[0].gotoPage({moduleName:r.attr("id"),subtab:r.attr("rel")}),void 0):!0})}),$("body").append('
    ')},overlay:{show:function(){$("#overlay").show()},hide:function(){$("#overlay").hide()}},modal:{el:"#modal",create:function(e){var t={el:kmc.layout.modal.el,title:"",content:"",help:"",width:680,height:"auto",className:""};$.extend(t,e);var r=$(t.el),a=r.find(".title h2"),n=r.find(".content");return t.className="modal "+t.className,r.css({width:t.width,height:t.height}).attr("class",t.className),t.title?a.text(t.title).attr("title",t.title).parent().show():(a.parent().hide(),n.addClass("flash_only")),r.find(".help").remove(),a.parent().append(t.help),n[0].innerHTML=t.content,r.find(".close").click(function(){kmc.layout.modal.close(t.el),$.isFunction(e.closeCallback)&&e.closeCallback()}),r},show:function(e,t){t=void 0===t?!0:t,e=e||kmc.layout.modal.el;var r=$(e);kmc.utils.hideFlash(!0),kmc.layout.overlay.show(),r.fadeIn(600),$.browser.msie||r.css("display","table"),t&&this.position(e)},open:function(e){this.create(e);var t=e.el||kmc.layout.modal.el;this.show(t)},position:function(e){e=e||kmc.layout.modal.el;var t=$(e),r=($(window).height()-t.height())/2,a=($(window).width()-t.width())/(2+$(window).scrollLeft());r=40>r?40:r,t.css({top:r+"px",left:a+"px"})},close:function(e){e=e||kmc.layout.modal.el,$(e).fadeOut(300,function(){$(e).find(".content").html(""),kmc.layout.overlay.hide(),kmc.utils.hideFlash()})},isOpen:function(e){return e=e||kmc.layout.modal.el,$(e).is(":visible")}}},kmc.user={openSupport:function(e){var t=e.href;kmc.utils.hideFlash(!0),kmc.layout.overlay.show();var r='';kmc.layout.modal.create({width:550,title:"Support Request",content:r}),$("#support").load(function(){kmc.layout.modal.show(),kmc.vars.support_frame_height||(kmc.vars.support_frame_height=$("#support")[0].contentWindow.document.body.scrollHeight),$("#support").height(kmc.vars.support_frame_height),kmc.layout.modal.position()})},logout:function(){var e=kmc.functions.checkForOngoingProcess();if(e)return alert(e),!1;var t=kmc.mediator.readUrlHash();$.ajax({url:kmc.vars.base_url+"/index.php/kmc/logout",type:"POST",data:{ks:kmc.vars.ks},dataType:"json",complete:function(){window.location=kmc.vars.logoutUrl?kmc.vars.logoutUrl:kmc.vars.service_url+"/index.php/kmc/kmc#"+t.moduleName+"|"+t.subtab}})},changeSetting:function(e){var t,r;switch(e){case"password":t="Change Password",r=180;break;case"email":t="Change Email Address",r=160;break;case"name":t="Edit Name",r=200}var a=kmc.vars.kmc_secured||"https:"==location.protocol?"https":"http",n=a+"://"+window.location.hostname,i=n+kmc.vars.port+"/index.php/kmc/updateLoginData/type/"+e;i=i+"?parent="+encodeURIComponent(document.location.href);var o='';kmc.layout.modal.open({width:370,title:t,content:o}),XD.receiveMessage(function(e){kmc.layout.modal.close(),"reload"==e.data&&($.browser.msie&&8>$.browser.version&&(window.location.hash="account|user"),window.location.reload())},n)},changePartner:function(){var e,t,r,a=0,n=kmc.vars.allowed_partners.length,i='
    Please choose partner:
    ';for(e=0;n>e;e++)a=kmc.vars.allowed_partners[e].id,kmc.vars.partner_id==a?(t=' checked="checked"',r=' style="font-weight: bold"'):(t="",r=""),i+="  "+kmc.vars.allowed_partners[e].name+"";return i+='
    ',kmc.layout.modal.open({width:300,title:"Change Account",content:i}),$("#do_change_partner").click(function(){var e=kmc.vars.base_url+"/index.php/kmc/extlogin",t=$("").attr({type:"hidden",name:"ks",value:kmc.vars.ks}),r=$("").attr({type:"hidden",name:"partner_id",value:$("input[name=pid]:radio:checked").val()}),a=$("").attr({action:e,method:"post",style:"display: none"}).append(t,r);$("body").append(a),a[0].submit()}),!1}},$(function(){kmc.layout.init(),kmc.utils.handleMenu(),kmc.functions.loadSwf(),$(window).wresize(kmc.utils.resize),kmc.vars.isLoadedInterval=setInterval(kmc.utils.isModuleLoaded,200),kmc.preview_embed.updateList(),kmc.preview_embed.updateList(!0),kmc.utils.setClientIP()}),$(window).resize(function(){kmc.layout.modal.isOpen()&&kmc.layout.modal.position()}),window.onbeforeunload=kmc.functions.checkForOngoingProcess,function(e){e.fn.wresize=function(t){function r(){if(e.browser.msie)if(wresize.fired){var t=parseInt(e.browser.version,10);if(wresize.fired=!1,7>t)return!1;if(7==t){var r=e(window).width();if(r!=wresize.width)return wresize.width=r,!1}}else wresize.fired=!0;return!0}function a(e){return r()?t.apply(this,[e]):void 0}return version="1.1",wresize={fired:!1,width:0},this.each(function(){this==window?e(this).resize(a):e(this).resize(t)}),this}}(jQuery);var XD=function(){var e,t,r,a=1,n=this;return{postMessage:function(e,t,r){t&&(r=r||parent,n.postMessage?r.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(r.location=t.replace(/#.*$/,"")+"#"+ +new Date+a++ +"&"+e))},receiveMessage:function(a,i){n.postMessage?(a&&(r=function(e){return"string"==typeof i&&e.origin!==i||"[object Function]"===Object.prototype.toString.call(i)&&i(e.origin)===!1?!1:(a(e),void 0)}),n.addEventListener?n[a?"addEventListener":"removeEventListener"]("message",r,!1):n[a?"attachEvent":"detachEvent"]("onmessage",r)):(e&&clearInterval(e),e=null,a&&(e=setInterval(function(){var e=document.location.hash,r=/^#?\d+&/;e!==t&&r.test(e)&&(t=e,a({data:e.replace(r,"")}))},100)))}}}(); \ No newline at end of file From 7111f897cf77a64b110800e60b1876035ab59e24 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Wed, 17 Jul 2013 13:54:34 +0300 Subject: [PATCH 022/132] Support missing XML elements --- tests/standAloneClient/test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/standAloneClient/test.php b/tests/standAloneClient/test.php index 9894988a88d..58e3be3da19 100644 --- a/tests/standAloneClient/test.php +++ b/tests/standAloneClient/test.php @@ -68,10 +68,13 @@ function parseInputArray(SimpleXMLElement $items) return $array; } -function parseInputObject(SimpleXMLElement $input) +function parseInputObject(SimpleXMLElement $input = null) { global $inFile; + if(is_null($input)) + return null; + $type = 'string'; if(isset($input['objectType'])) $type = strval($input['objectType']); From 204db425d9bf628cd787458ea6e81a26e1488252 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Wed, 17 Jul 2013 13:56:15 +0300 Subject: [PATCH 023/132] Add permissions to list event notification template by admin console users --- .../service.eventnotification.eventnotificationtemplate.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/permissions/service.eventnotification.eventnotificationtemplate.ini b/deployment/permissions/service.eventnotification.eventnotificationtemplate.ini index 672bcbb1dc9..6059a6cca78 100644 --- a/deployment/permissions/service.eventnotification.eventnotificationtemplate.ini +++ b/deployment/permissions/service.eventnotification.eventnotificationtemplate.ini @@ -83,5 +83,5 @@ permissionItem9.permissions = -2>eventNotification.SYSTEM_ADMIN_EVENT_NOTIFICATI permissionItem10.service = eventnotification_eventnotificationtemplate permissionItem10.action = listTemplates permissionItem10.partnerId = 0 -permissionItem10.permissions = eventNotification.EVENT_NOTIFICATIONS_TEMPLATE_BASE +permissionItem10.permissions = eventNotification.EVENT_NOTIFICATIONS_TEMPLATE_BASE, -2>eventNotification.SYSTEM_ADMIN_EVENT_NOTIFICATION_BASE From fa4104ece1359778106450d2eaacf0f5f50fb0f2 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Wed, 17 Jul 2013 13:57:20 +0300 Subject: [PATCH 024/132] Add permissions to list event notification template by admin console users --- ..._07_17_admin_event_notification_templates.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 deployment/updates/scripts/add_permissions/2013_07_17_admin_event_notification_templates.php diff --git a/deployment/updates/scripts/add_permissions/2013_07_17_admin_event_notification_templates.php b/deployment/updates/scripts/add_permissions/2013_07_17_admin_event_notification_templates.php new file mode 100644 index 00000000000..9c105d909e5 --- /dev/null +++ b/deployment/updates/scripts/add_permissions/2013_07_17_admin_event_notification_templates.php @@ -0,0 +1,16 @@ + Date: Wed, 17 Jul 2013 13:59:23 +0300 Subject: [PATCH 025/132] move download action to work with the new code. --- .../modules/extwidget/actions/downloadAction.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/downloadAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/downloadAction.class.php index 03dddd84885..a6ccd1f8c7d 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/downloadAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/downloadAction.class.php @@ -229,10 +229,7 @@ private function handleFileSyncRedirection(FileSyncKey $syncKey) if (!$local) { - $dc = kDataCenterMgr::getDcById($fileSync->getDc()); - $url = $dc["url"] . $_SERVER['REQUEST_URI']; - $url = preg_replace('/^https?:\/\//', '', $url); - $url = infraRequestUtils::getProtocol() . '://' . $url; + $url = kDataCenterMgr::getRedirectExternalUrl($fileSync); $this->redirect($url); } } From 7ba1bdbdeaaa5260ca02535127bae54125588298 Mon Sep 17 00:00:00 2001 From: ranyefet Date: Wed, 17 Jul 2013 14:27:41 +0300 Subject: [PATCH 026/132] Restore old preview action to support old links --- .../modules/kmc/actions/previewAction.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php diff --git a/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php b/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php new file mode 100644 index 00000000000..d1d004c4b61 --- /dev/null +++ b/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php @@ -0,0 +1,16 @@ + Date: Wed, 17 Jul 2013 14:35:03 +0300 Subject: [PATCH 027/132] add querystring if exists --- .../apps/kaltura/modules/kmc/actions/previewAction.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php b/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php index d1d004c4b61..db67576f387 100644 --- a/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php +++ b/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php @@ -10,7 +10,9 @@ public function execute() // Preview page moved into /extwidget/preview $url = '/index.php'; $url .= str_replace('/kmc', '/extwidget', $_SERVER['PATH_INFO']); - $url .= '?' . $_SERVER['QUERY_STRING']; + if( isset($_SERVER['QUERY_STRING']) ) { + $url .= '?' . $_SERVER['QUERY_STRING']; + } header("location: $url"); } } \ No newline at end of file From 5cadeb1a55c8ce5fded1d5854e24614d8e98401e Mon Sep 17 00:00:00 2001 From: ranyefet Date: Wed, 17 Jul 2013 14:59:16 +0300 Subject: [PATCH 028/132] die after redirect --- alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php b/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php index db67576f387..f1ce7511c65 100644 --- a/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php +++ b/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php @@ -14,5 +14,6 @@ public function execute() $url .= '?' . $_SERVER['QUERY_STRING']; } header("location: $url"); + die(); } } \ No newline at end of file From cb69bc5cc91d75d4259e0dd00e4a0dae1b5c24db Mon Sep 17 00:00:00 2001 From: hilak Date: Wed, 17 Jul 2013 15:01:46 +0300 Subject: [PATCH 029/132] error- null object reference. KontikiAPIWrapper::getUrn should not throw kExternalError --- plugins/kontiki/lib/KontikiAPIWrapper.php | 2 +- plugins/kontiki/lib/urlManager/kKontikiUrlManager.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/kontiki/lib/KontikiAPIWrapper.php b/plugins/kontiki/lib/KontikiAPIWrapper.php index 647e48d0931..b114ed410bb 100644 --- a/plugins/kontiki/lib/KontikiAPIWrapper.php +++ b/plugins/kontiki/lib/KontikiAPIWrapper.php @@ -130,7 +130,7 @@ public static function getPlaybackUrn ($serviceToken, $contentMoid, $timeout = n $curlWrapper = new KCurlWrapper($url); $result = $curlWrapper->exec(); if (!$result) - KExternalErrors::dieError(KExternalErrors::BAD_QUERY); + return; $resultAsXml = new SimpleXMLElement($result); return strval($resultAsXml->urn) . ";realmId:" . strval($resultAsXml->realmId) . ";realmTicket:" .strval($resultAsXml->realmTicket); diff --git a/plugins/kontiki/lib/urlManager/kKontikiUrlManager.php b/plugins/kontiki/lib/urlManager/kKontikiUrlManager.php index 2665eb7ffd9..c5307bf0f20 100644 --- a/plugins/kontiki/lib/urlManager/kKontikiUrlManager.php +++ b/plugins/kontiki/lib/urlManager/kKontikiUrlManager.php @@ -9,8 +9,9 @@ public function getFileSyncUrl(FileSync $fileSync, $tokenizeUrl = true) protected function doGetFileSyncUrl(FileSync $fileSync) { - $storageProfile = StorageProfilePeer::retrieveByPK($fileSync->getDc()); - KontikiAPIWrapper::$entryPoint = $this->storageProfileId->getApiEntryPoint(); + $storageProfile = StorageProfilePeer::retrieveByPK($this->storageProfileId); + /* @var $storageProfile KontikiStorageProfile */ + KontikiAPIWrapper::$entryPoint = $storageProfile->getApiEntryPoint(); return KontikiAPIWrapper::getPlaybackUrn("srv-".base64_encode($this->storageProfile->getServiceToken()), $fileSync->getFilePath()); } } From 2fe771e93d70a26a2cba4a6e7365709bf8741e64 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Wed, 17 Jul 2013 15:18:09 +0300 Subject: [PATCH 030/132] Enable clone as is by passing null as the event notification template --- .../services/EventNotificationTemplateService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/event_notification/services/EventNotificationTemplateService.php b/plugins/event_notification/services/EventNotificationTemplateService.php index d60852b6535..6964a6c6322 100644 --- a/plugins/event_notification/services/EventNotificationTemplateService.php +++ b/plugins/event_notification/services/EventNotificationTemplateService.php @@ -64,7 +64,7 @@ public function cloneAction($id, KalturaEventNotificationTemplate $eventNotifica // init new Kaltura object $newEventNotificationTemplate = KalturaEventNotificationTemplate::getInstanceByType($newDbEventNotificationTemplate->getType()); $templateClass = get_class($newEventNotificationTemplate); - if(get_class($eventNotificationTemplate) != $templateClass && !is_subclass_of($eventNotificationTemplate, $templateClass)) + if($eventNotificationTemplate && get_class($eventNotificationTemplate) != $templateClass && !is_subclass_of($eventNotificationTemplate, $templateClass)) throw new KalturaAPIException(KalturaEventNotificationErrors::EVENT_NOTIFICATION_WRONG_TYPE, $id, kPluginableEnumsManager::coreToApi('EventNotificationTemplateType', $dbEventNotificationTemplate->getType())); if ($eventNotificationTemplate) From 45595ea05b75e33d35acc75a53a8dd831e8c59d8 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Wed, 17 Jul 2013 15:19:35 +0300 Subject: [PATCH 031/132] Prevent creation of new templates and enable clone of shared partner templates --- ...entNotificationTemplateConfigureAction.php | 15 ++++- .../EventNotificationTemplatesListAction.php | 15 +++++ .../forms/NewEventNotificationTemplate.php | 23 ++++---- ...t-notification-templates-list-action.phtml | 55 +++++++++++++++++++ 4 files changed, 93 insertions(+), 15 deletions(-) diff --git a/plugins/event_notification/admin/EventNotificationTemplateConfigureAction.php b/plugins/event_notification/admin/EventNotificationTemplateConfigureAction.php index c92942882a5..163033beeaf 100644 --- a/plugins/event_notification/admin/EventNotificationTemplateConfigureAction.php +++ b/plugins/event_notification/admin/EventNotificationTemplateConfigureAction.php @@ -37,10 +37,10 @@ public function doAction(Zend_Controller_Action $action) $partnerId = 0; $templateId = $this->_getParam('template_id'); + $cloneTemplateId = $this->_getParam('clone_template_id'); $type = null; $eventNotificationTemplate = null; - $action->view->templateId = $templateId; $action->view->errMessage = null; $action->view->form = ''; $form = null; @@ -48,7 +48,14 @@ public function doAction(Zend_Controller_Action $action) try { Infra_ClientHelper::impersonate($partnerId); - if ($templateId) + + if($cloneTemplateId) + { + $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->cloneAction($cloneTemplateId); + $templateId = $eventNotificationTemplate->id; + $type = $eventNotificationTemplate->type; + } + elseif ($templateId) { $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->get($templateId); $type = $eventNotificationTemplate->type; @@ -130,9 +137,11 @@ public function doAction(Zend_Controller_Action $action) } } Infra_ClientHelper::unimpersonate(); + $action->view->form = $form; - + $action->view->templateId = $templateId; $action->view->plugins = array(); + $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaApplicationPartialView'); KalturaLog::debug("plugin instances [" . count($pluginInstances) . "]"); foreach($pluginInstances as $pluginInstance) diff --git a/plugins/event_notification/admin/EventNotificationTemplatesListAction.php b/plugins/event_notification/admin/EventNotificationTemplatesListAction.php index 5ddeacdab6b..0de3135f999 100644 --- a/plugins/event_notification/admin/EventNotificationTemplatesListAction.php +++ b/plugins/event_notification/admin/EventNotificationTemplatesListAction.php @@ -85,10 +85,25 @@ public function doAction(Zend_Controller_Action $action) if ($partnerFilter) $newForm->getElement('newPartnerId')->setValue($partnerFilter->idIn); + $listTemplatespager = new Kaltura_Client_Type_FilterPager(); + $listTemplatespager->pageSize = 500; + $templatesList = $eventNotificationPlugin->eventNotificationTemplate->listTemplates(null, $listTemplatespager); + + $templates = array(); + foreach($templatesList->objects as $template) + { + $obj = new stdClass(); + $obj->id = $template->id; + $obj->type = $template->type; + $obj->name = $template->name; + $templates[] = $obj; + } + // set view $action->view->form = $form; $action->view->newForm = $newForm; $action->view->paginator = $paginator; + $action->view->templates = $templates; } /* (non-PHPdoc) diff --git a/plugins/event_notification/admin/forms/NewEventNotificationTemplate.php b/plugins/event_notification/admin/forms/NewEventNotificationTemplate.php index b95c430ac89..aa55c66bf6b 100644 --- a/plugins/event_notification/admin/forms/NewEventNotificationTemplate.php +++ b/plugins/event_notification/admin/forms/NewEventNotificationTemplate.php @@ -20,25 +20,24 @@ public function init() 'filters' => array('StringTrim'), )); - $element = $this->addElement('select', 'newType', array( + $newType = new Kaltura_Form_Element_EnumSelect('cloneTemplateType', array( + 'enum' => 'Kaltura_Client_EventNotification_Enum_EventNotificationTemplateType', 'label' => 'Type:', + 'onchange' => "switchTemplatesBox()", + 'filters' => array('StringTrim'), + )); + $this->addElements(array($newType)); + + $element = $this->addElement('select', 'cloneTemplateId', array( + 'label' => 'Template:', 'filters' => array('StringTrim'), )); // submit button $this->addElement('button', 'newEventNotificationTemplate', array( - 'label' => 'Create New', - 'onclick' => "doAction('newEventNotificationTemplate', $('#newPartnerId').val(), $('#newType').val())", + 'label' => 'Add from template', + 'onclick' => "cloneEventNotificationTemplate()", 'decorators' => array('ViewHelper'), )); - - $element = $this->getElement('newType'); - $reflect = new ReflectionClass('Kaltura_Client_EventNotification_Enum_EventNotificationTemplateType'); - $types = $reflect->getConstants(); - foreach($types as $constName => $value) - { - $name = ucfirst(str_replace('_', ' ', $constName)); - $element->addMultiOption($value, $name); - } } } \ No newline at end of file diff --git a/plugins/event_notification/admin/scripts/plugin/event-notification-templates-list-action.phtml b/plugins/event_notification/admin/scripts/plugin/event-notification-templates-list-action.phtml index 059c6ad32a1..69a4b04d99d 100644 --- a/plugins/event_notification/admin/scripts/plugin/event-notification-templates-list-action.phtml +++ b/plugins/event_notification/admin/scripts/plugin/event-notification-templates-list-action.phtml @@ -51,6 +51,7 @@ From 40edc0edaab5d7b9f428e5132f3c1dfed2244c6b Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Wed, 17 Jul 2013 21:36:03 +0300 Subject: [PATCH 037/132] Load partial plugins after the javascript in order to enable the plugins to use the javascript functions. --- ...vent-notification-template-configure-action.phtml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/event_notification/admin/scripts/plugin/event-notification-template-configure-action.phtml b/plugins/event_notification/admin/scripts/plugin/event-notification-template-configure-action.phtml index f8fc1acaa74..0f38598e2a1 100644 --- a/plugins/event_notification/admin/scripts/plugin/event-notification-template-configure-action.phtml +++ b/plugins/event_notification/admin/scripts/plugin/event-notification-template-configure-action.phtml @@ -5,11 +5,6 @@ form ?> -plugins as $phtml => $pluginData) - echo $this->partial($phtml, $pluginData); -?> - \ No newline at end of file + + +plugins as $phtml => $pluginData) + echo $this->partial($phtml, $pluginData); +?> From 2e0d87edecb0f4b483b7e5d7ef4217c9fe50a5a4 Mon Sep 17 00:00:00 2001 From: hilak Date: Thu, 18 Jul 2013 01:37:08 +0300 Subject: [PATCH 038/132] replace references to $this->taskConfig and $this->kClient with KBatchBase::$taskConfig and KBatchBase::$kClient, respectively --- .../KAsyncWidevineRepositorySync.class.php | 6 +++--- .../KAsyncWidevineRepositorySyncCloser.class.php | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/drm/widevine/batch/widevineRepositorySync/KAsyncWidevineRepositorySync.class.php b/plugins/drm/widevine/batch/widevineRepositorySync/KAsyncWidevineRepositorySync.class.php index 676dd9ead6e..dfeda47d6a2 100644 --- a/plugins/drm/widevine/batch/widevineRepositorySync/KAsyncWidevineRepositorySync.class.php +++ b/plugins/drm/widevine/batch/widevineRepositorySync/KAsyncWidevineRepositorySync.class.php @@ -55,7 +55,7 @@ private function sendModifyRequest(KalturaBatchJob $job, KalturaWidevineReposito { KalturaLog::debug("Starting sendModifyRequest"); - $cgiUrl = $this->taskConfig->params->vodPackagerHost . WidevinePlugin::ASSET_NOTIFY_CGI; + $cgiUrl = self::$taskConfig->params->vodPackagerHost . WidevinePlugin::ASSET_NOTIFY_CGI; $dataWrap = new WidevineRepositorySyncJobDataWrap($data); $widevineAssets = $dataWrap->getWidevineAssetIds(); @@ -70,7 +70,7 @@ private function sendModifyRequest(KalturaBatchJob $job, KalturaWidevineReposito private function prepareAssetNotifyGetRequestXml($assetId) { - $requestInput = new WidevineAssetNotifyRequest(WidevineAssetNotifyRequest::REQUEST_GET, $this->taskConfig->params->portal); + $requestInput = new WidevineAssetNotifyRequest(WidevineAssetNotifyRequest::REQUEST_GET, self::$taskConfig->params->portal); $requestInput->setAssetId($assetId); $requestXml = $requestInput->createAssetNotifyRequestXml(); @@ -82,7 +82,7 @@ private function prepareAssetNotifyGetRequestXml($assetId) private function prepareAssetNotifyRegisterRequestXml(WidevineAssetNotifyResponse $assetGetResponse, $licenseStartDate, $licenseEndDate) { - $requestInput = new WidevineAssetNotifyRequest(WidevineAssetNotifyRequest::REQUEST_REGISTER, $this->taskConfig->params->portal); + $requestInput = new WidevineAssetNotifyRequest(WidevineAssetNotifyRequest::REQUEST_REGISTER, self::$taskConfig->params->portal); $requestInput->setAssetName($assetGetResponse->getName()); $requestInput->setPolicy($assetGetResponse->getPolicy()); $requestInput->setLicenseStartDate($licenseStartDate); diff --git a/plugins/drm/widevine/batch/widevineRepositorySync/KAsyncWidevineRepositorySyncCloser.class.php b/plugins/drm/widevine/batch/widevineRepositorySync/KAsyncWidevineRepositorySyncCloser.class.php index 6bd02ce53bf..889ad25558a 100644 --- a/plugins/drm/widevine/batch/widevineRepositorySync/KAsyncWidevineRepositorySyncCloser.class.php +++ b/plugins/drm/widevine/batch/widevineRepositorySync/KAsyncWidevineRepositorySyncCloser.class.php @@ -41,7 +41,7 @@ private function closeWidevineSync(KalturaBatchJob $job, KalturaWidevineReposito { KalturaLog::debug("fetchStatus($job->id)"); - if(($job->queueTime + $this->taskConfig->params->maxTimeBeforeFail) < time()) + if(($job->queueTime + self::$taskConfig->params->maxTimeBeforeFail) < time()) return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::CLOSER_TIMEOUT, 'Timed out', KalturaBatchJobStatus::FAILED); $dataWrap = new WidevineRepositorySyncJobDataWrap($data); @@ -69,7 +69,7 @@ private function isModificationCompleted(KalturaBatchJob $job, WidevineRepositor { KalturaLog::debug("Starting isModificationCompleted"); - $cgiUrl = $this->taskConfig->params->vodPackagerHost . WidevinePlugin::ASSET_NOTIFY_CGI; + $cgiUrl = self::$taskConfig->params->vodPackagerHost . WidevinePlugin::ASSET_NOTIFY_CGI; $widevineAssets = $dataWrap->getWidevineAssetIds(); $startDate = $dataWrap->getLicenseStartDate(); @@ -90,7 +90,7 @@ private function isModificationCompleted(KalturaBatchJob $job, WidevineRepositor private function prepareAssetNotifyGetRequestXml($assetId) { - $requestInput = new WidevineAssetNotifyRequest(WidevineAssetNotifyRequest::REQUEST_GET, $this->taskConfig->params->portal); + $requestInput = new WidevineAssetNotifyRequest(WidevineAssetNotifyRequest::REQUEST_GET, self::$taskConfig->params->portal); $requestInput->setAssetId($assetId); $requestXml = $requestInput->createAssetNotifyRequestXml(); @@ -116,7 +116,7 @@ private function updateFlavorAssets(KalturaBatchJob $job, WidevineRepositorySync $filter = new KalturaAssetFilter(); $filter->entryIdEqual = $job->entryId; $filter->tagsLike = 'widevine'; - $flavorAssetsList = $this->kClient->flavorAsset->listAction($filter, new KalturaFilterPager()); + $flavorAssetsList = self::$kClient->flavorAsset->listAction($filter, new KalturaFilterPager()); foreach ($flavorAssetsList->objects as $flavorAsset) { @@ -127,7 +127,7 @@ private function updateFlavorAssets(KalturaBatchJob $job, WidevineRepositorySync $updatedFlavorAsset = new KalturaWidevineFlavorAsset(); $updatedFlavorAsset->widevineDistributionStartDate = $startDate; $updatedFlavorAsset->widevineDistributionEndDate = $endDate; - $this->kClient->flavorAsset->update($flavorAsset->id, $updatedFlavorAsset); + self::$kClient->flavorAsset->update($flavorAsset->id, $updatedFlavorAsset); } } $this->unimpersonate(); From f14a6cc18664659d73e4bb67728fab46a797bb1b Mon Sep 17 00:00:00 2001 From: hilak Date: Thu, 18 Jul 2013 15:45:05 +0300 Subject: [PATCH 039/132] fix syntax error : KalturaStorageProfile instead of StorageProfile --- api_v3/lib/types/storageProfile/KalturaStorageProfile.php | 2 +- plugins/kontiki/KontikiPlugin.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api_v3/lib/types/storageProfile/KalturaStorageProfile.php b/api_v3/lib/types/storageProfile/KalturaStorageProfile.php index 614c6556e60..3b51721963d 100644 --- a/api_v3/lib/types/storageProfile/KalturaStorageProfile.php +++ b/api_v3/lib/types/storageProfile/KalturaStorageProfile.php @@ -352,7 +352,7 @@ public static function getInstanceByType ($protocol) $obj = new KalturaAmazonS3StorageProfile(); break; default: - $obj = KalturaPluginManager::loadObject('StorageProfile', $protocol); + $obj = KalturaPluginManager::loadObject('KalturaStorageProfile', $protocol); break; } diff --git a/plugins/kontiki/KontikiPlugin.php b/plugins/kontiki/KontikiPlugin.php index 43788d06dd9..f8d9cfb498a 100644 --- a/plugins/kontiki/KontikiPlugin.php +++ b/plugins/kontiki/KontikiPlugin.php @@ -65,8 +65,8 @@ public static function loadObject($baseClass, $enumValue, array $constructorArgs * @see IKalturaObjectLoader::getObjectClass() */ public static function getObjectClass($baseClass, $enumValue) { - if($baseClass == 'StorageProfile' && $enumValue == self::getStorageProfileProtocolCoreValue(KontikiStorageProfileProtocol::KONTIKI)) - return 'KontikiStorageProfile'; + if($baseClass == 'KalturaStorageProfile' && $enumValue == self::getStorageProfileProtocolCoreValue(KontikiStorageProfileProtocol::KONTIKI)) + return 'KalturaKontikiStorageProfile'; } From 1266d9c57d88e8f20c0581089c9c486f72fab3ee Mon Sep 17 00:00:00 2001 From: rotema Date: Thu, 18 Jul 2013 15:56:09 +0300 Subject: [PATCH 040/132] migration of featuresStatus to featuresStatuses --- alpha/lib/model/Partner.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/alpha/lib/model/Partner.php b/alpha/lib/model/Partner.php index aee63090798..989389a9850 100644 --- a/alpha/lib/model/Partner.php +++ b/alpha/lib/model/Partner.php @@ -454,10 +454,11 @@ public function setEnforceHttpsApi( $v ) { return $this->putInCustomData( "enfo public function getFeaturesStatus() { - $featuresStatus = $this->getFromCustomData(null, "featuresStatus"); - if (!is_null($featuresStatus) && (!is_array($featuresStatus))){ - $featuresStatus = unserialize($featuresStatus); + $featuresStatus = $this->getFromCustomData(null, 'featuresStatuses'); + if (is_null($featuresStatus)){ + $featuresStatus = array(); } + return $featuresStatus; } @@ -485,19 +486,19 @@ public function addFeaturesStatus($type, $value = 1) $newFeatureStatus->setType($type); $newFeatureStatus->setValue($value); - $this->putInCustomData($type, $newFeatureStatus, 'featuresStatus'); + $this->putInCustomData($type, $newFeatureStatus, 'featuresStatuses'); $this->save(); } public function removeFeaturesStatus($type) { - $this->removeFromCustomData($type, 'featuresStatus'); + $this->removeFromCustomData($type, 'featuresStatuses'); $this->save(); } public function getFeaturesStatusByType($type) { - return $this->getFromCustomData($type, 'featuresStatus'); + return $this->getFromCustomData($type, 'featuresStatuses'); } public function resetFeaturesStatusByType($type) From 9e021ab95bca51631eccfc594c0ac8e98002b150 Mon Sep 17 00:00:00 2001 From: rotema Date: Thu, 18 Jul 2013 16:12:43 +0300 Subject: [PATCH 041/132] SUP-454 #time 1h #comment support partners which are set with appear_in_search <> 2 --- plugins/drm/widevine/lib/kWidevineEventsConsumer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/drm/widevine/lib/kWidevineEventsConsumer.php b/plugins/drm/widevine/lib/kWidevineEventsConsumer.php index 4f4986a988f..f64cd2993fe 100644 --- a/plugins/drm/widevine/lib/kWidevineEventsConsumer.php +++ b/plugins/drm/widevine/lib/kWidevineEventsConsumer.php @@ -174,6 +174,7 @@ private function hasWidevineFlavorAssetsWithSameWvAssetIdInOtherEntries($wvAsset { $entryFilter = new entryFilter(); $entryFilter->fields['_like_plugins_data'] = WidevinePlugin::getWidevineAssetIdSearchData($wvAssetId); + $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); $c = KalturaCriteria::create(entryPeer::OM_CLASS); $entryFilter->attachToCriteria($c); $c->add(entryPeer::ID, $entryId, Criteria::NOT_EQUAL); From aa0a1547893ba15bec71191615af1e5c62c266ca Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Thu, 18 Jul 2013 16:42:40 +0300 Subject: [PATCH 042/132] change the conditions to work on any scope type --- .../kAssetPropertiesCompareCondition.php | 8 +++++--- .../conditions/kAuthenticatedCondition.php | 6 ++++-- .../model/conditions/kCompareCondition.php | 10 +++++----- .../model/conditions/kCondition.php | 10 +++++----- .../model/conditions/kCountryCondition.php | 3 +-- .../model/conditions/kFieldCompareCondition.php | 4 ++-- .../model/conditions/kFieldMatchCondition.php | 4 ++-- .../model/conditions/kIpAddressCondition.php | 3 +-- .../model/conditions/kMatchCondition.php | 10 +++++----- .../model/conditions/kSiteCondition.php | 8 +++----- .../model/conditions/kUserAgentCondition.php | 3 +-- .../lib/access_control/model/rules/kRule.php | 5 +++-- .../model/data/kCompareMetadataCondition.php | 17 ++++++++++++++--- .../lib/model/data/kMatchMetadataCondition.php | 17 ++++++++++++++--- 14 files changed, 65 insertions(+), 43 deletions(-) diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kAssetPropertiesCompareCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kAssetPropertiesCompareCondition.php index 349db10b480..610d2be90dc 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kAssetPropertiesCompareCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kAssetPropertiesCompareCondition.php @@ -20,16 +20,18 @@ public function __construct($not = false) } /** - * @param accessControl $accessControl + * @param kScope $scope * @return bool */ - protected function internalFulfilled(accessControl $accessControl) + protected function internalFulfilled(kScope $scope) { // no properties defined, the condition is fulfilled if (count($this->getProperties()) == 0) return true; - $scope = $accessControl->getScope(); + if(!($scope instanceof accessControlScope)) + return false; + $entryId = $scope->getEntryId(); $entryAssets = assetPeer::retrieveReadyByEntryId($scope->getEntryId()); foreach($entryAssets as $asset) diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kAuthenticatedCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kAuthenticatedCondition.php index 077777a7d7a..a95046c212a 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kAuthenticatedCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kAuthenticatedCondition.php @@ -40,9 +40,11 @@ function getPrivileges() /* (non-PHPdoc) * @see kCondition::internalFulfilled() */ - protected function internalFulfilled(accessControl $accessControl) + protected function internalFulfilled(kScope $scope) { - $scope = $accessControl->getScope(); + if(!($scope instanceof accessControlScope)) + return false; + if (!$scope->getKs() || (!$scope->getKs() instanceof ks)) return false; diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kCompareCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kCompareCondition.php index c21f7744996..d687ee7bddf 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kCompareCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kCompareCondition.php @@ -54,10 +54,10 @@ public function setComparison($comparison) /** * Return single integer or array of integers - * @param accessControl $accessControl + * @param kScope $scope * @return int|array the field content */ - abstract public function getFieldValue(accessControl $accessControl); + abstract public function getFieldValue(kScope $scope); /** * @return int @@ -110,10 +110,10 @@ protected function fieldFulfilled($field, $value) /* (non-PHPdoc) * @see kCondition::internalFulfilled() */ - protected function internalFulfilled(accessControl $accessControl) + protected function internalFulfilled(kScope $scope) { - $field = $this->getFieldValue($accessControl); - $value = $this->getIntegerValue($accessControl->getScope()); + $field = $this->getFieldValue($scope); + $value = $this->getIntegerValue($scope); KalturaLog::debug("Copares field [$field] to value [$value]"); if (is_null($value)) diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php index f468ba145a5..19ddfd2db22 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php @@ -22,18 +22,18 @@ public function __construct($not = false) } /** - * @param accessControl $accessControl + * @param kScope $scope * @return bool */ - abstract protected function internalFulfilled(accessControl $accessControl); + abstract protected function internalFulfilled(kScope $scope); /** - * @param accessControl $accessControl + * @param kScope $scope * @return bool */ - final public function fulfilled(accessControl $accessControl) + final public function fulfilled(kScope $scope) { - return $this->calcNot($this->internalFulfilled($accessControl)); + return $this->calcNot($this->internalFulfilled($scope)); } /** diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kCountryCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kCountryCondition.php index b93252966f2..84212629b37 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kCountryCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kCountryCondition.php @@ -41,9 +41,8 @@ function getGeoCoderType() /* (non-PHPdoc) * @see kCondition::getFieldValue() */ - public function getFieldValue(accessControl $accessControl) + public function getFieldValue(kScope $scope) { - $scope = $accessControl->getScope(); kApiCache::addExtraField(kApiCache::ECF_COUNTRY, kApiCache::COND_MATCH, $this->getStringValues($scope)); $ip = $scope->getIp(); diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kFieldCompareCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kFieldCompareCondition.php index 5ff45a2f2e2..2f4f219abc8 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kFieldCompareCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kFieldCompareCondition.php @@ -24,9 +24,9 @@ public function __construct($not = false) /* (non-PHPdoc) * @see kMatchCondition::getFieldValue() */ - public function getFieldValue(accessControl $accessControl) + public function getFieldValue(kScope $scope) { - $this->field->setScope($accessControl->getScope()); + $this->field->setScope($scope); return $this->field->getValue(); } diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kFieldMatchCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kFieldMatchCondition.php index 42e3f47103b..3f9936fc6a1 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kFieldMatchCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kFieldMatchCondition.php @@ -23,9 +23,9 @@ public function __construct($not = false) /* (non-PHPdoc) * @see kMatchCondition::getFieldValue() */ - public function getFieldValue(accessControl $accessControl) + public function getFieldValue(kScope $scope) { - $this->field->setScope($accessControl->getScope()); + $this->field->setScope($scope); return $this->field->getValue(); } diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kIpAddressCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kIpAddressCondition.php index e5a8772232b..f854054ca47 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kIpAddressCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kIpAddressCondition.php @@ -17,9 +17,8 @@ public function __construct($not = false) /* (non-PHPdoc) * @see kCondition::getFieldValue() */ - public function getFieldValue(accessControl $accessControl) + public function getFieldValue(kScope $scope) { - $scope = $accessControl->getScope(); kApiCache::addExtraField(kApiCache::ECF_IP, kApiCache::COND_IP_RANGE, $this->getStringValues($scope)); return $scope->getIp(); } diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kMatchCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kMatchCondition.php index fbccedd6e0c..e2b25236801 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kMatchCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kMatchCondition.php @@ -63,10 +63,10 @@ function getStringValues($scope = null) } /** - * @param accessControl $accessControl + * @param kScope $scope * @return string the field content */ - abstract public function getFieldValue(accessControl $accessControl); + abstract public function getFieldValue(kScope $scope); /** * @param string $field @@ -106,10 +106,10 @@ public function fieldFulfilled($field, $values) /* (non-PHPdoc) * @see kCondition::internalFulfilled() */ - protected function internalFulfilled(accessControl $accessControl) + protected function internalFulfilled(kScope $scope) { - $field = $this->getFieldValue($accessControl); - $values = $this->getStringValues($accessControl->getScope()); + $field = $this->getFieldValue($scope); + $values = $this->getStringValues($scope); KalturaLog::debug("Matches field [$field] to values [" . print_r($values, true) . "]"); if (!count($values)) diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kSiteCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kSiteCondition.php index f0ed6a17826..aef53f0bbba 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kSiteCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kSiteCondition.php @@ -23,9 +23,8 @@ public function __construct($not = false) /* (non-PHPdoc) * @see kCondition::getFieldValue() */ - public function getFieldValue(accessControl $accessControl) + public function getFieldValue(kScope $scope) { - $scope = $accessControl->getScope(); $referrer = $scope->getReferrer(); return requestUtils::parseUrlHost($referrer); } @@ -33,9 +32,8 @@ public function getFieldValue(accessControl $accessControl) /* (non-PHPdoc) * @see kCondition::internalFulfilled() */ - protected function internalFulfilled(accessControl $accessControl) + protected function internalFulfilled(kScope $scope) { - $scope = $accessControl->getScope(); $referrer = $scope->getReferrer(); if ($this->getNot()===true && !$this->globalWhitelistDomainsAppended && strpos($referrer, "kwidget") === false && kConf::hasParam("global_whitelisted_domains")) @@ -56,7 +54,7 @@ protected function internalFulfilled(accessControl $accessControl) kApiCache::addExtraField(kApiCache::ECF_REFERRER, kApiCache::COND_SITE_MATCH, $this->getStringValues($scope)); - return parent::internalFulfilled($accessControl); + return parent::internalFulfilled($scope); } /* (non-PHPdoc) diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kUserAgentCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kUserAgentCondition.php index 86611cbd6d6..55c2d86aa67 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kUserAgentCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kUserAgentCondition.php @@ -17,9 +17,8 @@ public function __construct($not = false) /* (non-PHPdoc) * @see kCondition::getFieldValue() */ - public function getFieldValue(accessControl $accessControl) + public function getFieldValue(kScope $scope) { - $scope = $accessControl->getScope(); kApiCache::addExtraField(kApiCache::ECF_USER_AGENT, kApiCache::COND_REGEX, $this->getStringValues($scope)); return $scope->getUserAgent(); } diff --git a/alpha/apps/kaltura/lib/access_control/model/rules/kRule.php b/alpha/apps/kaltura/lib/access_control/model/rules/kRule.php index ec40bc22e23..3d397fe746d 100644 --- a/alpha/apps/kaltura/lib/access_control/model/rules/kRule.php +++ b/alpha/apps/kaltura/lib/access_control/model/rules/kRule.php @@ -20,7 +20,8 @@ class kRule protected $accessControl; /** - * Message to be thrown to the player in case the rule fulfilled + * Message to be thrown to the player in case the rule + * * @var string */ @@ -107,7 +108,7 @@ protected function fulfilled() foreach($this->conditions as $condition) { - if(!$condition->fulfilled($this->accessControl)) + if(!$condition->fulfilled($this->accessControl->getScope())) { KalturaLog::debug("Condition [" . get_class($condition) . "] not fulfilled"); return false; diff --git a/plugins/metadata/lib/model/data/kCompareMetadataCondition.php b/plugins/metadata/lib/model/data/kCompareMetadataCondition.php index 9c3ba02d615..a84432f51fb 100644 --- a/plugins/metadata/lib/model/data/kCompareMetadataCondition.php +++ b/plugins/metadata/lib/model/data/kCompareMetadataCondition.php @@ -32,10 +32,21 @@ public function __construct($not = false) /* (non-PHPdoc) * @see kCondition::getFieldValue() */ - public function getFieldValue(accessControl $accessControl) + public function getFieldValue(kScope $scope) { - $scope = $accessControl->getScope(); - $metadata = MetadataPeer::retrieveByObject($this->profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); + $metadata = null; + + if($scope instanceof accessControlScope) + { + $metadata = MetadataPeer::retrieveByObject($this->profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); + } + elseif($scope instanceof kEventScope && $scope->getEvent() instanceof kApplicativeEvent) + { + $object = $scope->getEvent()->getObject(); + if($object instanceof IMetadataObject) + $metadata = MetadataPeer::retrieveByObject($this->profileId, $object->getMetadataObjectType(), $object->getId()); + } + if(!$metadata) return null; diff --git a/plugins/metadata/lib/model/data/kMatchMetadataCondition.php b/plugins/metadata/lib/model/data/kMatchMetadataCondition.php index 85d4dcfa267..e4b100e67ef 100644 --- a/plugins/metadata/lib/model/data/kMatchMetadataCondition.php +++ b/plugins/metadata/lib/model/data/kMatchMetadataCondition.php @@ -32,10 +32,21 @@ public function __construct($not = false) /* (non-PHPdoc) * @see kCondition::getFieldValue() */ - public function getFieldValue(accessControl $accessControl) + public function getFieldValue(kScope $scope) { - $scope = $accessControl->getScope(); - $metadata = MetadataPeer::retrieveByObject($this->profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); + $metadata = null; + + if($scope instanceof accessControlScope) + { + $metadata = MetadataPeer::retrieveByObject($this->profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); + } + elseif($scope instanceof kEventScope && $scope->getEvent() instanceof kApplicativeEvent) + { + $object = $scope->getEvent()->getObject(); + if($object instanceof IMetadataObject) + $metadata = MetadataPeer::retrieveByObject($this->profileId, $object->getMetadataObjectType(), $object->getId()); + } + if($metadata) return kMetadataManager::parseMetadataValues($metadata, $this->xPath); From ea65d9ecb0e5fa833729c5be525eb2144f1fda95 Mon Sep 17 00:00:00 2001 From: hilak Date: Thu, 18 Jul 2013 16:50:01 +0300 Subject: [PATCH 043/132] fix errors after testing --- plugins/kontiki/KontikiPlugin.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/kontiki/KontikiPlugin.php b/plugins/kontiki/KontikiPlugin.php index f8d9cfb498a..0f491456a4d 100644 --- a/plugins/kontiki/KontikiPlugin.php +++ b/plugins/kontiki/KontikiPlugin.php @@ -58,6 +58,14 @@ public static function loadObject($baseClass, $enumValue, array $constructorArgs return new KalturaKontikiStorageDeleteJobData(); } } + + if ($baseClass == 'KalturaStorageProfile') + { + if ($enumValue == self::getStorageProfileProtocolCoreValue(KontikiStorageProfileProtocol::KONTIKI)) + { + return new KalturaKontikiStorageProfile(); + } + } } @@ -65,9 +73,8 @@ public static function loadObject($baseClass, $enumValue, array $constructorArgs * @see IKalturaObjectLoader::getObjectClass() */ public static function getObjectClass($baseClass, $enumValue) { - if($baseClass == 'KalturaStorageProfile' && $enumValue == self::getStorageProfileProtocolCoreValue(KontikiStorageProfileProtocol::KONTIKI)) - return 'KalturaKontikiStorageProfile'; - + if($baseClass == 'StorageProfile' && $enumValue == self::getStorageProfileProtocolCoreValue(KontikiStorageProfileProtocol::KONTIKI)) + return 'KontikiStorageProfile'; } /* (non-PHPdoc) From 550dbdc95199ae3a9cbb5139e1a45355525acb09 Mon Sep 17 00:00:00 2001 From: ranyefet Date: Thu, 18 Jul 2013 16:50:15 +0300 Subject: [PATCH 044/132] Redirect to www_host --- .../apps/kaltura/modules/kmc/actions/previewAction.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php b/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php index f1ce7511c65..ef103e06f58 100644 --- a/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php +++ b/alpha/apps/kaltura/modules/kmc/actions/previewAction.class.php @@ -8,7 +8,9 @@ class previewAction extends kalturaAction public function execute() { // Preview page moved into /extwidget/preview - $url = '/index.php'; + $https_enabled = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false; + $protocol = ($https_enabled) ? 'https' : 'http'; + $url = $protocol . '://' . kConf::get('www_host') . '/index.php'; $url .= str_replace('/kmc', '/extwidget', $_SERVER['PATH_INFO']); if( isset($_SERVER['QUERY_STRING']) ) { $url .= '?' . $_SERVER['QUERY_STRING']; From 8cc26e3e0b469050083cfe2326084fb51414c3dc Mon Sep 17 00:00:00 2001 From: ranyefet Date: Thu, 18 Jul 2013 16:50:43 +0300 Subject: [PATCH 045/132] updated 6.0.7 files --- alpha/web/lib/js/kmc/6.0.7/kmc.js | 28 +++++++++++++++++++++------ alpha/web/lib/js/kmc/6.0.7/kmc.min.js | 6 +++--- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/alpha/web/lib/js/kmc/6.0.7/kmc.js b/alpha/web/lib/js/kmc/6.0.7/kmc.js index 9eee74124c4..5de9a6bd92a 100644 --- a/alpha/web/lib/js/kmc/6.0.7/kmc.js +++ b/alpha/web/lib/js/kmc/6.0.7/kmc.js @@ -1,4 +1,4 @@ -/*! KMC - v6.0.7 - 2013-07-17 +/*! KMC - v6.0.7 - 2013-07-18 * https://github.com/kaltura/KMC_V2 * Copyright (c) 2013 Ran Yefet; Licensed GNU */ /*! Kaltura Embed Code Generator - v1.0.6 - 2013-02-28 @@ -2632,7 +2632,7 @@ if ( window.XDomainRequest ) { Preview.iframeContainer = 'previewIframe'; // We use this flag to ignore all change evnets when we initilize the preview ( on page start up ) - // We will set that to true once Preview is opened. + // We will set that to false once Preview is opened. Preview.ignoreChangeEvents = true; // Set generator @@ -2760,12 +2760,14 @@ if ( window.XDomainRequest ) { }; options = $.extend({}, defaults, options); + previewService.disableEvents(); // In case of live entry preview, set delivery type to auto if( options.liveBitrates ) { previewService.setDeliveryType('auto'); } // Update our players previewService.updatePlayers(options); + previewService.enableEvents(); // Set options previewService.set(options); @@ -2948,6 +2950,7 @@ if ( window.XDomainRequest ) { var kmcApp = angular.module('kmcApp', []); kmcApp.factory('previewService', ['$rootScope', function($rootScope) { var previewProps = {}; + var disableCount = 0; return { get: function(key) { if(key === undefined) return previewProps; @@ -2959,10 +2962,16 @@ kmcApp.factory('previewService', ['$rootScope', function($rootScope) { } else { previewProps[key] = value; } - if(!quiet) { + if( !quiet && disableCount === 0 ) { $rootScope.$broadcast('previewChanged'); } }, + enableEvents: function(){ + disableCount--; + }, + disableEvents: function(){ + disableCount++ + }, updatePlayers: function(options) { $rootScope.$broadcast('playersUpdated', options); }, @@ -2970,7 +2979,7 @@ kmcApp.factory('previewService', ['$rootScope', function($rootScope) { $rootScope.$broadcast('changePlayer', playerId); }, setDeliveryType: function( deliveryTypeId ) { - $rootScope.$broadcast('changeDelivery', deliveryTypeId); + $rootScope.$broadcast('changeDelivery', deliveryTypeId ); } }; }]); @@ -3023,12 +3032,14 @@ kmcApp.controller('PreviewCtrl', ['$scope', 'previewService', function($scope, p if(!Preview.playlistMode) { Preview.playlistMode = true; $scope.$broadcast('changePlayer', playerId); + return; } } else { $scope.players = kmc.vars.players_list; if(Preview.playlistMode || !$scope.player) { Preview.playlistMode = false; $scope.$broadcast('changePlayer', playerId); + return; } } if(playerId){ @@ -3134,12 +3145,17 @@ kmcApp.controller('PreviewCtrl', ['$scope', 'previewService', function($scope, p $scope.$watch('player', function() { var player = Preview.getObjectById($scope.player, $scope.players); if(!player) { return ; } + previewService.disableEvents(); setDeliveryTypes(player); setEmbedTypes(player); - previewService.set('player', player); + setTimeout(function(){ + previewService.enableEvents(); + previewService.set('player', player); + },0); }); $scope.$watch('deliveryType', function() { - previewService.set('deliveryType', Preview.getObjectById($scope.deliveryType, $scope.deliveryTypes)); + var deliveryType = Preview.getObjectById($scope.deliveryType, $scope.deliveryTypes); + previewService.set('deliveryType', deliveryType); }); $scope.$watch('embedType', function() { previewService.set('embedType', $scope.embedType); diff --git a/alpha/web/lib/js/kmc/6.0.7/kmc.min.js b/alpha/web/lib/js/kmc/6.0.7/kmc.min.js index 15b7b3f6770..9c554424c6e 100644 --- a/alpha/web/lib/js/kmc/6.0.7/kmc.min.js +++ b/alpha/web/lib/js/kmc/6.0.7/kmc.min.js @@ -1,6 +1,6 @@ -/*! KMC - v6.0.7 - 2013-07-17 +/*! KMC - v6.0.7 - 2013-07-18 * https://github.com/kaltura/KMC_V2 * Copyright (c) 2013 Ran Yefet; Licensed GNU */ function openPlayer(e,t,r,a,n){n===!0&&$("#kcms")[0].alert("previewOnly from studio"),kmc.preview_embed.doPreviewEmbed("multitab_playlist",e,null,n,!0,a,!1,!1,!1)}function playlistAdded(){kmc.preview_embed.updateList(!0)}function playerAdded(){kmc.preview_embed.updateList(!1)}function md5(e){var t,r,a,n,i,o,s,l,c,d,h=function(e,t){return e<>>32-t},u=function(e,t){var r,a,n,i,o;return n=2147483648&e,i=2147483648&t,r=1073741824&e,a=1073741824&t,o=(1073741823&e)+(1073741823&t),r&a?2147483648^o^n^i:r|a?1073741824&o?3221225472^o^n^i:1073741824^o^n^i:o^n^i},p=function(e,t,r){return e&t|~e&r},f=function(e,t,r){return e&r|t&~r},m=function(e,t,r){return e^t^r},v=function(e,t,r){return t^(e|~r)},g=function(e,t,r,a,n,i,o){return e=u(e,u(u(p(t,r,a),n),o)),u(h(e,i),t)},y=function(e,t,r,a,n,i,o){return e=u(e,u(u(f(t,r,a),n),o)),u(h(e,i),t)},b=function(e,t,r,a,n,i,o){return e=u(e,u(u(m(t,r,a),n),o)),u(h(e,i),t)},w=function(e,t,r,a,n,i,o){return e=u(e,u(u(v(t,r,a),n),o)),u(h(e,i),t)},k=function(e){for(var t,r=e.length,a=r+8,n=(a-a%64)/64,i=16*(n+1),o=Array(i-1),s=0,l=0;r>l;)t=(l-l%4)/4,s=8*(l%4),o[t]=o[t]|e.charCodeAt(l)<>>29,o},_=function(e){var t,r,a="",n="";for(r=0;3>=r;r++)t=255&e>>>8*r,n="0"+t.toString(16),a+=n.substr(n.length-2,2);return a},C=[],I=7,T=12,E=17,P=22,M=5,A=9,S=14,L=20,$=4,x=11,N=16,B=23,D=6,O=10,H=15,U=21;for(e=this.utf8_encode(e),C=k(e),s=1732584193,l=4023233417,c=2562383102,d=271733878,t=C.length,r=0;t>r;r+=16)a=s,n=l,i=c,o=d,s=g(s,l,c,d,C[r+0],I,3614090360),d=g(d,s,l,c,C[r+1],T,3905402710),c=g(c,d,s,l,C[r+2],E,606105819),l=g(l,c,d,s,C[r+3],P,3250441966),s=g(s,l,c,d,C[r+4],I,4118548399),d=g(d,s,l,c,C[r+5],T,1200080426),c=g(c,d,s,l,C[r+6],E,2821735955),l=g(l,c,d,s,C[r+7],P,4249261313),s=g(s,l,c,d,C[r+8],I,1770035416),d=g(d,s,l,c,C[r+9],T,2336552879),c=g(c,d,s,l,C[r+10],E,4294925233),l=g(l,c,d,s,C[r+11],P,2304563134),s=g(s,l,c,d,C[r+12],I,1804603682),d=g(d,s,l,c,C[r+13],T,4254626195),c=g(c,d,s,l,C[r+14],E,2792965006),l=g(l,c,d,s,C[r+15],P,1236535329),s=y(s,l,c,d,C[r+1],M,4129170786),d=y(d,s,l,c,C[r+6],A,3225465664),c=y(c,d,s,l,C[r+11],S,643717713),l=y(l,c,d,s,C[r+0],L,3921069994),s=y(s,l,c,d,C[r+5],M,3593408605),d=y(d,s,l,c,C[r+10],A,38016083),c=y(c,d,s,l,C[r+15],S,3634488961),l=y(l,c,d,s,C[r+4],L,3889429448),s=y(s,l,c,d,C[r+9],M,568446438),d=y(d,s,l,c,C[r+14],A,3275163606),c=y(c,d,s,l,C[r+3],S,4107603335),l=y(l,c,d,s,C[r+8],L,1163531501),s=y(s,l,c,d,C[r+13],M,2850285829),d=y(d,s,l,c,C[r+2],A,4243563512),c=y(c,d,s,l,C[r+7],S,1735328473),l=y(l,c,d,s,C[r+12],L,2368359562),s=b(s,l,c,d,C[r+5],$,4294588738),d=b(d,s,l,c,C[r+8],x,2272392833),c=b(c,d,s,l,C[r+11],N,1839030562),l=b(l,c,d,s,C[r+14],B,4259657740),s=b(s,l,c,d,C[r+1],$,2763975236),d=b(d,s,l,c,C[r+4],x,1272893353),c=b(c,d,s,l,C[r+7],N,4139469664),l=b(l,c,d,s,C[r+10],B,3200236656),s=b(s,l,c,d,C[r+13],$,681279174),d=b(d,s,l,c,C[r+0],x,3936430074),c=b(c,d,s,l,C[r+3],N,3572445317),l=b(l,c,d,s,C[r+6],B,76029189),s=b(s,l,c,d,C[r+9],$,3654602809),d=b(d,s,l,c,C[r+12],x,3873151461),c=b(c,d,s,l,C[r+15],N,530742520),l=b(l,c,d,s,C[r+2],B,3299628645),s=w(s,l,c,d,C[r+0],D,4096336452),d=w(d,s,l,c,C[r+7],O,1126891415),c=w(c,d,s,l,C[r+14],H,2878612391),l=w(l,c,d,s,C[r+5],U,4237533241),s=w(s,l,c,d,C[r+12],D,1700485571),d=w(d,s,l,c,C[r+3],O,2399980690),c=w(c,d,s,l,C[r+10],H,4293915773),l=w(l,c,d,s,C[r+1],U,2240044497),s=w(s,l,c,d,C[r+8],D,1873313359),d=w(d,s,l,c,C[r+15],O,4264355552),c=w(c,d,s,l,C[r+6],H,2734768916),l=w(l,c,d,s,C[r+13],U,1309151649),s=w(s,l,c,d,C[r+4],D,4149444226),d=w(d,s,l,c,C[r+11],O,3174756917),c=w(c,d,s,l,C[r+2],H,718787259),l=w(l,c,d,s,C[r+9],U,3951481745),s=u(s,a),l=u(l,n),c=u(c,i),d=u(d,o);var j=_(s)+_(l)+_(c)+_(d);return j.toLowerCase()}function utf8_encode(e){if(null===e||e===void 0)return"";var t,r,a=e+"",n="",i=0;t=r=0,i=a.length;for(var o=0;i>o;o++){var s=a.charCodeAt(o),l=null;128>s?r++:l=s>127&&2048>s?String.fromCharCode(192|s>>6)+String.fromCharCode(128|63&s):String.fromCharCode(224|s>>12)+String.fromCharCode(128|63&s>>6)+String.fromCharCode(128|63&s),null!==l&&(r>t&&(n+=a.slice(t,r)),n+=l,t=r=o+1)}return r>t&&(n+=a.slice(t,i)),n}this.Handlebars={},function(e){e.VERSION="1.0.rc.2",e.helpers={},e.partials={},e.registerHelper=function(e,t,r){r&&(t.not=r),this.helpers[e]=t},e.registerPartial=function(e,t){this.partials[e]=t},e.registerHelper("helperMissing",function(e){if(2===arguments.length)return void 0;throw Error("Could not find property '"+e+"'")});var t=Object.prototype.toString,r="[object Function]";e.registerHelper("blockHelperMissing",function(a,n){var i=n.inverse||function(){},o=n.fn,s=t.call(a);return s===r&&(a=a.call(this)),a===!0?o(this):a===!1||null==a?i(this):"[object Array]"===s?a.length>0?e.helpers.each(a,n):i(this):o(a)}),e.K=function(){},e.createFrame=Object.create||function(t){e.K.prototype=t;var r=new e.K;return e.K.prototype=null,r},e.logger={DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,methodMap:{0:"debug",1:"info",2:"warn",3:"error"},log:function(t,r){if(t>=e.logger.level){var a=e.logger.methodMap[t];"undefined"!=typeof console&&console[a]&&console[a].call(console,r)}}},e.log=function(t,r){e.logger.log(t,r)},e.registerHelper("each",function(t,r){var a,n=r.fn,i=r.inverse,o=0,s="";if(r.data&&(a=e.createFrame(r.data)),t&&"object"==typeof t)if(t instanceof Array)for(var l=t.length;l>o;o++)a&&(a.index=o),s+=n(t[o],{data:a});else for(var c in t)t.hasOwnProperty(c)&&(a&&(a.key=c),s+=n(t[c],{data:a}),o++);return 0===o&&(s=i(this)),s}),e.registerHelper("if",function(a,n){var i=t.call(a);return i===r&&(a=a.call(this)),!a||e.Utils.isEmpty(a)?n.inverse(this):n.fn(this)}),e.registerHelper("unless",function(t,r){var a=r.fn,n=r.inverse;return r.fn=n,r.inverse=a,e.helpers["if"].call(this,t,r)}),e.registerHelper("with",function(e,t){return t.fn(e)}),e.registerHelper("log",function(t,r){var a=r.data&&null!=r.data.level?parseInt(r.data.level,10):1;e.log(a,t)})}(this.Handlebars);var errorProps=["description","fileName","lineNumber","message","name","number","stack"];Handlebars.Exception=function(){for(var e=Error.prototype.constructor.apply(this,arguments),t=0;errorProps.length>t;t++)this[errorProps[t]]=e[errorProps[t]]},Handlebars.Exception.prototype=Error(),Handlebars.SafeString=function(e){this.string=e},Handlebars.SafeString.prototype.toString=function(){return""+this.string},function(){var e={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},t=/[&<>"'`]/g,r=/[&<>"'`]/,a=function(t){return e[t]||"&"};Handlebars.Utils={escapeExpression:function(e){return e instanceof Handlebars.SafeString?""+e:null==e||e===!1?"":r.test(e)?e.replace(t,a):e},isEmpty:function(e){return e||0===e?"[object Array]"===Object.prototype.toString.call(e)&&0===e.length?!0:!1:!0}}}(),Handlebars.VM={template:function(e){var t={escapeExpression:Handlebars.Utils.escapeExpression,invokePartial:Handlebars.VM.invokePartial,programs:[],program:function(e,t,r){var a=this.programs[e];return r?Handlebars.VM.program(t,r):a?a:a=this.programs[e]=Handlebars.VM.program(t)},programWithDepth:Handlebars.VM.programWithDepth,noop:Handlebars.VM.noop};return function(r,a){return a=a||{},e.call(t,Handlebars,r,a.helpers,a.partials,a.data)}},programWithDepth:function(e,t){var r=Array.prototype.slice.call(arguments,2);return function(a,n){return n=n||{},e.apply(this,[a,n.data||t].concat(r))}},program:function(e,t){return function(r,a){return a=a||{},e(r,a.data||t)}},noop:function(){return""},invokePartial:function(e,t,r,a,n,i){var o={helpers:a,partials:n,data:i};if(void 0===e)throw new Handlebars.Exception("The partial "+t+" could not be found");if(e instanceof Function)return e(r,o);if(Handlebars.compile)return n[t]=Handlebars.compile(e,{data:void 0!==i}),n[t](r,o);throw new Handlebars.Exception("The partial "+t+" could not be compiled when running in runtime-only mode")}},Handlebars.template=Handlebars.VM.template,function(e,t){var r=function(e,t){var r="",a=t?t+"[":"",n=t?"]":"";for(var i in e)if("object"==typeof e[i])for(var o in e[i])r+="&"+a+encodeURIComponent(i)+"."+encodeURIComponent(o)+n+"="+encodeURIComponent(e[i][o]);else r+="&"+a+encodeURIComponent(i)+n+"="+encodeURIComponent(e[i]);return r};t.registerHelper("flashVarsUrl",function(e){return r(e,"flashvars")}),t.registerHelper("flashVarsString",function(e){return r(e)}),t.registerHelper("elAttributes",function(e){var t="";for(var r in e)t+=" "+r+'="'+e[r]+'"';return t}),t.registerHelper("kalturaLinks",function(){if(!this.includeKalturaLinks)return"";var e=t.templates.kaltura_links;return e()}),t.registerHelper("seoMetadata",function(){var e=t.templates.seo_metadata;return e(this)})}(this,this.Handlebars),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.auto=e(function(e,t,r,a,n){function i(e){var t,a,n="";return n+='
    ",d=r.seoMetadata,t=d||e.seoMetadata,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"seoMetadata",{hash:{}})),(t||0===t)&&(n+=t),d=r.kalturaLinks,t=d||e.kalturaLinks,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"kalturaLinks",{hash:{}})),(t||0===t)&&(n+=t),n+="
    \n"}function o(e){var t,a="";return a+="&entry_id=",d=r.entryId,t=d||e.entryId,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"entryId",{hash:{}})),a+=g(t)}function s(e){var t,a="";return a+="&cache_st=",d=r.cacheSt,t=d||e.cacheSt,typeof t===f?t=t.call(e,{hash:{}}):t===v&&(t=m.call(e,"cacheSt",{hash:{}})),a+=g(t)}r=r||e.helpers;var l,c,d,h,u="",p=this,f="function",m=r.helperMissing,v=void 0,g=this.escapeExpression;return d=r.includeSeoMetadata,l=d||t.includeSeoMetadata,c=r["if"],h=p.program(1,i,n),h.hash={},h.fn=h,h.inverse=p.noop,l=c.call(t,l,h),(l||0===l)&&(u+=l),u+=''}),t.dynamic=e(function(e,t,r){r=r||e.helpers;var a,n,i,o="",s="function",l=r.helperMissing,c=void 0,d=this.escapeExpression;return o+='\n
    ",i=r.seoMetadata,a=i||t.seoMetadata,typeof a===s?a=a.call(t,{hash:{}}):a===c&&(a=l.call(t,"seoMetadata",{hash:{}})),(a||0===a)&&(o+=a),i=r.kalturaLinks,a=i||t.kalturaLinks,typeof a===s?a=a.call(t,{hash:{}}):a===c&&(a=l.call(t,"kalturaLinks",{hash:{}})),(a||0===a)&&(o+=a),o+="
    \n"}),t.iframe=e(function(e,t,r,a,n){function i(e){var t,a="";return a+="&entry_id=",l=r.entryId,t=l||e.entryId,typeof t===u?t=t.call(e,{hash:{}}):t===f&&(t=p.call(e,"entryId",{hash:{}})),a+=m(t)}r=r||e.helpers;var o,s,l,c,d="",h=this,u="function",p=r.helperMissing,f=void 0,m=this.escapeExpression;return d+='"}),t.kaltura_links=e(function(e,t,r){return r=r||e.helpers,'Video Platform\nVideo Management \nVideo Solutions\nVideo Player'}),t.legacy=e(function(e,t,r,a,n){function i(e){var t,a="";return a+='\n'}function o(e){var t,a="";return a+='\n \n \n \n \n \n \n '}r=r||e.helpers;var s,l,c,d,h="",u=this,p="function",f=r.helperMissing,m=void 0,v=this.escapeExpression;return c=r.includeHtml5Library,s=c||t.includeHtml5Library,l=r["if"],d=u.program(1,i,n),d.hash={},d.fn=d,d.inverse=u.noop,s=l.call(t,s,d),(s||0===s)&&(h+=s),h+='\n \n \n \n \n \n \n ',c=r.includeSeoMetadata,s=c||t.includeSeoMetadata,l=r["if"],d=u.program(3,o,n),d.hash={},d.fn=d,d.inverse=u.noop,s=l.call(t,s,d),(s||0===s)&&(h+=s),c=r.kalturaLinks,s=c||t.kalturaLinks,typeof s===p?s=s.call(t,{hash:{}}):s===m&&(s=f.call(t,"kalturaLinks",{hash:{}})),(s||0===s)&&(h+=s),h+="\n"}),t.seo_metadata=e(function(e,t,r,a,n){function i(e){var t,a="";return a+='\n\n\n\n\n\n\n'}r=r||e.helpers;var o,s,l,c,d=this,h="function",u=r.helperMissing,p=void 0,f=this.escapeExpression;return l=r.includeSeoMetadata,o=l||t.includeSeoMetadata,s=r["if"],c=d.program(1,i,n),c.hash={},c.fn=c,c.inverse=d.noop,o=s.call(t,o,c),o||0===o?o:""})}(),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){"use strict";if(null==this)throw new TypeError;var t=Object(this),r=t.length>>>0;if(0===r)return-1;var a=0;if(arguments.length>1&&(a=Number(arguments[1]),a!==a?a=0:0!==a&&1/0!==a&&a!==-1/0&&(a=(a>0||-1)*Math.floor(Math.abs(a)))),a>=r)return-1;for(var n=a>=0?a:Math.max(r-Math.abs(a),0);r>n;n++)if(n in t&&t[n]===e)return n;return-1}),Object.keys||(Object.keys=function(){var e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=r.length;return function(n){if("object"!=typeof n&&"function"!=typeof n||null===n)throw new TypeError("Object.keys called on non-object");var i=[];for(var o in n)e.call(n,o)&&i.push(o);if(t)for(var s=0;a>s;s++)e.call(n,r[s])&&i.push(r[s]);return i}}()),function(e,t){var r=function(e){this.init(e)};r.prototype={types:["auto","dynamic","thumb","iframe","legacy"],required:["widgetId","partnerId","uiConfId"],defaults:{embedType:"auto",playerId:"kaltura_player",protocol:"http",host:"www.kaltura.com",securedHost:"www.kaltura.com",widgetId:null,partnerId:null,cacheSt:null,uiConfId:null,entryId:null,entryMeta:{},width:400,height:330,attributes:{},flashVars:{},includeKalturaLinks:!0,includeSeoMetadata:!1,includeHtml5Library:!0},extend:function(e,t){for(var r in t)t.hasOwnProperty(r)&&!e.hasOwnProperty(r)&&(e[r]=t[r]);return e},isNull:function(e){return e.length&&e.length>0?!1:e.length&&0===e.length?!0:"object"==typeof e?Object.keys(e).length>0?!1:!0:!e},init:function(e){if(e=e||{},this.defaults,typeof Handlebars===t)throw"Handlebars is not defined, please include Handlebars.js before this script";return"object"==typeof e&&(this.options=this.extend(e,this.defaults)),!this.config("widgetId")&&this.config("partnerId")&&this.config("widgetId","_"+this.config("partnerId")),this},config:function(e,r){return r===t&&"string"==typeof e&&this.options.hasOwnProperty(e)?this.options[e]:e===t&&r===t?this.options:("string"==typeof e&&r!==t&&(this.options[e]=r),null)},checkRequiredParams:function(e){var t=this.required.length,r=0;for(r;t>r;r++)if(this.isNull(e[this.required[r]]))throw"Missing required parameter: "+this.required[r]},checkValidType:function(e){var t=-1!==this.types.indexOf(e)?!0:!1;if(!t)throw"Embed type: "+e+" is not valid. Available types: "+this.types.join(",")},getTemplate:function(e){return e="thumb"==e?"dynamic":e,e&&Handlebars.templates&&Handlebars.templates[e]?Handlebars.templates[e]:null},isKWidgetEmbed:function(e){return"dynamic"==e||"thumb"==e?!0:!1},getHost:function(e){return"http"===e.protocol?e.host:e.securedHost},getScriptUrl:function(e){return e.protocol+"://"+this.getHost(e)+"/p/"+e.partnerId+"/sp/"+e.partnerId+"00/embedIframeJs/uiconf_id/"+e.uiConfId+"/partner_id/"+e.partnerId},getSwfUrl:function(e){var t=e.cacheSt?"/cache_st/"+e.cacheSt:"",r=e.entryId?"/entry_id/"+e.entryId:"";return e.protocol+"://"+this.getHost(e)+"/index.php/kwidget"+t+"/wid/"+e.widgetId+"/uiconf_id/"+e.uiConfId+r},getAttributes:function(e){var t={};return(this.isKWidgetEmbed(e.embedType)||e.includeSeoMetadata)&&(t.style="width: "+e.width+"px; height: "+e.height+"px;"),e.includeSeoMetadata&&("legacy"==e.embedType?(t["xmlns:dc"]="http://purl.org/dc/terms/",t["xmlns:media"]="http://search.yahoo.com/searchmonkey/media/",t.rel="media:video",t.resource=this.getSwfUrl(e)):(t.itemprop="video",t["itemscope itemtype"]="http://schema.org/VideoObject")),t},getEmbedObject:function(e){var t={targetId:e.playerId,wid:e.widgetId,uiconf_id:e.uiConfId,flashvars:e.flashVars};return e.cacheSt&&(t.cache_st=e.cacheSt),e.entryId&&(t.entry_id=e.entryId),JSON.stringify(t,null,2)},getCode:function(e){var r=e===t?{}:this.extend({},e);r=this.extend(r,this.config()),!r.widgetId&&r.partnerId&&(r.widgetId="_"+r.partnerId),this.checkRequiredParams(r),this.checkValidType(r.embedType);var a=this.getTemplate(r.embedType);if(!a)throw"Template: "+r.embedType+" is not defined as Handlebars template";var n={host:this.getHost(r),scriptUrl:this.getScriptUrl(r),attributes:this.getAttributes(r)};return"legacy"===r.embedType&&(n.swfUrl=this.getSwfUrl(r)),this.isKWidgetEmbed(r.embedType)&&(n.embedMethod="dynamic"==r.embedType?"embed":"thumbEmbed",n.kWidgetObject=this.getEmbedObject(r)),n=this.extend(n,r),a(n)}},e.kEmbedCodeGenerator=r}(this),function(e){e.fn.qrcode=function(t){function r(e){this.mode=s.MODE_8BIT_BYTE,this.data=e}function a(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function n(e,t){if(void 0==e.length)throw Error(e.length+"/"+t);for(var r=0;e.length>r&&0==e[r];)r++;this.num=Array(e.length-r+t);for(var a=0;e.length-r>a;a++)this.num[a]=e[a+r]}function i(e,t){this.totalCount=e,this.dataCount=t}function o(){this.buffer=[],this.length=0}r.prototype={getLength:function(){return this.data.length},write:function(e){for(var t=0;this.data.length>t;t++)e.put(this.data.charCodeAt(t),8)}},a.prototype={addData:function(e){var t=new r(e);this.dataList.push(t),this.dataCache=null},isDark:function(e,t){if(0>e||e>=this.moduleCount||0>t||t>=this.moduleCount)throw Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){var e=1;for(e=1;40>e;e++){for(var t=i.getRSBlocks(e,this.errorCorrectLevel),r=new o,a=0,n=0;t.length>n;n++)a+=t[n].dataCount;for(var n=0;this.dataList.length>n;n++){var s=this.dataList[n];r.put(s.mode,4),r.put(s.getLength(),d.getLengthInBits(s.mode,e)),s.write(r)}if(8*a>=r.getLengthInBits())break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,t){this.moduleCount=4*this.typeNumber+17,this.modules=Array(this.moduleCount);for(var r=0;this.moduleCount>r;r++){this.modules[r]=Array(this.moduleCount);for(var n=0;this.moduleCount>n;n++)this.modules[r][n]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,t),this.typeNumber>=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=a.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;7>=r;r++)if(!(-1>=e+r||e+r>=this.moduleCount))for(var a=-1;7>=a;a++)-1>=t+a||t+a>=this.moduleCount||(this.modules[e+r][t+a]=r>=0&&6>=r&&(0==a||6==a)||a>=0&&6>=a&&(0==r||6==r)||r>=2&&4>=r&&a>=2&&4>=a?!0:!1)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;8>r;r++){this.makeImpl(!0,r);var a=d.getLostPoint(this);(0==r||e>a)&&(e=a,t=r)}return t},createMovieClip:function(e,t,r){var a=e.createEmptyMovieClip(t,r),n=1;this.make();for(var i=0;this.modules.length>i;i++)for(var o=i*n,s=0;this.modules[i].length>s;s++){var l=s*n,c=this.modules[i][s];c&&(a.beginFill(0,100),a.moveTo(l,o),a.lineTo(l+n,o),a.lineTo(l+n,o+n),a.lineTo(l,o+n),a.endFill())}return a},setupTimingPattern:function(){for(var e=8;this.moduleCount-8>e;e++)null==this.modules[e][6]&&(this.modules[e][6]=0==e%2);for(var t=8;this.moduleCount-8>t;t++)null==this.modules[6][t]&&(this.modules[6][t]=0==t%2)},setupPositionAdjustPattern:function(){for(var e=d.getPatternPosition(this.typeNumber),t=0;e.length>t;t++)for(var r=0;e.length>r;r++){var a=e[t],n=e[r];if(null==this.modules[a][n])for(var i=-2;2>=i;i++)for(var o=-2;2>=o;o++)this.modules[a+i][n+o]=-2==i||2==i||-2==o||2==o||0==i&&0==o?!0:!1}},setupTypeNumber:function(e){for(var t=d.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var a=!e&&1==(1&t>>r);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=a}for(var r=0;18>r;r++){var a=!e&&1==(1&t>>r);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=a}},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,a=d.getBCHTypeInfo(r),n=0;15>n;n++){var i=!e&&1==(1&a>>n);6>n?this.modules[n][8]=i:8>n?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(var n=0;15>n;n++){var i=!e&&1==(1&a>>n);8>n?this.modules[8][this.moduleCount-n-1]=i:9>n?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,a=this.moduleCount-1,n=7,i=0,o=this.moduleCount-1;o>0;o-=2)for(6==o&&o--;;){for(var s=0;2>s;s++)if(null==this.modules[a][o-s]){var l=!1;e.length>i&&(l=1==(1&e[i]>>>n));var c=d.getMask(t,a,o-s);c&&(l=!l),this.modules[a][o-s]=l,n--,-1==n&&(i++,n=7)}if(a+=r,0>a||a>=this.moduleCount){a-=r,r=-r;break}}}},a.PAD0=236,a.PAD1=17,a.createData=function(e,t,r){for(var n=i.getRSBlocks(e,t),s=new o,l=0;r.length>l;l++){var c=r[l];s.put(c.mode,4),s.put(c.getLength(),d.getLengthInBits(c.mode,e)),c.write(s)}for(var h=0,l=0;n.length>l;l++)h+=n[l].dataCount;if(s.getLengthInBits()>8*h)throw Error("code length overflow. ("+s.getLengthInBits()+">"+8*h+")");for(8*h>=s.getLengthInBits()+4&&s.put(0,4);0!=s.getLengthInBits()%8;)s.putBit(!1);for(;;){if(s.getLengthInBits()>=8*h)break;if(s.put(a.PAD0,8),s.getLengthInBits()>=8*h)break;s.put(a.PAD1,8)}return a.createBytes(s,n)},a.createBytes=function(e,t){for(var r=0,a=0,i=0,o=Array(t.length),s=Array(t.length),l=0;t.length>l;l++){var c=t[l].dataCount,h=t[l].totalCount-c;a=Math.max(a,c),i=Math.max(i,h),o[l]=Array(c);for(var u=0;o[l].length>u;u++)o[l][u]=255&e.buffer[u+r];r+=c;var p=d.getErrorCorrectPolynomial(h),f=new n(o[l],p.getLength()-1),m=f.mod(p);s[l]=Array(p.getLength()-1);for(var u=0;s[l].length>u;u++){var v=u+m.getLength()-s[l].length;s[l][u]=v>=0?m.get(v):0}}for(var g=0,u=0;t.length>u;u++)g+=t[u].totalCount;for(var y=Array(g),b=0,u=0;a>u;u++)for(var l=0;t.length>l;l++)o[l].length>u&&(y[b++]=o[l][u]);for(var u=0;i>u;u++)for(var l=0;t.length>l;l++)s[l].length>u&&(y[b++]=s[l][u]);return y};for(var s={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},l={L:1,M:0,Q:3,H:2},c={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},d={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var t=e<<10;d.getBCHDigit(t)-d.getBCHDigit(d.G15)>=0;)t^=d.G15<=0;)t^=d.G18<>>=1;return t},getPatternPosition:function(e){return d.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case c.PATTERN000:return 0==(t+r)%2;case c.PATTERN001:return 0==t%2;case c.PATTERN010:return 0==r%3;case c.PATTERN011:return 0==(t+r)%3;case c.PATTERN100:return 0==(Math.floor(t/2)+Math.floor(r/3))%2;case c.PATTERN101:return 0==t*r%2+t*r%3;case c.PATTERN110:return 0==(t*r%2+t*r%3)%2;case c.PATTERN111:return 0==(t*r%3+(t+r)%2)%2;default:throw Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new n([1],0),r=0;e>r;r++)t=t.multiply(new n([1,h.gexp(r)],0));return t},getLengthInBits:function(e,t){if(t>=1&&10>t)switch(e){case s.MODE_NUMBER:return 10;case s.MODE_ALPHA_NUM:return 9;case s.MODE_8BIT_BYTE:return 8;case s.MODE_KANJI:return 8;default:throw Error("mode:"+e)}else if(27>t)switch(e){case s.MODE_NUMBER:return 12;case s.MODE_ALPHA_NUM:return 11;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 10;default:throw Error("mode:"+e)}else{if(!(41>t))throw Error("type:"+t);switch(e){case s.MODE_NUMBER:return 14;case s.MODE_ALPHA_NUM:return 13;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 12;default:throw Error("mode:"+e)}}},getLostPoint:function(e){for(var t=e.getModuleCount(),r=0,a=0;t>a;a++)for(var n=0;t>n;n++){for(var i=0,o=e.isDark(a,n),s=-1;1>=s;s++)if(!(0>a+s||a+s>=t))for(var l=-1;1>=l;l++)0>n+l||n+l>=t||(0!=s||0!=l)&&o==e.isDark(a+s,n+l)&&i++; -i>5&&(r+=3+i-5)}for(var a=0;t-1>a;a++)for(var n=0;t-1>n;n++){var c=0;e.isDark(a,n)&&c++,e.isDark(a+1,n)&&c++,e.isDark(a,n+1)&&c++,e.isDark(a+1,n+1)&&c++,(0==c||4==c)&&(r+=3)}for(var a=0;t>a;a++)for(var n=0;t-6>n;n++)e.isDark(a,n)&&!e.isDark(a,n+1)&&e.isDark(a,n+2)&&e.isDark(a,n+3)&&e.isDark(a,n+4)&&!e.isDark(a,n+5)&&e.isDark(a,n+6)&&(r+=40);for(var n=0;t>n;n++)for(var a=0;t-6>a;a++)e.isDark(a,n)&&!e.isDark(a+1,n)&&e.isDark(a+2,n)&&e.isDark(a+3,n)&&e.isDark(a+4,n)&&!e.isDark(a+5,n)&&e.isDark(a+6,n)&&(r+=40);for(var d=0,n=0;t>n;n++)for(var a=0;t>a;a++)e.isDark(a,n)&&d++;var h=Math.abs(100*d/t/t-50)/5;return r+=10*h}},h={glog:function(e){if(1>e)throw Error("glog("+e+")");return h.LOG_TABLE[e]},gexp:function(e){for(;0>e;)e+=255;for(;e>=256;)e-=255;return h.EXP_TABLE[e]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},u=0;8>u;u++)h.EXP_TABLE[u]=1<u;u++)h.EXP_TABLE[u]=h.EXP_TABLE[u-4]^h.EXP_TABLE[u-5]^h.EXP_TABLE[u-6]^h.EXP_TABLE[u-8];for(var u=0;255>u;u++)h.LOG_TABLE[h.EXP_TABLE[u]]=u;n.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=Array(this.getLength()+e.getLength()-1),r=0;this.getLength()>r;r++)for(var a=0;e.getLength()>a;a++)t[r+a]^=h.gexp(h.glog(this.get(r))+h.glog(e.get(a)));return new n(t,0)},mod:function(e){if(0>this.getLength()-e.getLength())return this;for(var t=h.glog(this.get(0))-h.glog(e.get(0)),r=Array(this.getLength()),a=0;this.getLength()>a;a++)r[a]=this.get(a);for(var a=0;e.getLength()>a;a++)r[a]^=h.gexp(h.glog(e.get(a))+t);return new n(r,0).mod(e)}},i.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],i.getRSBlocks=function(e,t){var r=i.getRsBlockTable(e,t);if(void 0==r)throw Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+t);for(var a=r.length/3,n=[],o=0;a>o;o++)for(var s=r[3*o+0],l=r[3*o+1],c=r[3*o+2],d=0;s>d;d++)n.push(new i(l,c));return n},i.getRsBlockTable=function(e,t){switch(t){case l.L:return i.RS_BLOCK_TABLE[4*(e-1)+0];case l.M:return i.RS_BLOCK_TABLE[4*(e-1)+1];case l.Q:return i.RS_BLOCK_TABLE[4*(e-1)+2];case l.H:return i.RS_BLOCK_TABLE[4*(e-1)+3];default:return void 0}},o.prototype={get:function(e){var t=Math.floor(e/8);return 1==(1&this.buffer[t]>>>7-e%8)},put:function(e,t){for(var r=0;t>r;r++)this.putBit(1==(1&e>>>t-r-1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);t>=this.buffer.length&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},"string"==typeof t&&(t={text:t}),t=e.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,correctLevel:l.H,background:"#ffffff",foreground:"#000000"},t);var p=function(){var e=new a(t.typeNumber,t.correctLevel);e.addData(t.text),e.make();var r=document.createElement("canvas");r.width=t.width,r.height=t.height;for(var n=r.getContext("2d"),i=t.width/e.getModuleCount(),o=t.height/e.getModuleCount(),s=0;e.getModuleCount()>s;s++)for(var l=0;e.getModuleCount()>l;l++){n.fillStyle=e.isDark(s,l)?t.foreground:t.background;var c=Math.ceil((l+1)*i)-Math.floor(l*i),d=Math.ceil((s+1)*i)-Math.floor(s*i);n.fillRect(Math.round(l*i),Math.round(s*o),c,d)}return r},f=function(){var r=new a(t.typeNumber,t.correctLevel);r.addData(t.text),r.make();for(var n=e("
    ").css("width",t.width+"px").css("height",t.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",t.background),i=t.width/r.getModuleCount(),o=t.height/r.getModuleCount(),s=0;r.getModuleCount()>s;s++)for(var l=e("").css("height",o+"px").appendTo(n),c=0;r.getModuleCount()>c;c++)e("").css("width",i+"px").css("background-color",r.isDark(s,c)?t.foreground:t.background).appendTo(l);return n};return this.each(function(){var r="canvas"==t.render?p():f();e(r).appendTo(this)})}}(jQuery),window.XDomainRequest&&jQuery.ajaxTransport(function(e){if(e.crossDomain&&e.async){e.timeout&&(e.xdrTimeout=e.timeout,delete e.timeout);var t;return{send:function(r,a){function n(e,r,n,i){t.onload=t.onerror=t.ontimeout=jQuery.noop,t=void 0,a(e,r,n,i)}t=new XDomainRequest,t.onload=function(){n(200,"OK",{text:t.responseText},"Content-Type: "+t.contentType)},t.onerror=function(){n(404,"Not Found")},t.onprogress=jQuery.noop,t.ontimeout=function(){n(0,"timeout")},t.timeout=e.xdrTimeout||Number.MAX_VALUE,t.open(e.type,e.url),t.send(e.hasContent&&e.data||null)},abort:function(){t&&(t.onerror=jQuery.noop,t.abort())}}}}),function(){"use strict";var e,t=function(e,t){var r=e.style[t];if(e.currentStyle?r=e.currentStyle[t]:window.getComputedStyle&&(r=document.defaultView.getComputedStyle(e,null).getPropertyValue(t)),"auto"==r&&"cursor"==t)for(var a=["a"],n=0;a.length>n;n++)if(e.tagName.toLowerCase()==a[n])return"pointer";return r},r=function(e){if(u.prototype._singleton){e||(e=window.event);var t;this!==window?t=this:e.target?t=e.target:e.srcElement&&(t=e.srcElement),u.prototype._singleton.setCurrent(t)}},a=function(e,t,r){e.addEventListener?e.addEventListener(t,r,!1):e.attachEvent&&e.attachEvent("on"+t,r)},n=function(e,t,r){e.removeEventListener?e.removeEventListener(t,r,!1):e.detachEvent&&e.detachEvent("on"+t,r)},i=function(e,t){if(e.addClass)return e.addClass(t),e;if(t&&"string"==typeof t){var r=(t||"").split(/\s+/);if(1===e.nodeType)if(e.className){for(var a=" "+e.className+" ",n=e.className,i=0,o=r.length;o>i;i++)0>a.indexOf(" "+r[i]+" ")&&(n+=" "+r[i]);e.className=n.replace(/^\s+|\s+$/g,"")}else e.className=t}return e},o=function(e,t){if(e.removeClass)return e.removeClass(t),e;if(t&&"string"==typeof t||void 0===t){var r=(t||"").split(/\s+/);if(1===e.nodeType&&e.className)if(t){for(var a=(" "+e.className+" ").replace(/[\n\t]/g," "),n=0,i=r.length;i>n;n++)a=a.replace(" "+r[n]+" "," ");e.className=a.replace(/^\s+|\s+$/g,"")}else e.className=""}return e},s=function(e){var r={left:0,top:0,width:e.width||e.offsetWidth||0,height:e.height||e.offsetHeight||0,zIndex:9999},a=t(e,"zIndex");for(a&&"auto"!=a&&(r.zIndex=parseInt(a,10));e;){var n=parseInt(t(e,"borderLeftWidth"),10),i=parseInt(t(e,"borderTopWidth"),10);r.left+=isNaN(e.offsetLeft)?0:e.offsetLeft,r.left+=isNaN(n)?0:n,r.top+=isNaN(e.offsetTop)?0:e.offsetTop,r.top+=isNaN(i)?0:i,e=e.offsetParent}return r},l=function(e){return(e.indexOf("?")>=0?"&":"?")+"nocache="+(new Date).getTime()},c=function(e){var t=[];return e.trustedDomains&&("string"==typeof e.trustedDomains?t.push("trustedDomain="+e.trustedDomains):t.push("trustedDomain="+e.trustedDomains.join(","))),t.join("&")},d=function(e,t){if(t.indexOf)return t.indexOf(e);for(var r=0,a=t.length;a>r;r++)if(t[r]===e)return r;return-1},h=function(e){if("string"==typeof e)throw new TypeError("ZeroClipboard doesn't accept query strings.");return e.length?e:[e]},u=function(e,t){if(e&&(u.prototype._singleton||this).glue(e),u.prototype._singleton)return u.prototype._singleton;u.prototype._singleton=this,this.options={};for(var r in f)this.options[r]=f[r];for(var a in t)this.options[a]=t[a];this.handlers={},u.detectFlashSupport()&&m()},p=[];u.prototype.setCurrent=function(r){e=r,this.reposition(),r.getAttribute("title")&&this.setTitle(r.getAttribute("title")),this.setHandCursor("pointer"==t(r,"cursor"))},u.prototype.setText=function(e){e&&""!==e&&(this.options.text=e,this.ready()&&this.flashBridge.setText(e))},u.prototype.setTitle=function(e){e&&""!==e&&this.htmlBridge.setAttribute("title",e)},u.prototype.setSize=function(e,t){this.ready()&&this.flashBridge.setSize(e,t)},u.prototype.setHandCursor=function(e){this.ready()&&this.flashBridge.setHandCursor(e)},u.version="1.1.7";var f={moviePath:"ZeroClipboard.swf",trustedDomains:null,text:null,hoverClass:"zeroclipboard-is-hover",activeClass:"zeroclipboard-is-active",allowScriptAccess:"sameDomain"};u.setDefaults=function(e){for(var t in e)f[t]=e[t]},u.destroy=function(){u.prototype._singleton.unglue(p);var e=u.prototype._singleton.htmlBridge;e.parentNode.removeChild(e),delete u.prototype._singleton},u.detectFlashSupport=function(){var e=!1;try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(e=!0)}catch(t){navigator.mimeTypes["application/x-shockwave-flash"]&&(e=!0)}return e};var m=function(){var e=u.prototype._singleton,t=document.getElementById("global-zeroclipboard-html-bridge");if(!t){var r=' ';t=document.createElement("div"),t.id="global-zeroclipboard-html-bridge",t.setAttribute("class","global-zeroclipboard-container"),t.setAttribute("data-clipboard-ready",!1),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="15px",t.style.height="15px",t.style.zIndex="9999",t.innerHTML=r,document.body.appendChild(t)}e.htmlBridge=t,e.flashBridge=document["global-zeroclipboard-flash-bridge"]||t.children[0].lastElementChild};u.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),o(e,this.options.activeClass),e=null,this.options.text=null},u.prototype.ready=function(){var e=this.htmlBridge.getAttribute("data-clipboard-ready");return"true"===e||e===!0},u.prototype.reposition=function(){if(!e)return!1;var t=s(e);this.htmlBridge.style.top=t.top+"px",this.htmlBridge.style.left=t.left+"px",this.htmlBridge.style.width=t.width+"px",this.htmlBridge.style.height=t.height+"px",this.htmlBridge.style.zIndex=t.zIndex+1,this.setSize(t.width,t.height)},u.dispatch=function(e,t){u.prototype._singleton.receiveEvent(e,t)},u.prototype.on=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++)e=r[a].toLowerCase().replace(/^on/,""),this.handlers[e]||(this.handlers[e]=t);this.handlers.noflash&&!u.detectFlashSupport()&&this.receiveEvent("onNoFlash",null)},u.prototype.addEventListener=u.prototype.on,u.prototype.off=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++){e=r[a].toLowerCase().replace(/^on/,"");for(var n in this.handlers)n===e&&this.handlers[n]===t&&delete this.handlers[n]}},u.prototype.removeEventListener=u.prototype.off,u.prototype.receiveEvent=function(t,r){t=(""+t).toLowerCase().replace(/^on/,"");var a=e;switch(t){case"load":if(r&&10>parseFloat(r.flashVersion.replace(",",".").replace(/[^0-9\.]/gi,"")))return this.receiveEvent("onWrongFlash",{flashVersion:r.flashVersion}),void 0;this.htmlBridge.setAttribute("data-clipboard-ready",!0);break;case"mouseover":i(a,this.options.hoverClass);break;case"mouseout":o(a,this.options.hoverClass),this.resetBridge();break;case"mousedown":i(a,this.options.activeClass);break;case"mouseup":o(a,this.options.activeClass);break;case"datarequested":var n=a.getAttribute("data-clipboard-target"),s=n?document.getElementById(n):null;if(s){var l=s.value||s.textContent||s.innerText;l&&this.setText(l)}else{var c=a.getAttribute("data-clipboard-text");c&&this.setText(c)}break;case"complete":this.options.text=null}if(this.handlers[t]){var d=this.handlers[t];"function"==typeof d?d.call(a,this,r):"string"==typeof d&&window[d].call(a,this,r)}},u.prototype.glue=function(e){e=h(e);for(var t=0;e.length>t;t++)-1==d(e[t],p)&&(p.push(e[t]),a(e[t],"mouseover",r))},u.prototype.unglue=function(e){e=h(e);for(var t=0;e.length>t;t++){n(e[t],"mouseover",r);var a=d(e[t],p);-1!=a&&p.splice(a,1)}},"undefined"!=typeof module?module.exports=u:"function"==typeof define&&define.amd?define(function(){return u}):window.ZeroClipboard=u}(),function(e){var t=e.Preview||{};e.vars.previewDefaults={showAdvancedOptions:!1,includeKalturaLinks:!e.vars.ignore_seo_links,includeSeoMetadata:!e.vars.ignore_entry_seo,deliveryType:e.vars.default_delivery_type,embedType:e.vars.default_embed_code_type,secureEmbed:e.vars.embed_code_protocol_https},"https:"==window.location.protocol&&(e.vars.previewDefaults.secureEmbed=!0),t.storageName="previewDefaults",t.el="#previewModal",t.iframeContainer="previewIframe",t.ignoreChangeEvents=!0,t.getGenerator=function(){return this.generator||(this.generator=new kEmbedCodeGenerator({host:e.vars.embed_host,securedHost:e.vars.embed_host_https,partnerId:e.vars.partner_id,includeKalturaLinks:e.vars.previewDefaults.includeKalturaLinks})),this.generator},t.clipboard=new ZeroClipboard($(".copy-code"),{moviePath:"/lib/flash/ZeroClipboard.swf",trustedDomains:["*"],allowScriptAccess:"always"}),t.clipboard.on("complete",function(){var e=$(this);$("#"+e.data("clipboard-target")).select(),e.data("close")===!0&&t.closeModal(t.el)}),t.objectToArray=function(e){var t=[];for(var r in e)e[r].id=r,t.push(e[r]);return t},t.getObjectById=function(e,t){var r=$.grep(t,function(t){return t.id==e});return r.length?r[0]:!1},t.getDefault=function(r){var a=localStorage.getItem(t.storageName);return a=a?JSON.parse(a):e.vars.previewDefaults,void 0!==a[r]?a[r]:null},t.savePreviewState=function(){var e=this.Service,r={embedType:e.get("embedType"),secureEmbed:e.get("secureEmbed"),includeSeoMetadata:e.get("includeSeo"),deliveryType:e.get("deliveryType").id,showAdvancedOptions:e.get("showAdvancedOptions")};localStorage.setItem(t.storageName,JSON.stringify(r))},t.getDeliveryTypeFlashVars=function(e){if(!e)return{};var t=e.flashvars?e.flashvars:{},r=$.extend({},t);return e.streamerType&&(r.streamerType=e.streamerType),e.mediaProtocol&&(r.mediaProtocol=e.mediaProtocol),r},t.getPreviewTitle=function(e){return e.entryMeta&&e.entryMeta.name?"Embedding: "+e.entryMeta.name:e.playlistName?"Playlist: "+e.playlistName:e.playerOnly?"Player Name:"+e.name:void 0},t.openPreviewEmbed=function(t,r){var a=this,n=a.el;this.ignoreChangeEvents=!1;var i={entryId:null,entryMeta:{},playlistId:null,playlistName:null,previewOnly:!1,liveBitrates:null,playerOnly:!1,uiConfId:null,name:null};t=$.extend({},i,t),t.liveBitrates&&r.setDeliveryType("auto"),r.updatePlayers(t),r.set(t);var o=this.getPreviewTitle(t),s=$(n);s.find(".title h2").text(o).attr("title",o),s.find(".close").unbind("click").click(function(){a.closeModal(n)});var l=$("body").height()-173;s.find(".content").height(l),e.layout.modal.show(n,!1)},t.closeModal=function(t){this.savePreviewState(),this.emptyDiv(this.iframeContainer),$(t).fadeOut(300,function(){e.layout.overlay.hide(),e.utils.hideFlash()})},t.emptyDiv=function(e){var t=$("#"+e),r=$("#previewIframe iframe");if(r.length)try{var a=$(r[0].contentWindow.document);a.find("#framePlayerContainer").empty()}catch(n){}return t.length?(t.empty(),t[0]):!1},t.hasIframe=function(){return $("#"+this.iframeContainer+" iframe").length},t.getCacheSt=function(){var e=new Date;return Math.floor(e.getTime()/1e3)+900},t.generateIframe=function(e){var t=$("html").hasClass("lt-ie10"),r="",a=this.emptyDiv(this.iframeContainer),n=document.createElement("iframe");if(n.frameborder="0",n.frameBorder="0",n.marginheight="0",n.marginwidth="0",n.frameborder="0",a.appendChild(n),t)n.src=this.getPreviewUrl(this.Service,!0);else{var i=n.contentDocument;i.open(),i.write(""+r+'
    '+e+"
    "),i.close()}},t.getEmbedProtocol=function(e,t){return t===!0?location.protocol.substring(0,location.protocol.length-1):e.get("secureEmbed")?"https":"http"},t.getEmbedFlashVars=function(t,r){var a=this.getEmbedProtocol(t,r),n=t.get("player"),i=this.getDeliveryTypeFlashVars(t.get("deliveryType"));r===!0&&(i.ks=e.vars.ks);var o=t.get("playlistId");if(o){var s=e.functions.getVersionFromPath(n.html5Url),l=e.functions.versionIsAtLeast(e.vars.min_kdp_version_for_playlist_api_v3,n.swf_version),c=e.functions.versionIsAtLeast(e.vars.min_html5_version_for_playlist_api_v3,s);l&&c?i["playlistAPI.kpl0Id"]=o:(i["playlistAPI.autoInsert"]="true",i["playlistAPI.kpl0Name"]=t.get("playlistName"),i["playlistAPI.kpl0Url"]=a+"://"+e.vars.api_host+"/index.php/partnerservices2/executeplaylist?"+"partner_id="+e.vars.partner_id+"&subp_id="+e.vars.partner_id+"00"+"&format=8&ks={ks}&playlist_id="+o)}return i},t.getEmbedCode=function(e,t){var r=e.get("player");if(!r||!e.get("embedType"))return"";var a=this.getCacheSt(),n={protocol:this.getEmbedProtocol(e,t),embedType:e.get("embedType"),uiConfId:r.id,width:r.width,height:r.height,entryMeta:e.get("entryMeta"),includeSeoMetadata:e.get("includeSeo"),playerId:"kaltura_player_"+a,cacheSt:a,flashVars:this.getEmbedFlashVars(e,t)};e.get("entryId")&&(n.entryId=e.get("entryId"));var i=this.getGenerator().getCode(n);return i},t.getPreviewUrl=function(t,r){var a=t.get("player");if(!a||!t.get("embedType"))return"";var n=this.getEmbedProtocol(t,r),i=n+"://"+e.vars.api_host+"/index.php/extwidget/preview";return i+="/partner_id/"+e.vars.partner_id,i+="/uiconf_id/"+a.id,t.get("entryId")&&(i+="/entry_id/"+t.get("entryId")),i+="/embed/"+t.get("embedType"),i+="?"+e.functions.flashVarsToUrl(this.getEmbedFlashVars(t,r)),r===!0&&(i+="&framed=true"),i},t.generateQrCode=function(e){var t=$("#qrcode").empty();e&&($("html").hasClass("lt-ie9")||t.qrcode({width:80,height:80,text:e}))},t.generateShortUrl=function(t,r){t&&e.client.createShortURL(t,r)},e.Preview=t}(window.kmc);var kmcApp=angular.module("kmcApp",[]);kmcApp.factory("previewService",["$rootScope",function(e){var t={};return{get:function(e){return void 0===e?t:t[e]},set:function(r,a,n){"object"==typeof r?angular.extend(t,r):t[r]=a,n||e.$broadcast("previewChanged")},updatePlayers:function(t){e.$broadcast("playersUpdated",t)},changePlayer:function(t){e.$broadcast("changePlayer",t)},setDeliveryType:function(t){e.$broadcast("changeDelivery",t)}}}]),kmcApp.directive("showSlide",function(){return{restrict:"A",link:function(e,t,r){r.showSlide,e.$watch(r.showSlide,function(e){e&&!t.is(":visible")?t.slideDown():t.slideUp()})}}}),kmcApp.controller("PreviewCtrl",["$scope","previewService",function(e,t){var r=function(){e.$$phase||e.$apply()},a=kmc.Preview;a.playlistMode=!1,a.Service=t;var n=function(t){t=t||{};var r=t.uiConfId?t.uiConfId:void 0;kmc.vars.playlists_list&&kmc.vars.players_list&&(t.playlistId||t.playerOnly?(e.players=kmc.vars.playlists_list,a.playlistMode||(a.playlistMode=!0,e.$broadcast("changePlayer",r))):(e.players=kmc.vars.players_list,(a.playlistMode||!e.player)&&(a.playlistMode=!1,e.$broadcast("changePlayer",r))),r&&e.$broadcast("changePlayer",r))},i=function(r){var n=a.objectToArray(kmc.vars.delivery_types),i=e.deliveryType||a.getDefault("deliveryType"),o=[];$.each(n,function(){return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,r.swf_version)?(this.id==i&&(i=null),!0):(o.push(this),void 0)}),e.deliveryTypes=o,i||(i=e.deliveryTypes[0].id),t.setDeliveryType(i)},o=function(t){var r=a.objectToArray(kmc.vars.embed_code_types),n=e.embedType||a.getDefault("embedType"),i=[];$.each(r,function(){if(a.playlistMode&&this.entryOnly)return this.id==n&&(n=null),!0;var e=kmc.functions.getVersionFromPath(t.html5Url);return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,e)?(this.id==n&&(n=null),!0):(i.push(this),void 0)}),e.embedTypes=i,n||(n=e.embedTypes[0].id),e.embedType=n};e.players=[],e.player=null,e.deliveryTypes=[],e.deliveryType=null,e.embedTypes=[],e.embedType=null,e.secureEmbed=a.getDefault("secureEmbed"),e.includeSeo=a.getDefault("includeSeoMetadata"),e.previewOnly=!1,e.playerOnly=!1,e.liveBitrates=!1,e.showAdvancedOptionsStatus=a.getDefault("showAdvancedOptions"),e.shortLinkGenerated=!1,e.$on("playersUpdated",function(e,t){n(t)}),e.$on("changePlayer",function(t,a){a=a?a:e.players[0].id,e.player=a,r()}),e.$on("changeDelivery",function(t,a){e.deliveryType=a,r()}),e.showAdvancedOptions=function(r,a){r.preventDefault(),t.set("showAdvancedOptions",a,!0),e.showAdvancedOptionsStatus=a},e.$watch("showAdvancedOptionsStatus",function(){a.clipboard.reposition()}),e.$watch("player",function(){var r=a.getObjectById(e.player,e.players);r&&(i(r),o(r),t.set("player",r))}),e.$watch("deliveryType",function(){t.set("deliveryType",a.getObjectById(e.deliveryType,e.deliveryTypes))}),e.$watch("embedType",function(){t.set("embedType",e.embedType)}),e.$watch("secureEmbed",function(){t.set("secureEmbed",e.secureEmbed)}),e.$watch("includeSeo",function(){t.set("includeSeo",e.includeSeo)}),e.$watch("embedCodePreview",function(){a.generateIframe(e.embedCodePreview)}),e.$watch("previewOnly",function(){e.closeButtonText=e.previewOnly?"Close":"Copy Embed & Close",r()}),e.$on("previewChanged",function(){if(!a.ignoreChangeEvents){var n=a.getPreviewUrl(t);e.embedCode=a.getEmbedCode(t),e.embedCodePreview=a.getEmbedCode(t,!0),e.previewOnly=t.get("previewOnly"),e.playerOnly=t.get("playerOnly"),e.liveBitrates=t.get("liveBitrates"),r(),a.hasIframe()||a.generateIframe(e.embedCodePreview),e.previewUrl="Updating...",e.shortLinkGenerated=!1,a.generateShortUrl(n,function(t){t||(t=n),e.shortLinkGenerated=!0,e.previewUrl=t,a.generateQrCode(t),r()})}})}]),0==kmc.vars.allowFrame&&top!=window&&(top.location=window.location),kmc.vars.debug=!1,kmc.vars.quickstart_guide="/content/docs/pdf/KMC_User_Manual.pdf",kmc.vars.help_url=kmc.vars.service_url+"/kmc5help.html",kmc.vars.port=window.location.port?":"+window.location.port:"",kmc.vars.base_host=window.location.hostname+kmc.vars.port,kmc.vars.base_url=window.location.protocol+"//"+kmc.vars.base_host,kmc.vars.api_host=kmc.vars.host,kmc.vars.api_url=window.location.protocol+"//"+kmc.vars.api_host,kmc.vars.min_kdp_version_for_playlist_api_v3="3.6.15",kmc.vars.min_html5_version_for_playlist_api_v3="1.7.1.3",kmc.log=function(){if(kmc.vars.debug&&"undefined"!=typeof console&&console.log)if(1==arguments.length)console.log(arguments[0]);else{var e=Array.prototype.slice.call(arguments);console.log(e[0],e.slice(1))}},kmc.functions={loadSwf:function(){var e=window.location.protocol+"//"+kmc.vars.cdn_host+"/flash/kmc/"+kmc.vars.kmc_version+"/kmc.swf",t={kmc_uiconf:kmc.vars.kmc_general_uiconf,permission_uiconf:kmc.vars.kmc_permissions_uiconf,host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,srvurl:"api_v3/index.php",protocol:window.location.protocol+"//",partnerid:kmc.vars.partner_id,subpid:kmc.vars.partner_id+"00",ks:kmc.vars.ks,entryId:"-1",kshowId:"-1",debugmode:"true",widget_id:"_"+kmc.vars.partner_id,urchinNumber:kmc.vars.google_analytics_account,firstLogin:kmc.vars.first_login,openPlayer:"kmc.preview_embed.doPreviewEmbed",openPlaylist:"kmc.preview_embed.doPreviewEmbed",openCw:"kmc.functions.openKcw",language:kmc.vars.language||""};kmc.vars.disable_analytics&&(t.disableAnalytics=!0);var r={allowNetworking:"all",allowScriptAccess:"always"};swfobject.embedSWF(e,"kcms","100%","100%","10.0.0",!1,t,r),$("#kcms").attr("style","")},checkForOngoingProcess:function(){var e;try{e=$("#kcms")[0].hasOngoingProcess()}catch(t){e=null}return null!==e?e:void 0},expired:function(){kmc.user.logout()},openKcw:function(e,t){e=e||"";var r="uploadWebCam"==t?kmc.vars.kcw_webcam_uiconf:kmc.vars.kcw_import_uiconf,a={host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,protocol:window.location.protocol.slice(0,-1),partnerid:kmc.vars.partner_id,subPartnerId:kmc.vars.partner_id+"00",sessionId:kmc.vars.ks,devFlag:"true",entryId:"-1",kshow_id:"-1",terms_of_use:kmc.vars.terms_of_use,close:"kmc.functions.onCloseKcw",quick_edit:0,kvar_conversionQuality:e},n={allowscriptaccess:"always",allownetworking:"all",bgcolor:"#DBE3E9",quality:"high",movie:kmc.vars.service_url+"/kcw/ui_conf_id/"+r};kmc.layout.modal.open({width:700,height:420,content:'
    '}),swfobject.embedSWF(n.movie,"kcw","680","400","9.0.0",!1,a,n)},onCloseKcw:function(){kmc.layout.modal.close(),$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})},openChangePwd:function(){kmc.user.changeSetting("password")},openChangeEmail:function(){kmc.user.changeSetting("email")},openChangeName:function(){kmc.user.changeSetting("name")},getAddPanelPosition:function(){var e=$("#add").parent();return e.position().left+e.width()-10},openClipApp:function(e,t){var r=kmc.vars.base_url+"/apps/clipapp/"+kmc.vars.clipapp.version;r+="/?kdpUiconf="+kmc.vars.clipapp.kdp+"&kclipUiconf="+kmc.vars.clipapp.kclip,r+="&partnerId="+kmc.vars.partner_id+"&host="+kmc.vars.host+"&mode="+t+"&config=kmc&entryId="+e;var a="trim"==t?"Trimming Tool":"Clipping Tool";kmc.layout.modal.open({width:950,height:616,title:a,content:'',className:"iframe",closeCallback:function(){$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})}})},flashVarsToUrl:function(e){var t="";for(var r in e){var a="object"==typeof e[r]?JSON.stringify(e[r]):e[r];t+="&flashvars["+encodeURIComponent(r)+"]="+encodeURIComponent(a)}return t},versionIsAtLeast:function(e,t){if(!t)return!1;for(var r=e.split("."),a=t.split("."),n=0;r.length>n;n++){if(parseInt(a[n])>parseInt(r[n]))return!0;if(parseInt(a[n]) *").each(function(){e+=$(this).width()});var t=function(){kmc.vars.close_menu=!0;var t={width:0,visibility:"visible",top:"6px",right:"6px"},r={width:e+"px","padding-top":"2px","padding-bottom":"2px"};$("#user_links").css(t),$("#user_links").animate(r,500)};$("#user").hover(t).click(t),$("#user_links").mouseover(function(){kmc.vars.close_menu=!1}),$("#user_links").mouseleave(function(){kmc.vars.close_menu=!0,setTimeout(kmc.utils.closeMenu,650)}),$("#closeMenu").click(function(){kmc.vars.close_menu=!0,kmc.utils.closeMenu()})},closeMenu:function(){kmc.vars.close_menu&&$("#user_links").animate({width:0},500,function(){$("#user_links").css({width:"auto",visibility:"hidden"})})},activateHeader:function(){$("#user_links a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id");switch(t){case"Quickstart Guide":return this.href=kmc.vars.quickstart_guide,!0;case"Logout":return kmc.user.logout(),!1;case"Support":return kmc.user.openSupport(this),!1;case"ChangePartner":return kmc.user.changePartner(),!1;default:return!1}})},resize:function(){var e=$.browser.ie?640:590,t=$(document).height(),r=$.browser.mozilla?37:74;t-=r,t=e>t?e:t,$("#flash_wrap").height(t+"px"),$("#server_wrap iframe").height(t+"px"),$("#server_wrap").css("margin-top","-"+(t+2)+"px")},isModuleLoaded:function(){($("#flash_wrap object").length||$("#flash_wrap embed").length)&&(kmc.utils.resize(),clearInterval(kmc.vars.isLoadedInterval),kmc.vars.isLoadedInterval=null)},debug:function(){try{console.info(" ks: ",kmc.vars.ks),console.info(" partner_id: ",kmc.vars.partner_id)}catch(e){}},maskHeader:function(e){e?$("#mask").hide():$("#mask").show()},createTabs:function(e){if($("#closeMenu").trigger("click"),e){for(var t,r=kmc.vars.service_url+"/index.php/kmc/kmc4",a=e.length,n="",i=0;a>i;i++)t="action"==e[i].type?'class="menu" ':"",n+='
  • '+e[i].display_name+"
  • ";$("#hTabs").html(n);var o=$("body").width()-($("#logo").width()+$("#hTabs").width()+100);$("#user").width()+20>o&&$("#user").width(o),$("#hTabs a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id"),r="A"==e.target.tagName?$(e.target).attr("rel"):$(e.target).parent().attr("rel"),a={moduleName:t,subtab:r};return $("#kcms")[0].gotoPage(a),!1})}else alert("Error geting tabs")},setTab:function(e,t){t&&$("#kmcHeader ul li a").removeClass("active"),$("a#"+e).addClass("active")},resetTab:function(e){$("a#"+e).removeClass("active")},hideFlash:function(e){var t=$("html").hasClass("lt-ie8");e?t?$("#flash_wrap").css("margin-right","3333px"):($("#flash_wrap").css("visibility","hidden"),$("#flash_wrap object").css("visibility","hidden")):t?$("#flash_wrap").css("margin-right","0"):($("#flash_wrap").css("visibility","visible"),$("#flash_wrap object").css("visibility","visible"))},showFlash:function(){$("#server_wrap").hide(),$("#server_frame").removeAttr("src"),kmc.layout.modal.isOpen()||$("#flash_wrap").css("visibility","visible"),$("#server_wrap").css("margin-top",0)},openIframe:function(e){$("#flash_wrap").css("visibility","hidden"),$("#server_frame").attr("src",e),$("#server_wrap").css("margin-top","-"+($("#flash_wrap").height()+2)+"px"),$("#server_wrap").show() -},openHelp:function(e){$("#kcms")[0].doHelp(e)},setClientIP:function(){kmc.vars.clientIP="",kmc.vars.akamaiEdgeServerIpURL&&$.ajax({url:window.location.protocol+"//"+kmc.vars.akamaiEdgeServerIpURL,crossDomain:!0,success:function(e){kmc.vars.clientIP=$(e).find("serverip").text()}})},getClientIP:function(){return kmc.vars.clientIP}},kmc.mediator={writeUrlHash:function(e,t){location.hash=e+"|"+t,document.title="KMC > "+e+(t&&""!==t?" > "+t+" |":"")},readUrlHash:function(){var e,t,r="dashboard",a="",n={};try{e=location.hash.split("#")[1].split("|")}catch(i){t=!0}if(!t&&""!==e[0]){if(r=e[0],a=e[1],e[2])for(var o=e[2].split("&"),s=0;o.length>s;s++){var l=o[s].split(":");n[l[0]]=l[1]}switch(r){case"content":switch(a){case"Moderate":a="moderation";break;case"Syndicate":a="syndication"}a=a.toLowerCase();break;case"appstudio":r="studio",a="playersList";break;case"Settings":switch(r="account",a){case"Account_Settings":a="overview";break;case"Integration Settings":a="integration";break;case"Access Control":a="accessControl";break;case"Transcoding Settings":a="transcoding";break;case"Account Upgrade":a="upgrade"}break;case"reports":r="analytics","Bandwidth Usage Reports"==a&&(a="usageTabTitle")}}return{moduleName:r,subtab:a,extra:n}}},kmc.preview_embed={doPreviewEmbed:function(e,t,r,a,n,i,o){var s={previewOnly:a};i&&(s.uiConfId=parseInt(i)),n?"multitab_playlist"==e?(s.playerOnly=!0,s.name=t):(s.playlistId=e,s.playlistName=t):(s.entryId=e,s.entryMeta={name:t,description:r},o&&(s.liveBitrates=o)),kmc.Preview.openPreviewEmbed(s,kmc.Preview.Service)},doFlavorPreview:function(e,t,r){var a=kmc.vars.default_kdp,n=kmc.Preview.getGenerator().getCode({protocol:location.protocol.substring(0,location.protocol.length-1),embedType:"legacy",entryId:e,uiConfId:parseInt(a.id),width:a.width,height:a.height,includeSeoMetadata:!1,includeHtml5Library:!1,flashVars:{ks:kmc.vars.ks,flavorId:r.asset_id}}),i='
    '+n+"
    "+"
    Entry Name:
     "+t+"
    "+"
    Entry Id:
     "+e+"
    "+"
    Flavor Name:
     "+r.flavor_name+"
    "+"
    Flavor Asset Id:
     "+r.asset_id+"
    "+"
    Bitrate:
     "+r.bitrate+"
    "+"
    Codec:
     "+r.codec+"
    "+"
    Dimensions:
     "+r.dimensions.width+" x "+r.dimensions.height+"
    "+"
    Format:
     "+r.format+"
    "+"
    Size (KB):
     "+r.sizeKB+"
    "+"
    Status:
     "+r.status+"
    "+"
    ";kmc.layout.modal.open({width:parseInt(a.width)+120,height:parseInt(a.height)+300,title:"Flavor Preview",content:'
    '+i+"
    "})},updateList:function(e){var t=e?"playlist":"player";$.ajax({url:kmc.vars.base_url+kmc.vars.getuiconfs_url,type:"POST",data:{type:t,partner_id:kmc.vars.partner_id,ks:kmc.vars.ks},dataType:"json",success:function(t){t&&t.length&&(e?kmc.vars.playlists_list=t:kmc.vars.players_list=t,kmc.Preview.Service.updatePlayers())}})}},kmc.client={makeRequest:function(e,t,r,a){var n=kmc.vars.api_url+"/api_v3/index.php?service="+e+"&action="+t,i={ks:kmc.vars.ks,format:9};$.extend(r,i);var o=function(e){var t=[],r=[],a=0;for(var n in e)r[a++]=n+"|"+e[n];r=r.sort();for(var i=0;r.length>i;i++){var o=r[i].split("|");t[o[0]]=o[1]}return t},s=function(e){e=o(e);var t="";for(var r in e){var a=e[r];t+=a+r}return md5(t)},l=s(r);n+="&kalsig="+l,$.ajax({type:"GET",url:n,dataType:"jsonp",data:r,cache:!1,success:a})},createShortURL:function(e,t){kmc.log("createShortURL");var r={"shortLink:objectType":"KalturaShortLink","shortLink:systemName":"KMC-PREVIEW","shortLink:fullUrl":e};kmc.client.makeRequest("shortlink_shortlink","add",r,function(e){var r=!1;t?(e.id&&(r=kmc.vars.service_url+"/tiny/"+e.id),t(r)):kmc.preview_embed.setShortURL(e.id)})}},kmc.layout={init:function(){$("#kmcHeader").bind("click",function(){$("#hTabs a").each(function(e,t){var r=$(t);return r.hasClass("menu")&&r.hasClass("active")?($("#kcms")[0].gotoPage({moduleName:r.attr("id"),subtab:r.attr("rel")}),void 0):!0})}),$("body").append('
    ')},overlay:{show:function(){$("#overlay").show()},hide:function(){$("#overlay").hide()}},modal:{el:"#modal",create:function(e){var t={el:kmc.layout.modal.el,title:"",content:"",help:"",width:680,height:"auto",className:""};$.extend(t,e);var r=$(t.el),a=r.find(".title h2"),n=r.find(".content");return t.className="modal "+t.className,r.css({width:t.width,height:t.height}).attr("class",t.className),t.title?a.text(t.title).attr("title",t.title).parent().show():(a.parent().hide(),n.addClass("flash_only")),r.find(".help").remove(),a.parent().append(t.help),n[0].innerHTML=t.content,r.find(".close").click(function(){kmc.layout.modal.close(t.el),$.isFunction(e.closeCallback)&&e.closeCallback()}),r},show:function(e,t){t=void 0===t?!0:t,e=e||kmc.layout.modal.el;var r=$(e);kmc.utils.hideFlash(!0),kmc.layout.overlay.show(),r.fadeIn(600),$.browser.msie||r.css("display","table"),t&&this.position(e)},open:function(e){this.create(e);var t=e.el||kmc.layout.modal.el;this.show(t)},position:function(e){e=e||kmc.layout.modal.el;var t=$(e),r=($(window).height()-t.height())/2,a=($(window).width()-t.width())/(2+$(window).scrollLeft());r=40>r?40:r,t.css({top:r+"px",left:a+"px"})},close:function(e){e=e||kmc.layout.modal.el,$(e).fadeOut(300,function(){$(e).find(".content").html(""),kmc.layout.overlay.hide(),kmc.utils.hideFlash()})},isOpen:function(e){return e=e||kmc.layout.modal.el,$(e).is(":visible")}}},kmc.user={openSupport:function(e){var t=e.href;kmc.utils.hideFlash(!0),kmc.layout.overlay.show();var r='';kmc.layout.modal.create({width:550,title:"Support Request",content:r}),$("#support").load(function(){kmc.layout.modal.show(),kmc.vars.support_frame_height||(kmc.vars.support_frame_height=$("#support")[0].contentWindow.document.body.scrollHeight),$("#support").height(kmc.vars.support_frame_height),kmc.layout.modal.position()})},logout:function(){var e=kmc.functions.checkForOngoingProcess();if(e)return alert(e),!1;var t=kmc.mediator.readUrlHash();$.ajax({url:kmc.vars.base_url+"/index.php/kmc/logout",type:"POST",data:{ks:kmc.vars.ks},dataType:"json",complete:function(){window.location=kmc.vars.logoutUrl?kmc.vars.logoutUrl:kmc.vars.service_url+"/index.php/kmc/kmc#"+t.moduleName+"|"+t.subtab}})},changeSetting:function(e){var t,r;switch(e){case"password":t="Change Password",r=180;break;case"email":t="Change Email Address",r=160;break;case"name":t="Edit Name",r=200}var a=kmc.vars.kmc_secured||"https:"==location.protocol?"https":"http",n=a+"://"+window.location.hostname,i=n+kmc.vars.port+"/index.php/kmc/updateLoginData/type/"+e;i=i+"?parent="+encodeURIComponent(document.location.href);var o='';kmc.layout.modal.open({width:370,title:t,content:o}),XD.receiveMessage(function(e){kmc.layout.modal.close(),"reload"==e.data&&($.browser.msie&&8>$.browser.version&&(window.location.hash="account|user"),window.location.reload())},n)},changePartner:function(){var e,t,r,a=0,n=kmc.vars.allowed_partners.length,i='
    Please choose partner:
    ';for(e=0;n>e;e++)a=kmc.vars.allowed_partners[e].id,kmc.vars.partner_id==a?(t=' checked="checked"',r=' style="font-weight: bold"'):(t="",r=""),i+="  "+kmc.vars.allowed_partners[e].name+"";return i+='
    ',kmc.layout.modal.open({width:300,title:"Change Account",content:i}),$("#do_change_partner").click(function(){var e=kmc.vars.base_url+"/index.php/kmc/extlogin",t=$("").attr({type:"hidden",name:"ks",value:kmc.vars.ks}),r=$("").attr({type:"hidden",name:"partner_id",value:$("input[name=pid]:radio:checked").val()}),a=$("").attr({action:e,method:"post",style:"display: none"}).append(t,r);$("body").append(a),a[0].submit()}),!1}},$(function(){kmc.layout.init(),kmc.utils.handleMenu(),kmc.functions.loadSwf(),$(window).wresize(kmc.utils.resize),kmc.vars.isLoadedInterval=setInterval(kmc.utils.isModuleLoaded,200),kmc.preview_embed.updateList(),kmc.preview_embed.updateList(!0),kmc.utils.setClientIP()}),$(window).resize(function(){kmc.layout.modal.isOpen()&&kmc.layout.modal.position()}),window.onbeforeunload=kmc.functions.checkForOngoingProcess,function(e){e.fn.wresize=function(t){function r(){if(e.browser.msie)if(wresize.fired){var t=parseInt(e.browser.version,10);if(wresize.fired=!1,7>t)return!1;if(7==t){var r=e(window).width();if(r!=wresize.width)return wresize.width=r,!1}}else wresize.fired=!0;return!0}function a(e){return r()?t.apply(this,[e]):void 0}return version="1.1",wresize={fired:!1,width:0},this.each(function(){this==window?e(this).resize(a):e(this).resize(t)}),this}}(jQuery);var XD=function(){var e,t,r,a=1,n=this;return{postMessage:function(e,t,r){t&&(r=r||parent,n.postMessage?r.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(r.location=t.replace(/#.*$/,"")+"#"+ +new Date+a++ +"&"+e))},receiveMessage:function(a,i){n.postMessage?(a&&(r=function(e){return"string"==typeof i&&e.origin!==i||"[object Function]"===Object.prototype.toString.call(i)&&i(e.origin)===!1?!1:(a(e),void 0)}),n.addEventListener?n[a?"addEventListener":"removeEventListener"]("message",r,!1):n[a?"attachEvent":"detachEvent"]("onmessage",r)):(e&&clearInterval(e),e=null,a&&(e=setInterval(function(){var e=document.location.hash,r=/^#?\d+&/;e!==t&&r.test(e)&&(t=e,a({data:e.replace(r,"")}))},100)))}}}(); \ No newline at end of file +i>5&&(r+=3+i-5)}for(var a=0;t-1>a;a++)for(var n=0;t-1>n;n++){var c=0;e.isDark(a,n)&&c++,e.isDark(a+1,n)&&c++,e.isDark(a,n+1)&&c++,e.isDark(a+1,n+1)&&c++,(0==c||4==c)&&(r+=3)}for(var a=0;t>a;a++)for(var n=0;t-6>n;n++)e.isDark(a,n)&&!e.isDark(a,n+1)&&e.isDark(a,n+2)&&e.isDark(a,n+3)&&e.isDark(a,n+4)&&!e.isDark(a,n+5)&&e.isDark(a,n+6)&&(r+=40);for(var n=0;t>n;n++)for(var a=0;t-6>a;a++)e.isDark(a,n)&&!e.isDark(a+1,n)&&e.isDark(a+2,n)&&e.isDark(a+3,n)&&e.isDark(a+4,n)&&!e.isDark(a+5,n)&&e.isDark(a+6,n)&&(r+=40);for(var d=0,n=0;t>n;n++)for(var a=0;t>a;a++)e.isDark(a,n)&&d++;var h=Math.abs(100*d/t/t-50)/5;return r+=10*h}},h={glog:function(e){if(1>e)throw Error("glog("+e+")");return h.LOG_TABLE[e]},gexp:function(e){for(;0>e;)e+=255;for(;e>=256;)e-=255;return h.EXP_TABLE[e]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},u=0;8>u;u++)h.EXP_TABLE[u]=1<u;u++)h.EXP_TABLE[u]=h.EXP_TABLE[u-4]^h.EXP_TABLE[u-5]^h.EXP_TABLE[u-6]^h.EXP_TABLE[u-8];for(var u=0;255>u;u++)h.LOG_TABLE[h.EXP_TABLE[u]]=u;n.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=Array(this.getLength()+e.getLength()-1),r=0;this.getLength()>r;r++)for(var a=0;e.getLength()>a;a++)t[r+a]^=h.gexp(h.glog(this.get(r))+h.glog(e.get(a)));return new n(t,0)},mod:function(e){if(0>this.getLength()-e.getLength())return this;for(var t=h.glog(this.get(0))-h.glog(e.get(0)),r=Array(this.getLength()),a=0;this.getLength()>a;a++)r[a]=this.get(a);for(var a=0;e.getLength()>a;a++)r[a]^=h.gexp(h.glog(e.get(a))+t);return new n(r,0).mod(e)}},i.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],i.getRSBlocks=function(e,t){var r=i.getRsBlockTable(e,t);if(void 0==r)throw Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+t);for(var a=r.length/3,n=[],o=0;a>o;o++)for(var s=r[3*o+0],l=r[3*o+1],c=r[3*o+2],d=0;s>d;d++)n.push(new i(l,c));return n},i.getRsBlockTable=function(e,t){switch(t){case l.L:return i.RS_BLOCK_TABLE[4*(e-1)+0];case l.M:return i.RS_BLOCK_TABLE[4*(e-1)+1];case l.Q:return i.RS_BLOCK_TABLE[4*(e-1)+2];case l.H:return i.RS_BLOCK_TABLE[4*(e-1)+3];default:return void 0}},o.prototype={get:function(e){var t=Math.floor(e/8);return 1==(1&this.buffer[t]>>>7-e%8)},put:function(e,t){for(var r=0;t>r;r++)this.putBit(1==(1&e>>>t-r-1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);t>=this.buffer.length&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},"string"==typeof t&&(t={text:t}),t=e.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,correctLevel:l.H,background:"#ffffff",foreground:"#000000"},t);var p=function(){var e=new a(t.typeNumber,t.correctLevel);e.addData(t.text),e.make();var r=document.createElement("canvas");r.width=t.width,r.height=t.height;for(var n=r.getContext("2d"),i=t.width/e.getModuleCount(),o=t.height/e.getModuleCount(),s=0;e.getModuleCount()>s;s++)for(var l=0;e.getModuleCount()>l;l++){n.fillStyle=e.isDark(s,l)?t.foreground:t.background;var c=Math.ceil((l+1)*i)-Math.floor(l*i),d=Math.ceil((s+1)*i)-Math.floor(s*i);n.fillRect(Math.round(l*i),Math.round(s*o),c,d)}return r},f=function(){var r=new a(t.typeNumber,t.correctLevel);r.addData(t.text),r.make();for(var n=e("
    ").css("width",t.width+"px").css("height",t.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",t.background),i=t.width/r.getModuleCount(),o=t.height/r.getModuleCount(),s=0;r.getModuleCount()>s;s++)for(var l=e("").css("height",o+"px").appendTo(n),c=0;r.getModuleCount()>c;c++)e("").css("width",i+"px").css("background-color",r.isDark(s,c)?t.foreground:t.background).appendTo(l);return n};return this.each(function(){var r="canvas"==t.render?p():f();e(r).appendTo(this)})}}(jQuery),window.XDomainRequest&&jQuery.ajaxTransport(function(e){if(e.crossDomain&&e.async){e.timeout&&(e.xdrTimeout=e.timeout,delete e.timeout);var t;return{send:function(r,a){function n(e,r,n,i){t.onload=t.onerror=t.ontimeout=jQuery.noop,t=void 0,a(e,r,n,i)}t=new XDomainRequest,t.onload=function(){n(200,"OK",{text:t.responseText},"Content-Type: "+t.contentType)},t.onerror=function(){n(404,"Not Found")},t.onprogress=jQuery.noop,t.ontimeout=function(){n(0,"timeout")},t.timeout=e.xdrTimeout||Number.MAX_VALUE,t.open(e.type,e.url),t.send(e.hasContent&&e.data||null)},abort:function(){t&&(t.onerror=jQuery.noop,t.abort())}}}}),function(){"use strict";var e,t=function(e,t){var r=e.style[t];if(e.currentStyle?r=e.currentStyle[t]:window.getComputedStyle&&(r=document.defaultView.getComputedStyle(e,null).getPropertyValue(t)),"auto"==r&&"cursor"==t)for(var a=["a"],n=0;a.length>n;n++)if(e.tagName.toLowerCase()==a[n])return"pointer";return r},r=function(e){if(u.prototype._singleton){e||(e=window.event);var t;this!==window?t=this:e.target?t=e.target:e.srcElement&&(t=e.srcElement),u.prototype._singleton.setCurrent(t)}},a=function(e,t,r){e.addEventListener?e.addEventListener(t,r,!1):e.attachEvent&&e.attachEvent("on"+t,r)},n=function(e,t,r){e.removeEventListener?e.removeEventListener(t,r,!1):e.detachEvent&&e.detachEvent("on"+t,r)},i=function(e,t){if(e.addClass)return e.addClass(t),e;if(t&&"string"==typeof t){var r=(t||"").split(/\s+/);if(1===e.nodeType)if(e.className){for(var a=" "+e.className+" ",n=e.className,i=0,o=r.length;o>i;i++)0>a.indexOf(" "+r[i]+" ")&&(n+=" "+r[i]);e.className=n.replace(/^\s+|\s+$/g,"")}else e.className=t}return e},o=function(e,t){if(e.removeClass)return e.removeClass(t),e;if(t&&"string"==typeof t||void 0===t){var r=(t||"").split(/\s+/);if(1===e.nodeType&&e.className)if(t){for(var a=(" "+e.className+" ").replace(/[\n\t]/g," "),n=0,i=r.length;i>n;n++)a=a.replace(" "+r[n]+" "," ");e.className=a.replace(/^\s+|\s+$/g,"")}else e.className=""}return e},s=function(e){var r={left:0,top:0,width:e.width||e.offsetWidth||0,height:e.height||e.offsetHeight||0,zIndex:9999},a=t(e,"zIndex");for(a&&"auto"!=a&&(r.zIndex=parseInt(a,10));e;){var n=parseInt(t(e,"borderLeftWidth"),10),i=parseInt(t(e,"borderTopWidth"),10);r.left+=isNaN(e.offsetLeft)?0:e.offsetLeft,r.left+=isNaN(n)?0:n,r.top+=isNaN(e.offsetTop)?0:e.offsetTop,r.top+=isNaN(i)?0:i,e=e.offsetParent}return r},l=function(e){return(e.indexOf("?")>=0?"&":"?")+"nocache="+(new Date).getTime()},c=function(e){var t=[];return e.trustedDomains&&("string"==typeof e.trustedDomains?t.push("trustedDomain="+e.trustedDomains):t.push("trustedDomain="+e.trustedDomains.join(","))),t.join("&")},d=function(e,t){if(t.indexOf)return t.indexOf(e);for(var r=0,a=t.length;a>r;r++)if(t[r]===e)return r;return-1},h=function(e){if("string"==typeof e)throw new TypeError("ZeroClipboard doesn't accept query strings.");return e.length?e:[e]},u=function(e,t){if(e&&(u.prototype._singleton||this).glue(e),u.prototype._singleton)return u.prototype._singleton;u.prototype._singleton=this,this.options={};for(var r in f)this.options[r]=f[r];for(var a in t)this.options[a]=t[a];this.handlers={},u.detectFlashSupport()&&m()},p=[];u.prototype.setCurrent=function(r){e=r,this.reposition(),r.getAttribute("title")&&this.setTitle(r.getAttribute("title")),this.setHandCursor("pointer"==t(r,"cursor"))},u.prototype.setText=function(e){e&&""!==e&&(this.options.text=e,this.ready()&&this.flashBridge.setText(e))},u.prototype.setTitle=function(e){e&&""!==e&&this.htmlBridge.setAttribute("title",e)},u.prototype.setSize=function(e,t){this.ready()&&this.flashBridge.setSize(e,t)},u.prototype.setHandCursor=function(e){this.ready()&&this.flashBridge.setHandCursor(e)},u.version="1.1.7";var f={moviePath:"ZeroClipboard.swf",trustedDomains:null,text:null,hoverClass:"zeroclipboard-is-hover",activeClass:"zeroclipboard-is-active",allowScriptAccess:"sameDomain"};u.setDefaults=function(e){for(var t in e)f[t]=e[t]},u.destroy=function(){u.prototype._singleton.unglue(p);var e=u.prototype._singleton.htmlBridge;e.parentNode.removeChild(e),delete u.prototype._singleton},u.detectFlashSupport=function(){var e=!1;try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(e=!0)}catch(t){navigator.mimeTypes["application/x-shockwave-flash"]&&(e=!0)}return e};var m=function(){var e=u.prototype._singleton,t=document.getElementById("global-zeroclipboard-html-bridge");if(!t){var r=' ';t=document.createElement("div"),t.id="global-zeroclipboard-html-bridge",t.setAttribute("class","global-zeroclipboard-container"),t.setAttribute("data-clipboard-ready",!1),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="15px",t.style.height="15px",t.style.zIndex="9999",t.innerHTML=r,document.body.appendChild(t)}e.htmlBridge=t,e.flashBridge=document["global-zeroclipboard-flash-bridge"]||t.children[0].lastElementChild};u.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),o(e,this.options.activeClass),e=null,this.options.text=null},u.prototype.ready=function(){var e=this.htmlBridge.getAttribute("data-clipboard-ready");return"true"===e||e===!0},u.prototype.reposition=function(){if(!e)return!1;var t=s(e);this.htmlBridge.style.top=t.top+"px",this.htmlBridge.style.left=t.left+"px",this.htmlBridge.style.width=t.width+"px",this.htmlBridge.style.height=t.height+"px",this.htmlBridge.style.zIndex=t.zIndex+1,this.setSize(t.width,t.height)},u.dispatch=function(e,t){u.prototype._singleton.receiveEvent(e,t)},u.prototype.on=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++)e=r[a].toLowerCase().replace(/^on/,""),this.handlers[e]||(this.handlers[e]=t);this.handlers.noflash&&!u.detectFlashSupport()&&this.receiveEvent("onNoFlash",null)},u.prototype.addEventListener=u.prototype.on,u.prototype.off=function(e,t){for(var r=(""+e).split(/\s/g),a=0;r.length>a;a++){e=r[a].toLowerCase().replace(/^on/,"");for(var n in this.handlers)n===e&&this.handlers[n]===t&&delete this.handlers[n]}},u.prototype.removeEventListener=u.prototype.off,u.prototype.receiveEvent=function(t,r){t=(""+t).toLowerCase().replace(/^on/,"");var a=e;switch(t){case"load":if(r&&10>parseFloat(r.flashVersion.replace(",",".").replace(/[^0-9\.]/gi,"")))return this.receiveEvent("onWrongFlash",{flashVersion:r.flashVersion}),void 0;this.htmlBridge.setAttribute("data-clipboard-ready",!0);break;case"mouseover":i(a,this.options.hoverClass);break;case"mouseout":o(a,this.options.hoverClass),this.resetBridge();break;case"mousedown":i(a,this.options.activeClass);break;case"mouseup":o(a,this.options.activeClass);break;case"datarequested":var n=a.getAttribute("data-clipboard-target"),s=n?document.getElementById(n):null;if(s){var l=s.value||s.textContent||s.innerText;l&&this.setText(l)}else{var c=a.getAttribute("data-clipboard-text");c&&this.setText(c)}break;case"complete":this.options.text=null}if(this.handlers[t]){var d=this.handlers[t];"function"==typeof d?d.call(a,this,r):"string"==typeof d&&window[d].call(a,this,r)}},u.prototype.glue=function(e){e=h(e);for(var t=0;e.length>t;t++)-1==d(e[t],p)&&(p.push(e[t]),a(e[t],"mouseover",r))},u.prototype.unglue=function(e){e=h(e);for(var t=0;e.length>t;t++){n(e[t],"mouseover",r);var a=d(e[t],p);-1!=a&&p.splice(a,1)}},"undefined"!=typeof module?module.exports=u:"function"==typeof define&&define.amd?define(function(){return u}):window.ZeroClipboard=u}(),function(e){var t=e.Preview||{};e.vars.previewDefaults={showAdvancedOptions:!1,includeKalturaLinks:!e.vars.ignore_seo_links,includeSeoMetadata:!e.vars.ignore_entry_seo,deliveryType:e.vars.default_delivery_type,embedType:e.vars.default_embed_code_type,secureEmbed:e.vars.embed_code_protocol_https},"https:"==window.location.protocol&&(e.vars.previewDefaults.secureEmbed=!0),t.storageName="previewDefaults",t.el="#previewModal",t.iframeContainer="previewIframe",t.ignoreChangeEvents=!0,t.getGenerator=function(){return this.generator||(this.generator=new kEmbedCodeGenerator({host:e.vars.embed_host,securedHost:e.vars.embed_host_https,partnerId:e.vars.partner_id,includeKalturaLinks:e.vars.previewDefaults.includeKalturaLinks})),this.generator},t.clipboard=new ZeroClipboard($(".copy-code"),{moviePath:"/lib/flash/ZeroClipboard.swf",trustedDomains:["*"],allowScriptAccess:"always"}),t.clipboard.on("complete",function(){var e=$(this);$("#"+e.data("clipboard-target")).select(),e.data("close")===!0&&t.closeModal(t.el)}),t.objectToArray=function(e){var t=[];for(var r in e)e[r].id=r,t.push(e[r]);return t},t.getObjectById=function(e,t){var r=$.grep(t,function(t){return t.id==e});return r.length?r[0]:!1},t.getDefault=function(r){var a=localStorage.getItem(t.storageName);return a=a?JSON.parse(a):e.vars.previewDefaults,void 0!==a[r]?a[r]:null},t.savePreviewState=function(){var e=this.Service,r={embedType:e.get("embedType"),secureEmbed:e.get("secureEmbed"),includeSeoMetadata:e.get("includeSeo"),deliveryType:e.get("deliveryType").id,showAdvancedOptions:e.get("showAdvancedOptions")};localStorage.setItem(t.storageName,JSON.stringify(r))},t.getDeliveryTypeFlashVars=function(e){if(!e)return{};var t=e.flashvars?e.flashvars:{},r=$.extend({},t);return e.streamerType&&(r.streamerType=e.streamerType),e.mediaProtocol&&(r.mediaProtocol=e.mediaProtocol),r},t.getPreviewTitle=function(e){return e.entryMeta&&e.entryMeta.name?"Embedding: "+e.entryMeta.name:e.playlistName?"Playlist: "+e.playlistName:e.playerOnly?"Player Name:"+e.name:void 0},t.openPreviewEmbed=function(t,r){var a=this,n=a.el;this.ignoreChangeEvents=!1;var i={entryId:null,entryMeta:{},playlistId:null,playlistName:null,previewOnly:!1,liveBitrates:null,playerOnly:!1,uiConfId:null,name:null};t=$.extend({},i,t),r.disableEvents(),t.liveBitrates&&r.setDeliveryType("auto"),r.updatePlayers(t),r.enableEvents(),r.set(t);var o=this.getPreviewTitle(t),s=$(n);s.find(".title h2").text(o).attr("title",o),s.find(".close").unbind("click").click(function(){a.closeModal(n)});var l=$("body").height()-173;s.find(".content").height(l),e.layout.modal.show(n,!1)},t.closeModal=function(t){this.savePreviewState(),this.emptyDiv(this.iframeContainer),$(t).fadeOut(300,function(){e.layout.overlay.hide(),e.utils.hideFlash()})},t.emptyDiv=function(e){var t=$("#"+e),r=$("#previewIframe iframe");if(r.length)try{var a=$(r[0].contentWindow.document);a.find("#framePlayerContainer").empty()}catch(n){}return t.length?(t.empty(),t[0]):!1},t.hasIframe=function(){return $("#"+this.iframeContainer+" iframe").length},t.getCacheSt=function(){var e=new Date;return Math.floor(e.getTime()/1e3)+900},t.generateIframe=function(e){var t=$("html").hasClass("lt-ie10"),r="",a=this.emptyDiv(this.iframeContainer),n=document.createElement("iframe");if(n.frameborder="0",n.frameBorder="0",n.marginheight="0",n.marginwidth="0",n.frameborder="0",a.appendChild(n),t)n.src=this.getPreviewUrl(this.Service,!0);else{var i=n.contentDocument;i.open(),i.write(""+r+'
    '+e+"
    "),i.close()}},t.getEmbedProtocol=function(e,t){return t===!0?location.protocol.substring(0,location.protocol.length-1):e.get("secureEmbed")?"https":"http"},t.getEmbedFlashVars=function(t,r){var a=this.getEmbedProtocol(t,r),n=t.get("player"),i=this.getDeliveryTypeFlashVars(t.get("deliveryType"));r===!0&&(i.ks=e.vars.ks);var o=t.get("playlistId");if(o){var s=e.functions.getVersionFromPath(n.html5Url),l=e.functions.versionIsAtLeast(e.vars.min_kdp_version_for_playlist_api_v3,n.swf_version),c=e.functions.versionIsAtLeast(e.vars.min_html5_version_for_playlist_api_v3,s);l&&c?i["playlistAPI.kpl0Id"]=o:(i["playlistAPI.autoInsert"]="true",i["playlistAPI.kpl0Name"]=t.get("playlistName"),i["playlistAPI.kpl0Url"]=a+"://"+e.vars.api_host+"/index.php/partnerservices2/executeplaylist?"+"partner_id="+e.vars.partner_id+"&subp_id="+e.vars.partner_id+"00"+"&format=8&ks={ks}&playlist_id="+o)}return i},t.getEmbedCode=function(e,t){var r=e.get("player");if(!r||!e.get("embedType"))return"";var a=this.getCacheSt(),n={protocol:this.getEmbedProtocol(e,t),embedType:e.get("embedType"),uiConfId:r.id,width:r.width,height:r.height,entryMeta:e.get("entryMeta"),includeSeoMetadata:e.get("includeSeo"),playerId:"kaltura_player_"+a,cacheSt:a,flashVars:this.getEmbedFlashVars(e,t)};e.get("entryId")&&(n.entryId=e.get("entryId"));var i=this.getGenerator().getCode(n);return i},t.getPreviewUrl=function(t,r){var a=t.get("player");if(!a||!t.get("embedType"))return"";var n=this.getEmbedProtocol(t,r),i=n+"://"+e.vars.api_host+"/index.php/extwidget/preview";return i+="/partner_id/"+e.vars.partner_id,i+="/uiconf_id/"+a.id,t.get("entryId")&&(i+="/entry_id/"+t.get("entryId")),i+="/embed/"+t.get("embedType"),i+="?"+e.functions.flashVarsToUrl(this.getEmbedFlashVars(t,r)),r===!0&&(i+="&framed=true"),i},t.generateQrCode=function(e){var t=$("#qrcode").empty();e&&($("html").hasClass("lt-ie9")||t.qrcode({width:80,height:80,text:e}))},t.generateShortUrl=function(t,r){t&&e.client.createShortURL(t,r)},e.Preview=t}(window.kmc);var kmcApp=angular.module("kmcApp",[]);kmcApp.factory("previewService",["$rootScope",function(e){var t={},r=0;return{get:function(e){return void 0===e?t:t[e]},set:function(a,n,i){"object"==typeof a?angular.extend(t,a):t[a]=n,i||0!==r||e.$broadcast("previewChanged")},enableEvents:function(){r--},disableEvents:function(){r++},updatePlayers:function(t){e.$broadcast("playersUpdated",t)},changePlayer:function(t){e.$broadcast("changePlayer",t)},setDeliveryType:function(t){e.$broadcast("changeDelivery",t)}}}]),kmcApp.directive("showSlide",function(){return{restrict:"A",link:function(e,t,r){r.showSlide,e.$watch(r.showSlide,function(e){e&&!t.is(":visible")?t.slideDown():t.slideUp()})}}}),kmcApp.controller("PreviewCtrl",["$scope","previewService",function(e,t){var r=function(){e.$$phase||e.$apply()},a=kmc.Preview;a.playlistMode=!1,a.Service=t;var n=function(t){t=t||{};var r=t.uiConfId?t.uiConfId:void 0;if(kmc.vars.playlists_list&&kmc.vars.players_list){if(t.playlistId||t.playerOnly){if(e.players=kmc.vars.playlists_list,!a.playlistMode)return a.playlistMode=!0,e.$broadcast("changePlayer",r),void 0}else if(e.players=kmc.vars.players_list,a.playlistMode||!e.player)return a.playlistMode=!1,e.$broadcast("changePlayer",r),void 0;r&&e.$broadcast("changePlayer",r)}},i=function(r){var n=a.objectToArray(kmc.vars.delivery_types),i=e.deliveryType||a.getDefault("deliveryType"),o=[];$.each(n,function(){return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,r.swf_version)?(this.id==i&&(i=null),!0):(o.push(this),void 0)}),e.deliveryTypes=o,i||(i=e.deliveryTypes[0].id),t.setDeliveryType(i)},o=function(t){var r=a.objectToArray(kmc.vars.embed_code_types),n=e.embedType||a.getDefault("embedType"),i=[];$.each(r,function(){if(a.playlistMode&&this.entryOnly)return this.id==n&&(n=null),!0;var e=kmc.functions.getVersionFromPath(t.html5Url);return this.minVersion&&!kmc.functions.versionIsAtLeast(this.minVersion,e)?(this.id==n&&(n=null),!0):(i.push(this),void 0)}),e.embedTypes=i,n||(n=e.embedTypes[0].id),e.embedType=n};e.players=[],e.player=null,e.deliveryTypes=[],e.deliveryType=null,e.embedTypes=[],e.embedType=null,e.secureEmbed=a.getDefault("secureEmbed"),e.includeSeo=a.getDefault("includeSeoMetadata"),e.previewOnly=!1,e.playerOnly=!1,e.liveBitrates=!1,e.showAdvancedOptionsStatus=a.getDefault("showAdvancedOptions"),e.shortLinkGenerated=!1,e.$on("playersUpdated",function(e,t){n(t)}),e.$on("changePlayer",function(t,a){a=a?a:e.players[0].id,e.player=a,r()}),e.$on("changeDelivery",function(t,a){e.deliveryType=a,r()}),e.showAdvancedOptions=function(r,a){r.preventDefault(),t.set("showAdvancedOptions",a,!0),e.showAdvancedOptionsStatus=a},e.$watch("showAdvancedOptionsStatus",function(){a.clipboard.reposition()}),e.$watch("player",function(){var r=a.getObjectById(e.player,e.players);r&&(t.disableEvents(),i(r),o(r),setTimeout(function(){t.enableEvents(),t.set("player",r)},0))}),e.$watch("deliveryType",function(){var r=a.getObjectById(e.deliveryType,e.deliveryTypes);t.set("deliveryType",r)}),e.$watch("embedType",function(){t.set("embedType",e.embedType)}),e.$watch("secureEmbed",function(){t.set("secureEmbed",e.secureEmbed)}),e.$watch("includeSeo",function(){t.set("includeSeo",e.includeSeo)}),e.$watch("embedCodePreview",function(){a.generateIframe(e.embedCodePreview)}),e.$watch("previewOnly",function(){e.closeButtonText=e.previewOnly?"Close":"Copy Embed & Close",r()}),e.$on("previewChanged",function(){if(!a.ignoreChangeEvents){var n=a.getPreviewUrl(t);e.embedCode=a.getEmbedCode(t),e.embedCodePreview=a.getEmbedCode(t,!0),e.previewOnly=t.get("previewOnly"),e.playerOnly=t.get("playerOnly"),e.liveBitrates=t.get("liveBitrates"),r(),a.hasIframe()||a.generateIframe(e.embedCodePreview),e.previewUrl="Updating...",e.shortLinkGenerated=!1,a.generateShortUrl(n,function(t){t||(t=n),e.shortLinkGenerated=!0,e.previewUrl=t,a.generateQrCode(t),r()})}})}]),0==kmc.vars.allowFrame&&top!=window&&(top.location=window.location),kmc.vars.debug=!1,kmc.vars.quickstart_guide="/content/docs/pdf/KMC_User_Manual.pdf",kmc.vars.help_url=kmc.vars.service_url+"/kmc5help.html",kmc.vars.port=window.location.port?":"+window.location.port:"",kmc.vars.base_host=window.location.hostname+kmc.vars.port,kmc.vars.base_url=window.location.protocol+"//"+kmc.vars.base_host,kmc.vars.api_host=kmc.vars.host,kmc.vars.api_url=window.location.protocol+"//"+kmc.vars.api_host,kmc.vars.min_kdp_version_for_playlist_api_v3="3.6.15",kmc.vars.min_html5_version_for_playlist_api_v3="1.7.1.3",kmc.log=function(){if(kmc.vars.debug&&"undefined"!=typeof console&&console.log)if(1==arguments.length)console.log(arguments[0]);else{var e=Array.prototype.slice.call(arguments);console.log(e[0],e.slice(1))}},kmc.functions={loadSwf:function(){var e=window.location.protocol+"//"+kmc.vars.cdn_host+"/flash/kmc/"+kmc.vars.kmc_version+"/kmc.swf",t={kmc_uiconf:kmc.vars.kmc_general_uiconf,permission_uiconf:kmc.vars.kmc_permissions_uiconf,host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,srvurl:"api_v3/index.php",protocol:window.location.protocol+"//",partnerid:kmc.vars.partner_id,subpid:kmc.vars.partner_id+"00",ks:kmc.vars.ks,entryId:"-1",kshowId:"-1",debugmode:"true",widget_id:"_"+kmc.vars.partner_id,urchinNumber:kmc.vars.google_analytics_account,firstLogin:kmc.vars.first_login,openPlayer:"kmc.preview_embed.doPreviewEmbed",openPlaylist:"kmc.preview_embed.doPreviewEmbed",openCw:"kmc.functions.openKcw",language:kmc.vars.language||""};kmc.vars.disable_analytics&&(t.disableAnalytics=!0);var r={allowNetworking:"all",allowScriptAccess:"always"};swfobject.embedSWF(e,"kcms","100%","100%","10.0.0",!1,t,r),$("#kcms").attr("style","")},checkForOngoingProcess:function(){var e;try{e=$("#kcms")[0].hasOngoingProcess()}catch(t){e=null}return null!==e?e:void 0},expired:function(){kmc.user.logout()},openKcw:function(e,t){e=e||"";var r="uploadWebCam"==t?kmc.vars.kcw_webcam_uiconf:kmc.vars.kcw_import_uiconf,a={host:kmc.vars.host,cdnhost:kmc.vars.cdn_host,protocol:window.location.protocol.slice(0,-1),partnerid:kmc.vars.partner_id,subPartnerId:kmc.vars.partner_id+"00",sessionId:kmc.vars.ks,devFlag:"true",entryId:"-1",kshow_id:"-1",terms_of_use:kmc.vars.terms_of_use,close:"kmc.functions.onCloseKcw",quick_edit:0,kvar_conversionQuality:e},n={allowscriptaccess:"always",allownetworking:"all",bgcolor:"#DBE3E9",quality:"high",movie:kmc.vars.service_url+"/kcw/ui_conf_id/"+r};kmc.layout.modal.open({width:700,height:420,content:'
    '}),swfobject.embedSWF(n.movie,"kcw","680","400","9.0.0",!1,a,n)},onCloseKcw:function(){kmc.layout.modal.close(),$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})},openChangePwd:function(){kmc.user.changeSetting("password")},openChangeEmail:function(){kmc.user.changeSetting("email")},openChangeName:function(){kmc.user.changeSetting("name")},getAddPanelPosition:function(){var e=$("#add").parent();return e.position().left+e.width()-10},openClipApp:function(e,t){var r=kmc.vars.base_url+"/apps/clipapp/"+kmc.vars.clipapp.version;r+="/?kdpUiconf="+kmc.vars.clipapp.kdp+"&kclipUiconf="+kmc.vars.clipapp.kclip,r+="&partnerId="+kmc.vars.partner_id+"&host="+kmc.vars.host+"&mode="+t+"&config=kmc&entryId="+e;var a="trim"==t?"Trimming Tool":"Clipping Tool";kmc.layout.modal.open({width:950,height:616,title:a,content:'',className:"iframe",closeCallback:function(){$("#kcms")[0].gotoPage({moduleName:"content",subtab:"manage"})}})},flashVarsToUrl:function(e){var t="";for(var r in e){var a="object"==typeof e[r]?JSON.stringify(e[r]):e[r];t+="&flashvars["+encodeURIComponent(r)+"]="+encodeURIComponent(a)}return t},versionIsAtLeast:function(e,t){if(!t)return!1;for(var r=e.split("."),a=t.split("."),n=0;r.length>n;n++){if(parseInt(a[n])>parseInt(r[n]))return!0;if(parseInt(a[n]) *").each(function(){e+=$(this).width()});var t=function(){kmc.vars.close_menu=!0;var t={width:0,visibility:"visible",top:"6px",right:"6px"},r={width:e+"px","padding-top":"2px","padding-bottom":"2px"};$("#user_links").css(t),$("#user_links").animate(r,500)};$("#user").hover(t).click(t),$("#user_links").mouseover(function(){kmc.vars.close_menu=!1}),$("#user_links").mouseleave(function(){kmc.vars.close_menu=!0,setTimeout(kmc.utils.closeMenu,650)}),$("#closeMenu").click(function(){kmc.vars.close_menu=!0,kmc.utils.closeMenu()})},closeMenu:function(){kmc.vars.close_menu&&$("#user_links").animate({width:0},500,function(){$("#user_links").css({width:"auto",visibility:"hidden"})})},activateHeader:function(){$("#user_links a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id");switch(t){case"Quickstart Guide":return this.href=kmc.vars.quickstart_guide,!0;case"Logout":return kmc.user.logout(),!1;case"Support":return kmc.user.openSupport(this),!1;case"ChangePartner":return kmc.user.changePartner(),!1;default:return!1}})},resize:function(){var e=$.browser.ie?640:590,t=$(document).height(),r=$.browser.mozilla?37:74;t-=r,t=e>t?e:t,$("#flash_wrap").height(t+"px"),$("#server_wrap iframe").height(t+"px"),$("#server_wrap").css("margin-top","-"+(t+2)+"px")},isModuleLoaded:function(){($("#flash_wrap object").length||$("#flash_wrap embed").length)&&(kmc.utils.resize(),clearInterval(kmc.vars.isLoadedInterval),kmc.vars.isLoadedInterval=null)},debug:function(){try{console.info(" ks: ",kmc.vars.ks),console.info(" partner_id: ",kmc.vars.partner_id)}catch(e){}},maskHeader:function(e){e?$("#mask").hide():$("#mask").show()},createTabs:function(e){if($("#closeMenu").trigger("click"),e){for(var t,r=kmc.vars.service_url+"/index.php/kmc/kmc4",a=e.length,n="",i=0;a>i;i++)t="action"==e[i].type?'class="menu" ':"",n+='
  • '+e[i].display_name+"
  • ";$("#hTabs").html(n);var o=$("body").width()-($("#logo").width()+$("#hTabs").width()+100);$("#user").width()+20>o&&$("#user").width(o),$("#hTabs a").click(function(e){var t="A"==e.target.tagName?e.target.id:$(e.target).parent().attr("id"),r="A"==e.target.tagName?$(e.target).attr("rel"):$(e.target).parent().attr("rel"),a={moduleName:t,subtab:r};return $("#kcms")[0].gotoPage(a),!1})}else alert("Error geting tabs")},setTab:function(e,t){t&&$("#kmcHeader ul li a").removeClass("active"),$("a#"+e).addClass("active")},resetTab:function(e){$("a#"+e).removeClass("active")},hideFlash:function(e){var t=$("html").hasClass("lt-ie8");e?t?$("#flash_wrap").css("margin-right","3333px"):($("#flash_wrap").css("visibility","hidden"),$("#flash_wrap object").css("visibility","hidden")):t?$("#flash_wrap").css("margin-right","0"):($("#flash_wrap").css("visibility","visible"),$("#flash_wrap object").css("visibility","visible")) +},showFlash:function(){$("#server_wrap").hide(),$("#server_frame").removeAttr("src"),kmc.layout.modal.isOpen()||$("#flash_wrap").css("visibility","visible"),$("#server_wrap").css("margin-top",0)},openIframe:function(e){$("#flash_wrap").css("visibility","hidden"),$("#server_frame").attr("src",e),$("#server_wrap").css("margin-top","-"+($("#flash_wrap").height()+2)+"px"),$("#server_wrap").show()},openHelp:function(e){$("#kcms")[0].doHelp(e)},setClientIP:function(){kmc.vars.clientIP="",kmc.vars.akamaiEdgeServerIpURL&&$.ajax({url:window.location.protocol+"//"+kmc.vars.akamaiEdgeServerIpURL,crossDomain:!0,success:function(e){kmc.vars.clientIP=$(e).find("serverip").text()}})},getClientIP:function(){return kmc.vars.clientIP}},kmc.mediator={writeUrlHash:function(e,t){location.hash=e+"|"+t,document.title="KMC > "+e+(t&&""!==t?" > "+t+" |":"")},readUrlHash:function(){var e,t,r="dashboard",a="",n={};try{e=location.hash.split("#")[1].split("|")}catch(i){t=!0}if(!t&&""!==e[0]){if(r=e[0],a=e[1],e[2])for(var o=e[2].split("&"),s=0;o.length>s;s++){var l=o[s].split(":");n[l[0]]=l[1]}switch(r){case"content":switch(a){case"Moderate":a="moderation";break;case"Syndicate":a="syndication"}a=a.toLowerCase();break;case"appstudio":r="studio",a="playersList";break;case"Settings":switch(r="account",a){case"Account_Settings":a="overview";break;case"Integration Settings":a="integration";break;case"Access Control":a="accessControl";break;case"Transcoding Settings":a="transcoding";break;case"Account Upgrade":a="upgrade"}break;case"reports":r="analytics","Bandwidth Usage Reports"==a&&(a="usageTabTitle")}}return{moduleName:r,subtab:a,extra:n}}},kmc.preview_embed={doPreviewEmbed:function(e,t,r,a,n,i,o){var s={previewOnly:a};i&&(s.uiConfId=parseInt(i)),n?"multitab_playlist"==e?(s.playerOnly=!0,s.name=t):(s.playlistId=e,s.playlistName=t):(s.entryId=e,s.entryMeta={name:t,description:r},o&&(s.liveBitrates=o)),kmc.Preview.openPreviewEmbed(s,kmc.Preview.Service)},doFlavorPreview:function(e,t,r){var a=kmc.vars.default_kdp,n=kmc.Preview.getGenerator().getCode({protocol:location.protocol.substring(0,location.protocol.length-1),embedType:"legacy",entryId:e,uiConfId:parseInt(a.id),width:a.width,height:a.height,includeSeoMetadata:!1,includeHtml5Library:!1,flashVars:{ks:kmc.vars.ks,flavorId:r.asset_id}}),i='
    '+n+"
    "+"
    Entry Name:
     "+t+"
    "+"
    Entry Id:
     "+e+"
    "+"
    Flavor Name:
     "+r.flavor_name+"
    "+"
    Flavor Asset Id:
     "+r.asset_id+"
    "+"
    Bitrate:
     "+r.bitrate+"
    "+"
    Codec:
     "+r.codec+"
    "+"
    Dimensions:
     "+r.dimensions.width+" x "+r.dimensions.height+"
    "+"
    Format:
     "+r.format+"
    "+"
    Size (KB):
     "+r.sizeKB+"
    "+"
    Status:
     "+r.status+"
    "+"
    ";kmc.layout.modal.open({width:parseInt(a.width)+120,height:parseInt(a.height)+300,title:"Flavor Preview",content:'
    '+i+"
    "})},updateList:function(e){var t=e?"playlist":"player";$.ajax({url:kmc.vars.base_url+kmc.vars.getuiconfs_url,type:"POST",data:{type:t,partner_id:kmc.vars.partner_id,ks:kmc.vars.ks},dataType:"json",success:function(t){t&&t.length&&(e?kmc.vars.playlists_list=t:kmc.vars.players_list=t,kmc.Preview.Service.updatePlayers())}})}},kmc.client={makeRequest:function(e,t,r,a){var n=kmc.vars.api_url+"/api_v3/index.php?service="+e+"&action="+t,i={ks:kmc.vars.ks,format:9};$.extend(r,i);var o=function(e){var t=[],r=[],a=0;for(var n in e)r[a++]=n+"|"+e[n];r=r.sort();for(var i=0;r.length>i;i++){var o=r[i].split("|");t[o[0]]=o[1]}return t},s=function(e){e=o(e);var t="";for(var r in e){var a=e[r];t+=a+r}return md5(t)},l=s(r);n+="&kalsig="+l,$.ajax({type:"GET",url:n,dataType:"jsonp",data:r,cache:!1,success:a})},createShortURL:function(e,t){kmc.log("createShortURL");var r={"shortLink:objectType":"KalturaShortLink","shortLink:systemName":"KMC-PREVIEW","shortLink:fullUrl":e};kmc.client.makeRequest("shortlink_shortlink","add",r,function(e){var r=!1;t?(e.id&&(r=kmc.vars.service_url+"/tiny/"+e.id),t(r)):kmc.preview_embed.setShortURL(e.id)})}},kmc.layout={init:function(){$("#kmcHeader").bind("click",function(){$("#hTabs a").each(function(e,t){var r=$(t);return r.hasClass("menu")&&r.hasClass("active")?($("#kcms")[0].gotoPage({moduleName:r.attr("id"),subtab:r.attr("rel")}),void 0):!0})}),$("body").append('
    ')},overlay:{show:function(){$("#overlay").show()},hide:function(){$("#overlay").hide()}},modal:{el:"#modal",create:function(e){var t={el:kmc.layout.modal.el,title:"",content:"",help:"",width:680,height:"auto",className:""};$.extend(t,e);var r=$(t.el),a=r.find(".title h2"),n=r.find(".content");return t.className="modal "+t.className,r.css({width:t.width,height:t.height}).attr("class",t.className),t.title?a.text(t.title).attr("title",t.title).parent().show():(a.parent().hide(),n.addClass("flash_only")),r.find(".help").remove(),a.parent().append(t.help),n[0].innerHTML=t.content,r.find(".close").click(function(){kmc.layout.modal.close(t.el),$.isFunction(e.closeCallback)&&e.closeCallback()}),r},show:function(e,t){t=void 0===t?!0:t,e=e||kmc.layout.modal.el;var r=$(e);kmc.utils.hideFlash(!0),kmc.layout.overlay.show(),r.fadeIn(600),$.browser.msie||r.css("display","table"),t&&this.position(e)},open:function(e){this.create(e);var t=e.el||kmc.layout.modal.el;this.show(t)},position:function(e){e=e||kmc.layout.modal.el;var t=$(e),r=($(window).height()-t.height())/2,a=($(window).width()-t.width())/(2+$(window).scrollLeft());r=40>r?40:r,t.css({top:r+"px",left:a+"px"})},close:function(e){e=e||kmc.layout.modal.el,$(e).fadeOut(300,function(){$(e).find(".content").html(""),kmc.layout.overlay.hide(),kmc.utils.hideFlash()})},isOpen:function(e){return e=e||kmc.layout.modal.el,$(e).is(":visible")}}},kmc.user={openSupport:function(e){var t=e.href;kmc.utils.hideFlash(!0),kmc.layout.overlay.show();var r='';kmc.layout.modal.create({width:550,title:"Support Request",content:r}),$("#support").load(function(){kmc.layout.modal.show(),kmc.vars.support_frame_height||(kmc.vars.support_frame_height=$("#support")[0].contentWindow.document.body.scrollHeight),$("#support").height(kmc.vars.support_frame_height),kmc.layout.modal.position()})},logout:function(){var e=kmc.functions.checkForOngoingProcess();if(e)return alert(e),!1;var t=kmc.mediator.readUrlHash();$.ajax({url:kmc.vars.base_url+"/index.php/kmc/logout",type:"POST",data:{ks:kmc.vars.ks},dataType:"json",complete:function(){window.location=kmc.vars.logoutUrl?kmc.vars.logoutUrl:kmc.vars.service_url+"/index.php/kmc/kmc#"+t.moduleName+"|"+t.subtab}})},changeSetting:function(e){var t,r;switch(e){case"password":t="Change Password",r=180;break;case"email":t="Change Email Address",r=160;break;case"name":t="Edit Name",r=200}var a=kmc.vars.kmc_secured||"https:"==location.protocol?"https":"http",n=a+"://"+window.location.hostname,i=n+kmc.vars.port+"/index.php/kmc/updateLoginData/type/"+e;i=i+"?parent="+encodeURIComponent(document.location.href);var o='';kmc.layout.modal.open({width:370,title:t,content:o}),XD.receiveMessage(function(e){kmc.layout.modal.close(),"reload"==e.data&&($.browser.msie&&8>$.browser.version&&(window.location.hash="account|user"),window.location.reload())},n)},changePartner:function(){var e,t,r,a=0,n=kmc.vars.allowed_partners.length,i='
    Please choose partner:
    ';for(e=0;n>e;e++)a=kmc.vars.allowed_partners[e].id,kmc.vars.partner_id==a?(t=' checked="checked"',r=' style="font-weight: bold"'):(t="",r=""),i+="  "+kmc.vars.allowed_partners[e].name+"";return i+='
    ',kmc.layout.modal.open({width:300,title:"Change Account",content:i}),$("#do_change_partner").click(function(){var e=kmc.vars.base_url+"/index.php/kmc/extlogin",t=$("").attr({type:"hidden",name:"ks",value:kmc.vars.ks}),r=$("").attr({type:"hidden",name:"partner_id",value:$("input[name=pid]:radio:checked").val()}),a=$("").attr({action:e,method:"post",style:"display: none"}).append(t,r);$("body").append(a),a[0].submit()}),!1}},$(function(){kmc.layout.init(),kmc.utils.handleMenu(),kmc.functions.loadSwf(),$(window).wresize(kmc.utils.resize),kmc.vars.isLoadedInterval=setInterval(kmc.utils.isModuleLoaded,200),kmc.preview_embed.updateList(),kmc.preview_embed.updateList(!0),kmc.utils.setClientIP()}),$(window).resize(function(){kmc.layout.modal.isOpen()&&kmc.layout.modal.position()}),window.onbeforeunload=kmc.functions.checkForOngoingProcess,function(e){e.fn.wresize=function(t){function r(){if(e.browser.msie)if(wresize.fired){var t=parseInt(e.browser.version,10);if(wresize.fired=!1,7>t)return!1;if(7==t){var r=e(window).width();if(r!=wresize.width)return wresize.width=r,!1}}else wresize.fired=!0;return!0}function a(e){return r()?t.apply(this,[e]):void 0}return version="1.1",wresize={fired:!1,width:0},this.each(function(){this==window?e(this).resize(a):e(this).resize(t)}),this}}(jQuery);var XD=function(){var e,t,r,a=1,n=this;return{postMessage:function(e,t,r){t&&(r=r||parent,n.postMessage?r.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(r.location=t.replace(/#.*$/,"")+"#"+ +new Date+a++ +"&"+e))},receiveMessage:function(a,i){n.postMessage?(a&&(r=function(e){return"string"==typeof i&&e.origin!==i||"[object Function]"===Object.prototype.toString.call(i)&&i(e.origin)===!1?!1:(a(e),void 0)}),n.addEventListener?n[a?"addEventListener":"removeEventListener"]("message",r,!1):n[a?"attachEvent":"detachEvent"]("onmessage",r)):(e&&clearInterval(e),e=null,a&&(e=setInterval(function(){var e=document.location.hash,r=/^#?\d+&/;e!==t&&r.test(e)&&(t=e,a({data:e.replace(r,"")}))},100)))}}}(); \ No newline at end of file From 959e850339a0864061233ea82c93c7ce124a37eb Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Thu, 18 Jul 2013 17:03:42 +0300 Subject: [PATCH 046/132] Conditions extend generic Kaltura condition directly --- ...EventNotificationTemplateConfiguration.php | 4 ++-- .../lib/api/data/KalturaEventCondition.php | 12 +--------- .../api/data/KalturaEventConditionArray.php | 22 +----------------- .../api/data/KalturaEventFieldCondition.php | 2 +- .../KalturaEventNotificationTemplate.php | 2 +- .../lib/kEventNotificationFlowManager.php | 2 +- .../lib/model/data/kEventCondition.php | 15 ------------ .../lib/model/data/kEventFieldCondition.php | 23 ++++++++++++++++--- 8 files changed, 27 insertions(+), 55 deletions(-) delete mode 100644 plugins/event_notification/lib/model/data/kEventCondition.php diff --git a/plugins/event_notification/admin/forms/EventNotificationTemplateConfiguration.php b/plugins/event_notification/admin/forms/EventNotificationTemplateConfiguration.php index 1833b5e7425..b98f0b7eb3f 100644 --- a/plugins/event_notification/admin/forms/EventNotificationTemplateConfiguration.php +++ b/plugins/event_notification/admin/forms/EventNotificationTemplateConfiguration.php @@ -231,9 +231,9 @@ public function init() } /** - * @param Kaltura_Client_EventNotification_Type_EventCondition $condition + * @param Kaltura_Client_Type_Condition $condition */ - protected function addCondition(Kaltura_Client_EventNotification_Type_EventCondition $condition) + protected function addCondition(Kaltura_Client_Type_Condition $condition) { if($condition instanceof Kaltura_Client_EventNotification_Type_EventFieldCondition && $condition->field instanceof Kaltura_Client_Type_EvalBooleanField) { diff --git a/plugins/event_notification/lib/api/data/KalturaEventCondition.php b/plugins/event_notification/lib/api/data/KalturaEventCondition.php index d8d5c6123c3..0af256c2bb6 100644 --- a/plugins/event_notification/lib/api/data/KalturaEventCondition.php +++ b/plugins/event_notification/lib/api/data/KalturaEventCondition.php @@ -3,18 +3,8 @@ * @package plugins.eventNotification * @subpackage api.objects * @abstract + * @deprecated */ abstract class KalturaEventCondition extends KalturaObject { - /** - * @param string $class class name of the core object - * @return KalturaEventCondition - */ - public static function getInstanceByClass($class) - { - if($class == 'kEventFieldCondition') - return new KalturaEventFieldCondition(); - - return KalturaPluginManager::loadObject('KalturaEventCondition', $class); - } } \ No newline at end of file diff --git a/plugins/event_notification/lib/api/data/KalturaEventConditionArray.php b/plugins/event_notification/lib/api/data/KalturaEventConditionArray.php index f867b970d7a..d835aeec10d 100644 --- a/plugins/event_notification/lib/api/data/KalturaEventConditionArray.php +++ b/plugins/event_notification/lib/api/data/KalturaEventConditionArray.php @@ -2,30 +2,10 @@ /** * @package plugins.eventNotification * @subpackage api.objects + * @deprecated */ class KalturaEventConditionArray extends KalturaTypedArray { - public static function fromDbArray($arr) - { - $newArr = new KalturaEventConditionArray(); - if ($arr == null) - return $newArr; - - foreach ($arr as $obj) - { - $nObj = KalturaEventCondition::getInstanceByClass(get_class($obj)); - if(!$nObj) - { - KalturaLog::err("Event condition could not find matching type for [" . get_class($obj) . "]"); - continue; - } - $nObj->fromObject($obj); - $newArr[] = $nObj; - } - - return $newArr; - } - public function __construct() { parent::__construct("KalturaEventCondition"); diff --git a/plugins/event_notification/lib/api/data/KalturaEventFieldCondition.php b/plugins/event_notification/lib/api/data/KalturaEventFieldCondition.php index 2839cc7f9e6..d0f93931b7c 100644 --- a/plugins/event_notification/lib/api/data/KalturaEventFieldCondition.php +++ b/plugins/event_notification/lib/api/data/KalturaEventFieldCondition.php @@ -3,7 +3,7 @@ * @package plugins.eventNotification * @subpackage api.objects */ -class KalturaEventFieldCondition extends KalturaEventCondition +class KalturaEventFieldCondition extends KalturaCondition { /** * The field to be evaluated at runtime diff --git a/plugins/event_notification/lib/api/types/KalturaEventNotificationTemplate.php b/plugins/event_notification/lib/api/types/KalturaEventNotificationTemplate.php index 9eea55eb163..078db74e766 100644 --- a/plugins/event_notification/lib/api/types/KalturaEventNotificationTemplate.php +++ b/plugins/event_notification/lib/api/types/KalturaEventNotificationTemplate.php @@ -99,7 +99,7 @@ class KalturaEventNotificationTemplate extends KalturaObject implements IFiltera /** * Define the conditions that cause this notification to be triggered - * @var KalturaEventConditionArray + * @var KalturaConditionArray * @requiresPermission update */ public $eventConditions; diff --git a/plugins/event_notification/lib/kEventNotificationFlowManager.php b/plugins/event_notification/lib/kEventNotificationFlowManager.php index 5baf2ef29be..ac298bf14a8 100644 --- a/plugins/event_notification/lib/kEventNotificationFlowManager.php +++ b/plugins/event_notification/lib/kEventNotificationFlowManager.php @@ -132,7 +132,7 @@ protected function notificationTemplatesConditionsFulfilled(EventNotificationTem foreach($eventConditions as $eventCondition) { - /* @var $eventCondition kEventCondition */ + /* @var $eventCondition kCondition */ if(!$eventCondition->fulfilled($scope)) return false; } diff --git a/plugins/event_notification/lib/model/data/kEventCondition.php b/plugins/event_notification/lib/model/data/kEventCondition.php deleted file mode 100644 index 69a7daf610c..00000000000 --- a/plugins/event_notification/lib/model/data/kEventCondition.php +++ /dev/null @@ -1,15 +0,0 @@ -setType(EventNotificationPlugin::getConditionTypeCoreValue(EventNotificationConditionType::EVENT_NOTIFICATION_FIELD)); + parent::__construct($not); + } + + /** + * Needed in order to migrate old kEventFieldCondition that serialized before kCondition defined as parent class + */ + public function __wakeup() + { + $this->setType(EventNotificationPlugin::getConditionTypeCoreValue(EventNotificationConditionType::EVENT_NOTIFICATION_FIELD)); + } + /** * The field to evaluate against the values * @var kBooleanField @@ -12,9 +29,9 @@ class kEventFieldCondition extends kEventCondition private $field; /* (non-PHPdoc) - * @see kEventCondition::fulfilled() + * @see kCondition::internalFulfilled() */ - public function fulfilled(kEventScope $scope) + protected function internalFulfilled(kScope $scope) { $this->field->setScope($scope); return $this->field->getValue(); From 3a828d6e0fb76d37480a7df3eb322c61ce205be6 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Thu, 18 Jul 2013 17:12:56 +0300 Subject: [PATCH 047/132] Enable using metadata profile system name instead of id --- .../data/KalturaCompareMetadataCondition.php | 24 ++++++++++-- .../data/KalturaMatchMetadataCondition.php | 24 ++++++++++-- .../model/data/kCompareMetadataCondition.php | 39 +++++++++++++++++-- .../model/data/kMatchMetadataCondition.php | 39 +++++++++++++++++-- 4 files changed, 114 insertions(+), 12 deletions(-) diff --git a/plugins/metadata/lib/api/data/KalturaCompareMetadataCondition.php b/plugins/metadata/lib/api/data/KalturaCompareMetadataCondition.php index c73848f1bfb..8a2fbb4917e 100644 --- a/plugins/metadata/lib/api/data/KalturaCompareMetadataCondition.php +++ b/plugins/metadata/lib/api/data/KalturaCompareMetadataCondition.php @@ -21,10 +21,17 @@ class KalturaCompareMetadataCondition extends KalturaCompareCondition */ public $profileId; + /** + * Metadata profile system name + * @var string + */ + public $profileSystemName; + private static $mapBetweenObjects = array ( 'xPath', 'profileId', + 'profileSystemName', ); /** @@ -35,19 +42,30 @@ public function __construct() $this->type = MetadataPlugin::getApiValue(MetadataConditionType::METADATA_FIELD_COMPARE); } + /* (non-PHPdoc) + * @see KalturaCompareCondition::getMapBetweenObjects() + */ public function getMapBetweenObjects() { return array_merge(parent::getMapBetweenObjects(), self::$mapBetweenObjects); } /* (non-PHPdoc) - * @see KalturaObject::toObject() + * @see KalturaObject::validateForUsage() */ - public function toObject($dbObject = null, $skip = array()) + public function validateForUsage($sourceObject, $propertiesToSkip = array()) { + parent::validateForUsage($sourceObject, $propertiesToSkip); + $this->validatePropertyNotNull('xPath'); - $this->validatePropertyNotNull('profileId'); + $this->validatePropertyNotNull(array('profileId', 'profileSystemName')); + } + /* (non-PHPdoc) + * @see KalturaObject::toObject() + */ + public function toObject($dbObject = null, $skip = array()) + { if(!$dbObject) $dbObject = new kCompareMetadataCondition(); diff --git a/plugins/metadata/lib/api/data/KalturaMatchMetadataCondition.php b/plugins/metadata/lib/api/data/KalturaMatchMetadataCondition.php index c25073fbcaa..c1a1e12d656 100644 --- a/plugins/metadata/lib/api/data/KalturaMatchMetadataCondition.php +++ b/plugins/metadata/lib/api/data/KalturaMatchMetadataCondition.php @@ -21,10 +21,17 @@ class KalturaMatchMetadataCondition extends KalturaMatchCondition */ public $profileId; + /** + * Metadata profile system name + * @var string + */ + public $profileSystemName; + private static $mapBetweenObjects = array ( 'xPath', 'profileId', + 'profileSystemName', ); /** @@ -35,19 +42,30 @@ public function __construct() $this->type = MetadataPlugin::getApiValue(MetadataConditionType::METADATA_FIELD_MATCH); } + /* (non-PHPdoc) + * @see KalturaMatchCondition::getMapBetweenObjects() + */ public function getMapBetweenObjects() { return array_merge(parent::getMapBetweenObjects(), self::$mapBetweenObjects); } + /* (non-PHPdoc) + * @see KalturaObject::validateForUsage() + */ + public function validateForUsage($sourceObject, $propertiesToSkip = array()) + { + parent::validateForUsage($sourceObject, $propertiesToSkip); + + $this->validatePropertyNotNull('xPath'); + $this->validatePropertyNotNull(array('profileId', 'profileSystemName')); + } + /* (non-PHPdoc) * @see KalturaObject::toObject() */ public function toObject($dbObject = null, $skip = array()) { - $this->validatePropertyNotNull('xPath'); - $this->validatePropertyNotNull('profileId'); - if(!$dbObject) $dbObject = new kMatchMetadataCondition(); diff --git a/plugins/metadata/lib/model/data/kCompareMetadataCondition.php b/plugins/metadata/lib/model/data/kCompareMetadataCondition.php index a84432f51fb..50f3d3f112f 100644 --- a/plugins/metadata/lib/model/data/kCompareMetadataCondition.php +++ b/plugins/metadata/lib/model/data/kCompareMetadataCondition.php @@ -20,6 +20,11 @@ class kCompareMetadataCondition extends kCompareCondition */ private $profileId; + /** + * @var string + */ + private $profileSystemName; + /* (non-PHPdoc) * @see kCondition::__construct() */ @@ -34,17 +39,29 @@ public function __construct($not = false) */ public function getFieldValue(kScope $scope) { - $metadata = null; + $profileId = $this->profileId; + if(!$profileId) + { + if(!$this->profileSystemName) + return null; + + $profile = MetadataProfilePeer::retrieveBySystemName($this->profileSystemName, kCurrentContext::getCurrentPartnerId()); + if(!$profile) + return null; + + $profileId = $profile->getId(); + } + $metadata = null; if($scope instanceof accessControlScope) { - $metadata = MetadataPeer::retrieveByObject($this->profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); + $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); } elseif($scope instanceof kEventScope && $scope->getEvent() instanceof kApplicativeEvent) { $object = $scope->getEvent()->getObject(); if($object instanceof IMetadataObject) - $metadata = MetadataPeer::retrieveByObject($this->profileId, $object->getMetadataObjectType(), $object->getId()); + $metadata = MetadataPeer::retrieveByObject($profileId, $object->getMetadataObjectType(), $object->getId()); } if(!$metadata) @@ -89,6 +106,22 @@ public function setProfileId($profileId) $this->profileId = $profileId; } + /** + * @return string + */ + public function getProfileSystemName() + { + return $this->profileSystemName; + } + + /** + * @param string $profileSystemName + */ + public function setProfileSystemName($profileSystemName) + { + $this->profileSystemName = $profileSystemName; + } + /* (non-PHPdoc) * @see kCompareCondition::shouldFieldDisableCache() */ diff --git a/plugins/metadata/lib/model/data/kMatchMetadataCondition.php b/plugins/metadata/lib/model/data/kMatchMetadataCondition.php index e4b100e67ef..24055fc8361 100644 --- a/plugins/metadata/lib/model/data/kMatchMetadataCondition.php +++ b/plugins/metadata/lib/model/data/kMatchMetadataCondition.php @@ -20,6 +20,11 @@ class kMatchMetadataCondition extends kMatchCondition */ private $profileId; + /** + * @var string + */ + private $profileSystemName; + /* (non-PHPdoc) * @see kCondition::__construct() */ @@ -34,17 +39,29 @@ public function __construct($not = false) */ public function getFieldValue(kScope $scope) { - $metadata = null; + $profileId = $this->profileId; + if(!$profileId) + { + if(!$this->profileSystemName) + return null; + + $profile = MetadataProfilePeer::retrieveBySystemName($this->profileSystemName, kCurrentContext::getCurrentPartnerId()); + if(!$profile) + return null; + + $profileId = $profile->getId(); + } + $metadata = null; if($scope instanceof accessControlScope) { - $metadata = MetadataPeer::retrieveByObject($this->profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); + $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); } elseif($scope instanceof kEventScope && $scope->getEvent() instanceof kApplicativeEvent) { $object = $scope->getEvent()->getObject(); if($object instanceof IMetadataObject) - $metadata = MetadataPeer::retrieveByObject($this->profileId, $object->getMetadataObjectType(), $object->getId()); + $metadata = MetadataPeer::retrieveByObject($profileId, $object->getMetadataObjectType(), $object->getId()); } if($metadata) @@ -85,6 +102,22 @@ public function setProfileId($profileId) $this->profileId = $profileId; } + /** + * @return string + */ + public function getProfileSystemName() + { + return $this->profileSystemName; + } + + /** + * @param string $profileSystemName + */ + public function setProfileSystemName($profileSystemName) + { + $this->profileSystemName = $profileSystemName; + } + /* (non-PHPdoc) * @see kMatchCondition::shouldFieldDisableCache() */ From 487228c220e26399215f570fe37c5c91a5b40c7f Mon Sep 17 00:00:00 2001 From: hilak Date: Thu, 18 Jul 2013 18:23:19 +0300 Subject: [PATCH 048/132] merge changes re: storage job data --- .../batch2/model/kStorageDeleteJobData.php | 31 ++++++++++++++++++- .../batch2/model/kStorageExportJobData.php | 9 ++++-- .../batch/KalturaStorageDeleteJobData.php | 24 +++++++++++--- .../batch/KalturaStorageExportJobData.php | 24 +++++++++++--- 4 files changed, 77 insertions(+), 11 deletions(-) diff --git a/alpha/apps/kaltura/lib/batch2/model/kStorageDeleteJobData.php b/alpha/apps/kaltura/lib/batch2/model/kStorageDeleteJobData.php index ae545a76233..b03a20b8b62 100644 --- a/alpha/apps/kaltura/lib/batch2/model/kStorageDeleteJobData.php +++ b/alpha/apps/kaltura/lib/batch2/model/kStorageDeleteJobData.php @@ -5,4 +5,33 @@ */ class kStorageDeleteJobData extends kStorageJobData { -} + /** + * @return kStorageDeleteJobData + */ + public static function getInstance($protocol) + { + $data = null; + + $data = KalturaPluginManager::loadObject('kStorageDeleteJobData', $protocol); + + if (!$data) + $data = new kStorageDeleteJobData(); + + return $data; + } + /** + * @var StorageProfile $storage + * @var FileSync $fileSync + */ + public function setJobData (StorageProfile $storage, FileSync $filesync) + { + $this->setServerUrl($storage->getStorageUrl()); + $this->setServerUsername($storage->getStorageUsername()); + $this->setServerPassword($storage->getStoragePassword()); + $this->setFtpPassiveMode($storage->getStorageFtpPassiveMode()); + + $this->setSrcFileSyncId($fileSync->getId()); + $this->setDestFileSyncStoredPath($storage->getStorageBaseDir() . '/' . $fileSync->getFilePath()); + } + +} \ No newline at end of file diff --git a/alpha/apps/kaltura/lib/batch2/model/kStorageExportJobData.php b/alpha/apps/kaltura/lib/batch2/model/kStorageExportJobData.php index 1e3ac2bd22b..29cb36543f9 100644 --- a/alpha/apps/kaltura/lib/batch2/model/kStorageExportJobData.php +++ b/alpha/apps/kaltura/lib/batch2/model/kStorageExportJobData.php @@ -12,13 +12,18 @@ class kStorageExportJobData extends kStorageJobData public static function getInstance($protocol) { + $data = null; switch($protocol) { case StorageProfile::STORAGE_PROTOCOL_S3: - return new kAmazonS3StorageExportJobData(); + $data = new kAmazonS3StorageExportJobData(); default: - return new kStorageExportJobData(); + $data = KalturaPluginManager::loadObject('kStorageExportJobData', $protocol); } + if (!$data) + $data = new kStorageExportJobData(); + + return $data; } public function setStorageExportJobData(StorageProfile $externalStorage, FileSync $fileSync, $srcFileSyncLocalPath, $force = false) diff --git a/api_v3/lib/types/batch/KalturaStorageDeleteJobData.php b/api_v3/lib/types/batch/KalturaStorageDeleteJobData.php index ee42a5e098f..449ac934694 100644 --- a/api_v3/lib/types/batch/KalturaStorageDeleteJobData.php +++ b/api_v3/lib/types/batch/KalturaStorageDeleteJobData.php @@ -29,8 +29,16 @@ public function toObject($dbData = null, $props_to_skip = array()) */ public function toSubType($subType) { - // TODO - change to pluginable enum to support more file export protocols - return $subType; + switch ($subType) { + case KalturaStorageProfileProtocol::SFTP: + case KalturaStorageProfileProtocol::FTP: + case KalturaStorageProfileProtocol::SCP: + case KalturaStorageProfileProtocol::S3: + case KalturaStorageProfileProtocol::KALTURA_DC: + return $subType; + default: + return kPluginableEnumsManager::apiToCore('StorageProfileProtocol', $subType); + } } /** @@ -39,8 +47,16 @@ public function toSubType($subType) */ public function fromSubType($subType) { - // TODO - change to pluginable enum to support more file export protocols - return $subType; + switch ($subType) { + case StorageProfileProtocol::SFTP: + case StorageProfileProtocol::FTP: + case StorageProfileProtocol::SCP: + case StorageProfileProtocol::S3: + case StorageProfileProtocol::KALTURA_DC: + return $subType; + default: + return kPluginableEnumsManager::coreToApi('KalturaStorageProfileProtocol', $subType); + } } } diff --git a/api_v3/lib/types/batch/KalturaStorageExportJobData.php b/api_v3/lib/types/batch/KalturaStorageExportJobData.php index c92b4dc949d..4f9ae51ff96 100644 --- a/api_v3/lib/types/batch/KalturaStorageExportJobData.php +++ b/api_v3/lib/types/batch/KalturaStorageExportJobData.php @@ -37,8 +37,16 @@ public function toObject($dbData = null, $props_to_skip = array()) */ public function toSubType($subType) { - // TODO - change to pluginable enum to support more file export protocols - return $subType; + switch ($subType) { + case KalturaStorageProfileProtocol::FTP: + case KalturaStorageProfileProtocol::SFTP: + case KalturaStorageProfileProtocol::SCP: + case KalturaStorageProfileProtocol::S3: + case KalturaStorageProfileProtocol::KALTURA_DC: + return $subType; + default: + return kPluginableEnumsManager::apiToCore('KalturaStorageProfileProtocol', $subType); + } } /** @@ -47,7 +55,15 @@ public function toSubType($subType) */ public function fromSubType($subType) { - // TODO - change to pluginable enum to support more file export protocols - return $subType; + switch ($subType) { + case StorageProfileProtocol::FTP: + case StorageProfileProtocol::SFTP: + case StorageProfileProtocol::SCP: + case StorageProfileProtocol::S3: + case StorageProfileProtocol::KALTURA_DC: + return $subType; + default: + return kPluginableEnumsManager::coreToApi('StorageProfileProtocol', $subType); + } } } From babb4a2c2f24d9f19936ba04d9592438c559e9ed Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Thu, 18 Jul 2013 18:37:37 +0300 Subject: [PATCH 049/132] Apply dynamic values through the scope on the conditions --- .../model/conditions/kCondition.php | 8 ++ .../model/conditions/kMatchCondition.php | 31 +++++++- alpha/apps/kaltura/lib/kScope.php | 38 ++++++++++ alpha/lib/data/kBooleanField.php | 2 +- alpha/lib/data/kIntegerField.php | 2 +- alpha/lib/data/kStringField.php | 2 +- alpha/lib/interfaces/IScopeField.php | 11 +++ .../KalturaEventNotificationTemplate.php | 7 ++ .../lib/kEventNotificationFlowManager.php | 9 +++ .../lib/model/EventNotificationTemplate.php | 3 + ...EmailNotificationTemplateConfiguration.php | 4 +- .../api/KalturaEmailNotificationParameter.php | 65 +--------------- ...KalturaEmailNotificationParameterArray.php | 23 +----- .../api/KalturaEmailNotificationTemplate.php | 8 -- .../lib/model/EmailNotificationTemplate.php | 6 +- .../lib/model/kEmailNotificationParameter.php | 51 ------------- .../HttpNotificationTemplateConfiguration.php | 2 +- .../api/KalturaHttpNotificationParameter.php | 74 ------------------- .../KalturaHttpNotificationParameterArray.php | 28 ------- .../api/KalturaHttpNotificationTemplate.php | 7 -- .../lib/model/HttpNotificationTemplate.php | 3 - .../lib/model/kHttpNotificationParameter.php | 51 ------------- .../model/data/kCompareMetadataCondition.php | 17 +++++ .../model/data/kMatchMetadataCondition.php | 17 +++++ 24 files changed, 148 insertions(+), 321 deletions(-) create mode 100644 alpha/lib/interfaces/IScopeField.php delete mode 100644 plugins/event_notification/providers/email/lib/model/kEmailNotificationParameter.php delete mode 100644 plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationParameter.php delete mode 100644 plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationParameterArray.php delete mode 100644 plugins/event_notification/providers/http/lib/model/kHttpNotificationParameter.php diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php index 19ddfd2db22..545b901b05c 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php @@ -21,6 +21,13 @@ public function __construct($not = false) $this->setNot($not); } + /** + * Enable changing the condition attributes according to additional data in the scope + */ + protected function applyDynamicValues(kScope $scope) + { + } + /** * @param kScope $scope * @return bool @@ -33,6 +40,7 @@ abstract protected function internalFulfilled(kScope $scope); */ final public function fulfilled(kScope $scope) { + $this->applyDynamicValues($scope); return $this->calcNot($this->internalFulfilled($scope)); } diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kMatchCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kMatchCondition.php index e2b25236801..0ab02b0d4dc 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kMatchCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kMatchCondition.php @@ -10,7 +10,12 @@ abstract class kMatchCondition extends kCondition * @var array */ protected $values; - + + /** + * @var array + */ + protected $dynamicValues; + /** * @param array $values */ @@ -31,6 +36,15 @@ function getValues() { return $this->values; } + + /* (non-PHPdoc) + * @see kCondition::applyDynamicValues() + */ + protected function applyDynamicValues(kScope $scope) + { + parent::applyDynamicValues($scope); + $this->dynamicValues = $scope->getDynamicValues('{', '}'); + } /** * @param kScope $scope @@ -42,21 +56,30 @@ function getStringValues($scope = null) return array(); $values = array(); + $dynamicValuesKeys = null; + if(is_array($this->dynamicValues) && count($this->dynamicValues)) + $dynamicValuesKeys = array_keys($this->dynamicValues); foreach($this->values as $value) { /* @var $value kStringValue */ + $calculatedValue = null; if(is_object($value)) { if($scope && $value instanceof kStringField) $value->setScope($scope); - - $values[] = $value->getValue(); + + $calculatedValue = $value->getValue(); } else { - $values[] = strval($value); + $calculatedValue = strval($value); } + + if($dynamicValuesKeys) + $calculatedValue = str_replace($dynamicValuesKeys, $this->dynamicValues, $calculatedValue); + + $values[] = $calculatedValue; } return $values; diff --git a/alpha/apps/kaltura/lib/kScope.php b/alpha/apps/kaltura/lib/kScope.php index 0b9b1cafa24..13a6e791596 100644 --- a/alpha/apps/kaltura/lib/kScope.php +++ b/alpha/apps/kaltura/lib/kScope.php @@ -31,6 +31,12 @@ class kScope */ protected $time; + /** + * Unix timestamp (In seconds) to be used to test entry scheduling, keep null to use now. + * @var array + */ + protected $dynamicValues = array(); + public function __construct() { $this->setIp(requestUtils::getRemoteAddress()); @@ -126,4 +132,36 @@ public function setTime($time) { $this->time = $time; } + + public function resetDynamicValues() + { + $this->dynamicValues= array(); + } + + /** + * @param string $key + * @param kValue $value + */ + public function addDynamicValue($key, kValue $value) + { + $this->dynamicValues[$key] = $value; + } + + /** + * @return array + */ + public function getDynamicValues($keyPrefix = '', $keySuffix = '') + { + $values = array(); + foreach($this->dynamicValues as $key => $value) + { + /* @var $value kValue */ + if($value instanceof IScopeField) + $value->setScope($this); + + $values[$keyPrefix . $key . $keySuffix] = $value->getValue(); + } + + return $values; + } } \ No newline at end of file diff --git a/alpha/lib/data/kBooleanField.php b/alpha/lib/data/kBooleanField.php index da0e944e25e..1415e784191 100644 --- a/alpha/lib/data/kBooleanField.php +++ b/alpha/lib/data/kBooleanField.php @@ -5,7 +5,7 @@ * @package Core * @subpackage model.data */ -abstract class kBooleanField extends kBooleanValue +abstract class kBooleanField extends kBooleanValue implements IScopeField { /** * @var kScope diff --git a/alpha/lib/data/kIntegerField.php b/alpha/lib/data/kIntegerField.php index 342017a4033..3888bbffe53 100644 --- a/alpha/lib/data/kIntegerField.php +++ b/alpha/lib/data/kIntegerField.php @@ -5,7 +5,7 @@ * @package Core * @subpackage model.data */ -abstract class kIntegerField extends kIntegerValue +abstract class kIntegerField extends kIntegerValue implements IScopeField { /** * @var kScope diff --git a/alpha/lib/data/kStringField.php b/alpha/lib/data/kStringField.php index 62a7c293ac1..aa1ea86ba28 100644 --- a/alpha/lib/data/kStringField.php +++ b/alpha/lib/data/kStringField.php @@ -5,7 +5,7 @@ * @package Core * @subpackage model.data */ -abstract class kStringField extends kStringValue +abstract class kStringField extends kStringValue implements IScopeField { /** * @var kScope diff --git a/alpha/lib/interfaces/IScopeField.php b/alpha/lib/interfaces/IScopeField.php new file mode 100644 index 00000000000..5a4211bdc78 --- /dev/null +++ b/alpha/lib/interfaces/IScopeField.php @@ -0,0 +1,11 @@ +resetDynamicValues(); + $notificationParameters = $notificationTemplate->getContentParameters(); + foreach($notificationParameters as $notificationParameter) + { + /* @var $notificationParameter kEventNotificationParameter */ + $scope->addDynamicValue($notificationParameter->getKey(), $notificationParameter->getValue()); + } + if($this->notificationTemplatesConditionsFulfilled($notificationTemplate, $scope)) $this->notificationTemplates[] = $notificationTemplate; } diff --git a/plugins/event_notification/lib/model/EventNotificationTemplate.php b/plugins/event_notification/lib/model/EventNotificationTemplate.php index 6b1203218ae..4dccc792213 100644 --- a/plugins/event_notification/lib/model/EventNotificationTemplate.php +++ b/plugins/event_notification/lib/model/EventNotificationTemplate.php @@ -16,6 +16,7 @@ abstract class EventNotificationTemplate extends BaseEventNotificationTemplate { const CUSTOM_DATA_EVENT_CONDITIONS = 'eventConditions'; + const CUSTOM_DATA_CONTENT_PARAMETERS = 'contentParameters'; const CUSTOM_DATA_MANUAL_DISPATCH_ENABLED = 'manualDispatchEnabled'; const CUSTOM_DATA_AUTOMATIC_DISPATCH_ENABLED = 'automaticDispatchEnabled'; @@ -27,10 +28,12 @@ abstract class EventNotificationTemplate extends BaseEventNotificationTemplate abstract public function getJobData(kScope $scope = null); public function getEventConditions() {return $this->getFromCustomData(self::CUSTOM_DATA_EVENT_CONDITIONS);} + public function getContentParameters() {return $this->getFromCustomData(self::CUSTOM_DATA_CONTENT_PARAMETERS, null, array());} public function getManualDispatchEnabled() {return $this->getFromCustomData(self::CUSTOM_DATA_MANUAL_DISPATCH_ENABLED);} public function getAutomaticDispatchEnabled() {return $this->getFromCustomData(self::CUSTOM_DATA_AUTOMATIC_DISPATCH_ENABLED);} public function setEventConditions(array $v) {return $this->putInCustomData(self::CUSTOM_DATA_EVENT_CONDITIONS, $v);} + public function setContentParameters(array $v) {return $this->putInCustomData(self::CUSTOM_DATA_CONTENT_PARAMETERS, $v);} public function setManualDispatchEnabled($v) {return $this->putInCustomData(self::CUSTOM_DATA_MANUAL_DISPATCH_ENABLED, $v);} public function setAutomaticDispatchEnabled($v) {return $this->putInCustomData(self::CUSTOM_DATA_AUTOMATIC_DISPATCH_ENABLED, $v);} diff --git a/plugins/event_notification/providers/email/lib/EmailNotificationTemplateConfiguration.php b/plugins/event_notification/providers/email/lib/EmailNotificationTemplateConfiguration.php index 6b5517847bc..a169bded181 100644 --- a/plugins/event_notification/providers/email/lib/EmailNotificationTemplateConfiguration.php +++ b/plugins/event_notification/providers/email/lib/EmailNotificationTemplateConfiguration.php @@ -69,7 +69,7 @@ public function getObject($objectType, array $properties, $add_underscore = true $field = new Kaltura_Client_Type_EvalStringField(); $field->code = $properties['contentParameterValue'][$index]; - $contentParameter = new Kaltura_Client_EmailNotification_Type_EmailNotificationParameter(); + $contentParameter = new Kaltura_Client_EmailNotification_Type_EventNotificationParameter(); $contentParameter->key = $value; $contentParameter->value = $field; @@ -194,7 +194,7 @@ protected function addTypeElements() } /** - * @param Kaltura_Client_EmailNotification_Type_EmailNotificationParameter $parameter + * @param Kaltura_Client_EmailNotification_Type_EventNotificationParameter $parameter */ protected function addContentParameter(Kaltura_Client_EventNotification_Type_EventNotificationParameter $parameter) { diff --git a/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationParameter.php b/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationParameter.php index 8adb868c3f7..fa964138e2a 100644 --- a/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationParameter.php +++ b/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationParameter.php @@ -2,69 +2,8 @@ /** * @package plugins.emailNotification * @subpackage api.objects + * @deprecated use KalturaEventNotificationParameter instead */ -class KalturaEmailNotificationParameter extends KalturaObject +class KalturaEmailNotificationParameter extends KalturaEventNotificationParameter { - /** - * The key in the subject and body to be replaced with the dynamic value - * @var string - */ - public $key; - - /** - * The dynamic value to be placed in the final output - * @var KalturaStringValue - */ - public $value; - - private static $map_between_objects = array - ( - 'key', - 'value', - ); - - public function getMapBetweenObjects ( ) - { - return array_merge ( parent::getMapBetweenObjects() , self::$map_between_objects ); - } - - /* (non-PHPdoc) - * @see KalturaObject::toObject() - */ - public function toObject($dbObject = null, $skip = array()) - { - if(!$dbObject) - $dbObject = new kEmailNotificationParameter(); - - return parent::toObject($dbObject, $skip); - } - - /* (non-PHPdoc) - * @see KalturaObject::fromObject() - */ - public function fromObject($dbObject) - { - /* @var $dbObject kEventValueCondition */ - parent::fromObject($dbObject); - - $valueType = get_class($dbObject->getValue()); - KalturaLog::debug("Loading KalturaStringValue from type [$valueType]"); - switch ($valueType) - { - case 'kStringValue': - $this->value = new KalturaStringValue(); - break; - - case 'kEvalStringField': - $this->value = new KalturaEvalStringField(); - break; - - default: - $this->value = KalturaPluginManager::loadObject('KalturaStringValue', $valueType); - break; - } - - if($this->value) - $this->value->fromObject($dbObject->getValue()); - } } diff --git a/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationParameterArray.php b/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationParameterArray.php index c9312ae0657..80f15221046 100644 --- a/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationParameterArray.php +++ b/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationParameterArray.php @@ -2,27 +2,8 @@ /** * @package plugins.emailNotification * @subpackage api.objects + * @deprecated use KalturaEventNotificationParameterArray instead */ -class KalturaEmailNotificationParameterArray extends KalturaTypedArray +class KalturaEmailNotificationParameterArray extends KalturaEventNotificationParameterArray { - public static function fromDbArray($arr) - { - $newArr = new KalturaEmailNotificationParameterArray(); - if ($arr == null) - return $newArr; - - foreach ($arr as $obj) - { - $nObj = new KalturaEmailNotificationParameter(); - $nObj->fromObject($obj); - $newArr[] = $nObj; - } - - return $newArr; - } - - public function __construct() - { - parent::__construct("KalturaEmailNotificationParameter"); - } } \ No newline at end of file diff --git a/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationTemplate.php b/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationTemplate.php index 6b5abd4752d..f4deeb80960 100644 --- a/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationTemplate.php +++ b/plugins/event_notification/providers/email/lib/api/KalturaEmailNotificationTemplate.php @@ -101,13 +101,6 @@ class KalturaEmailNotificationTemplate extends KalturaEventNotificationTemplate */ public $customHeaders; - /** - * Define the content dynamic parameters - * @var KalturaEventNotificationParameterArray - * @requiresPermission update - */ - public $contentParameters; - /** * mapping between the field on this object (on the left) and the setter/getter on the entry object (on the right) */ @@ -126,7 +119,6 @@ class KalturaEmailNotificationTemplate extends KalturaEventNotificationTemplate 'hostname', 'messageID', 'customHeaders', - 'contentParameters', ); public function __construct() diff --git a/plugins/event_notification/providers/email/lib/model/EmailNotificationTemplate.php b/plugins/event_notification/providers/email/lib/model/EmailNotificationTemplate.php index cc006c38986..be194d9a6b7 100644 --- a/plugins/event_notification/providers/email/lib/model/EmailNotificationTemplate.php +++ b/plugins/event_notification/providers/email/lib/model/EmailNotificationTemplate.php @@ -18,7 +18,6 @@ class EmailNotificationTemplate extends EventNotificationTemplate implements ISy const CUSTOM_DATA_HOSTNAME = 'hostname'; const CUSTOM_DATA_MESSAGE_ID = 'messageID'; const CUSTOM_DATA_CUSTOM_HEADERS = 'customHeaders'; - const CUSTOM_DATA_CONTENT_PARAMETERS = 'contentParameters'; const CUSTOM_DATA_BODY_FILE_VERSION = 'bodyFileVersion'; const FILE_SYNC_BODY = 1; @@ -67,7 +66,7 @@ public function getJobData(kScope $scope = null) $contentParameters = $this->getContentParameters(); foreach($contentParameters as $contentParameter) { - /* @var $contentParameter kEmailNotificationParameter */ + /* @var $contentParameter kEventNotificationParameter */ $value = $contentParameter->getValue(); if($scope && $value instanceof kStringField) $value->setScope($scope); @@ -287,8 +286,6 @@ public function getBcc() {return $this->getFromCustomData(self::CUSTOM_D */ public function getReplyTo() {return $this->getFromCustomData(self::CUSTOM_DATA_REPLY_TO);} - public function getContentParameters() {return $this->getFromCustomData(self::CUSTOM_DATA_CONTENT_PARAMETERS, null, array());} - public function incrementBodyFileVersion() {return $this->incInCustomData(self::CUSTOM_DATA_BODY_FILE_VERSION);} public function resetBodyFileVersion() {return $this->putInCustomData(self::CUSTOM_DATA_BODY_FILE_VERSION, 1);} public function setFormat($v) {return $this->putInCustomData(self::CUSTOM_DATA_FORMAT, $v);} @@ -304,5 +301,4 @@ public function setTo(kEmailNotificationRecipientProvider $v) {return $th public function setCc(kEmailNotificationRecipientProvider $v) {return $this->putInCustomData(self::CUSTOM_DATA_CC, $v);} public function setBcc(kEmailNotificationRecipientProvider $v) {return $this->putInCustomData(self::CUSTOM_DATA_BCC, $v);} public function setReplyTo(kEmailNotificationRecipientProvider $v) {return $this->putInCustomData(self::CUSTOM_DATA_REPLY_TO, $v);} - public function setContentParameters(array $v) {return $this->putInCustomData(self::CUSTOM_DATA_CONTENT_PARAMETERS, $v);} } diff --git a/plugins/event_notification/providers/email/lib/model/kEmailNotificationParameter.php b/plugins/event_notification/providers/email/lib/model/kEmailNotificationParameter.php deleted file mode 100644 index 4de600d3cab..00000000000 --- a/plugins/event_notification/providers/email/lib/model/kEmailNotificationParameter.php +++ /dev/null @@ -1,51 +0,0 @@ -key; - } - - /** - * @return kStringValue $value - */ - public function getValue() - { - return $this->value; - } - - /** - * @param string $key - */ - public function setKey($key) - { - $this->key = $key; - } - - /** - * @param kStringValue $value - */ - public function setValue(kStringValue $value) - { - $this->value = $value; - } -} \ No newline at end of file diff --git a/plugins/event_notification/providers/http/admin/HttpNotificationTemplateConfiguration.php b/plugins/event_notification/providers/http/admin/HttpNotificationTemplateConfiguration.php index a19e249a418..810a248fd29 100644 --- a/plugins/event_notification/providers/http/admin/HttpNotificationTemplateConfiguration.php +++ b/plugins/event_notification/providers/http/admin/HttpNotificationTemplateConfiguration.php @@ -245,7 +245,7 @@ protected function addTypeElements() } /** - * @param Kaltura_Client_HttpNotification_Type_HttpNotificationParameter $parameter + * @param Kaltura_Client_HttpNotification_Type_EventNotificationParameter $parameter */ protected function addContentParameter(Kaltura_Client_EventNotification_Type_EventNotificationParameter $parameter) { diff --git a/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationParameter.php b/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationParameter.php deleted file mode 100644 index 4b589e1f0ad..00000000000 --- a/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationParameter.php +++ /dev/null @@ -1,74 +0,0 @@ -getValue()); - KalturaLog::debug("Loading KalturaStringValue from type [$valueType]"); - switch ($valueType) - { - case 'kStringValue': - $this->value = new KalturaStringValue(); - break; - - case 'kEvalStringField': - $this->value = new KalturaEvalStringField(); - break; - - case 'kHttpNotificationObjectField': - $this->value = new KalturaHttpNotificationObjectField(); - break; - - default: - $this->value = KalturaPluginManager::loadObject('KalturaStringValue', $valueType); - break; - } - - if($this->value) - $this->value->fromObject($dbObject->getValue()); - } -} diff --git a/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationParameterArray.php b/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationParameterArray.php deleted file mode 100644 index 0c93d399d98..00000000000 --- a/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationParameterArray.php +++ /dev/null @@ -1,28 +0,0 @@ -fromObject($obj); - $newArr[] = $nObj; - } - - return $newArr; - } - - public function __construct() - { - parent::__construct("KalturaHttpNotificationParameter"); - } -} \ No newline at end of file diff --git a/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationTemplate.php b/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationTemplate.php index 1c3352c5554..3215aaa8aa3 100644 --- a/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationTemplate.php +++ b/plugins/event_notification/providers/http/lib/api/KalturaHttpNotificationTemplate.php @@ -131,12 +131,6 @@ class KalturaHttpNotificationTemplate extends KalturaEventNotificationTemplate */ public $customHeaders; - /** - * Define the content dynamic parameters - * @var KalturaEventNotificationParameterArray - */ - public $contentParameters; - private static $map_between_objects = array ( 'url', @@ -157,7 +151,6 @@ class KalturaHttpNotificationTemplate extends KalturaEventNotificationTemplate 'sslKey', 'sslKeyPassword', 'customHeaders', - 'contentParameters', ); public function __construct() diff --git a/plugins/event_notification/providers/http/lib/model/HttpNotificationTemplate.php b/plugins/event_notification/providers/http/lib/model/HttpNotificationTemplate.php index 7fd49d868b3..158018ea699 100644 --- a/plugins/event_notification/providers/http/lib/model/HttpNotificationTemplate.php +++ b/plugins/event_notification/providers/http/lib/model/HttpNotificationTemplate.php @@ -23,7 +23,6 @@ class HttpNotificationTemplate extends EventNotificationTemplate implements ISyn const CUSTOM_DATA_SSL_KEY = 'sslKey'; const CUSTOM_DATA_SSL_KEY_PASSWORD = 'sslKeyPassword'; const CUSTOM_DATA_CUSTOM_HEADERS = 'customHeaders'; - const CUSTOM_DATA_CONTENT_PARAMETERS = 'contentParameters'; const CUSTOM_DATA_POST_FILE_VERSION = 'postFileVersion'; const FILE_SYNC_POST = 1; @@ -268,7 +267,6 @@ public function getSslKeyType() {return $this->getFromCustomData(self::CU public function getSslKey() {return $this->getFromCustomData(self::CUSTOM_DATA_SSL_KEY);} public function getSslKeyPassword() {return $this->getFromCustomData(self::CUSTOM_DATA_SSL_KEY_PASSWORD);} public function getCustomHeaders() {return $this->getFromCustomData(self::CUSTOM_DATA_CUSTOM_HEADERS, null, array());} - public function getContentParameters() {return $this->getFromCustomData(self::CUSTOM_DATA_CONTENT_PARAMETERS, null, array());} public function incrementPostFileVersion() {return $this->incInCustomData(self::CUSTOM_DATA_POST_FILE_VERSION);} public function resetPostFileVersion() {return $this->putInCustomData(self::CUSTOM_DATA_POST_FILE_VERSION, 1);} @@ -291,5 +289,4 @@ public function setSslKeyType($v) {return $this->putInCustomData(self::CUS public function setSslKey($v) {return $this->putInCustomData(self::CUSTOM_DATA_SSL_KEY, $v);} public function setSslKeyPassword($v) {return $this->putInCustomData(self::CUSTOM_DATA_SSL_KEY_PASSWORD, $v);} public function setCustomHeaders(array $v) {return $this->putInCustomData(self::CUSTOM_DATA_CUSTOM_HEADERS, $v);} - public function setContentParameters(array $v) {return $this->putInCustomData(self::CUSTOM_DATA_CONTENT_PARAMETERS, $v);} } diff --git a/plugins/event_notification/providers/http/lib/model/kHttpNotificationParameter.php b/plugins/event_notification/providers/http/lib/model/kHttpNotificationParameter.php deleted file mode 100644 index b7e74aece07..00000000000 --- a/plugins/event_notification/providers/http/lib/model/kHttpNotificationParameter.php +++ /dev/null @@ -1,51 +0,0 @@ -key; - } - - /** - * @return kStringValue $value - */ - public function getValue() - { - return $this->value; - } - - /** - * @param string $key - */ - public function setKey($key) - { - $this->key = $key; - } - - /** - * @param kStringValue $value - */ - public function setValue(kStringValue $value) - { - $this->value = $value; - } -} \ No newline at end of file diff --git a/plugins/metadata/lib/model/data/kCompareMetadataCondition.php b/plugins/metadata/lib/model/data/kCompareMetadataCondition.php index 50f3d3f112f..1bf3f05d3fe 100644 --- a/plugins/metadata/lib/model/data/kCompareMetadataCondition.php +++ b/plugins/metadata/lib/model/data/kCompareMetadataCondition.php @@ -34,6 +34,23 @@ public function __construct($not = false) parent::__construct($not); } + /* (non-PHPdoc) + * @see kCondition::applyDynamicValues() + */ + protected function applyDynamicValues(kScope $scope) + { + parent::applyDynamicValues($scope); + + $dynamicValues = $scope->getDynamicValues('{', '}'); + + if(is_array($dynamicValues) && count($dynamicValues)) + { + $this->xPath = str_replace(array_keys($dynamicValues), $dynamicValues, $this->xPath); + if($this->profileSystemName) + $this->profileSystemName = str_replace(array_keys($dynamicValues), $dynamicValues, $this->profileSystemName); + } + } + /* (non-PHPdoc) * @see kCondition::getFieldValue() */ diff --git a/plugins/metadata/lib/model/data/kMatchMetadataCondition.php b/plugins/metadata/lib/model/data/kMatchMetadataCondition.php index 24055fc8361..a9d889a4a7e 100644 --- a/plugins/metadata/lib/model/data/kMatchMetadataCondition.php +++ b/plugins/metadata/lib/model/data/kMatchMetadataCondition.php @@ -34,6 +34,23 @@ public function __construct($not = false) parent::__construct($not); } + /* (non-PHPdoc) + * @see kCondition::applyDynamicValues() + */ + protected function applyDynamicValues(kScope $scope) + { + parent::applyDynamicValues($scope); + + $dynamicValues = $scope->getDynamicValues('{', '}'); + + if(is_array($dynamicValues) && count($dynamicValues)) + { + $this->xPath = str_replace(array_keys($dynamicValues), $dynamicValues, $this->xPath); + if($this->profileSystemName) + $this->profileSystemName = str_replace(array_keys($dynamicValues), $dynamicValues, $this->profileSystemName); + } + } + /* (non-PHPdoc) * @see kCondition::getFieldValue() */ From 0302ba94ee8702cd19a1d05d399f34bfc78e36ba Mon Sep 17 00:00:00 2001 From: hilak Date: Sun, 21 Jul 2013 08:30:47 +0300 Subject: [PATCH 050/132] removed reference to non-existent class --- batch/batches/Storage/KAsyncStorageExport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batch/batches/Storage/KAsyncStorageExport.class.php b/batch/batches/Storage/KAsyncStorageExport.class.php index 5b13b58aaf4..81cfa43e784 100644 --- a/batch/batches/Storage/KAsyncStorageExport.class.php +++ b/batch/batches/Storage/KAsyncStorageExport.class.php @@ -77,7 +77,7 @@ protected function export(KalturaBatchJob $job, KalturaStorageExportJobData $dat { return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::ENGINE_NOT_FOUND, "Engine not found", KalturaBatchJobStatus::FAILED); } - $this->updateJob($job, $initResult->message, KalturaBatchJobStatus::QUEUED); + $this->updateJob($job, null, KalturaBatchJobStatus::QUEUED); $exportResult = $engine->export(); return $this->closeJob($job, null , null, null, $exportResult ? KalturaBatchJobStatus::FINISHED : KalturaBatchJobStatus::ALMOST_DONE, $data ); From 8f12867c34e564aa29557d1da06f5af28fe47e8f Mon Sep 17 00:00:00 2001 From: hilak Date: Sun, 21 Jul 2013 11:37:39 +0300 Subject: [PATCH 051/132] kontikiAPIWrapper class changed from having static functions to class public functions. --- .../batch/Engine/KKontikiExportEngine.php | 16 +++-- plugins/kontiki/lib/KontikiAPIWrapper.php | 60 +++++++++---------- plugins/kontiki/lib/KontikiManager.php | 1 + .../lib/urlManager/kKontikiUrlManager.php | 10 +++- 4 files changed, 48 insertions(+), 39 deletions(-) diff --git a/plugins/kontiki/batch/Engine/KKontikiExportEngine.php b/plugins/kontiki/batch/Engine/KKontikiExportEngine.php index a00ef0ac651..a69aae6a686 100644 --- a/plugins/kontiki/batch/Engine/KKontikiExportEngine.php +++ b/plugins/kontiki/batch/Engine/KKontikiExportEngine.php @@ -5,6 +5,11 @@ class KKontikiExportEngine extends KExportEngine { protected $partnerId; + /** + * @var KontikiAPWrapper + */ + protected $kontikiAPIWrapper; + protected static $pending_statuses = array ("PENDING_RESTART","RESTARTING","PENDING","PROCESSING","TRANSCODE_QUEUED","TRANSCODE_DONE","TRANSCODING","UPLOADING","SCANNING","ENCRYPTING","ENCRYPT_DONE","SIGNING","SIGN_DONE","RESIZING_THUMBNAILS","RESIZING_THUMBNAILS_DONE","PUBLISHING","PENDING_APPROVAL"); protected static $failed_statuses = array("RESTART_FAILED","UNPROCESSABLE","TRANSCODE_FAILED","TRANSCODE_ERROR","TRANSCODE_CANCELLED","TRANSCODE_INTERRUPTED","UPLOAD_FAILED","SCAN_FAILED","SCAN_ERROR","ENCRYPT_FAILED","SIGN_FAILED","RESIZING_THUMBNAILS_FAILED","SMIL_FILE_GENERATION_FAILED","PUBLISHING_FAILED","PENDING_APPROVAL_FAIL","READY_FAIL" ); @@ -15,8 +20,7 @@ function __construct($data, $partnerId, $jobSubType) { parent::__construct($data, $jobSubType); $this->partnerId = $partnerId; - /* @var $data KalturaKontikiStorageExportJobData */ - KontikiAPIWrapper::$entryPoint = $data->entryPoint; + $this->kontikiAPIWrapper = new KontikiAPIWrapper($data->entryPoint); } /* (non-PHPdoc) @@ -27,7 +31,7 @@ public function export() KBatchBase::impersonate($this->partnerId); $url = KBatchBase::$kClient->flavorAsset->getUrl($this->data->flavorAssetId); KBatchBase::unimpersonate(); - $result = KontikiAPIWrapper::addKontikiUploadResource('srv-' . base64_encode($this->data->serviceToken), $url); + $result = $this->kontikiAPIWrapper->addKontikiUploadResource('srv-' . base64_encode($this->data->serviceToken), $url); KalturaLog::info("Upload result: $result"); $kontikiResult = new SimpleXMLElement($result); @@ -42,7 +46,7 @@ public function export() $entry = KBatchBase::$kClient->baseEntry->get($flavorAsset->entryId); $result = KBatchBase::$kClient->doMultiRequest(); KBatchBase::unimpersonate(); - $contentResourceResult = KontikiAPIWrapper::addKontikiVideoContentResource('srv-' . base64_encode($this->data->serviceToken), $uploadMoid, $result[1], $result[0]); + $contentResourceResult = $this->kontikiAPIWrapper->addKontikiVideoContentResource('srv-' . base64_encode($this->data->serviceToken), $uploadMoid, $result[1], $result[0]); KalturaLog::info("Content resource result: " . $contentResourceResult); $resultAsXml = new SimpleXMLElement($contentResourceResult); @@ -56,7 +60,7 @@ public function export() */ public function verifyExportedResource() { - $contentResource = KontikiAPIWrapper::getKontikiContentResource('srv-' . base64_encode($this->data->serviceToken), $this->data->contentMoid); + $contentResource = $this->kontikiAPIWrapper->getKontikiContentResource('srv-' . base64_encode($this->data->serviceToken), $this->data->contentMoid); if (!$contentResource) { throw new kKontikiApplicativeException(kKontikiApplicativeException::KONTIKI_API_EXCEPTION, "Failed to retrieve content resource"); @@ -88,7 +92,7 @@ public function verifyExportedResource() */ public function delete () { - $deleteResult = KontikiAPIWrapper::deleteKontikiContentResource('srv-' . base64_encode($this->data->serviceToken), $this->data->contentMoid); + $deleteResult = $this->kontikiAPIWrapper->deleteKontikiContentResource('srv-' . base64_encode($this->data->serviceToken), $this->data->contentMoid); if (!$deleteResult) { throw new kKontikiApplicativeException(kKontikiApplicativeException::KONTIKI_API_EXCEPTION, "Failed to delete content resource"); diff --git a/plugins/kontiki/lib/KontikiAPIWrapper.php b/plugins/kontiki/lib/KontikiAPIWrapper.php index b114ed410bb..20710247816 100644 --- a/plugins/kontiki/lib/KontikiAPIWrapper.php +++ b/plugins/kontiki/lib/KontikiAPIWrapper.php @@ -16,18 +16,11 @@ class KontikiAPIWrapper const FORMAT_TYPE_IOS = 'IOS'; - public static $entryPoint; + public $entryPoint; - public static function createKontikiToken ($serviceToken, $actAsUser) + public function __construct($entryPoint) { - // $url = self::$entryPoint."/auth/login?serviceTokenId=$serviceToken&actAsUser=$actAsUser"; - // $curlWrapper = new KCurlWrapper($url); - // $authResponse = $curlWrapper->exec(); -// - // if (!$authResponse) - // { - // throw new kCoreException(); - // } + $this->entryPoint = $entryPoint; } /** @@ -38,7 +31,7 @@ public static function createKontikiToken ($serviceToken, $actAsUser) * * @return string */ - public static function addKontikiVideoContentResource ($serviceToken, $uploadMoid, KalturaBaseEntry $entry, KalturaFlavorAsset $asset) + public function addKontikiVideoContentResource ($serviceToken, $uploadMoid, KalturaBaseEntry $entry, KalturaFlavorAsset $asset) { $data = " ". self::CONTENT_TYPE_VOD ." @@ -59,10 +52,9 @@ public static function addKontikiVideoContentResource ($serviceToken, $uploadMoi $data = urlencode($data); $url = self::$entryPoint."/metadata/content?_method=POST&_ctype=xml&_data=$data&auth=$serviceToken"; - $curlWrapper = new KCurlWrapper($url); - $resultHeader = $curlWrapper->getHeader(); - - return $curlWrapper->exec(); + + return $this->execAPICall($url); + } /** @@ -71,13 +63,11 @@ public static function addKontikiVideoContentResource ($serviceToken, $uploadMoi * * @return string */ - public static function getKontikiContentResource ($serviceToken, $contentMoid) + public function getKontikiContentResource ($serviceToken, $contentMoid) { $url = self::$entryPoint."/metadata/content/$contentMoid;uploads=true?auth=$serviceToken"; - $curlWrapper = new KCurlWrapper($url); - $resultHeader = $curlWrapper->getHeader(); - return $curlWrapper->exec(); + return $this->execAPICall($url); } /** @@ -86,7 +76,7 @@ public static function getKontikiContentResource ($serviceToken, $contentMoid) * * @return string */ - public static function addKontikiUploadResource ($serviceToken, $contentUrl) + public function addKontikiUploadResource ($serviceToken, $contentUrl) { //hard-coded temporary value - testing environments inaccessible to Kontiki for pull //$contentUrl = 'http://sites.google.com/site/demokmc/Home/titanicin5seconds.flv'; @@ -96,8 +86,6 @@ public static function addKontikiUploadResource ($serviceToken, $contentUrl) $url = self::$entryPoint."/upload/init/pull?_method=POST&_ctype=xml&_data={$data}&auth=$serviceToken"; $curlWrapper = new KCurlWrapper($url); - $resultHeader = $curlWrapper->getHeader(); -KalturaLog::info("upload result headers: " . print_r($resultHeader, true)); return $curlWrapper->exec(); } @@ -108,13 +96,10 @@ public static function addKontikiUploadResource ($serviceToken, $contentUrl) * * @return string */ - public static function deleteKontikiContentResource ($serviceToken, $contentMoid) + public function deleteKontikiContentResource ($serviceToken, $contentMoid) { $url = self::$entryPoint . "/metadata/content/$contentMoid?grid=true&_method=DELETE&auth=$serviceToken"; - $curlWrapper = new KCurlWrapper($url); - $resultHeader = $curlWrapper->getHeader(); - - return $curlWrapper->exec(); + return $this->execAPICall($url); } /** @@ -124,15 +109,28 @@ public static function deleteKontikiContentResource ($serviceToken, $contentMoid * * @return string */ - public static function getPlaybackUrn ($serviceToken, $contentMoid, $timeout = null) + public function getPlaybackUrn ($serviceToken, $contentMoid, $timeout = null) { - $url = self::$entryPoint . "/playback/video/$contentMoid?timeout=$timeout&auth=$serviceToken"; - $curlWrapper = new KCurlWrapper($url); - $result = $curlWrapper->exec(); + $url = self::$entryPoint . "/playback/video/$contentMoid?". ($timeout ? "timeout=$timeout" : "" ) . "&auth=$serviceToken"; + $result = $this->execAPICall($url); if (!$result) return; $resultAsXml = new SimpleXMLElement($result); return strval($resultAsXml->urn) . ";realmId:" . strval($resultAsXml->realmId) . ";realmTicket:" .strval($resultAsXml->realmTicket); } + + protected function execAPICall($url) + { + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + $res = curl_exec($ch); + + $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if (!$res || ($httpcode < 200 || $httpcode >300)) + return null; + + return $res; + } } \ No newline at end of file diff --git a/plugins/kontiki/lib/KontikiManager.php b/plugins/kontiki/lib/KontikiManager.php index 1fa1807f735..3594b08fd33 100644 --- a/plugins/kontiki/lib/KontikiManager.php +++ b/plugins/kontiki/lib/KontikiManager.php @@ -18,6 +18,7 @@ public function updatedJob(BatchJob $dbBatchJob) { //Get Kontiki file sync and set the external URL $filesyncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $kontikiFileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($filesyncKey); + $kontikiFileSync->setFileRoot(""); $kontikiFileSync->setFilePath($data->getContentMoid()); $kontikiFileSync->save(); break; diff --git a/plugins/kontiki/lib/urlManager/kKontikiUrlManager.php b/plugins/kontiki/lib/urlManager/kKontikiUrlManager.php index c5307bf0f20..5257125131c 100644 --- a/plugins/kontiki/lib/urlManager/kKontikiUrlManager.php +++ b/plugins/kontiki/lib/urlManager/kKontikiUrlManager.php @@ -11,7 +11,13 @@ protected function doGetFileSyncUrl(FileSync $fileSync) { $storageProfile = StorageProfilePeer::retrieveByPK($this->storageProfileId); /* @var $storageProfile KontikiStorageProfile */ - KontikiAPIWrapper::$entryPoint = $storageProfile->getApiEntryPoint(); - return KontikiAPIWrapper::getPlaybackUrn("srv-".base64_encode($this->storageProfile->getServiceToken()), $fileSync->getFilePath()); + $kontikiAPIWrapper = new KontikiAPIWrapper($storageProfile->getApiEntryPoint()); + $urn = $kontikiAPIWrapper->getPlaybackUrn("srv-".base64_encode($storageProfile->getServiceToken()), $fileSync->getFilePath()); + if (!$urn) + { + KExternalErrors::dieError(KExternalErrors::BAD_QUERY); + } + + return $urn; } } From 6fbd39c918430596deefb5df78050f92c3cf8dcc Mon Sep 17 00:00:00 2001 From: "eran.kornblau" Date: Sun, 21 Jul 2013 12:57:36 +0300 Subject: [PATCH 052/132] prevented a race condition between the file_exists and file_get_contents in KalturaTypeReflectorCacher --- api_v3/lib/KalturaTypeReflectorCacher.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api_v3/lib/KalturaTypeReflectorCacher.php b/api_v3/lib/KalturaTypeReflectorCacher.php index adb580ecf89..b17e552c1df 100644 --- a/api_v3/lib/KalturaTypeReflectorCacher.php +++ b/api_v3/lib/KalturaTypeReflectorCacher.php @@ -35,14 +35,17 @@ static function get($type) mkdir($cachedDir); chmod($cachedDir, 0755); } - + $cachedFilePath = $cachedDir.DIRECTORY_SEPARATOR.$type.".cache"; + + $typeReflector = null; if (file_exists($cachedFilePath)) { $cachedData = file_get_contents($cachedFilePath); $typeReflector = unserialize($cachedData); } - else + + if (!$typeReflector) { $typeReflector = new KalturaTypeReflector($type); $cachedData = serialize($typeReflector); From 2b93a84e92ff010e23e792b3c2070b94a05d92a6 Mon Sep 17 00:00:00 2001 From: hilak Date: Sun, 21 Jul 2013 13:20:19 +0300 Subject: [PATCH 053/132] remove references to static $entrypoint --- plugins/kontiki/lib/KontikiAPIWrapper.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/kontiki/lib/KontikiAPIWrapper.php b/plugins/kontiki/lib/KontikiAPIWrapper.php index 20710247816..8cf46a7e29b 100644 --- a/plugins/kontiki/lib/KontikiAPIWrapper.php +++ b/plugins/kontiki/lib/KontikiAPIWrapper.php @@ -51,7 +51,7 @@ public function addKontikiVideoContentResource ($serviceToken, $uploadMoid, Kalt $data = base64_encode($data); $data = urlencode($data); - $url = self::$entryPoint."/metadata/content?_method=POST&_ctype=xml&_data=$data&auth=$serviceToken"; + $url = $this->entryPoint."/metadata/content?_method=POST&_ctype=xml&_data=$data&auth=$serviceToken"; return $this->execAPICall($url); @@ -65,7 +65,7 @@ public function addKontikiVideoContentResource ($serviceToken, $uploadMoid, Kalt */ public function getKontikiContentResource ($serviceToken, $contentMoid) { - $url = self::$entryPoint."/metadata/content/$contentMoid;uploads=true?auth=$serviceToken"; + $url = $this->entryPoint."/metadata/content/$contentMoid;uploads=true?auth=$serviceToken"; return $this->execAPICall($url); } @@ -84,7 +84,7 @@ public function addKontikiUploadResource ($serviceToken, $contentUrl) $data = base64_encode($data); $data = urlencode($data); - $url = self::$entryPoint."/upload/init/pull?_method=POST&_ctype=xml&_data={$data}&auth=$serviceToken"; + $url = $this->entryPoint."/upload/init/pull?_method=POST&_ctype=xml&_data={$data}&auth=$serviceToken"; $curlWrapper = new KCurlWrapper($url); return $curlWrapper->exec(); @@ -98,7 +98,7 @@ public function addKontikiUploadResource ($serviceToken, $contentUrl) */ public function deleteKontikiContentResource ($serviceToken, $contentMoid) { - $url = self::$entryPoint . "/metadata/content/$contentMoid?grid=true&_method=DELETE&auth=$serviceToken"; + $url = $this->entryPoint . "/metadata/content/$contentMoid?grid=true&_method=DELETE&auth=$serviceToken"; return $this->execAPICall($url); } @@ -111,7 +111,7 @@ public function deleteKontikiContentResource ($serviceToken, $contentMoid) */ public function getPlaybackUrn ($serviceToken, $contentMoid, $timeout = null) { - $url = self::$entryPoint . "/playback/video/$contentMoid?". ($timeout ? "timeout=$timeout" : "" ) . "&auth=$serviceToken"; + $url = $this->entryPoint . "/playback/video/$contentMoid?". ($timeout ? "timeout=$timeout" : "" ) . "&auth=$serviceToken"; $result = $this->execAPICall($url); if (!$result) return; From 23678fd61d083bc231ee69dee7933d961e26e16c Mon Sep 17 00:00:00 2001 From: hilak Date: Sun, 21 Jul 2013 13:43:48 +0300 Subject: [PATCH 054/132] added StorageExport Closer to the template batch configuration --- configurations/batch/batch.ini.template | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configurations/batch/batch.ini.template b/configurations/batch/batch.ini.template index 215cdef71a1..4153f0a3b6c 100644 --- a/configurations/batch/batch.ini.template +++ b/configurations/batch/batch.ini.template @@ -31,6 +31,7 @@ enabledWorkers.KAsyncProvisionProvide = 1 enabledWorkers.KAsyncProvisionDelete = 1 enabledWorkers.KAsyncProvisionProvideCloser = 1 enabledWorkers.KAsyncStorageExport = 3 +enabledWorkers.KAsyncStorageExportCloser = 1 enabledWorkers.KAsyncStorageDelete = 1 enabledWorkers.KAsyncCaptureThumb = 1 enabledWorkers.KAsyncDistributeSubmit = 1 @@ -388,7 +389,12 @@ type = KAsyncStorageExport maximumExecutionTime = 1800 scriptPath = batches/Storage/KAsyncStorageExportExe.php params.chmod = 755 - + +[KAsyncStorageExportCloser : JobCloserWorker] +id = 161 +friendlyName = storage export closer +type = KAsyncStorageExportCloser +scriptPath = batches/Storage/KAsyncStorageExportCloserExe.php [KAsyncStorageDelete : JobHandlerWorker] id = 380 From 1fd92ded5d5f1dfde06482a588a88177ac39244f Mon Sep 17 00:00:00 2001 From: hilak Date: Sun, 21 Jul 2013 14:19:55 +0300 Subject: [PATCH 055/132] stroage export closer requires unique id --- configurations/batch/batch.ini.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configurations/batch/batch.ini.template b/configurations/batch/batch.ini.template index 4153f0a3b6c..a6d5851839d 100644 --- a/configurations/batch/batch.ini.template +++ b/configurations/batch/batch.ini.template @@ -391,7 +391,7 @@ scriptPath = batches/Storage/KAsyncStorageExportExe.php params.chmod = 755 [KAsyncStorageExportCloser : JobCloserWorker] -id = 161 +id = 181 friendlyName = storage export closer type = KAsyncStorageExportCloser scriptPath = batches/Storage/KAsyncStorageExportCloserExe.php From c45f2c8c5c6c21bf77319536fba580da4bb053e4 Mon Sep 17 00:00:00 2001 From: hilak Date: Sun, 21 Jul 2013 18:21:46 +0300 Subject: [PATCH 056/132] 1. fix issue on category.php which fixes the problem of a category changing inheritance type where owner on the category would be set to NULL (kms-953) 2. Wrong status in list of failed Kontiki statuses --- alpha/lib/model/category.php | 4 ++-- plugins/kontiki/batch/Engine/KKontikiExportEngine.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/alpha/lib/model/category.php b/alpha/lib/model/category.php index 5bbcb135461..da66603a394 100644 --- a/alpha/lib/model/category.php +++ b/alpha/lib/model/category.php @@ -130,8 +130,8 @@ public function save(PropelPDO $con = null) if ($this->inheritance_type == InheritanceType::MANUAL && $this->old_inheritance_type == InheritanceType::INHERIT) { - if($this->old_parent_id) - $categoryToCopyInheritedFields = categoryPeer::retrieveByPK($this->old_parent_id); + if($this->parent_id) + $categoryToCopyInheritedFields = categoryPeer::retrieveByPK($this->parent_id); if($categoryToCopyInheritedFields) $this->copyInheritedFields($categoryToCopyInheritedFields); diff --git a/plugins/kontiki/batch/Engine/KKontikiExportEngine.php b/plugins/kontiki/batch/Engine/KKontikiExportEngine.php index a69aae6a686..54d6e4d8db2 100644 --- a/plugins/kontiki/batch/Engine/KKontikiExportEngine.php +++ b/plugins/kontiki/batch/Engine/KKontikiExportEngine.php @@ -12,7 +12,7 @@ class KKontikiExportEngine extends KExportEngine protected static $pending_statuses = array ("PENDING_RESTART","RESTARTING","PENDING","PROCESSING","TRANSCODE_QUEUED","TRANSCODE_DONE","TRANSCODING","UPLOADING","SCANNING","ENCRYPTING","ENCRYPT_DONE","SIGNING","SIGN_DONE","RESIZING_THUMBNAILS","RESIZING_THUMBNAILS_DONE","PUBLISHING","PENDING_APPROVAL"); - protected static $failed_statuses = array("RESTART_FAILED","UNPROCESSABLE","TRANSCODE_FAILED","TRANSCODE_ERROR","TRANSCODE_CANCELLED","TRANSCODE_INTERRUPTED","UPLOAD_FAILED","SCAN_FAILED","SCAN_ERROR","ENCRYPT_FAILED","SIGN_FAILED","RESIZING_THUMBNAILS_FAILED","SMIL_FILE_GENERATION_FAILED","PUBLISHING_FAILED","PENDING_APPROVAL_FAIL","READY_FAIL" ); + protected static $failed_statuses = array("RESTART_FAILED","UNPROCESSABLE","TRANSCODE_FAILED","TRANSCODE_ERROR","TRANSCODE_CANCELLED","TRANSCODE_INTERRUPTED","UPLOADING_FAILED","SCAN_FAILED","SCAN_ERROR","ENCRYPT_FAILED","SIGN_FAILED","RESIZING_THUMBNAILS_FAILED","SMIL_FILE_GENERATION_FAILED","PUBLISHING_FAILED","PENDING_APPROVAL_FAIL","READY_FAIL" ); const FINISHED_STATUS = 'READY'; From 0bfec76c2500878b06484856bed4786973785960 Mon Sep 17 00:00:00 2001 From: rotema Date: Sun, 21 Jul 2013 18:22:35 +0300 Subject: [PATCH 057/132] making the mysql md5 func match the php's md5 --- alpha/apps/kaltura/lib/propel/php5/KalturaObjectBuilder.php | 3 ++- alpha/lib/model/om/BasePartner.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/alpha/apps/kaltura/lib/propel/php5/KalturaObjectBuilder.php b/alpha/apps/kaltura/lib/propel/php5/KalturaObjectBuilder.php index d61f74a2c6d..6f6ef34b662 100644 --- a/alpha/apps/kaltura/lib/propel/php5/KalturaObjectBuilder.php +++ b/alpha/apps/kaltura/lib/propel/php5/KalturaObjectBuilder.php @@ -1106,7 +1106,8 @@ protected function addBuildPkeyCriteriaClose(&$script) if (\$this->isColumnModified(".$this->getPeerClassname()."::CUSTOM_DATA)) { if (!is_null(\$this->custom_data)) - \$criteria->add(".$this->getPeerClassname()."::CUSTOM_DATA, \"MD5(\" . ".$this->getPeerClassname()."::CUSTOM_DATA . \") = '\$this->custom_data_md5'\", Criteria::CUSTOM); + \$criteria->add(".$this->getPeerClassname()."::CUSTOM_DATA, \"MD5(cast(\" . ".$this->getPeerClassname()."::CUSTOM_DATA . \" as char character set latin1)) = '\$this->custom_data_md5'\", Criteria::CUSTOM); + //casting to latin char set to avoid mysql and php md5 difference else \$criteria->add(".$this->getPeerClassname()."::CUSTOM_DATA, NULL, Criteria::IS_NULL); } diff --git a/alpha/lib/model/om/BasePartner.php b/alpha/lib/model/om/BasePartner.php index 5d67a2d9288..a40a4f7cb38 100644 --- a/alpha/lib/model/om/BasePartner.php +++ b/alpha/lib/model/om/BasePartner.php @@ -2995,7 +2995,8 @@ public function buildPkeyCriteria() if ($this->isColumnModified(PartnerPeer::CUSTOM_DATA)) { if (!is_null($this->custom_data)) - $criteria->add(PartnerPeer::CUSTOM_DATA, "MD5(" . PartnerPeer::CUSTOM_DATA . ") = '$this->custom_data_md5'", Criteria::CUSTOM); + $criteria->add(PartnerPeer::CUSTOM_DATA, "MD5(cast(" . PartnerPeer::CUSTOM_DATA . " as char character set latin1)) = '$this->custom_data_md5'", Criteria::CUSTOM); + //casting to latin char set to avoid mysql and php md5 difference else $criteria->add(PartnerPeer::CUSTOM_DATA, NULL, Criteria::IS_NULL); } From c512336e76286b169f8f856fabc0645c7bfa3c5e Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Sun, 21 Jul 2013 20:39:42 +0300 Subject: [PATCH 058/132] Support description to be presented in the admin console --- .../model/conditions/kCondition.php | 21 +++++++++++++++++++ .../conditions/KalturaCondition.php | 6 ++++++ .../KalturaEventNotificationParameter.php | 8 ++++++- .../data/kEventNotificationParameter.php | 21 +++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php b/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php index 545b901b05c..e2f40b505c1 100644 --- a/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php +++ b/alpha/apps/kaltura/lib/access_control/model/conditions/kCondition.php @@ -11,6 +11,11 @@ abstract class kCondition */ protected $type; + /** + * @var string + */ + protected $description; + /** * @var bool */ @@ -59,6 +64,22 @@ protected function setType($type) { $this->type = $type; } + + /** + * @return string $description + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } /** * @return bool diff --git a/api_v3/lib/types/accessControl/conditions/KalturaCondition.php b/api_v3/lib/types/accessControl/conditions/KalturaCondition.php index d6103c0788f..cc4492f00f6 100644 --- a/api_v3/lib/types/accessControl/conditions/KalturaCondition.php +++ b/api_v3/lib/types/accessControl/conditions/KalturaCondition.php @@ -14,6 +14,11 @@ abstract class KalturaCondition extends KalturaObject */ public $type; + /** + * @var string + */ + public $description; + /** * @var bool */ @@ -21,6 +26,7 @@ abstract class KalturaCondition extends KalturaObject private static $mapBetweenObjects = array ( + 'description', 'not', ); diff --git a/plugins/event_notification/lib/api/types/KalturaEventNotificationParameter.php b/plugins/event_notification/lib/api/types/KalturaEventNotificationParameter.php index 36a845172ab..fa83e39f659 100644 --- a/plugins/event_notification/lib/api/types/KalturaEventNotificationParameter.php +++ b/plugins/event_notification/lib/api/types/KalturaEventNotificationParameter.php @@ -5,11 +5,16 @@ */ class KalturaEventNotificationParameter extends KalturaObject { -/** + /** * The key in the subject and body to be replaced with the dynamic value * @var string */ public $key; + + /** + * @var string + */ + public $description; /** * The dynamic value to be placed in the final output @@ -20,6 +25,7 @@ class KalturaEventNotificationParameter extends KalturaObject private static $map_between_objects = array ( 'key', + 'description', 'value', ); diff --git a/plugins/event_notification/lib/model/data/kEventNotificationParameter.php b/plugins/event_notification/lib/model/data/kEventNotificationParameter.php index 2bee0af0597..4316bf5c8cc 100644 --- a/plugins/event_notification/lib/model/data/kEventNotificationParameter.php +++ b/plugins/event_notification/lib/model/data/kEventNotificationParameter.php @@ -10,6 +10,11 @@ class kEventNotificationParameter * @var string */ protected $key; + + /** + * @var string + */ + protected $description; /** * The value that replace the key @@ -33,6 +38,22 @@ public function getValue() return $this->value; } + /** + * @return string $description + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + /** * @param string $key */ From 1f322af117edf51c4bc6beb27b3382421040f984 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Sun, 21 Jul 2013 20:40:51 +0300 Subject: [PATCH 059/132] Doc comment change only --- plugins/metadata/lib/model/data/kMatchMetadataCondition.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/metadata/lib/model/data/kMatchMetadataCondition.php b/plugins/metadata/lib/model/data/kMatchMetadataCondition.php index a9d889a4a7e..6845da9052d 100644 --- a/plugins/metadata/lib/model/data/kMatchMetadataCondition.php +++ b/plugins/metadata/lib/model/data/kMatchMetadataCondition.php @@ -52,7 +52,7 @@ protected function applyDynamicValues(kScope $scope) } /* (non-PHPdoc) - * @see kCondition::getFieldValue() + * @see kMatchCondition::getFieldValue() */ public function getFieldValue(kScope $scope) { From 6313a2820606c984862f6005d000542017d686c6 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Sun, 21 Jul 2013 20:42:03 +0300 Subject: [PATCH 060/132] New condition type that returns true when specific field changed The change checked between two metadata versions. --- plugins/metadata/lib/kMetadataManager.php | 4 ++-- plugins/metadata/lib/model/enums/MetadataConditionType.php | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/metadata/lib/kMetadataManager.php b/plugins/metadata/lib/kMetadataManager.php index 855df53f57b..d725a362d69 100644 --- a/plugins/metadata/lib/kMetadataManager.php +++ b/plugins/metadata/lib/kMetadataManager.php @@ -65,9 +65,9 @@ public static function getObjectFromPeer(Metadata $metadata) * @param string $xPathPattern * @return array */ - public static function parseMetadataValues(Metadata $metadata, $xPathPattern) + public static function parseMetadataValues(Metadata $metadata, $xPathPattern, $version = null) { - $key = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); + $key = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA, $version); $source = kFileSyncUtils::file_get_contents($key, true, false); if(!$source) return null; diff --git a/plugins/metadata/lib/model/enums/MetadataConditionType.php b/plugins/metadata/lib/model/enums/MetadataConditionType.php index 2846efec80a..7887e08e92d 100644 --- a/plugins/metadata/lib/model/enums/MetadataConditionType.php +++ b/plugins/metadata/lib/model/enums/MetadataConditionType.php @@ -7,12 +7,14 @@ class MetadataConditionType implements IKalturaPluginEnum, ConditionType { const METADATA_FIELD_MATCH = 'FieldMatch'; const METADATA_FIELD_COMPARE = 'FieldCompare'; + const METADATA_FIELD_CHANGED = 'FieldChanged'; public static function getAdditionalValues() { return array( 'METADATA_FIELD_MATCH' => self::METADATA_FIELD_MATCH, 'METADATA_FIELD_COMPARE' => self::METADATA_FIELD_COMPARE, + 'METADATA_FIELD_CHANGED' => self::METADATA_FIELD_CHANGED, ); } @@ -24,6 +26,7 @@ public static function getAdditionalDescriptions() return array( MetadataPlugin::getApiValue(self::METADATA_FIELD_COMPARE) => 'Validate that all metadata elements number compared correctly to all listed numeric values.', MetadataPlugin::getApiValue(self::METADATA_FIELD_MATCH) => 'Validate that any of the metadata elements text matches any of listed textual values.', + MetadataPlugin::getApiValue(self::METADATA_FIELD_CHANGED) => 'Check if metadata element changed between metadata versions.', ); } } From 7d06d00228ff493c6ca4b304f706d2fbc18c8e79 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Sun, 21 Jul 2013 20:43:29 +0300 Subject: [PATCH 061/132] kEventFieldCondition extends generic Kaltura kCondition --- .../EventNotificationPlugin.php | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/plugins/event_notification/EventNotificationPlugin.php b/plugins/event_notification/EventNotificationPlugin.php index 51ba73e400f..011970d4225 100644 --- a/plugins/event_notification/EventNotificationPlugin.php +++ b/plugins/event_notification/EventNotificationPlugin.php @@ -52,7 +52,7 @@ public static function isAllowedPartner($partnerId) public static function getEnums($baseEnumName = null) { if(is_null($baseEnumName)) - return array('EventNotificationBatchType', 'EventNotificationPermissionName'); + return array('EventNotificationBatchType', 'EventNotificationPermissionName', 'EventNotificationConditionType'); if($baseEnumName == 'BatchJobType') return array('EventNotificationBatchType'); @@ -60,6 +60,9 @@ public static function getEnums($baseEnumName = null) if($baseEnumName == 'PermissionName') return array('EventNotificationPermissionName'); + if($baseEnumName == 'ConditionType') + return array('EventNotificationConditionType'); + return array(); } @@ -230,7 +233,13 @@ public static function getObjectClass($baseClass, $enumValue) return 'categoryEntry'; } } - + + if($baseClass == 'KalturaCondition') + { + if($enumValue == EventNotificationPlugin::getConditionTypeCoreValue(EventNotificationConditionType::EVENT_NOTIFICATION_FIELD)) + return 'KalturaEventFieldCondition'; + } + return null; } @@ -243,6 +252,15 @@ public static function getBatchJobTypeCoreValue($valueName) return kPluginableEnumsManager::apiToCore('BatchJobType', $value); } + /** + * @return int id of dynamic enum in the DB. + */ + public static function getConditionTypeCoreValue($valueName) + { + $value = self::getPluginName() . IKalturaEnumerator::PLUGIN_VALUE_DELIMITER . $valueName; + return kPluginableEnumsManager::apiToCore('ConditionType', $value); + } + /** * @return string external API value of dynamic enum. */ From ea361a9b5a29a0ac774d4e64bcea3c06801b29c3 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Sun, 21 Jul 2013 20:44:11 +0300 Subject: [PATCH 062/132] Added new user parameters attribute to be edited from the admin console --- .../lib/api/types/KalturaEventNotificationTemplate.php | 8 ++++++++ .../lib/kEventNotificationFlowManager.php | 8 ++++++++ .../lib/model/EventNotificationTemplate.php | 3 +++ 3 files changed, 19 insertions(+) diff --git a/plugins/event_notification/lib/api/types/KalturaEventNotificationTemplate.php b/plugins/event_notification/lib/api/types/KalturaEventNotificationTemplate.php index d3eb737d29d..10c10bdbe88 100644 --- a/plugins/event_notification/lib/api/types/KalturaEventNotificationTemplate.php +++ b/plugins/event_notification/lib/api/types/KalturaEventNotificationTemplate.php @@ -111,6 +111,12 @@ class KalturaEventNotificationTemplate extends KalturaObject implements IFiltera */ public $contentParameters; + /** + * Define the content dynamic parameters + * @var KalturaEventNotificationParameterArray + */ + public $userParameters; + /** * mapping between the field on this object (on the left) and the setter/getter on the entry object (on the right) */ @@ -128,6 +134,8 @@ class KalturaEventNotificationTemplate extends KalturaObject implements IFiltera 'eventType', 'eventObjectType' => 'objectType', 'eventConditions', + 'contentParameters', + 'userParameters', ); /* (non-PHPdoc) diff --git a/plugins/event_notification/lib/kEventNotificationFlowManager.php b/plugins/event_notification/lib/kEventNotificationFlowManager.php index ab3e5572629..45a8be2f884 100644 --- a/plugins/event_notification/lib/kEventNotificationFlowManager.php +++ b/plugins/event_notification/lib/kEventNotificationFlowManager.php @@ -196,6 +196,7 @@ public function shouldConsumeEvent(KalturaEvent $event) /* @var $notificationTemplate EventNotificationTemplate */ $scope->resetDynamicValues(); + $notificationParameters = $notificationTemplate->getContentParameters(); foreach($notificationParameters as $notificationParameter) { @@ -203,6 +204,13 @@ public function shouldConsumeEvent(KalturaEvent $event) $scope->addDynamicValue($notificationParameter->getKey(), $notificationParameter->getValue()); } + $notificationParameters = $notificationTemplate->getUserParameters(); + foreach($notificationParameters as $notificationParameter) + { + /* @var $notificationParameter kEventNotificationParameter */ + $scope->addDynamicValue($notificationParameter->getKey(), $notificationParameter->getValue()); + } + if($this->notificationTemplatesConditionsFulfilled($notificationTemplate, $scope)) $this->notificationTemplates[] = $notificationTemplate; } diff --git a/plugins/event_notification/lib/model/EventNotificationTemplate.php b/plugins/event_notification/lib/model/EventNotificationTemplate.php index 4dccc792213..d5f9561c5da 100644 --- a/plugins/event_notification/lib/model/EventNotificationTemplate.php +++ b/plugins/event_notification/lib/model/EventNotificationTemplate.php @@ -17,6 +17,7 @@ abstract class EventNotificationTemplate extends BaseEventNotificationTemplate { const CUSTOM_DATA_EVENT_CONDITIONS = 'eventConditions'; const CUSTOM_DATA_CONTENT_PARAMETERS = 'contentParameters'; + const CUSTOM_DATA_USER_PARAMETERS = 'userParameters'; const CUSTOM_DATA_MANUAL_DISPATCH_ENABLED = 'manualDispatchEnabled'; const CUSTOM_DATA_AUTOMATIC_DISPATCH_ENABLED = 'automaticDispatchEnabled'; @@ -29,11 +30,13 @@ abstract public function getJobData(kScope $scope = null); public function getEventConditions() {return $this->getFromCustomData(self::CUSTOM_DATA_EVENT_CONDITIONS);} public function getContentParameters() {return $this->getFromCustomData(self::CUSTOM_DATA_CONTENT_PARAMETERS, null, array());} + public function getUserParameters() {return $this->getFromCustomData(self::CUSTOM_DATA_USER_PARAMETERS, null, array());} public function getManualDispatchEnabled() {return $this->getFromCustomData(self::CUSTOM_DATA_MANUAL_DISPATCH_ENABLED);} public function getAutomaticDispatchEnabled() {return $this->getFromCustomData(self::CUSTOM_DATA_AUTOMATIC_DISPATCH_ENABLED);} public function setEventConditions(array $v) {return $this->putInCustomData(self::CUSTOM_DATA_EVENT_CONDITIONS, $v);} public function setContentParameters(array $v) {return $this->putInCustomData(self::CUSTOM_DATA_CONTENT_PARAMETERS, $v);} + public function setUserParameters(array $v) {return $this->putInCustomData(self::CUSTOM_DATA_USER_PARAMETERS, $v);} public function setManualDispatchEnabled($v) {return $this->putInCustomData(self::CUSTOM_DATA_MANUAL_DISPATCH_ENABLED, $v);} public function setAutomaticDispatchEnabled($v) {return $this->putInCustomData(self::CUSTOM_DATA_AUTOMATIC_DISPATCH_ENABLED, $v);} From baa303df547515b5447345e2ee4d1d540e6bc119 Mon Sep 17 00:00:00 2001 From: "eran.kornblau" Date: Mon, 22 Jul 2013 10:54:38 +0300 Subject: [PATCH 063/132] zend client bug fix - in case of an error during multirequest should return an exception object instead of throwing an exception --- generator/sources/zend/Kaltura/Client/ClientBase.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generator/sources/zend/Kaltura/Client/ClientBase.php b/generator/sources/zend/Kaltura/Client/ClientBase.php index b61ba12d28b..2ab1f2770c2 100644 --- a/generator/sources/zend/Kaltura/Client/ClientBase.php +++ b/generator/sources/zend/Kaltura/Client/ClientBase.php @@ -258,6 +258,9 @@ public function doQueue() if ($this->config->format == self::KALTURA_SERVICE_FORMAT_XML) { $result = $this->unmarshal($postResult); + + if ($result instanceof Kaltura_Client_Exception) + throw $result; if (is_null($result)) throw new Kaltura_Client_ClientException("failed to unserialize server result\n$postResult", Kaltura_Client_ClientException::ERROR_UNSERIALIZE_FAILED); @@ -301,7 +304,7 @@ public static function unmarshalItem(SimpleXMLElement $xml) { $code = "{$xml->error->code}"; $message = "{$xml->error->message}"; - throw new Kaltura_Client_Exception($message, $code); + return new Kaltura_Client_Exception($message, $code); } return "$xml"; From 7d2c0942df372b3c6094cd2008f49f1a18e8bea1 Mon Sep 17 00:00:00 2001 From: "eran.kornblau" Date: Mon, 22 Jul 2013 11:00:23 +0300 Subject: [PATCH 064/132] kalcli - added installation instructions for windows --- generator/sources/cli/README | 188 +++++++++++++++++++---------------- 1 file changed, 102 insertions(+), 86 deletions(-) diff --git a/generator/sources/cli/README b/generator/sources/cli/README index 19ccfeb1387..564edad55c0 100644 --- a/generator/sources/cli/README +++ b/generator/sources/cli/README @@ -1,86 +1,102 @@ - -Overview -========= -The Kaltura CLI client is a bundle of command line utilities that can be used to interface with the -Kaltura API. The client is intended mostly for experimentation / small tasks, not for full-fledged -applications. - -The following utilities are included in the package: -1. kalcli - responsible for issuing Kaltura API calls, it builds the request URL and parses the - response to a format that can be easily processed by command line utilities such as grep / awk. - The client library contains an additional script (kalcliAutoComplete) that provides bash-autocompletion - functionality to the kalcli utility, for example: - kalcli med[TAB] - kalcli media l[TAB] - kalcli media list f[TAB] - kalcli media list filter:objectType=KalturaM[TAB] - kalcli media list filter:objectType=KalturaMediaEntryFilter - ... -2. extractKs - parses a Kaltura session (KS) to its different fields. -3. generateKs - generates a KS. -4. renewKs - useful to renew expired Kaltura sessions, generates a KS identical to the input KS with - a 1 day expiry. -5. genIpHeader - generates a signed HTTP header that can be used to simulate access to the Kaltura API - from a different source IP. - -All the utilities display usage information incl. all available switches when executed without parameters. - -Installation instructions -========================== -1. Unzip the package contents -2. Replace the @BASEDIR@ token with the path to kalcliAutoComplete.php in: - kalcliAliases.sh - kalcliAutoComplete - logToCli - (e.g. if kalcliAutoComplete was copied to /a/b/kalcliAutoComplete @BASEDIR@ should be set to /a/b) -3. Create a link to kalcliAutoComplete in /etc/bash_completion.d/ - cd /etc/bash_completion.d/ - ln -s @BASEDIR@/kalcliAutoComplete kalcliAutoComplete -4. Register the auto completion: - source /etc/bash_completion.d/kalcliAutoComplete -5. Create a link to kalcliAliases.sh in /etc/profile.d/ - cd /etc/profile.d/ - ln -s @BASEDIR@/kalcliAliases.sh kalcliAliases.sh -6. Copy config/config.template.ini to config/config.ini and fill out the parameters: - a. Secret repositories - required for the extractKs / generateKs / renewKs utilities. - Two types of repositories can be configured: - 1. Preset repositories - contain a fixed list of (partner id, admin secret) pairs - 2. Database repositories - contain the connection details for a Kaltura server database, - that can be used to pull the secrets of partner accounts. - b. IP address salt - required for the genIpHeader utility. - The salt has to match the parameter 'remote_addr_header_salt' that is configured in - configuration/local.ini on the Kaltura server. - -Examples -========= -(1234 denotes the partner id) - -1. Getting the ids of 30 entries: -> genks 1234 | kalcli media list | awk '$1 == "id"' - -2. Diffing access control profiles: -> (genks 1234 | kalcli accesscontrol get id=7003 > /tmp/a1) ; (genks 1234 | kalcli accesscontrol get id=8005 > /tmp/a2) ; diff /tmp/a1 /tmp/a2 - -3. Getting the number of distinct entries in a playlist -> genks 1234 | kalcli playlist execute id=1_1a2b3c | grep -P 'id\t' | sort | uniq | wc -l - -4. Using a precreated session -> kalcli -x media list ks=MDQ2ZThjOTI0MTJmZGIxYTVlMWVhNDJlZDZhNDAyMDkyMWJhNzE0OXw0Mzc0ODE7NDM3NDgxOzEzNjI0OTI3Njc7MDsxMzYyNDA2MzY3Ljc3NzM7MDt3aWRnZXQ6MSx2aWV3Oio7Ow== - -5. Using an expired session -> renewks MDQ2ZThjOTI0MTJmZGIxYTVlMWVhNDJlZDZhNDAyMDkyMWJhNzE0OXw0Mzc0ODE7NDM3NDgxOzEzNjI0OTI3Njc7MDsxMzYyNDA2MzY3Ljc3NzM7MDt3aWRnZXQ6MSx2aWV3Oio7Ow== | kalcli media list - -6. Parsing a KS: -> extks MDQ2ZThjOTI0MTJmZGIxYTVlMWVhNDJlZDZhNDAyMDkyMWJhNzE0OXw0Mzc0ODE7NDM3NDgxOzEzNjI0OTI3Njc7MDsxMzYyNDA2MzY3Ljc3NzM7MDt3aWRnZXQ6MSx2aWV3Oio7Ow== - -7. Executing an API with a different source IP address: -> ip=`genipheader 9.8.7.6` ; genks 1234 | kalcli -H$ip baseentry getContextData entryId=0_abcd56 - -8. Using a serve action: -> genks 1234 | kalcli -r document_documents serve entryId=0_abcdef > \temp\test.doc - -9. Nesting requests -> kalcli -x session start partnerId=1234 secret=abcdef type=2 | awk '{print "ks "$1}' | kalcli media list - -10. Uploading files -> ks=`genks -b 1234` ; kalcli -x uploadtoken add ks=$ks | awk '$1 == "id" {print "uploadTokenId "$2}' | kalcli uploadtoken upload ks=$ks fileData=@/tmp/test.php + +Overview +========= +The Kaltura CLI client is a bundle of command line utilities that can be used to interface with the +Kaltura API. The client is intended mostly for experimentation / small tasks, not for full-fledged +applications. + +The following utilities are included in the package: +1. kalcli - responsible for issuing Kaltura API calls, it builds the request URL and parses the + response to a format that can be easily processed by command line utilities such as grep / awk. + The client library contains an additional script (kalcliAutoComplete) that provides bash-autocompletion + functionality to the kalcli utility, for example: + kalcli med[TAB] + kalcli media l[TAB] + kalcli media list f[TAB] + kalcli media list filter:objectType=KalturaM[TAB] + kalcli media list filter:objectType=KalturaMediaEntryFilter + ... +2. extractKs - parses a Kaltura session (KS) to its different fields. +3. generateKs - generates a KS. +4. renewKs - useful to renew expired Kaltura sessions, generates a KS identical to the input KS with + a 1 day expiry. +5. genIpHeader - generates a signed HTTP header that can be used to simulate access to the Kaltura API + from a different source IP. + +All the utilities display usage information incl. all available switches when executed without parameters. + +Installation instructions +========================== +Linux +------ +1. Unzip the package contents +2. Replace the @BASEDIR@ token with the path to kalcliAutoComplete.php in: + kalcliAliases.sh + kalcliAutoComplete + logToCli + (e.g. if kalcliAutoComplete was copied to /a/b/kalcliAutoComplete @BASEDIR@ should be set to /a/b) +3. Create a link to kalcliAutoComplete in /etc/bash_completion.d/ + ln -s @BASEDIR@/kalcliAutoComplete /etc/bash_completion.d/kalcliAutoComplete +4. Register the auto completion: + source /etc/bash_completion.d/kalcliAutoComplete +5. Create a link to kalcliAliases.sh in /etc/profile.d/ + ln -s @BASEDIR@/kalcliAliases.sh /etc/profile.d/kalcliAliases.sh +6. Enable the aliases + source /etc/profile.d/kalcliAliases.sh +7. Copy config/config.template.ini to config/config.ini and fill out the parameters: + a. Secret repositories - required for the extractKs / generateKs / renewKs utilities. + Two types of repositories can be configured: + 1. Preset repositories - contain a fixed list of (partner id, admin secret) pairs + 2. Database repositories - contain the connection details for a Kaltura server database, + that can be used to pull the secrets of partner accounts. + b. IP address salt - required for the genIpHeader utility. + The salt has to match the parameter 'remote_addr_header_salt' that is configured in + configuration/local.ini on the Kaltura server. + +Windows +-------- +To use kalcli on Windows you'll need to install: +1. Cygwin - make sure to include the bash-completion package (not included by default) +2. Xampp (for PHP) + +Installation is the same as for Linux, but note the following: +1. Perform the steps from the Cygwin bash +2. The meaning of BASEDIR in step 2 is different than steps 3 & 5 - in step 2 you need to use a + path relative to the drive root while in steps 3 & 5 you need to use a path relative to Cygwin root. + For example: + a. If you install kalcli in C:\Cygwin\cli, you'll need to use /cygwin/cli in step 2, and use /cli in 3 & 5. + a. If you install kalcli in C:\cli, you'll need to use /cli in step 2, and use /cygdrive/c/cli in 3 & 5. + +Examples +========= +(1234 denotes the partner id) + +1. Getting the ids of 30 entries: +> genks 1234 | kalcli media list | awk '$1 == "id"' + +2. Diffing access control profiles: +> (genks 1234 | kalcli accesscontrol get id=7003 > /tmp/a1) ; (genks 1234 | kalcli accesscontrol get id=8005 > /tmp/a2) ; diff /tmp/a1 /tmp/a2 + +3. Getting the number of distinct entries in a playlist +> genks 1234 | kalcli playlist execute id=1_1a2b3c | grep -P 'id\t' | sort | uniq | wc -l + +4. Using a precreated session +> kalcli -x media list ks=MDQ2ZThjOTI0MTJmZGIxYTVlMWVhNDJlZDZhNDAyMDkyMWJhNzE0OXw0Mzc0ODE7NDM3NDgxOzEzNjI0OTI3Njc7MDsxMzYyNDA2MzY3Ljc3NzM7MDt3aWRnZXQ6MSx2aWV3Oio7Ow== + +5. Using an expired session +> renewks MDQ2ZThjOTI0MTJmZGIxYTVlMWVhNDJlZDZhNDAyMDkyMWJhNzE0OXw0Mzc0ODE7NDM3NDgxOzEzNjI0OTI3Njc7MDsxMzYyNDA2MzY3Ljc3NzM7MDt3aWRnZXQ6MSx2aWV3Oio7Ow== | kalcli media list + +6. Parsing a KS: +> extks MDQ2ZThjOTI0MTJmZGIxYTVlMWVhNDJlZDZhNDAyMDkyMWJhNzE0OXw0Mzc0ODE7NDM3NDgxOzEzNjI0OTI3Njc7MDsxMzYyNDA2MzY3Ljc3NzM7MDt3aWRnZXQ6MSx2aWV3Oio7Ow== + +7. Executing an API with a different source IP address: +> ip=`genipheader 9.8.7.6` ; genks 1234 | kalcli -H$ip baseentry getContextData entryId=0_abcd56 + +8. Using a serve action: +> genks 1234 | kalcli -r document_documents serve entryId=0_abcdef > \temp\test.doc + +9. Nesting requests +> kalcli -x session start partnerId=1234 secret=abcdef type=2 | awk '{print "ks "$1}' | kalcli media list + +10. Uploading files +> ks=`genks -b 1234` ; kalcli -x uploadtoken add ks=$ks | awk '$1 == "id" {print "uploadTokenId "$2}' | kalcli uploadtoken upload ks=$ks fileData=@/tmp/test.php From 377466a55eae6526913ffa57c854fad3d5b33451 Mon Sep 17 00:00:00 2001 From: tan-tan-kanarek Date: Mon, 22 Jul 2013 11:35:21 +0300 Subject: [PATCH 065/132] Avoid null in dynamic values strings --- alpha/apps/kaltura/lib/kScope.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/kScope.php b/alpha/apps/kaltura/lib/kScope.php index 13a6e791596..9fc3e763b49 100644 --- a/alpha/apps/kaltura/lib/kScope.php +++ b/alpha/apps/kaltura/lib/kScope.php @@ -159,7 +159,11 @@ public function getDynamicValues($keyPrefix = '', $keySuffix = '') if($value instanceof IScopeField) $value->setScope($this); - $values[$keyPrefix . $key . $keySuffix] = $value->getValue(); + $dynamicValue = $value->getValue(); + if(is_null($dynamicValue)) + $dynamicValue = ''; + + $values[$keyPrefix . $key . $keySuffix] = $dynamicValue; } return $values; From 677c0b9dfab254457a695f3062c5f4d1a82d3c4c Mon Sep 17 00:00:00 2001 From: ranyefet Date: Mon, 22 Jul 2013 14:05:27 +0300 Subject: [PATCH 066/132] removed x-iframe-options header --- .../kaltura/modules/extwidget/actions/previewAction.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/previewAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/previewAction.class.php index 133e6f190cc..06fb267a7bf 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/previewAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/previewAction.class.php @@ -7,8 +7,6 @@ class previewAction extends kalturaAction { public function execute ( ) { - // Prevent the page fron being embeded in an iframe - header( 'X-Frame-Options: SAMEORIGIN' ); $this->uiconf_id = intval($this->getRequestParameter('uiconf_id')); if(!$this->uiconf_id) From 687abda89eb202cacfa8378b78c943d79dc5d924 Mon Sep 17 00:00:00 2001 From: ranyefet Date: Mon, 22 Jul 2013 14:28:05 +0300 Subject: [PATCH 067/132] removed iframe check --- .../kaltura/modules/extwidget/templates/previewSuccess.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/templates/previewSuccess.php b/alpha/apps/kaltura/modules/extwidget/templates/previewSuccess.php index 19dc60b9771..9619dc51ec5 100644 --- a/alpha/apps/kaltura/modules/extwidget/templates/previewSuccess.php +++ b/alpha/apps/kaltura/modules/extwidget/templates/previewSuccess.php @@ -60,11 +60,6 @@