1 2 3(function() { 4 5 var defaults = { 6 clickable: false, 7 url: "", 8 className: 'vjs-watermark', 9 text: false, 10 debug: false 11 }, 12 extend = function() { 13 var args, target, i, object, property; 14 args = Array.prototype.slice.call(arguments); 15 target = args.shift() || {}; 16 for (i in args) { 17 object = args[i]; 18 for (property in object) { 19 if (object.hasOwnProperty(property)) { 20 if (typeof object[property] === 'object') { 21 target[property] = extend(target[property], object[property]); 22 } else { 23 target[property] = object[property]; 24 } 25 } 26 } 27 } 28 return target; 29 }; 30 31 //! global varible containing reference to the DOM element 32 var div; 33 34 /** 35 * register the thubmnails plugin 36 */ 37 videojs.registerPlugin('watermark', function(settings) { 38 39 40 var options, player, video, img, link; 41 options = extend(defaults, settings); 42 43 /* Grab the necessary DOM elements */ 44 player = this.el(); 45 video = this.el().getElementsByTagName('video')[0]; 46 47 // create the watermark element 48 if (!div) { 49 div = document.createElement('div'); 50 div.className = options.className; 51 } 52 else { 53 //! if div already exists, empty it 54 div.innerHTML = ''; 55 } 56 57 // if text is set, display text 58 if (options.text) 59 div.textContent = options.text; 60 61 // if img is set, add img 62 if (options.file) { 63 img = document.createElement('img'); 64 div.appendChild(img); 65 img.src = options.file; 66 } 67 68 //img.style.bottom = "0"; 69 //img.style.right = "0"; 70 if ((options.ypos === 0) && (options.xpos === 0)) // Top left 71 { 72 div.style.top = "0"; 73 div.style.left = "0"; 74 } 75 else if ((options.ypos === 0) && (options.xpos === 100)) // Top right 76 { 77 div.style.top = "0"; 78 div.style.right = "0"; 79 } 80 else if ((options.ypos === 100) && (options.xpos === 100)) // Bottom right 81 { 82 div.style.bottom = "0"; 83 div.style.right = "0"; 84 } 85 else if ((options.ypos === 100) && (options.xpos === 0)) // Bottom left 86 { 87 div.style.bottom = "0"; 88 div.style.left = "0"; 89 } 90 else if ((options.ypos === 50) && (options.xpos === 50)) // Center 91 { 92 if (options.debug) console.log('watermark: player:' + player.width + 'x' + player.height); 93 if (options.debug) console.log('watermark: video:' + video.videoWidth + 'x' + video.videoHeight); 94 if (options.debug) console.log('watermark: image:' + img.width + 'x' + img.height); 95 div.style.top = (this.height()/2)+"px"; 96 div.style.left = (this.width()/2)+"px"; 97 } 98 div.style.opacity = options.opacity; 99 100 //div.style.backgroundImage = "url("+options.file+")"; 101 //div.style.backgroundPosition.x = options.xpos+"%"; 102 //div.style.backgroundPosition.y = options.ypos+"%"; 103 //div.style.backgroundRepeat = options.xrepeat; 104 //div.style.opacity = (options.opacity/100); 105 106 //if user wants watermark to be clickable, add anchor elem 107 //todo: check if options.url is an actual url? 108 if (options.clickable && options.url !== "") { 109 link = document.createElement("a"); 110 link.href = options.url; 111 link.target = "_blank"; 112 link.appendChild(div); 113 //add clickable watermark to the player 114 player.appendChild(link); 115 } else { 116 //add normal watermark to the player 117 player.appendChild(div); 118 } 119 120 if (options.debug) console.log('watermark: Register end'); 121 }); 122})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.