From 88c98119b6e8d6d30731cd0d3e7fb3f9af5557cb Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Mon, 7 Apr 2014 20:32:41 +0800 Subject: Add a script for downloading an article with ANSI color. And it supports more BBS systems than the native copyArticle() function, but it's slower. --- res/script/downloadart.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 res/script/downloadart.js (limited to 'res') diff --git a/res/script/downloadart.js b/res/script/downloadart.js new file mode 100644 index 0000000..f0fd212 --- /dev/null +++ b/res/script/downloadart.js @@ -0,0 +1,40 @@ +fqterm.importFile("utils.js"); + +var saveFile = "/tmp/save.txt"; +var LastLine = 23; +var timeout = 300; +var retries = 5; +// when the article is not completely read +// there'll be a 'XX%' at the last line +var r = new RegExp("%"); +var esc = new RegExp('\x1b\x1b','g'); + +getAnsiLine = function(i){ + var line = fqterm.getAttrText(i).replace(esc, "\x1b["); + return line+"\n"; +} + +// first copy the previous lines +for (var i=0; i