Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Commit

Permalink
Added capability to remove debug functions when building minified ver…
Browse files Browse the repository at this point in the history
…sion. Corrected feature detect to avoid latest Chrome. Removing cruft
  • Loading branch information
cgiffard committed Dec 19, 2011
1 parent 64b0319 commit a9f9a63
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 13 deletions.
16 changes: 15 additions & 1 deletion Jakefile
Expand Up @@ -112,13 +112,27 @@ file("build",[],function() {

desc("Minifies an already built Captionator.js.");
task("minify",["build"],function() {

// Remove debug code
function removeDebugCode(codeIn) {
var codeParts = codeIn.split(/\/\/\s*DEBUG\->/g);

return codeParts.map(function(part) {
if (part.match(/\/\/\s*<\-DEBUG/g)) {
return part.split(/\s*\/\/\s*<\-DEBUG/g).pop();
}
// console.log(part);
return part;
}).join("");
}

console.log("Minifying...");
fs.readFile("./js/captionator.js",function(err,data) {
if (err) {
fail("Unable to read unminified captionator.js infile.",1);
} else {
var unminifiedLength = data.length;
var captionatorData = data.toString("utf8");
var captionatorData = removeDebugCode(data.toString("utf8"));
var ast = uglifyParser.parse(captionatorData);
ast = uglifyProcessor.ast_mangle(ast);
ast = uglifyProcessor.ast_squeeze(ast);
Expand Down
Binary file removed audio/arduino-en.mp3
Binary file not shown.
Binary file removed audio/arduino-en.ogg
Binary file not shown.
Binary file removed audio/arduino-en.wav
Binary file not shown.
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -33,7 +33,7 @@ <h1>HTML5 Video Closed Captioning Example</h1>
<h2 id="mediacontrols">Media Controls</h2>

<!-- Include Captionator -->
<script type="text/javascript" src="js/captionator.js"></script>
<script type="text/javascript" src="js/captionator-min.js"></script>

<!-- Example Usage -->
<script type="text/javascript" src="js/captionator-example-api.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion js/captionator-min.js

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions js/captionator.js
Expand Up @@ -649,11 +649,12 @@
if (!HTMLVideoElement && !(element instanceof VirtualMediaContainer) ) {
// Browser doesn't support HTML5 video - die here.
return false;
} else {
// Browser supports native track API
if (typeof(document.createElement("video").addTextTrack) === "function") {
return false;
}
}

// Browser supports native track API
// This should catch Chrome latest and IE10.
if (typeof(document.createElement("video").addTextTrack) === "function" || typeof(document.createElement("video").addTrack) === "function") {
return false;
}

// if requested by options, export the object types
Expand Down Expand Up @@ -1785,6 +1786,8 @@
videoElement._captionator_availableCueArea.top;
}

// DEBUG->

// DEBUG FUNCTIONS
// This function can be used for debugging WebVTT captions. It will not be
// included in production versions of Captionator.
Expand Down Expand Up @@ -1886,6 +1889,7 @@
drawLines();
}
// END DEBUG FUNCTIONS
// <-DEBUG
};

/*
Expand Down
11 changes: 6 additions & 5 deletions source/captionator.general.init.js
Expand Up @@ -54,11 +54,12 @@ captionator.captionify = function(element,defaultLanguage,options) {
if (!HTMLVideoElement && !(element instanceof VirtualMediaContainer) ) {
// Browser doesn't support HTML5 video - die here.
return false;
} else {
// Browser supports native track API
if (typeof(document.createElement("video").addTextTrack) === "function") {
return false;
}
}

// Browser supports native track API
// This should catch Chrome latest and IE10.
if (typeof(document.createElement("video").addTextTrack) === "function" || typeof(document.createElement("video").addTrack) === "function") {
return false;
}

// if requested by options, export the object types
Expand Down
3 changes: 3 additions & 0 deletions source/captionator.general.style.js
Expand Up @@ -466,6 +466,8 @@ captionator.styleCue = function(DOMNode, cueObject, videoElement) {
videoElement._captionator_availableCueArea.top;
}

// DEBUG->

// DEBUG FUNCTIONS
// This function can be used for debugging WebVTT captions. It will not be
// included in production versions of Captionator.
Expand Down Expand Up @@ -567,6 +569,7 @@ captionator.styleCue = function(DOMNode, cueObject, videoElement) {
drawLines();
}
// END DEBUG FUNCTIONS
// <-DEBUG
};

/*
Expand Down

0 comments on commit a9f9a63

Please sign in to comment.