first commit as plugin
This commit is contained in:
commit
f65741fa97
4
chrome.manifest
Normal file
4
chrome.manifest
Normal file
|
@ -0,0 +1,4 @@
|
|||
content speedtag chrome/content/
|
||||
overlay chrome://browser/content/browser.xul chrome://speedtag/content/menu.xul
|
||||
|
||||
|
BIN
chrome/content/icon.png
Normal file
BIN
chrome/content/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
18
chrome/content/jquery-1.6.1.min.js
vendored
Normal file
18
chrome/content/jquery-1.6.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
21
chrome/content/menu.js
Normal file
21
chrome/content/menu.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
var speedtag={
|
||||
open:function()
|
||||
{
|
||||
window.open("chrome://speedtag/content/speedtag.html");
|
||||
/*
|
||||
window.open("chrome://speedtrans/content/transcribe.html",
|
||||
"annot", "chrome,centerscreen,resizable=yes,toolbar=no,menubar=no");
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
function getMainWindow() {
|
||||
return window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
|
||||
.rootTreeItem
|
||||
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindow);
|
||||
}
|
||||
|
||||
|
15
chrome/content/menu.xul
Normal file
15
chrome/content/menu.xul
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0"?>
|
||||
<overlay id="annot"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://speedtag/content/menu.js" />
|
||||
|
||||
<menupopup id="menu_ToolsPopup">
|
||||
<menuitem id="speedtag_menu" image="chrome://speedtag/content/icon.png"
|
||||
class="menuitem-iconic"
|
||||
insertafter="javascriptConsole,devToolsSeparator"
|
||||
label="Pad.ma Speedtag"
|
||||
oncommand="speedtag.open();"/>
|
||||
</menupopup>
|
||||
</overlay>
|
46
chrome/content/speedtag.css
Normal file
46
chrome/content/speedtag.css
Normal file
|
@ -0,0 +1,46 @@
|
|||
body, html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
direction: rtl;
|
||||
}
|
||||
|
||||
#leftForm {
|
||||
width: 40%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#buttons {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
#rightForm {
|
||||
width: 40%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#notesArea {
|
||||
width: 90%;
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
#formTable {
|
||||
width: 80%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.formLabel {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.formInput {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.formInput input {
|
||||
width: 90%;
|
||||
}
|
38
chrome/content/speedtag.html
Normal file
38
chrome/content/speedtag.html
Normal file
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
|
||||
<script type="text/javascript" src="staticfuncs.js"></script>
|
||||
<script type="text/javascript" src="speedtag.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="speedtag.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<div id="buttons">
|
||||
<button id="saveLocationBtn">Select Output Folder</button>
|
||||
<button id="selectAudioFile">Select Audio File</button>
|
||||
<button id="saveFormData">Save Metadata</button>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
<div id="leftForm">
|
||||
<form id="metadataForm" action="" method="GET">
|
||||
<table id="formTable">
|
||||
<tr>
|
||||
<td class="formLabel optional">
|
||||
Witness Name:
|
||||
</td>
|
||||
<td class="formInput">
|
||||
<input type="text" name="witnessName" id="witnessName" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div id="rightForm">
|
||||
<textarea id="notesArea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
11
chrome/content/speedtag.js
Normal file
11
chrome/content/speedtag.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
$(function() {
|
||||
var savePath = '';
|
||||
$('#saveLocationBtn').click(function() {
|
||||
savePath = selectFile();
|
||||
});
|
||||
$('#selectAudioFile').click(function() {
|
||||
fil = selectFile();
|
||||
data = mozillaLoadFile(fil);
|
||||
mozillaSaveFile("/tmp/blah.mp3", data);
|
||||
});
|
||||
});
|
223
chrome/content/staticfuncs.js
Executable file
223
chrome/content/staticfuncs.js
Executable file
|
@ -0,0 +1,223 @@
|
|||
function npt2ms(npt) {
|
||||
var ms = 0.0
|
||||
npt = String(npt);
|
||||
var p = npt.split(':')
|
||||
for(i=0;i<p.length;i++)
|
||||
ms = ms * 60 + parseFloat(p[i])
|
||||
return ms * 1000;
|
||||
}
|
||||
|
||||
function ms2npt(ms) {
|
||||
var it, ss, mm, hh, npt;
|
||||
var it = parseInt(ms / 1000)
|
||||
ms = ms - it * 1000;
|
||||
if (ms.toString().length > 3) {
|
||||
ms = ms.toString().substring(0,3);
|
||||
}
|
||||
ss = it % 60;
|
||||
mm = ((it - ss) / 60) % 60;
|
||||
hh = ((it - (mm * 60) - ss) / 3600) % 60;
|
||||
npt = hh+':'+strpad(mm.toString(), '0', 2, 'left')
|
||||
npt += ':'+strpad(ss.toString(), '0', 2, 'left')
|
||||
npt += '.'+strpad(ms.toString(), '0', 3, 'left')
|
||||
return npt;
|
||||
}
|
||||
|
||||
function ms2frames(ms, fmt) {
|
||||
if (!fmt) var fmt = "PAL";
|
||||
var npt = ms2npt(ms);
|
||||
var dotpos = npt.lastIndexOf(".");
|
||||
var mmStr = npt.substring(dotpos + 1, npt.length);
|
||||
var mmInt = parseInt(mmStr);
|
||||
if (fmt == 'PAL') {
|
||||
var frames = parseInt((mmInt / 1000) * 24);
|
||||
} else if (fmt == "NTSC") {
|
||||
var frames = parseInt((mmInt / 1000) * 29.97);
|
||||
}
|
||||
var framesTc = '';
|
||||
var joinToken = ":";
|
||||
var framesTc = npt.substring(0, dotpos ) + joinToken + frames;
|
||||
return framesTc;
|
||||
}
|
||||
|
||||
function ms2time(ms) {
|
||||
var npt = ms2npt(ms)
|
||||
return npt.substr(npt.length-9, npt.length-6);
|
||||
}
|
||||
|
||||
function framesToNpt(timeCode) {
|
||||
var frames = timeCode.substring(9, 11);
|
||||
var ms = parseInt(frames) / 25 * 1000;
|
||||
var ms = String(ms);
|
||||
var ms = strpad(ms, '0', 3, 'right');
|
||||
var timeCodeNpt = timeCode.substring(0,8) + "." + ms;
|
||||
return timeCodeNpt;
|
||||
}
|
||||
|
||||
|
||||
function strpad(str, pad, len, dir) {
|
||||
while (str.length < len) {
|
||||
if (dir == 'left')
|
||||
str = pad + str;
|
||||
else if (dir == 'right')
|
||||
str = str + pad;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function isValidTimecode(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]?$");
|
||||
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'}
|
||||
function selectFile(filters) {
|
||||
// netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
fp.init(window, "Choose a File", nsIFilePicker.modeOpen);
|
||||
//fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
|
||||
// fp.appendFilter("Ogg Video Files", "*.ogg;*.ogv;*.ogx;");
|
||||
for (var f in filters) {
|
||||
if (filters.hasOwnProperty(f)) {
|
||||
fp.appendFilter(f, filters[f]);
|
||||
}
|
||||
}
|
||||
// fp.appendFilter("All Video Files", "*.dv;*.ogg;*.ogv;*.ogx;*.avi;*.mov;*.mp4;*.mpeg;*.mpg;*.vob");
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
var rv = fp.show();
|
||||
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
|
||||
return fp;
|
||||
/*
|
||||
var file = fp.file;
|
||||
var path = fp.file.path;
|
||||
return path;
|
||||
*/
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function mozillaSaveFile(filePath,content)
|
||||
{
|
||||
if(window.Components) {
|
||||
try {
|
||||
// netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
||||
file.initWithPath(filePath);
|
||||
if(!file.exists())
|
||||
file.create(0,0664);
|
||||
var os = Components.classes["@mozilla.org/intl/converter-output-stream;1"].createInstance(Components.interfaces.nsIConverterOutputStream);
|
||||
var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
out.init(file,0x20|0x02,00004,null);
|
||||
os.init(out, "UTF-8", 0, 0x0000);
|
||||
os.writeString(content);
|
||||
//out.write(content,content.length);
|
||||
os.close();
|
||||
//out.flush();
|
||||
out.close();
|
||||
return true;
|
||||
} catch(ex) {
|
||||
alert(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function mozillaSaveAs() {
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker);
|
||||
fp.init(window, "Save srt as...", Components.interfaces.nsIFilePicker.modeSave);
|
||||
fp.appendFilters(Components.interfaces.nsIFilePicker.filterAll);
|
||||
var output = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
||||
var pth = typeof(srtFilePath) != 'undefined' ? srtFilePath : filePath + ".srt";
|
||||
output.initWithPath(pth);
|
||||
fp.defaultString = output.leafName;
|
||||
var rv = fp.show();
|
||||
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
|
||||
return fp.file.path;
|
||||
/*
|
||||
var file = fp.file;
|
||||
srtFilePath = file.path;
|
||||
saveSrt(srtFilePath);
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
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)
|
||||
{
|
||||
if(window.Components) {
|
||||
try {
|
||||
// netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
||||
file.initWithPath(filePath);
|
||||
if(!file.exists())
|
||||
return null;
|
||||
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
|
||||
inputStream.init(file,0x01,00004,null);
|
||||
//var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
|
||||
//sInputStream.init(inputStream);
|
||||
var charset = "UTF-8";
|
||||
const replacementChar = Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER;
|
||||
var cInputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIConverterInputStream);
|
||||
cInputStream.init(inputStream, charset, 1024, replacementChar);
|
||||
var str = {};
|
||||
var contents = '';
|
||||
while (cInputStream.readString(4096, str) != 0) {
|
||||
contents += str.value;
|
||||
}
|
||||
|
||||
//var contents = sInputStream.read(sInputStream.available());
|
||||
cInputStream.close();
|
||||
//sInputStream.close();
|
||||
inputStream.close();
|
||||
return contents;
|
||||
} catch(ex) {
|
||||
alert(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function checkFileExists(filePath) {
|
||||
if(window.Components) {
|
||||
try {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
||||
file.initWithPath(filePath);
|
||||
if (file.exists()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch(ex) {
|
||||
//alert("Error");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getFileNameExt(filename) {
|
||||
var dotPos = filename.lastIndexOf(".");
|
||||
var ext = filename.substring(dotPos + 1, filename.length);
|
||||
return ext;
|
||||
}
|
||||
|
||||
function getFileNameSansExt(filename) {
|
||||
var dotPos = filename.lastIndexOf(".");
|
||||
if (dotPos != '-1') {
|
||||
var filenameSansExt = filename.substring(0,dotPos);
|
||||
} else {
|
||||
var filenameSansExt = filename;
|
||||
}
|
||||
return filenameSansExt;
|
||||
}
|
||||
|
22
install.rdf
Normal file
22
install.rdf
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
|
||||
xmlns:NC="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<RDF:Description RDF:about="rdf:#$uOho32"
|
||||
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
|
||||
em:minVersion="1.5"
|
||||
em:maxVersion="5.0" />
|
||||
<RDF:Description RDF:about="urn:mozilla:install-manifest"
|
||||
em:id="b@pad.ma"
|
||||
em:version="0.1"
|
||||
em:type="2"
|
||||
em:name="Pad.ma Speedtag"
|
||||
em:description="Pad.ma Speedtag"
|
||||
em:creator="pad.ma"
|
||||
em:updateURL="http://files.pad.ma/speedtag/update.rdf"
|
||||
em:homepageURL="http://files.pad.ma/speedtag/"
|
||||
em:iconURL="chrome://speedtag/content/icon.png"
|
||||
em:updateKey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDZutlQBmSw+Pc2G6DvJkhOFsKrh5bcGqnzCOvgZiRCgFVKYKM0M0h9zosV9t/pfUIfHHDeYp9L1GR6gPJnwWdDTC/LCV2K7M9K5L5cF5et+0Tf0yfchOnCx+SAQyJ++8DAyN2mgNtNPXfZrpz1vCePf6TLQuKciobrXPJa+aji2wIDAQAB">
|
||||
<em:targetApplication RDF:resource="rdf:#$uOho32"/>
|
||||
</RDF:Description>
|
||||
</RDF:RDF>
|
31
make_dist.sh
Executable file
31
make_dist.sh
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
#run ./make_dist.sh upload to upload new version to http://files.pad.ma/speedtag
|
||||
repos_version=0.2
|
||||
version=1.`cat .bzr/branch/last-revision | cut -f1 -d" "`
|
||||
|
||||
sed -i "s/em:version=\"$repos_version\"/em:version=\"$version\"/g" install.rdf
|
||||
zip -9 -r speedtag-$version.xpi install.rdf chrome.manifest chrome \
|
||||
-x chrome/content/oxjs/.bzr/\* \
|
||||
-x chrome/content/oxjs/demos/\* \
|
||||
-x chrome/content/oxjs/source/\* \
|
||||
-x chrome/content/oxjs/tests/\* \
|
||||
-x chrome/content/oxjs/build/js/jquery-\* \
|
||||
-x chrome/content/oxjs/tools/\* \
|
||||
-x \*.~1~ -x \*.orig
|
||||
|
||||
updateHash=`sha1sum speedtag-$version.xpi | cut -f1 -d' '`
|
||||
|
||||
sed -i "s/em:version=\"$version\"/em:version=\"$repos_version\"/g" install.rdf
|
||||
|
||||
cp update.rdf.in update.rdf
|
||||
sed -i -e "s/updateHash>.*<\/em:updateHash/updateHash>sha1:$updateHash<\/em:updateHash/g" \
|
||||
-e "s/speedtag-.*.xpi/speedtag-$version.xpi/g" \
|
||||
-e "s/<em:version>.*</<em:version>$version</g" update.rdf
|
||||
|
||||
echo "select update.rdf and sign"
|
||||
mccoy
|
||||
host=pad.ma
|
||||
path=/srv/files/speedtag
|
||||
# scp update.rdf speedtag-$version.xpi $host:$path
|
||||
# ssh $host "ln -sf $path/speedtag-$version.xpi $path/speedtag.xpi"
|
||||
|
BIN
speedtag.xpi
Normal file
BIN
speedtag.xpi
Normal file
Binary file not shown.
26
update.rdf
Normal file
26
update.rdf
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
<RDF:Description about="urn:mozilla:extension:speedtrans@pad.ma">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>1.</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>1.5</em:minVersion>
|
||||
<em:maxVersion>5.0</em:maxVersion>
|
||||
<em:updateLink>http://files.pad.ma/speedtrans/speedtrans-1.0.xpi</em:updateLink>
|
||||
<em:updateHash>sha1:3ccc3f9176622d9556ad42bf7e84975972f536a5</em:updateHash>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
</RDF:Description>
|
||||
</RDF:RDF>
|
||||
|
26
update.rdf.in
Normal file
26
update.rdf.in
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
<RDF:Description about="urn:mozilla:extension:speedtrans@pad.ma">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>1.0</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>1.5</em:minVersion>
|
||||
<em:maxVersion>5.0</em:maxVersion>
|
||||
<em:updateLink>http://files.pad.ma/speedtrans/speedtrans-1.0.xpi</em:updateLink>
|
||||
<em:updateHash>sha1:fillme</em:updateHash>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
</RDF:Description>
|
||||
</RDF:RDF>
|
||||
|
Loading…
Reference in New Issue
Block a user