space
This commit is contained in:
parent
dd9892020c
commit
a3c1081964
2 changed files with 323 additions and 333 deletions
|
@ -6,7 +6,6 @@ var filePath = false;
|
||||||
var videoListener;
|
var videoListener;
|
||||||
var seekBar;
|
var seekBar;
|
||||||
var globalUser;
|
var globalUser;
|
||||||
var srtFilePath = undefined;
|
|
||||||
var videoPath = undefined;
|
var videoPath = undefined;
|
||||||
var videoHash = undefined;
|
var videoHash = undefined;
|
||||||
|
|
||||||
|
@ -152,7 +151,6 @@ Ox.load({
|
||||||
saveTxt();
|
saveTxt();
|
||||||
videoPath = undefined;
|
videoPath = undefined;
|
||||||
videoHash = undefined;
|
videoHash = undefined;
|
||||||
srtFilePath = undefined;
|
|
||||||
textArea.elem.val('');
|
textArea.elem.val('');
|
||||||
var path = data.files[0].name;
|
var path = data.files[0].name;
|
||||||
if ($.inArray(getFileNameExt(path.toLowerCase()), [
|
if ($.inArray(getFileNameExt(path.toLowerCase()), [
|
||||||
|
@ -349,12 +347,5 @@ End Preview functions
|
||||||
|
|
||||||
|
|
||||||
$(window).unload(function() {
|
$(window).unload(function() {
|
||||||
console.log('unload');
|
|
||||||
if (typeof filePath != 'undefined' && typeof srtFilePath != 'undefined') {
|
|
||||||
globalUser.set_prefs({
|
|
||||||
'recentVideo': $('#video').attr("src").replace("file://", ""),
|
|
||||||
'recentSrt': srtFilePath
|
|
||||||
});
|
|
||||||
}
|
|
||||||
saveTxt();
|
saveTxt();
|
||||||
});
|
});
|
||||||
|
|
647
js/classes.js
647
js/classes.js
|
@ -4,421 +4,420 @@ var storage = window.localStorage;
|
||||||
|
|
||||||
//elem = string (elementId to make TextArea)
|
//elem = string (elementId to make TextArea)
|
||||||
var TextArea = function(elem) {
|
var TextArea = function(elem) {
|
||||||
this.elem = $('#' + elem);
|
this.elem = $('#' + elem);
|
||||||
var that = this;
|
var that = this;
|
||||||
// this.elem = new Ox.Input({'type': 'textarea', 'id': 'textArea'}).attr("id", elem).appendTo('#txtWrapper');
|
//this.elem = new Ox.Input({'type': 'textarea', 'id': 'textArea'}).attr("id", elem).appendTo('#txtWrapper');
|
||||||
this.hasFocus = false;
|
this.hasFocus = false;
|
||||||
this.width = this.elem.width();
|
this.width = this.elem.width();
|
||||||
this.spans = [];
|
this.spans = [];
|
||||||
this.init()
|
this.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
TextArea.prototype.init = function() {
|
TextArea.prototype.init = function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
var e = this.elem;
|
var e = this.elem;
|
||||||
var tc;
|
var tc;
|
||||||
e.focus(function() {
|
e.focus(function() {
|
||||||
that.hasFocus = true;
|
that.hasFocus = true;
|
||||||
}).blur(function() {
|
}).blur(function() {
|
||||||
that.hasFocus = false;
|
that.hasFocus = false;
|
||||||
});
|
});
|
||||||
e.dblclick(function(e) {
|
e.dblclick(function(e) {
|
||||||
var tc = that.isTc();
|
var tc = that.isTc();
|
||||||
if (tc) {
|
if (tc) {
|
||||||
Video.set(tc);
|
Video.set(tc);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//returns tc in ms if cursor is at a time-code, else returns false
|
//returns tc in ms if cursor is at a time-code, else returns false
|
||||||
TextArea.prototype.isTc = function() {
|
TextArea.prototype.isTc = function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
var e = this.elem;
|
var e = this.elem;
|
||||||
var eDom = e.get(0);
|
var eDom = e.get(0);
|
||||||
var val = e.val();
|
var val = e.val();
|
||||||
var pos = eDom.selectionStart;
|
var pos = eDom.selectionStart;
|
||||||
var word = this.getWord(pos);
|
var word = this.getWord(pos);
|
||||||
if (isValidTimecode(word)) {
|
if (isValidTimecode(word)) {
|
||||||
return npt2ms(word);
|
return npt2ms(word);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//inserts current timecode at cursor position
|
//inserts current timecode at cursor position
|
||||||
TextArea.prototype.insertTc = function(tcNpt) {
|
TextArea.prototype.insertTc = function(tcNpt) {
|
||||||
var that = this;
|
var that = this;
|
||||||
var e = that.elem;
|
var e = that.elem;
|
||||||
var eDom = e.get(0);
|
var eDom = e.get(0);
|
||||||
var scrollTop = eDom.scrollTop;
|
var scrollTop = eDom.scrollTop;
|
||||||
var val = this.elem.val();
|
var val = this.elem.val();
|
||||||
var pos = eDom.selectionStart;
|
var pos = eDom.selectionStart;
|
||||||
if(!tcNpt) {
|
if(!tcNpt) {
|
||||||
tcNpt = ms2npt(Video.get());
|
tcNpt = ms2npt(Video.get());
|
||||||
}
|
}
|
||||||
var newVal = val.substring(0,pos) + "\n" + tcNpt + "\n" + val.substring(pos, val.length);
|
var newVal = val.substring(0,pos) + "\n" + tcNpt + "\n" + val.substring(pos, val.length);
|
||||||
e.val(newVal);
|
e.val(newVal);
|
||||||
e.focus();
|
e.focus();
|
||||||
eDom.selectionStart = pos + tcNpt.length + 2;
|
eDom.selectionStart = pos + tcNpt.length + 2;
|
||||||
eDom.selectionEnd = pos + tcNpt.length + 2;
|
eDom.selectionEnd = pos + tcNpt.length + 2;
|
||||||
eDom.scrollTop = scrollTop + 15;
|
eDom.scrollTop = scrollTop + 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
//gets the word at character pos (int) [in val (str)]
|
//gets the word at character pos (int) [in val (str)]
|
||||||
TextArea.prototype.getWord = function(pos, val) {
|
TextArea.prototype.getWord = function(pos, val) {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
val = this.elem.val();
|
val = this.elem.val();
|
||||||
|
}
|
||||||
|
var c;
|
||||||
|
var i = pos;
|
||||||
|
var j = pos;
|
||||||
|
while (c != " " && c != "\n") {
|
||||||
|
if (i==0) {
|
||||||
|
i = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i--;
|
||||||
|
c = val.substring(i,i+1);
|
||||||
}
|
}
|
||||||
var c;
|
var firstLetter = i+1;
|
||||||
var i = pos;
|
var d;
|
||||||
var j = pos;
|
while (d != " " && d != "\n") {
|
||||||
while (c != " " && c != "\n") {
|
if (j >= val.length) {
|
||||||
if (i==0) {
|
break;
|
||||||
i = -1;
|
}
|
||||||
break;
|
j++;
|
||||||
}
|
d = val.substring(j,j+1);
|
||||||
i--;
|
|
||||||
c = val.substring(i,i+1);
|
|
||||||
}
|
}
|
||||||
var firstLetter = i+1;
|
var lastLetter = j;
|
||||||
var d;
|
var word = val.substring(firstLetter, lastLetter);
|
||||||
while (d != " " && d != "\n") {
|
return word;
|
||||||
if (j >= val.length) {
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
d = val.substring(j,j+1);
|
|
||||||
}
|
|
||||||
var lastLetter = j;
|
|
||||||
var word = val.substring(firstLetter, lastLetter);
|
|
||||||
return word;
|
|
||||||
}
|
|
||||||
|
|
||||||
function cleanNewlines(str) {
|
function cleanNewlines(str) {
|
||||||
var s = str.replace(/\r\n|\r|\n/g, '\n');
|
var s = str.replace(/\r\n|\r|\n/g, '\n');
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
//takes an srt as param, loads into txtarea
|
//takes an srt as param, loads into txtarea
|
||||||
TextArea.prototype.fromSrt = function(txt) {
|
TextArea.prototype.fromSrt = function(txt) {
|
||||||
var that = this;
|
var that = this;
|
||||||
this.spans = [];
|
this.spans = [];
|
||||||
var cleaned = cleanNewlines(txt);
|
var cleaned = cleanNewlines(txt);
|
||||||
var srt = strip(cleaned);
|
var srt = strip(cleaned);
|
||||||
var srt_ = srt.split('\n\n');
|
var srt_ = srt.split('\n\n');
|
||||||
var s;
|
var s;
|
||||||
for(s in srt_) {
|
for(s in srt_) {
|
||||||
st = srt_[s].split('\n');
|
st = srt_[s].split('\n');
|
||||||
if(st.length >=2) {
|
if(st.length >=2) {
|
||||||
var n = st[0];
|
var n = st[0];
|
||||||
var i = strip(st[1].split(' --> ')[0]);
|
var i = strip(st[1].split(' --> ')[0]);
|
||||||
var o = strip(st[1].split(' --> ')[1]);
|
var o = strip(st[1].split(' --> ')[1]);
|
||||||
var t = st[2];
|
var t = st[2];
|
||||||
if(st.length > 2) {
|
if(st.length > 2) {
|
||||||
for(j=3; j<st.length;j++) {
|
for(j=3; j<st.length;j++) {
|
||||||
t += '\n'+st[j];
|
t += '\n'+st[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var is = toSeconds(i);
|
var is = toSeconds(i);
|
||||||
var os = toSeconds(o);
|
var os = toSeconds(o);
|
||||||
if (parseInt(n) - this.spans.length == 1) {
|
if (parseInt(n) - this.spans.length == 1) {
|
||||||
this.spans[this.spans.length] = new Span(is, os, t, that.spans.length);
|
this.spans[this.spans.length] = new Span(is, os, t, that.spans.length);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var out = '';
|
var out = '';
|
||||||
var spans = this.spans;
|
var spans = this.spans;
|
||||||
for (span in spans) {
|
for (span in spans) {
|
||||||
if (spans.hasOwnProperty(span)) {
|
if (spans.hasOwnProperty(span)) {
|
||||||
var sp = spans[span];
|
var sp = spans[span];
|
||||||
out += ms2npt(sp.tcInMs) + "\n";
|
out += ms2npt(sp.tcInMs) + "\n";
|
||||||
out += sp.text;
|
out += sp.text;
|
||||||
out += "\n";
|
out += "\n";
|
||||||
//If the outpoint of current span is equal to inpoint of next span, dont print out timecode, and just add the extra \n to go to next span.
|
//If the outpoint of current span is equal to inpoint of next span, dont print out timecode, and just add the extra \n to go to next span.
|
||||||
if (span < spans.length - 1) {
|
if (span < spans.length - 1) {
|
||||||
var p = parseInt(span) + 1;
|
var p = parseInt(span) + 1;
|
||||||
if (spans[p].tcInMs != sp.tcOutMs) {
|
if (spans[p].tcInMs != sp.tcOutMs) {
|
||||||
out += ms2npt(sp.tcOutMs) + "\n\n";
|
out += ms2npt(sp.tcOutMs) + "\n\n";
|
||||||
} else {
|
} else {
|
||||||
out += "\n";
|
out += "\n";
|
||||||
}
|
}
|
||||||
} else if (parseInt(sp.tcOutMs) < parseInt(Video.player.duration * 1000)) {
|
} else if (parseInt(sp.tcOutMs) < parseInt(Video.player.duration * 1000)) {
|
||||||
out += "\n" + ms2npt(sp.tcOutMs) + "\n\n";
|
out += "\n" + ms2npt(sp.tcOutMs) + "\n\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.elem.val(out);
|
||||||
|
if (this.elem.val == '' || this.spans.length == 0) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.elem.val(out);
|
|
||||||
if (this.elem.val == '' || this.spans.length == 0) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function strip(s) {
|
function strip(s) {
|
||||||
return s.replace(/^\s+|\s+$/g,"");
|
return s.replace(/^\s+|\s+$/g,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
function toSeconds(t) {
|
function toSeconds(t) {
|
||||||
var s = 0.0;
|
var s = 0.0;
|
||||||
if(t) {
|
if(t) {
|
||||||
var p = t.split(':');
|
var p = t.split(':');
|
||||||
for(i=0;i<p.length;i++) {
|
for(i=0;i<p.length;i++) {
|
||||||
s = s * 60 + parseFloat(p[i].replace(',', '.'))
|
s = s * 60 + parseFloat(p[i].replace(',', '.'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function spansToSrt(arr, fmt, start_no) {
|
function spansToSrt(arr, fmt, start_no) {
|
||||||
if (typeof start_no == 'undefined') {
|
if (typeof start_no == 'undefined') {
|
||||||
start_no = 1;
|
start_no = 1;
|
||||||
}
|
|
||||||
var srt = '';
|
|
||||||
var srtNo = start_no;
|
|
||||||
for (var k=0; k < arr.length; k++) {
|
|
||||||
var s = arr[k];
|
|
||||||
if (s.text.trim() == '') {
|
|
||||||
} else {
|
|
||||||
var text = s.text.trim();
|
|
||||||
linebreaksRegex = new RegExp('\n+', "g")
|
|
||||||
text = text.replace(linebreaksRegex, "\n");
|
|
||||||
if (!s.tcOutMs) {
|
|
||||||
s.tcOutMs = parseInt(Video.player.duration * 1000);
|
|
||||||
}
|
}
|
||||||
if (fmt == 'srt') {
|
var srt = '';
|
||||||
srt += srtNo + " ";
|
var srtNo = start_no;
|
||||||
srt += "\n";
|
for (var k=0; k < arr.length; k++) {
|
||||||
srt += "0" + ms2npt(s.tcInMs).replace(".", ",") + " --> " + "0" + ms2npt(s.tcOutMs).replace(".", ",");
|
var s = arr[k];
|
||||||
srt += "\n";
|
if (s.text.trim() == '') {
|
||||||
srt += text;
|
} else {
|
||||||
srt += "\n\n";
|
var text = s.text.trim();
|
||||||
|
linebreaksRegex = new RegExp('\n+', "g")
|
||||||
|
text = text.replace(linebreaksRegex, "\n");
|
||||||
|
if (!s.tcOutMs) {
|
||||||
|
s.tcOutMs = parseInt(Video.player.duration * 1000);
|
||||||
|
}
|
||||||
|
if (fmt == 'srt') {
|
||||||
|
srt += srtNo + " ";
|
||||||
|
srt += "\n";
|
||||||
|
srt += "0" + ms2npt(s.tcInMs).replace(".", ",") + " --> " + "0" + ms2npt(s.tcOutMs).replace(".", ",");
|
||||||
|
srt += "\n";
|
||||||
|
srt += text;
|
||||||
|
srt += "\n\n";
|
||||||
|
}
|
||||||
|
else if (fmt == 'enc') {
|
||||||
|
srt += srtNo + ms2frames(s.tcInMs) + " " + ms2frames(s.tcOutMs) + " " + text;
|
||||||
|
srt += "\n\n";
|
||||||
|
}
|
||||||
|
srtNo++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (fmt == 'enc') {
|
return srt;
|
||||||
srt += srtNo + ms2frames(s.tcInMs) + " " + ms2frames(s.tcOutMs) + " " + text;
|
}
|
||||||
srt += "\n\n";
|
|
||||||
}
|
|
||||||
srtNo++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return srt;
|
|
||||||
}
|
|
||||||
|
|
||||||
//returns textarea formatted to .srt
|
//returns textarea formatted to .srt
|
||||||
TextArea.prototype.toSrt = function(fmt) {
|
TextArea.prototype.toSrt = function(fmt) {
|
||||||
if (!fmt) var fmt = 'srt';
|
if (!fmt) var fmt = 'srt';
|
||||||
var text = cleanNewlines(this.elem.val());
|
var text = cleanNewlines(this.elem.val());
|
||||||
var lines = [];
|
var lines = [];
|
||||||
lines = text.split("\n");
|
lines = text.split("\n");
|
||||||
var i=0;
|
var i=0;
|
||||||
var j=0;
|
var j=0;
|
||||||
var spans = this.spans = [];
|
var spans = this.spans = [];
|
||||||
while (i < lines.length) {
|
while (i < lines.length) {
|
||||||
var l = lines[i];
|
var l = lines[i];
|
||||||
if (isValidTimecode(l.trim())) {
|
if (isValidTimecode(l.trim())) {
|
||||||
var tcIn = l.trim();
|
var tcIn = l.trim();
|
||||||
var t = "";
|
var t = "";
|
||||||
var thisLine = '';
|
var thisLine = '';
|
||||||
while (!isValidTimecode(thisLine.trim())) {
|
while (!isValidTimecode(thisLine.trim())) {
|
||||||
i++;
|
i++;
|
||||||
if (i >= lines.length) {
|
if (i >= lines.length) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
thisLine = lines[i];
|
thisLine = lines[i];
|
||||||
if (!isValidTimecode(thisLine.trim())) {
|
if (!isValidTimecode(thisLine.trim())) {
|
||||||
t += thisLine + "\n";
|
t += thisLine + "\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
var tcOut = $.trim(thisLine);
|
||||||
|
spans[j] = new Span(tcIn, tcOut, t, j);
|
||||||
|
j++;
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
var tcOut = $.trim(thisLine);
|
|
||||||
spans[j] = new Span(tcIn, tcOut, t, j);
|
|
||||||
j++;
|
|
||||||
} else {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.spans = spans;
|
this.spans = spans;
|
||||||
var srt = spansToSrt(spans, fmt);
|
var srt = spansToSrt(spans, fmt);
|
||||||
// console.log(srt);
|
//console.log(srt);
|
||||||
return Ox.encodeUTF8(srt);
|
return Ox.encodeUTF8(srt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TextArea.prototype.addTime = function(ms, start_no) {
|
TextArea.prototype.addTime = function(ms, start_no) {
|
||||||
// console.log(ms);
|
//console.log(ms);
|
||||||
this.toSrt();
|
this.toSrt();
|
||||||
var s = [];
|
var s = [];
|
||||||
var spans = this.spans;
|
var spans = this.spans;
|
||||||
for (var i=0; i < spans.length;i++) {
|
for (var i=0; i < spans.length;i++) {
|
||||||
s[i] = {
|
s[i] = {
|
||||||
index: i,
|
index: i,
|
||||||
tcOutMs: spans[i].tcOutMs + ms,
|
tcOutMs: spans[i].tcOutMs + ms,
|
||||||
text: spans[i].text,
|
text: spans[i].text,
|
||||||
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() {
|
||||||
var spans = this.spans;
|
var spans = this.spans;
|
||||||
var html = '';
|
var html = '';
|
||||||
var span, txt;
|
var span, txt;
|
||||||
for (var i=0; i<spans.length; i++) {
|
for (var i=0; i<spans.length; i++) {
|
||||||
span = spans[i];
|
span = spans[i];
|
||||||
txt = '';
|
txt = '';
|
||||||
txt += '<p>\n';
|
txt += '<p>\n';
|
||||||
txt += '<a href="https://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';
|
||||||
txt += span.text + "\n";
|
txt += span.text + "\n";
|
||||||
txt += "</p>\n\n";
|
txt += "</p>\n\n";
|
||||||
html += txt;
|
html += txt;
|
||||||
}
|
}
|
||||||
return Ox.encodeUTF8(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;
|
||||||
this.tcOutMs = npt2ms(tcOut);
|
this.tcOutMs = npt2ms(tcOut);
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.tcInMs = npt2ms(tcIn);
|
this.tcInMs = npt2ms(tcIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
var SeekBar = function(elem) {
|
var SeekBar = function(elem) {
|
||||||
this.elem = $('#' + elem);
|
this.elem = $('#' + elem);
|
||||||
this.pointerId = "seekPointer";
|
this.pointerId = "seekPointer";
|
||||||
this.width = this.elem.width();
|
this.width = this.elem.width();
|
||||||
this.init()
|
this.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
SeekBar.prototype.init = function() {
|
SeekBar.prototype.init = function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
var e = $('<div />');
|
var e = $('<div />');
|
||||||
e.attr("id", that.pointerId);
|
e.attr("id", that.pointerId);
|
||||||
e.draggable({
|
e.draggable({
|
||||||
containment: 'parent',
|
containment: 'parent',
|
||||||
axis: 'horizontally',
|
axis: 'horizontally',
|
||||||
drag: function() {
|
drag: function() {
|
||||||
clearInterval(videoListener);
|
clearInterval(videoListener);
|
||||||
var pos = that.get();
|
var pos = that.get();
|
||||||
$('#timeCode').html(ms2npt(pos));
|
$('#timeCode').html(ms2npt(pos));
|
||||||
},
|
},
|
||||||
stop: function() {
|
stop: function() {
|
||||||
var pos = that.get();
|
var pos = that.get();
|
||||||
Video.set(pos);
|
Video.set(pos);
|
||||||
videoListener = setInterval(Video.listener, 250);
|
videoListener = setInterval(Video.listener, 250);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
that.elem.append(e);
|
that.elem.append(e);
|
||||||
this.pointerElem = e;
|
this.pointerElem = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
//gets current time-code (int) of seekbar position
|
//gets current time-code (int) of seekbar position
|
||||||
SeekBar.prototype.get = function() {
|
SeekBar.prototype.get = function() {
|
||||||
var cssPos = parseInt(this.pointerElem.css("left"));
|
var cssPos = parseInt(this.pointerElem.css("left"));
|
||||||
var pos = parseInt((cssPos / this.width) * (Video.player.duration * 1000));
|
var pos = parseInt((cssPos / this.width) * (Video.player.duration * 1000));
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sets seek bar css pos according to current time-code
|
//sets seek bar css pos according to current time-code
|
||||||
SeekBar.prototype.set = function(ms) {
|
SeekBar.prototype.set = function(ms) {
|
||||||
var cssPos = parseInt(((ms / 1000) / Video.player.duration) * this.width);
|
var cssPos = parseInt(((ms / 1000) / Video.player.duration) * this.width);
|
||||||
this.elem.css("left", cssPos + "px");
|
this.elem.css("left", cssPos + "px");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var KeyboardController = function() {
|
var KeyboardController = function() {
|
||||||
this.
|
this.
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var User = function() {
|
var User = function() {
|
||||||
this.padmaUser = typeof user != 'undefined' ? user : null;
|
this.padmaUser = typeof user != 'undefined' ? user : null;
|
||||||
this.hostname = 'chrome://speedtrans';
|
this.hostname = 'chrome://speedtrans';
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
'fontSize': '13',
|
'fontSize': '13',
|
||||||
'theme': 'oxlight',
|
'theme': 'oxlight',
|
||||||
'recentVideo': '',
|
'recentVideo': '',
|
||||||
'recentSrt': '',
|
'recentSrt': '',
|
||||||
'autosave': 5,
|
'autosave': 5,
|
||||||
'direction': 'ltr'
|
'direction': 'ltr'
|
||||||
};
|
};
|
||||||
var autoSaveInterval = -1;
|
var autoSaveInterval = -1;
|
||||||
this.callbacks = {
|
this.callbacks = {
|
||||||
'fontSize': function(newSize) {
|
'fontSize': function(newSize) {
|
||||||
textArea.elem.css("font-size", newSize + "px");
|
textArea.elem.css("font-size", newSize + "px");
|
||||||
},
|
},
|
||||||
'theme': function(theme) {
|
'theme': function(theme) {
|
||||||
if(['oxdark', 'oxmedium', 'oxlight'].indexOf(theme) == -1) {
|
if(['oxdark', 'oxmedium', 'oxlight'].indexOf(theme) == -1) {
|
||||||
console.log('only supporting oxlight, oxmedium, oxdark, but ' + theme + ' was requested');
|
console.log('only supporting oxlight, oxmedium, oxdark, but ' + theme + ' was requested');
|
||||||
theme = 'oxlight';
|
theme = 'oxlight';
|
||||||
}
|
}
|
||||||
Ox.Theme(theme);
|
Ox.Theme(theme);
|
||||||
},
|
},
|
||||||
'recentVideo': $.noop,
|
'recentVideo': $.noop,
|
||||||
'recentSrt': $.noop,
|
'recentSrt': $.noop,
|
||||||
'direction': function(val) {
|
'direction': function(val) {
|
||||||
textArea.elem.css("direction", val);
|
textArea.elem.css("direction", val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.init = function() {
|
User.prototype.init = function() {
|
||||||
var prefs = ['fontSize', 'theme', 'direction'];
|
var prefs = ['fontSize', 'theme', 'direction'];
|
||||||
for (var i = 0; i < prefs.length; i++) {
|
for (var i = 0; i < prefs.length; i++) {
|
||||||
var key = prefs[i];
|
var key = prefs[i];
|
||||||
var val = this.get_pref(key);
|
var val = this.get_pref(key);
|
||||||
this.callbacks[key](val);
|
this.callbacks[key](val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.set_pref = function(key, val) {
|
User.prototype.set_pref = function(key, val) {
|
||||||
var that = this;
|
var that = this;
|
||||||
storage[key] = val;
|
storage[key] = val;
|
||||||
this.callbacks[key](val);
|
this.callbacks[key](val);
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.get_pref = function(key) {
|
User.prototype.get_pref = function(key) {
|
||||||
var that = this;
|
var that = this;
|
||||||
if (typeof storage[key] === 'undefined') {
|
if (typeof storage[key] === 'undefined') {
|
||||||
storage[key] = that.defaults[key];
|
storage[key] = that.defaults[key];
|
||||||
}
|
}
|
||||||
return storage[key];
|
return storage[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.set_prefs = function(keyvals) {
|
User.prototype.set_prefs = function(keyvals) {
|
||||||
for (key in keyvals) {
|
for (key in keyvals) {
|
||||||
if (keyvals.hasOwnProperty(key)) {
|
if (keyvals.hasOwnProperty(key)) {
|
||||||
this.set_pref(key, keyvals[key]);
|
this.set_pref(key, keyvals[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.get_prefs = function(keys) {
|
User.prototype.get_prefs = function(keys) {
|
||||||
var ret = {};
|
var ret = {};
|
||||||
for (var i=0; i < keys.length; i++) {
|
for (var i=0; i < keys.length; i++) {
|
||||||
var key = keys[i];
|
var key = keys[i];
|
||||||
ret[key] = this.get_pref(key);
|
ret[key] = this.get_pref(key);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.set_txt = function(filename, txt) {
|
User.prototype.set_txt = function(filename, txt) {
|
||||||
var that = this;
|
var that = this;
|
||||||
storage['txt_' + filename] = txt;
|
storage['txt_' + filename] = txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.get_txt = function(filename) {
|
User.prototype.get_txt = function(filename) {
|
||||||
var that = this;
|
var that = this;
|
||||||
return storage['txt_' + filename];
|
return storage['txt_' + filename];
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadCuts(url, id) {
|
function loadCuts(url, id) {
|
||||||
|
|
Loading…
Reference in a new issue