remove unused code and use folders
This commit is contained in:
parent
33905afb28
commit
0b81967464
15 changed files with 53 additions and 6848 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.swp
|
0
styles.css → css/styles.css
Executable file → Normal file
0
styles.css → css/styles.css
Executable file → Normal file
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
@ -1,18 +0,0 @@
|
||||||
|
|
||||||
$(function() {
|
|
||||||
Firefogg.prototype.loadFromFp = function(fp) {
|
|
||||||
var file = fp.file;
|
|
||||||
this._inputFile = fp.file.path;
|
|
||||||
this.sourceFilename = fp.file.leafName;
|
|
||||||
this.state = "";
|
|
||||||
this.sourceInfo = JSON.stringify(this.getFormatInfo(this._inputFile, false));
|
|
||||||
this.sourceInfo.video && this.sourceInfo.video.forEach(function(video) {
|
|
||||||
if (!video.display_aspect_ratio) {
|
|
||||||
video.display_aspect_ratio = video.width + ':' + video.height;
|
|
||||||
video.pixel_aspect_ratio = '1:1';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
});
|
|
14
index.html
Executable file → Normal file
14
index.html
Executable file → Normal file
|
@ -5,13 +5,13 @@
|
||||||
<title>SpeedTrans</title>
|
<title>SpeedTrans</title>
|
||||||
<script type="text/javascript" src="oxjs/min/UI/jquery/jquery.js"></script>
|
<script type="text/javascript" src="oxjs/min/UI/jquery/jquery.js"></script>
|
||||||
<script type="text/javascript" src="oxjs/min/Ox.js"></script>
|
<script type="text/javascript" src="oxjs/min/Ox.js"></script>
|
||||||
<script type="text/javascript" src="player.js"></script>
|
<script type="text/javascript" src="js/player.js"></script>
|
||||||
<script type="text/javascript" src="staticfuncs.js"></script>
|
<script type="text/javascript" src="js/staticfuncs.js"></script>
|
||||||
<script type="text/javascript" src="classes.js"></script>
|
<script type="text/javascript" src="js/classes.js"></script>
|
||||||
<script type="text/javascript" src="app.js"></script>
|
<script type="text/javascript" src="js/app.js"></script>
|
||||||
<script type="text/javascript" src="ox.extra.js"></script>
|
<script type="text/javascript" src="js/ox.extra.js"></script>
|
||||||
<script type="text/javascript" src="dnd.js"></script>
|
<script type="text/javascript" src="js/dnd.js"></script>
|
||||||
<link rel="stylesheet" href="styles.css" />
|
<link rel="stylesheet" href="css/styles.css" />
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body style="display:none">
|
<body style="display:none">
|
||||||
|
|
556
jquery-ui.js
vendored
556
jquery-ui.js
vendored
File diff suppressed because one or more lines are too long
|
@ -158,7 +158,7 @@ Ox.load({
|
||||||
if ($.inArray(getFileNameExt(path.toLowerCase()), [
|
if ($.inArray(getFileNameExt(path.toLowerCase()), [
|
||||||
'oga', 'ogg', 'ogv', 'ogx', 'wav', 'webm', 'mp4', 'm4v'
|
'oga', 'ogg', 'ogv', 'ogx', 'wav', 'webm', 'mp4', 'm4v'
|
||||||
]) != -1) {
|
]) != -1) {
|
||||||
loadVideoObject(data.files[0]);
|
loadVideo(data.files[0]);
|
||||||
} else {
|
} else {
|
||||||
alert('can only open video formats supported by browser');
|
alert('can only open video formats supported by browser');
|
||||||
}
|
}
|
||||||
|
@ -201,23 +201,15 @@ Ox.load({
|
||||||
stDialog("Keyboard Shortcuts", html);
|
stDialog("Keyboard Shortcuts", html);
|
||||||
} else if(data.id == 'save_srt') {
|
} else if(data.id == 'save_srt') {
|
||||||
var content = textArea.toSrt();
|
var content = textArea.toSrt();
|
||||||
uriContent = 'data:text/plain;base64,' + btoa(Ox.encodeUTF8(content));
|
saveContent(content, 'text/plain', getFileNameSansExt(videoPath) + '.srt');
|
||||||
saveContent(uriContent, videoPath + '.srt');
|
|
||||||
} else if(data.id == 'load_srt') {
|
} else if(data.id == 'load_srt') {
|
||||||
var filters = {'Srt files': '*.srt'};
|
loadSrt(data.files[0]);
|
||||||
var fileObj = selectFile(filters);
|
|
||||||
if (fileObj) {
|
|
||||||
var srtPath = fileObj.file.path;
|
|
||||||
loadSrt(srtPath);
|
|
||||||
}
|
|
||||||
} else if(data.id == 'export_encore') {
|
} else if(data.id == 'export_encore') {
|
||||||
var content = textArea.toSrt("enc");
|
var content = textArea.toSrt("enc");
|
||||||
uriContent = 'data:text/plain;base64,' + btoa(Ox.encodeUTF8(content));
|
saveContent(content, 'text/plain', getFileNameSansExt(videoPath) + '.enc.txt');
|
||||||
saveContent(uriContent, videoPath + '.enc.txt');
|
|
||||||
} else if(data.id == 'export_html') {
|
} else if(data.id == 'export_html') {
|
||||||
var content = textArea.toHTML();
|
var content = textArea.toHTML();
|
||||||
uriContent = 'data:text/html;base64,' + btoa(Ox.encodeUTF8(content));
|
saveContent(content, 'text/html', getFileNameSansExt(videoPath) + '.html');
|
||||||
saveContent(uriContent, videoPath + '.html');
|
|
||||||
} else if(data.id == 'load_cuts') {
|
} else if(data.id == 'load_cuts') {
|
||||||
var html = Ox.tmpl("dialog_load_cuts");
|
var html = Ox.tmpl("dialog_load_cuts");
|
||||||
var loadDialog = Ox.Dialog({
|
var loadDialog = Ox.Dialog({
|
||||||
|
@ -273,7 +265,8 @@ function saveTxt() {
|
||||||
globalUser.set_txt(videoHash, txt);
|
globalUser.set_txt(videoHash, txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveContent(content, path) {
|
function saveContent(content, type, path) {
|
||||||
|
var uriContent = 'data:'+type+';base64,' + btoa(content);
|
||||||
var pom = document.createElement('a');
|
var pom = document.createElement('a');
|
||||||
pom.setAttribute('href', content);
|
pom.setAttribute('href', content);
|
||||||
pom.setAttribute('download', path);
|
pom.setAttribute('download', path);
|
||||||
|
@ -285,17 +278,6 @@ function saveContent(content, path) {
|
||||||
pom.click();
|
pom.click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function saveSrt() {
|
|
||||||
var content = textArea.toSrt();
|
|
||||||
uriContent = 'data:text/plain;base64,' + btoa(Ox.encodeUTF8(content));
|
|
||||||
saveContent(uriContent, videoPath + '.srt');
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveHTML(path) {
|
|
||||||
var content = textArea.toHTML();
|
|
||||||
uriContent = 'data:text/plain;base64,' + btoa(Ox.encodeUTF8(content));
|
|
||||||
saveContent(uriContent, videoPath + '.html');
|
|
||||||
}
|
|
||||||
|
|
||||||
function stDialog(titleTxt, text) {
|
function stDialog(titleTxt, text) {
|
||||||
var that = Ox.Dialog({
|
var that = Ox.Dialog({
|
||||||
|
@ -314,7 +296,7 @@ function stDialog(titleTxt, text) {
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadVideoObject(videoFile) {
|
function loadVideo(videoFile) {
|
||||||
Ox.oshash(videoFile, function(hash) {
|
Ox.oshash(videoFile, function(hash) {
|
||||||
videoHash = hash;
|
videoHash = hash;
|
||||||
var storageKey = 'txt_' + videoHash;
|
var storageKey = 'txt_' + videoHash;
|
||||||
|
@ -337,41 +319,6 @@ function loadVideoObject(videoFile) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function loadVideo(videoFile, isRecent) {
|
|
||||||
videoPath = videoFile;
|
|
||||||
filePath = getFileNameSansExt(videoFile);
|
|
||||||
srtFilePath = filePath + ".srt";
|
|
||||||
Ox.oshash(new File(videoPath), function(hash) {
|
|
||||||
videoHash = hash;
|
|
||||||
var storageKey = 'txt_' + videoHash;
|
|
||||||
if (storageKey in storage) {
|
|
||||||
loadTxt();
|
|
||||||
} else if (isRecent) {
|
|
||||||
/* If contents are not in local storage,
|
|
||||||
attempt to load recent srt file. This is mostly
|
|
||||||
to aid in users migrating to version that saves
|
|
||||||
in localStorage */
|
|
||||||
var srtPath = globalUser.get_pref('recentSrt');
|
|
||||||
if (srtPath) {
|
|
||||||
loadSrt(srtPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
$('#video').attr("src", "file://" + videoFile);
|
|
||||||
$('#filepath').text(videoFile);
|
|
||||||
document.getElementById("video").load();
|
|
||||||
$('#video').one("loadedmetadata", function() {
|
|
||||||
Video = new VideoPlayer();
|
|
||||||
Video.init("video");
|
|
||||||
Video.setDuration(Video.player.duration);
|
|
||||||
$('#insertTc').click(textArea.insertTc);
|
|
||||||
videoListener = setInterval(Video.listener, 250);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Functions to generate preview while encoding: see http://firefogg.org/examples
|
Functions to generate preview while encoding: see http://firefogg.org/examples
|
||||||
*/
|
*/
|
||||||
|
@ -409,11 +356,3 @@ $(window).unload(function() {
|
||||||
}
|
}
|
||||||
saveTxt();
|
saveTxt();
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
This is just to kill console.logs that maybe generated by Ox.print calls, because that seems to mess with Firefogg. Debug and remove.
|
|
||||||
*/
|
|
||||||
Ox.print = function() {
|
|
||||||
$.noop();
|
|
||||||
}
|
|
||||||
|
|
49
classes.js → js/classes.js
Executable file → Normal file
49
classes.js → js/classes.js
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
||||||
var url = "http://speedtrans.pad.ma";
|
var url = "https://speedtrans.pad.ma";
|
||||||
|
|
||||||
var storage = window.localStorage;
|
var storage = window.localStorage;
|
||||||
|
|
||||||
|
@ -243,8 +243,8 @@ TextArea.prototype.toSrt = function(fmt) {
|
||||||
this.spans = spans;
|
this.spans = spans;
|
||||||
var srt = spansToSrt(spans, fmt);
|
var srt = spansToSrt(spans, fmt);
|
||||||
// console.log(srt);
|
// console.log(srt);
|
||||||
return srt;
|
return Ox.encodeUTF8(srt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TextArea.prototype.addTime = function(ms, start_no) {
|
TextArea.prototype.addTime = function(ms, start_no) {
|
||||||
|
@ -260,8 +260,8 @@ TextArea.prototype.addTime = function(ms, start_no) {
|
||||||
tcInMs: spans[i].tcInMs + ms
|
tcInMs: spans[i].tcInMs + ms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return spansToSrt(s, 'srt', start_no)
|
return spansToSrt(s, 'srt', start_no);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TextArea.prototype.toHTML = function() {
|
TextArea.prototype.toHTML = function() {
|
||||||
|
@ -272,7 +272,7 @@ TextArea.prototype.toHTML = function() {
|
||||||
span = spans[i];
|
span = spans[i];
|
||||||
txt = '';
|
txt = '';
|
||||||
txt += '<p>\n';
|
txt += '<p>\n';
|
||||||
txt += '<a href="http://pad.ma/PADMA_VIDEO_ID/' + ms2npt(span.tcInMs) + "-" + ms2npt(span.tcOutMs) + '">';
|
txt += '<a href="https://pad.ma/PADMA_VIDEO_ID/' + ms2npt(span.tcInMs) + "-" + ms2npt(span.tcOutMs) + '">';
|
||||||
txt += (i + 1).toString();
|
txt += (i + 1).toString();
|
||||||
txt += "</a>\n";
|
txt += "</a>\n";
|
||||||
txt += '<br />\n';
|
txt += '<br />\n';
|
||||||
|
@ -280,11 +280,10 @@ TextArea.prototype.toHTML = function() {
|
||||||
txt += "</p>\n\n";
|
txt += "</p>\n\n";
|
||||||
html += txt;
|
html += txt;
|
||||||
}
|
}
|
||||||
return html;
|
return Ox.encodeUTF8(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//creates new Span (tcIn and tcOut in npt format)
|
//creates new Span (tcIn and tcOut in npt format)
|
||||||
var Span = function(tcIn, tcOut, text, index) {
|
var Span = function(tcIn, tcOut, text, index) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
@ -440,32 +439,10 @@ function loadCuts(url, id) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSrt(filename) {
|
function loadSrt(file) {
|
||||||
//alert(filename);
|
var reader = new FileReader();
|
||||||
if (!checkFileExists(filename)) {
|
reader.onload = function(data) {
|
||||||
alert("Could not find Srt file " + filename);
|
textArea.fromSrt(data.target.result);
|
||||||
return;
|
};
|
||||||
}
|
reader.readAsBinaryString(file);
|
||||||
// alert("hmm.. you have a .srt file but not a txt file - this is a bug. sorry.");
|
|
||||||
var txt = mozillaLoadFile(filename);
|
|
||||||
if (textArea.fromSrt(txt)) {
|
|
||||||
srtFilePath = filename;
|
|
||||||
} else {
|
|
||||||
var recovery_txt = globalUser.get_txt(filename);
|
|
||||||
textArea.elem.val(recovery_txt);
|
|
||||||
var html = Ox.tmpl("tmpl_loadError", {'filename': filename, 'txt': txt, 'recovery_txt': recovery_txt});
|
|
||||||
stDialog("Error Loading File", html);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
function loadMeta(filename) {
|
|
||||||
var m = mozillaLoadFile(filename);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
function loadSrtTxt(filename) {
|
|
||||||
var txt = mozillaLoadFile(filename);
|
|
||||||
$('#txt').val(txt);
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -8,7 +8,7 @@ $(function() {
|
||||||
document.addEventListener('drop', function(event) {
|
document.addEventListener('drop', function(event) {
|
||||||
if (event.dataTransfer.files && event.dataTransfer.files.length) {
|
if (event.dataTransfer.files && event.dataTransfer.files.length) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
loadVideoObject(event.dataTransfer.files[0])
|
loadVideo(event.dataTransfer.files[0])
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -34,11 +34,3 @@ John Resig's micro-templating: http://ejohn.org/blog/javascript-micro-templating
|
||||||
return data ? fn( data ) : fn;
|
return data ? fn( data ) : fn;
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
Ox.ElementFromTemplate = function(tmpl_id, data) {
|
|
||||||
var that = this;
|
|
||||||
var html = Ox.tmpl(tmpl_id, data);
|
|
||||||
// console.log("TMpL", that);
|
|
||||||
this.html(html);
|
|
||||||
return this;
|
|
||||||
};
|
|
0
player.js → js/player.js
Executable file → Normal file
0
player.js → js/player.js
Executable file → Normal file
45
staticfuncs.js → js/staticfuncs.js
Executable file → Normal file
45
staticfuncs.js → js/staticfuncs.js
Executable file → Normal file
|
@ -23,7 +23,7 @@ function ms2npt(ms) {
|
||||||
return npt;
|
return npt;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ms2frames(ms, fmt) {
|
function ms2frames(ms, fmt) {
|
||||||
if (!fmt) var fmt = "PAL";
|
if (!fmt) var fmt = "PAL";
|
||||||
var npt = ms2npt(ms);
|
var npt = ms2npt(ms);
|
||||||
var dotpos = npt.lastIndexOf(".");
|
var dotpos = npt.lastIndexOf(".");
|
||||||
|
@ -38,12 +38,12 @@ function ms2npt(ms) {
|
||||||
var joinToken = ":";
|
var joinToken = ":";
|
||||||
var framesTc = npt.substring(0, dotpos ) + joinToken + frames;
|
var framesTc = npt.substring(0, dotpos ) + joinToken + frames;
|
||||||
return framesTc;
|
return framesTc;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ms2time(ms) {
|
function ms2time(ms) {
|
||||||
var npt = ms2npt(ms)
|
var npt = ms2npt(ms)
|
||||||
return npt.substr(npt.length-9, npt.length-6);
|
return npt.substr(npt.length-9, npt.length-6);
|
||||||
}
|
}
|
||||||
|
|
||||||
function framesToNpt(timeCode) {
|
function framesToNpt(timeCode) {
|
||||||
var frames = timeCode.substring(9, 11);
|
var frames = timeCode.substring(9, 11);
|
||||||
|
@ -52,8 +52,7 @@ function framesToNpt(timeCode) {
|
||||||
var ms = strpad(ms, '0', 3, 'right');
|
var ms = strpad(ms, '0', 3, 'right');
|
||||||
var timeCodeNpt = timeCode.substring(0,8) + "." + ms;
|
var timeCodeNpt = timeCode.substring(0,8) + "." + ms;
|
||||||
return timeCodeNpt;
|
return timeCodeNpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function strpad(str, pad, len, dir) {
|
function strpad(str, pad, len, dir) {
|
||||||
while (str.length < len) {
|
while (str.length < len) {
|
||||||
|
@ -63,13 +62,13 @@ function strpad(str, pad, len, dir) {
|
||||||
str = str + pad;
|
str = str + pad;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidTimecode(tc) {
|
function isValidTimecode(tc) {
|
||||||
var tc = $.trim(tc);
|
var tc = $.trim(tc);
|
||||||
var nptRegex = new RegExp("^[0-9][0-9]?\:[0-9][0-9]\:[0-9][0-9][\.|\,|\:][0-9]?[0-9]?[0-9]?$");
|
var nptRegex = new RegExp("^[0-9][0-9]?\:[0-9][0-9]\:[0-9][0-9][\.|\,|\:][0-9]?[0-9]?[0-9]?$");
|
||||||
return nptRegex.test(tc);to
|
return nptRegex.test(tc);to
|
||||||
}
|
}
|
||||||
|
|
||||||
//where filters is a JSON object, for eg. {'Video Files': '*.dv;*.ogg;*.ogv;*.ogx;*.avi;*.mov;*.mp4;*.mpeg;*.mpg;*.vob'}
|
//where filters is a JSON object, for eg. {'Video Files': '*.dv;*.ogg;*.ogv;*.ogx;*.avi;*.mov;*.mp4;*.mpeg;*.mpg;*.vob'}
|
||||||
function selectFile(filters, callback) {
|
function selectFile(filters, callback) {
|
||||||
|
@ -78,36 +77,11 @@ function selectFile(filters, callback) {
|
||||||
callback && callback(fp);
|
callback && callback(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function mozillaSaveFile(filePath,content)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mozillaSaveAs() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns null if it can't do it, false if there's an error, or a string of the content if successful
|
|
||||||
function mozillaLoadFile(filePath)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function checkFileExists(filePath) {
|
|
||||||
if (mozillaLoadFile(filePath)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFileNameExt(filename) {
|
function getFileNameExt(filename) {
|
||||||
var dotPos = filename.lastIndexOf(".");
|
var dotPos = filename.lastIndexOf(".");
|
||||||
var ext = filename.substring(dotPos + 1, filename.length);
|
var ext = filename.substring(dotPos + 1, filename.length);
|
||||||
return ext;
|
return ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFileNameSansExt(filename) {
|
function getFileNameSansExt(filename) {
|
||||||
var dotPos = filename.lastIndexOf(".");
|
var dotPos = filename.lastIndexOf(".");
|
||||||
|
@ -117,5 +91,4 @@ function getFileNameSansExt(filename) {
|
||||||
var filenameSansExt = filename;
|
var filenameSansExt = filename;
|
||||||
}
|
}
|
||||||
return filenameSansExt;
|
return filenameSansExt;
|
||||||
}
|
}
|
||||||
|
|
95
oshash.js
95
oshash.js
|
@ -1,95 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Ox.oshash = function (file, callback) {
|
|
||||||
|
|
||||||
// Needs to go via string to work for files > 2GB
|
|
||||||
var hash = fromString(file.size.toString());
|
|
||||||
|
|
||||||
read(0);
|
|
||||||
|
|
||||||
function add(A, B) {
|
|
||||||
var a, b, c, d;
|
|
||||||
d = A[3] + B[3];
|
|
||||||
c = A[2] + B[2] + (d >> 16);
|
|
||||||
d &= 0xffff;
|
|
||||||
b = A[1] + B[1] + (c >> 16);
|
|
||||||
c &= 0xffff;
|
|
||||||
a = A[0] + B[0] + (b >> 16);
|
|
||||||
b &= 0xffff;
|
|
||||||
// Cut off overflow
|
|
||||||
a &= 0xffff;
|
|
||||||
return [a, b, c, d];
|
|
||||||
}
|
|
||||||
|
|
||||||
function fromData(s, offset) {
|
|
||||||
offset = offset || 0;
|
|
||||||
return [
|
|
||||||
s.charCodeAt(offset + 6) + (s.charCodeAt(offset + 7) << 8),
|
|
||||||
s.charCodeAt(offset + 4) + (s.charCodeAt(offset + 5) << 8),
|
|
||||||
s.charCodeAt(offset + 2) + (s.charCodeAt(offset + 3) << 8),
|
|
||||||
s.charCodeAt(offset + 0) + (s.charCodeAt(offset + 1) << 8)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
function fromString(str) {
|
|
||||||
var base = 10,
|
|
||||||
blen = 1,
|
|
||||||
i,
|
|
||||||
num,
|
|
||||||
pos,
|
|
||||||
r = [0, 0, 0, 0];
|
|
||||||
for (pos = 0; pos < str.length; pos++) {
|
|
||||||
num = parseInt(str.charAt(pos), base);
|
|
||||||
i = 0;
|
|
||||||
do {
|
|
||||||
while (i < blen) {
|
|
||||||
num += r[3 - i] * base;
|
|
||||||
r[3 - i++] = (num & 0xFFFF);
|
|
||||||
num >>>= 16;
|
|
||||||
}
|
|
||||||
if (num) {
|
|
||||||
blen++;
|
|
||||||
}
|
|
||||||
} while (num);
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
function pad(string, length, padding) {
|
|
||||||
padding = Ox.repeat(padding, length - string.length);
|
|
||||||
return (padding + string).slice(-length);
|
|
||||||
};
|
|
||||||
|
|
||||||
function hex(h) {
|
|
||||||
return (
|
|
||||||
pad(h[0].toString(16), 4, '0')
|
|
||||||
+ pad(h[1].toString(16), 4, '0')
|
|
||||||
+ pad(h[2].toString(16), 4, '0')
|
|
||||||
+ pad(h[3].toString(16), 4, '0')
|
|
||||||
).toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
function read(offset, last) {
|
|
||||||
var blob,
|
|
||||||
block = 65536,
|
|
||||||
length = 8,
|
|
||||||
reader = new FileReader();
|
|
||||||
reader.onload = function(data) {
|
|
||||||
var s = data.target.result,
|
|
||||||
s_length = s.length - length,
|
|
||||||
i;
|
|
||||||
for (i = 0; i <= s_length; i += length) {
|
|
||||||
hash = add(hash, fromData(s, i));
|
|
||||||
}
|
|
||||||
if (file.size < block || last) {
|
|
||||||
callback(hex(hash));
|
|
||||||
} else {
|
|
||||||
read(file.size - block, true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
blob = file.slice(offset, offset + block);
|
|
||||||
reader.readAsBinaryString(blob);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,9 +0,0 @@
|
||||||
/* Original CSS */
|
|
||||||
#speedtrans-toolbarbutton {
|
|
||||||
list-style-image: url("chrome://speedtrans/content/icon.png");
|
|
||||||
}
|
|
||||||
/* Added for Australis support */
|
|
||||||
#speedtrans-toolbarbutton[cui-areatype="menu-panel"],
|
|
||||||
toolbarpaletteitem[place="palette"] > #speedtrans-toolbarbutton {
|
|
||||||
list-style-image: url("chrome://speedtrans/content/icon.png");
|
|
||||||
}
|
|
Loading…
Reference in a new issue