replace all \r\n with \n

This commit is contained in:
sanj 2010-02-23 22:43:51 +05:30
parent 35f74aa1ed
commit ccb867d121
2 changed files with 8 additions and 2 deletions

View File

@ -88,10 +88,15 @@ TextArea.prototype.getWord = function(pos, val) {
return word;
}
function cleanNewlines(str) {
var s = str.replace('\r\n|\r|\n', '\n');
return s;
}
//takes an srt as param, loads into txtarea
TextArea.prototype.fromSrt = function(srt) {
var spans = [];
srt = srt.replace('\r\n|\r|\n', '\n')
srt = cleanNewlines(srt);
srt = strip(srt);
var srt_ = srt.split('\n\n');
for(s in srt_) {
@ -184,7 +189,7 @@ function spansToSrt(arr, fmt, start_no) {
//returns textarea formatted to .srt
TextArea.prototype.toSrt = function(fmt) {
if (!fmt) var fmt = 'srt';
var text = this.elem.val();
var text = cleanNewlines(this.elem.val());
var lines = [];
lines = text.split("\n");
var i=0;

View File

@ -187,6 +187,7 @@ function saveEncore() {
Shortcuts: <br /><br />
Esc: Pause / Unpause <br />
Insert: Insert time-code<br />
PageUp / PageDown: Volume Up / Down<br />
Double-click in Textarea: insert time-code <br />
Double-click on video: insert time-code<br />
Double-click on time-code in textarea: Seek video to time-code. <br />