This commit is contained in:
j 2016-02-29 14:44:47 +05:30
parent dd9892020c
commit a3c1081964
2 changed files with 323 additions and 333 deletions

View file

@ -6,7 +6,6 @@ var filePath = false;
var videoListener;
var seekBar;
var globalUser;
var srtFilePath = undefined;
var videoPath = undefined;
var videoHash = undefined;
@ -152,7 +151,6 @@ Ox.load({
saveTxt();
videoPath = undefined;
videoHash = undefined;
srtFilePath = undefined;
textArea.elem.val('');
var path = data.files[0].name;
if ($.inArray(getFileNameExt(path.toLowerCase()), [
@ -349,12 +347,5 @@ End Preview functions
$(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();
});

View file

@ -6,12 +6,12 @@ var storage = window.localStorage;
var TextArea = function(elem) {
this.elem = $('#' + elem);
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.width = this.elem.width();
this.spans = [];
this.init()
}
}
TextArea.prototype.init = function() {
var that = this;
@ -28,7 +28,7 @@ TextArea.prototype.init = function() {
Video.set(tc);
}
});
}
}
//returns tc in ms if cursor is at a time-code, else returns false
@ -44,7 +44,7 @@ TextArea.prototype.isTc = function() {
} else {
return false;
}
}
}
//inserts current timecode at cursor position
TextArea.prototype.insertTc = function(tcNpt) {
@ -63,7 +63,7 @@ TextArea.prototype.insertTc = function(tcNpt) {
eDom.selectionStart = pos + tcNpt.length + 2;
eDom.selectionEnd = pos + tcNpt.length + 2;
eDom.scrollTop = scrollTop + 15;
}
}
//gets the word at character pos (int) [in val (str)]
TextArea.prototype.getWord = function(pos, val) {
@ -93,12 +93,12 @@ TextArea.prototype.getWord = function(pos, val) {
var lastLetter = j;
var word = val.substring(firstLetter, lastLetter);
return word;
}
}
function cleanNewlines(str) {
var s = str.replace(/\r\n|\r|\n/g, '\n');
return s;
}
}
//takes an srt as param, loads into txtarea
TextArea.prototype.fromSrt = function(txt) {
@ -160,7 +160,7 @@ TextArea.prototype.fromSrt = function(txt) {
function strip(s) {
return s.replace(/^\s+|\s+$/g,"");
}
}
function toSeconds(t) {
var s = 0.0;
@ -171,8 +171,7 @@ function toSeconds(t) {
}
}
return s;
}
}
function spansToSrt(arr, fmt, start_no) {
if (typeof start_no == 'undefined') {
@ -206,7 +205,7 @@ function spansToSrt(arr, fmt, start_no) {
}
}
return srt;
}
}
//returns textarea formatted to .srt
TextArea.prototype.toSrt = function(fmt) {
@ -242,13 +241,13 @@ TextArea.prototype.toSrt = function(fmt) {
}
this.spans = spans;
var srt = spansToSrt(spans, fmt);
// console.log(srt);
//console.log(srt);
return Ox.encodeUTF8(srt);
}
TextArea.prototype.addTime = function(ms, start_no) {
// console.log(ms);
//console.log(ms);
this.toSrt();
var s = [];
var spans = this.spans;
@ -290,14 +289,14 @@ var Span = function(tcIn, tcOut, text, index) {
this.tcOutMs = npt2ms(tcOut);
this.text = text;
this.tcInMs = npt2ms(tcIn);
}
}
var SeekBar = function(elem) {
this.elem = $('#' + elem);
this.pointerId = "seekPointer";
this.width = this.elem.width();
this.init()
}
}
SeekBar.prototype.init = function() {
var that = this;
@ -319,25 +318,25 @@ SeekBar.prototype.init = function() {
});
that.elem.append(e);
this.pointerElem = e;
}
}
//gets current time-code (int) of seekbar position
SeekBar.prototype.get = function() {
var cssPos = parseInt(this.pointerElem.css("left"));
var pos = parseInt((cssPos / this.width) * (Video.player.duration * 1000));
return pos;
}
}
//sets seek bar css pos according to current time-code
SeekBar.prototype.set = function(ms) {
var cssPos = parseInt(((ms / 1000) / Video.player.duration) * this.width);
this.elem.css("left", cssPos + "px");
}
}
/*
var KeyboardController = function() {
this.
}
}
*/
var User = function() {