summaryrefslogtreecommitdiff
path: root/res/script
diff options
context:
space:
mode:
Diffstat (limited to 'res/script')
-rw-r--r--res/script/README112
-rw-r--r--res/script/buildindex.js132
-rw-r--r--res/script/continuous.py19
-rw-r--r--res/script/download.js19
-rw-r--r--res/script/download.py253
-rw-r--r--res/script/downloadelite.js207
-rw-r--r--res/script/downloadelite_smth.js255
-rw-r--r--res/script/post.js17
-rw-r--r--res/script/post.py21
-rw-r--r--res/script/postfile.py48
-rw-r--r--res/script/search.js22
-rw-r--r--res/script/sendmsg.py33
-rw-r--r--res/script/system.js48
-rw-r--r--res/script/system.py103
-rw-r--r--res/script/test.js4
-rw-r--r--res/script/tools.py65
-rw-r--r--res/script/utils.js46
-rw-r--r--res/script/weiboshare.js51
18 files changed, 1455 insertions, 0 deletions
diff --git a/res/script/README b/res/script/README
new file mode 100644
index 0000000..c7dacbc
--- /dev/null
+++ b/res/script/README
@@ -0,0 +1,112 @@
+
+I've contacted one of the authors of CTerm, and got his permisson to use these scripts with FQTerm.
+Other scripts were directly drawn from qterm0.4.1.
+
+Any file to be written to or read from should be in the format of UTF-8.
+
+Usage:
+
+sessionID=long(sys.argv[0])
+
+formatError(sessionID)
+get the traceback info
+return string
+
+getArticle(sessionID, interval)
+copy current article
+return (string, success)
+
+
+copyArticle(sessionID)
+copy current article (obsolete)
+return string
+
+getText(sessionID, line)
+get text at line
+return string
+
+
+getAttrText(sessionID, line)
+get attr text at line
+return string
+
+sendString(sessionID, str)
+send string to server
+return number of bytes written
+
+
+sendParsedString(sessionID, str)
+send string with escape
+return number of bytes written
+
+caretX(sessionID)
+caret x
+return int
+
+caretY(sessionID)
+caret y
+return int
+
+
+columns(sessionID)
+screen width
+return int
+
+
+rows(sessionID)
+screen height
+return int
+
+
+isConnected(sessionID)
+connected to server or not
+return int
+
+disconnect(sessionID)
+disconnect from server
+
+
+reconnect(sessionID)
+reconnect
+
+
+getBBSCodec(sessionID)
+get the bbs encoding, GBK or Big5
+return string
+
+getAddress(sessionID)
+get the bbs address
+return string
+
+getPort(sessionID)
+get the bbs port number
+return int
+
+getProtocol(sessionID)
+get the bbs protocol, 0/1/2 TELNET/SSH1/SSH2
+return int
+
+getReplyKey(sessionID)
+get the key to reply messages
+return string (wtf...?)
+
+
+getURL(sessionID)
+get the url string under mouse (not sure if works)
+return string
+
+
+previewImage(sessionID, url)
+preview the image link
+
+
+fromUTF8(str, codec)
+decode from utf8 to string in specified codec
+return string
+
+
+toUTF8(str, codec)
+decode from string in specified codec to utf8
+return string
+
+
diff --git a/res/script/buildindex.js b/res/script/buildindex.js
new file mode 100644
index 0000000..d5235d4
--- /dev/null
+++ b/res/script/buildindex.js
@@ -0,0 +1,132 @@
+fqterm.import("utils.js");
+//NOTE: 1. this file should be in utf8
+//first enter the folder, then start script.
+var timeout = 2000;
+var path = "c:\\fix-elite\\"; //DO NOT miss last slash
+var base_path = path;
+
+var make_html_header = function(num)
+{
+ num = parseInt(num);
+ var result = '<html><head>\n'+
+ '<meta http-equiv="Content-Language" content="zh-cn">\n'+
+ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n'+
+ '<title>FQTerm Article Downloader</title>\n'+
+ '</head>\n'+
+ '<body>\n'+
+ '<p><b><h1>FQTerm Article Downloader</h1></b></p>\n'+
+ '<p><p align=center><a href=' + (num - 1) + '.html>Prevoius</a>\n'+
+ '<a href=index.html>Index</a>\n'+
+ '<a href=' + (num + 1) + '.html>Next</a></p align=center></p>'+
+ '<hr><p></p>\n';
+ return result;
+}
+
+var make_html_ender = function(num)
+{
+ num = parseInt(num);
+ var result = '<hr><p></p>\n'+
+ '<p><p align=center><a href=' + (num - 1) + '.html>Prevoius</a>\n'+
+ '<a href=index.html>Index</a>\n'+
+ '<a href=' + (num + 1) + '.html>Next</a></p align=center></p>\n'+
+ '<p><b>FQTerm --- BBS client based on Qt library</b><p>\n'+
+ '<p><a href=http://code.google.com/p/fqterm>\n'+
+ 'http://code.google.com/p/fqterm</a><p>\n'+
+ '</body>\n'+
+ '</html>\n';
+ return result;
+}
+
+var make_index_header = function() {
+ var result = '<html><head>\n' +
+ '<meta http-equiv="Content-Language" content="zh-cn">\n' +
+ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n' +
+ '<title>FQTerm Article Downloader</title>\n' +
+ '</head>\n' +
+ '<p><b><h1>FQTerm Article Downloader</h1></b></p>\n' +
+ '<p><p align=center>\n' +
+ '<a href=\"../index.html\">Up</a>\n' +
+ '</p align=center</p>\n' +
+ '<hr><p></p>\n\n';
+ return result;
+}
+
+var make_index_ender = function() {
+ var result = '<hr><p></p>\n' +
+ '<p><p align=center>\n' +
+ '<a href=\"../index.html\">Up</a>\n' +
+ '</p align=center</p>\n' +
+ '<p><b>FQTerm --- BBS client based on Qt library</b><p>\n' +
+ '<p><a href=http://code.google.com/p/fqterm>\n' +
+ 'http://code.google.com/p/fqterm</a><p>\n' +
+ '</body>\n' +
+ '</html>\n';
+ return result;
+}
+
+var get_list_num = function(str_line) {
+ // get the number
+ try{
+ var re = /[0-9]+/;
+ var num = re.exec(str_line);
+ return num[0];
+ } catch(err) {
+ return "";
+ }
+}
+
+var get_list_categary = function(str_line) {
+ try{
+ var re = /\[[^0-9]{2}\]/; //utf8!
+ var cat = re.exec(str_line);
+ return cat[0];
+ } catch(err) {
+ return "";
+ }
+}
+
+var get_list_title = function(str_line) {
+ try{
+ var re = /\[[^0-9]{2}\]/; //utf8!
+ var cat = re.exec(str_line);
+ var i = str_line.search(re);
+ return str_line.substr(i + cat[0].length);
+ } catch(err) {
+ return "";
+ }
+}
+
+
+var build_index = function() {
+ fqterm.makePath(path);
+ var h = make_index_header();
+ fqterm.writeFile(path + 'index.html', h);
+ while (true) {
+ var line = fqterm.caretY();
+ var str_line = fqterm.getText(line);
+ var article_num = get_list_num(str_line);
+ var article_category = get_list_categary(str_line);
+ var article_title = get_list_title(str_line);
+ if (article_category == '[文件]') {
+ var a = '<p><a href=' + article_num + '.html>[文件] ' + article_title + '</a></p>\n';
+ fqterm.appendFile(path + "index.html", a);
+ } else if (article_category == '[目录]') {
+ var a = '<p><a href=' + article_num + '/index.html>[目录] ' + article_title + '</a></p>\n';
+ fqterm.appendFile(path + "index.html", a);
+ } else {
+ break;
+ }
+ fqterm.sendString('j');
+ sleep(timeout);
+ var str_next = fqterm.getText(fqterm.caretY());
+ article_num_next = get_list_num(str_next);
+ if (article_num_next == "" || parseInt(article_num_next) <= parseInt(article_num)) {
+ break;
+ }
+ }
+ var e = make_index_ender();
+ fqterm.appendFile(path + 'index.html', e);
+ fqterm.sendString('q');
+}
+
+build_index();
diff --git a/res/script/continuous.py b/res/script/continuous.py
new file mode 100644
index 0000000..4240f3a
--- /dev/null
+++ b/res/script/continuous.py
@@ -0,0 +1,19 @@
+# This is demo script to continuousely download 4 articles
+import fqterm
+import sys, time
+
+# f=open("/home/dp2/test.txt","w")
+f = open("c:\\test.txt", "w")
+
+lp=long(sys.argv[0])
+
+for i in range(4):
+ fqterm.sendString(lp,"r")
+ time.sleep(1)
+ f.write(fqterm.getArticle(lp, 100)[0])
+ time.sleep(1)
+ fqterm.sendString(lp,"q")
+ time.sleep(1)
+ fqterm.sendString(lp,"j")
+ time.sleep(1)
+f.close()
diff --git a/res/script/download.js b/res/script/download.js
new file mode 100644
index 0000000..1a27fa4
--- /dev/null
+++ b/res/script/download.js
@@ -0,0 +1,19 @@
+fqterm.import("utils.js");
+
+var n = 4;
+var timeout = 1000;
+var filename = "c:\\test.txt";
+fqterm.writeFile(filename, "")
+
+while(n--)
+{
+ fqterm.sendString("r");
+ sleep(timeout);
+ var article = fqterm.copyArticle();
+ fqterm.appendFile(filename, article)
+ fqterm.sendString("q");
+ sleep(timeout);
+ fqterm.sendString("j");
+ sleep(timeout);
+}
+
diff --git a/res/script/download.py b/res/script/download.py
new file mode 100644
index 0000000..d274cc5
--- /dev/null
+++ b/res/script/download.py
@@ -0,0 +1,253 @@
+# coding=UTF-8
+"""
+download the directory
+
+ 13/09/04 kingson
+ * add this changelog
+
+Notes:
+ 1. make sure the path is empty, otherwise mkdir complain and stoped
+ 2. the time for sleep() varies dependent on sites
+ 3. tested for FireBird BBS only
+Bugs:
+ 1.
+TODO:
+ 1. add some GUI for control, e.g. stop, pause, resume, inside script
+ 2. make it robust
+"""
+
+import fqterm
+import sys,os,string,time,re
+
+# the pointer to fqtermWindow object
+lp=long(sys.argv[0])
+
+wait_time = 2.0
+
+def txt2html(txt):
+ txt=string.replace(txt,"\n","\n<br>")
+ return string.replace(txt," ","&nbsp;")
+
+def upper_dir(path):
+ if(sys.platform=="win32"): # '\' for win32
+ i=path.rfind("\\",0,-1)
+ else:
+ i=path.rfind("/",0,-1) # '/' for *nix
+ return path[:i+1]
+
+def lower_dir(path, subdir):
+ if(sys.platform=="win32"): # '\' for win32
+ return path+subdir+"\\"
+ else:
+ return path+subdir+"/" # '/' for *nix
+
+def write_html_header(hfile, num):
+ hfile.write("""<html><head>
+ <meta http-equiv="Content-Language" content="zh-cn">
+ <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
+ <title>FQTerm Article Downloader</title>
+ </head>""")
+ hfile.write("<body>")
+ hfile.write("<p><b><h1>FQTerm Article Downloader</h1></b></p>")
+ txt="""<p><p align=center><a href=%d.html>Prevoius</a>
+ <a href=index.html>Index</a>
+ <a href=%d.html>Next</a></p align=center></p>""" % (num-1,num+1)
+ hfile.write(txt)
+ hfile.write("<hr><p></p>\n")
+
+def write_html_ender(hfile,num):
+ hfile.write("<hr><p></p>")
+ txt="""<p><p align=center><a href=%d.html>Prevoius</a>
+ <a href=index.html>Index</a>
+ <a href=%d.html>Next</a></p align=center></p>""" % (num-1,num+1)
+ hfile.write(txt)
+ hfile.write("<p><b>FQTerm --- BBS client based on Qt library</b><p>")
+ hfile.write("""<p><a href=http://code.google.com/p/fqterm>
+ http://code.google.com/p/fqterm</a><p>""")
+ hfile.write("</body>")
+ hfile.write("</html>")
+
+def write_index_header(hfile):
+ hfile.write("""<html><head>
+ <meta http-equiv="Content-Language" content="zh-cn">
+ <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
+ <title>FQTerm Article Downloader</title>
+ </head>""")
+ hfile.write("<p><b><h1>FQTerm Article Downloader</h1></b></p>")
+ hfile.write("""<p><p align=center>
+ <a href=\"../index.html\">Up</a>
+ </p align=center</p>""")
+ hfile.write("<hr><p></p>\n")
+
+def write_index_ender(hfile):
+ hfile.write("<hr><p></p>")
+ hfile.write("""<p><p align=center>
+ <a href=\"../index.html\">Up</a>
+ </p align=center</p>""")
+ hfile.write("<p><b>FQTerm --- BBS client based on Qt library</b><p>")
+ hfile.write("""<p><a href=http://code.google.com/p/fqterm>
+ http://code.google.com/p/fqterm</a><p>""")
+ hfile.write("</body>")
+ hfile.write("</html>")
+
+def get_list_num(str_line):
+ # get the number
+ matchobj = re.search("[0-9]+",str_line)
+ if(matchobj==None):
+ # wrong format
+ return None
+ else:
+ return str_line[matchobj.start():matchobj.end()]
+
+def get_list_categary(str_line):
+ # get the categary
+ matchobj = re.search("\[[^0-9]{6}\]",str_line)
+ if(matchobj==None):
+ # wrong format
+ return None
+ else:
+ return str_line[matchobj.start():matchobj.end()]
+
+def get_list_title(str_line):
+ matchobj = re.search("\[[^0-9]{6}\]",str_line)
+ if(matchobj==None):
+ # wrong format
+ return None
+ else:
+ # get the title
+ return str_line[matchobj.end()+1:]
+
+def down_folder():
+ global path
+ first_num = -1
+ while(1):
+ line=fqterm.caretY(lp)
+ str_line=fqterm.getText(lp,line)
+
+ article_num = get_list_num(str_line)
+ if (first_num == -1):
+ first_num = article_num
+ if(article_num==None):
+ print "Wrong format list"
+ # end the index.html
+ f=open(path+"index.html","a+")
+ write_index_ender(f)
+ f.close()
+ # wrong formated list, leave out
+ print "leave %s" % path
+ fqterm.sendString(lp,'q')
+ path=upper_dir(path)
+ time.sleep(wait_time)
+ return
+
+ article_categary = get_list_categary(str_line)
+ article_title = get_list_title(str_line)
+
+ # download if its file
+ if article_categary == '[文件]':
+ # log in index.html
+ f=open(path+"index.html","a+")
+ f.write("<p><a href="+article_num+".html>")
+ f.write("[文件] "+article_title+"</a></p>\n")
+ f.close()
+ # downlaod and save article
+ f=open(path+article_num+".html","w")
+ fqterm.sendString(lp,'r')
+ time.sleep(wait_time)
+ write_html_header(f,int(article_num))
+ f.write(txt2html(fqterm.getArticle(lp, 100)[0]))
+ f.write("\n")
+ write_html_ender(f,int(article_num))
+ f.close()
+ time.sleep(wait_time)
+ fqterm.sendString(lp,"q")
+ time.sleep(wait_time)
+ # recursive callback if its directory
+ elif article_categary == '[目录]':
+ # log in index.html
+ f=open(path+"index.html","a+")
+ f.write("<p><a href="+article_num+"/index.html>")
+ f.write("[目录] "+article_title+"</a></p>\n")
+ f.close()
+ # make dir and enter
+ path=lower_dir(path,article_num)
+ os.mkdir(path)
+ print "enter %s" % path
+ # create index.html and write the header
+ f=open(path+"index.html","w")
+ write_index_header(f)
+ f.close()
+ # recursive call
+ fqterm.sendString(lp,'r')
+ time.sleep(wait_time)
+ # increase delay when condition not met
+ down_folder()
+ else:
+ print "Unrecognized Categary"
+ # end the index.html
+ f=open(path+"index.html","a+")
+ write_index_ender(f)
+ f.close()
+ # wrong formated list, leave out
+ print "leave %s" % path
+ fqterm.sendString(lp,'q')
+ path=upper_dir(path)
+ time.sleep(wait_time)
+ return
+ str_next=fqterm.getText(lp,line+1)
+ # move cursor down and get the num
+ fqterm.sendString(lp,'j')
+ time.sleep(wait_time)
+ str_next=fqterm.getText(lp,fqterm.caretY(lp))
+ article_num_next = get_list_num(str_next)
+ if(article_num_next==None):
+ print "Wrong format list"
+ # end the index.html
+ f=open(path+"index.html","a+")
+ write_index_ender(f)
+ f.close()
+ # wrong formated list, leave out
+ print "leave %s" % path
+ fqterm.sendString(lp,'q')
+ path=upper_dir(path)
+ time.sleep(wait_time)
+ return
+ # exit current dir when the number of the next one equals or small then last
+ # this may cause problem when the server is extra slow
+ if(int(article_num_next) <= int(article_num)):
+ #print "leaving, because cur: %s < pre: %s" % (article_num_next , article_num)
+ if(path!=path_dir):
+ # end the index.html
+ f=open(path+"index.html","a+")
+ write_index_ender(f)
+ f.close()
+ # leave out
+ print "leave %s" % path
+ fqterm.sendString(lp,'q')
+ path=upper_dir(path)
+ time.sleep(wait_time)
+ return
+
+# NOTE: make sure path ended with '/'(*nix) or '\\'(windowz)
+#path_dir=path="e:\\temp\\test\\"
+path_dir=path="/home/dp2/temp/test/"
+
+# try to save all to home dir
+# path_dir=path=os.environ['HOME']+"/.fqterm/downloads/"+time.ctime()+"/"
+os.makedirs(path)
+
+# enter
+fqterm.sendString(lp,'x')
+time.sleep(wait_time)
+# create index.html and write the header
+f=open(path+"index.html","w")
+write_index_header(f)
+f.close()
+down_folder()
+# end the index.html
+f=open(path+"index.html","a+")
+write_index_ender(f)
+f.close()
+# exit
+fqterm.sendString(lp,'q')
+
diff --git a/res/script/downloadelite.js b/res/script/downloadelite.js
new file mode 100644
index 0000000..b835d6b
--- /dev/null
+++ b/res/script/downloadelite.js
@@ -0,0 +1,207 @@
+fqterm.import("utils.js");
+//NOTE: 1. this file should be in utf8
+// 2. if you cannot enter "BMS", this script may fail.
+//first enter the folder, then start script.
+var timeout = 2000;
+var path = "c:\\elite\\"; //DO NOT miss last slash
+var base_path = path;
+var newlinere;
+if (fqterm.platform() == "Win") {
+ newlinere = /%0D%0A/g;
+} else if (fqterm.platform() == "Mac"){
+ newlinere = /%0D/g;
+} else {
+ newlinere = /%0A/g;
+}
+newlinere = /\r\n|\n|\r/mg;
+//var path = /home/dp2/elite/
+var download = function(filename) {
+ fqterm.sendString("r");
+ sleep(timeout);
+ var article = fqterm.copyArticle();
+ fqterm.sendString("q");
+ sleep(timeout);
+ return article;
+}
+
+var make_html_header = function(num)
+{
+ num = parseInt(num);
+ var result = '<html><head>\n'+
+ '<meta http-equiv="Content-Language" content="zh-cn">\n'+
+ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n'+
+ '<title>FQTerm Article Downloader</title>\n'+
+ '</head>\n'+
+ '<body>\n'+
+ '<p><b><h1>FQTerm Article Downloader</h1></b></p>\n'+
+ '<p><p align=center><a href=' + (num - 1) + '.html>Prevoius</a>\n'+
+ '<a href=index.html>Index</a>\n'+
+ '<a href=' + (num + 1) + '.html>Next</a></p align=center></p>'+
+ '<hr><p></p>\n';
+ return result;
+}
+
+var make_html_ender = function(num)
+{
+ num = parseInt(num);
+ var result = '<hr><p></p>\n'+
+ '<p><p align=center><a href=' + (num - 1) + '.html>Prevoius</a>\n'+
+ '<a href=index.html>Index</a>\n'+
+ '<a href=' + (num + 1) + '.html>Next</a></p align=center></p>\n'+
+ '<p><b>FQTerm --- BBS client based on Qt library</b><p>\n'+
+ '<p><a href=http://code.google.com/p/fqterm>\n'+
+ 'http://code.google.com/p/fqterm</a><p>\n'+
+ '</body>\n'+
+ '</html>\n';
+ return result;
+}
+
+var make_index_header = function() {
+ var result = '<html><head>\n' +
+ '<meta http-equiv="Content-Language" content="zh-cn">\n' +
+ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n' +
+ '<title>FQTerm Article Downloader</title>\n' +
+ '</head>\n' +
+ '<p><b><h1>FQTerm Article Downloader</h1></b></p>\n' +
+ '<p><p align=center>\n' +
+ '<a href=\"../index.html\">Up</a>\n' +
+ '</p align=center</p>\n' +
+ '<hr><p></p>\n\n';
+ return result;
+}
+
+var make_index_ender = function() {
+ var result = '<hr><p></p>\n' +
+ '<p><p align=center>\n' +
+ '<a href=\"../index.html\">Up</a>\n' +
+ '</p align=center</p>\n' +
+ '<p><b>FQTerm --- BBS client based on Qt library</b><p>\n' +
+ '<p><a href=http://code.google.com/p/fqterm>\n' +
+ 'http://code.google.com/p/fqterm</a><p>\n' +
+ '</body>\n' +
+ '</html>\n';
+ return result;
+}
+
+var get_list_num = function(str_line) {
+ // get the number
+ try{
+ var re = /[0-9]+/;
+ var num = re.exec(str_line);
+ return num[0];
+ } catch(err) {
+ return "";
+ }
+}
+
+var get_list_categary = function(str_line) {
+ try{
+ var re = /\[[^0-9]{2}\]/; //utf8!
+ var cat = re.exec(str_line);
+ return cat[0];
+ } catch(err) {
+ return "";
+ }
+}
+
+var get_list_title = function(str_line) {
+ try{
+ var re = /\[[^0-9]{2}\]/; //utf8!
+ var cat = re.exec(str_line);
+ var i = str_line.search(re);
+ return str_line.substr(i + cat[0].length);
+ } catch(err) {
+ return "";
+ }
+}
+
+var txt2html = function(txt) {
+ var result = escape(txt);
+ var re_nlchar;
+ var newline;
+ if(result.indexOf('%0D%0A') > -1){
+ re_nlchar = /%0D%0A/g ;
+ newline = "%0D%0A";
+ }else if(result.indexOf('%0A') > -1) {
+ re_nlchar = /%0A/g ;
+ newline = "%0A";
+ }else if(result.indexOf('%0D') > -1){
+ re_nlchar = /%0D/g ;
+ newline = "%0A";
+ }
+ result = result.replace(re_nlchar, newline + '<br />');
+ result = result.replace(/%20/g, '&nbsp;');
+ return unescape(result);
+}
+
+var upper_dir = function(path) {
+ var spliter;
+ if (fqterm.platform() == "Win") {
+ spliter = '\\';
+ } else {
+ spliter = '/';
+ }
+ if (path.lastIndexOf(spliter) == path.length - 1) {
+ path = path.substr(0, path.length - 1);
+ }
+ var i = path.lastIndexOf(spliter);
+
+ return path.substr(0, i + 1);
+}
+
+var lower_dir = function(path, subdir) {
+ var spliter;
+ if (fqterm.platform() == "Win") {
+ spliter = '\\';
+ } else {
+ spliter = '/';
+ }
+ if (path.lastIndexOf(spliter) != path.length - 1) {
+ path += spliter;
+ }
+ return path + subdir + spliter;
+}
+
+
+var down_folder = function() {
+ fqterm.makePath(path);
+ var h = make_index_header();
+ fqterm.writeFile(path + 'index.html', h);
+ while (true) {
+ var line = fqterm.caretY();
+ var str_line = fqterm.getText(line);
+ var article_num = get_list_num(str_line);
+ var article_category = get_list_categary(str_line);
+ var article_title = get_list_title(str_line);
+ if (article_category == '[文件]') {
+ var a = '<p><a href=' + article_num + '.html>[文件] ' + article_title + '</a></p>\n';
+ fqterm.appendFile(path + "index.html", a);
+ var content = make_html_header(article_num) + txt2html(download()) + '\n' + make_html_ender(article_num);
+ fqterm.writeFile(path + article_num + ".html", content);
+ } else if (article_category == '[目录]') {
+ var a = '<p><a href=' + article_num + '/index.html>[目录] ' + article_title + '</a></p>\n';
+ fqterm.appendFile(path + "index.html", a);
+ path = lower_dir(path, article_num);
+ fqterm.sendString('r');
+ sleep(timeout);
+ down_folder();
+ } else {
+ break;
+ }
+ fqterm.sendString('j');
+ sleep(timeout);
+ var str_next = fqterm.getText(fqterm.caretY());
+ article_num_next = get_list_num(str_next);
+ if (article_num_next == "" || parseInt(article_num_next) <= parseInt(article_num)) {
+ break;
+ }
+ }
+ var e = make_index_ender();
+ fqterm.appendFile(path + 'index.html', e);
+ fqterm.sendString('q');
+ path = upper_dir(path);
+ sleep(timeout);
+}
+//fqterm.sendString('x');
+//sleep(timeout);
+down_folder();
diff --git a/res/script/downloadelite_smth.js b/res/script/downloadelite_smth.js
new file mode 100644
index 0000000..42a9d2f
--- /dev/null
+++ b/res/script/downloadelite_smth.js
@@ -0,0 +1,255 @@
+fqterm.import("utils.js");
+//NOTE: 1. this file should be in utf8
+// 2. if you cannot enter "BMS", this script may fail.
+//first enter the folder, then start script.
+var timeout = 6000;
+var path = "c:\\elite-sex\\"; //DO NOT miss last slash
+var base_path = path;
+
+newlinere = /\r\n|\n|\r/mg;
+//var path = /home/dp2/elite/
+
+var lastline = function() {
+ return fqterm.getText(fqterm.rows() - 1);
+}
+
+var firstline = function() {
+ return fqterm.getText(0);
+}
+
+var currentline = function(){
+ return fqterm.getText(fqterm.caretY());
+}
+
+var download = function(filename) {
+
+ var last_line = lastline();
+ fqterm.sendString("r");
+ var n = 10;
+ while(n--) {
+ sleep(timeout / 10);
+ if (lastline() != last_line) break;
+ }
+ var article = fqterm.copyArticle();
+
+ last_line = lastline();
+ fqterm.sendString("q");
+ n = 10;
+ while(n--) {
+ sleep(timeout / 10);
+ var c = lastline();
+ if (c != last_line) {
+ break;
+ }
+ }
+ return article;
+}
+
+var make_html_header = function(num)
+{
+ num = parseInt(num);
+ var result = '<html><head>\n'+
+ '<meta http-equiv="Content-Language" content="zh-cn">\n'+
+ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n'+
+ '<title>FQTerm Article Downloader</title>\n'+
+ '</head>\n'+
+ '<body>\n'+
+ '<p><b><h1>FQTerm Article Downloader</h1></b></p>\n'+
+ '<p><p align=center><a href=' + (num - 1) + '.html>Prevoius</a>\n'+
+ '<a href=index.html>Index</a>\n'+
+ '<a href=' + (num + 1) + '.html>Next</a></p align=center></p>'+
+ '<hr><p></p>\n';
+ return result;
+}
+
+var make_html_ender = function(num)
+{
+ num = parseInt(num);
+ var result = '<hr><p></p>\n'+
+ '<p><p align=center><a href=' + (num - 1) + '.html>Prevoius</a>\n'+
+ '<a href=index.html>Index</a>\n'+
+ '<a href=' + (num + 1) + '.html>Next</a></p align=center></p>\n'+
+ '<p><b>FQTerm --- BBS client based on Qt library</b><p>\n'+
+ '<p><a href=http://code.google.com/p/fqterm>\n'+
+ 'http://code.google.com/p/fqterm</a><p>\n'+
+ '</body>\n'+
+ '</html>\n';
+ return result;
+}
+
+var make_index_header = function() {
+ var result = '<html><head>\n' +
+ '<meta http-equiv="Content-Language" content="zh-cn">\n' +
+ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n' +
+ '<title>FQTerm Article Downloader</title>\n' +
+ '</head>\n' +
+ '<p><b><h1>FQTerm Article Downloader</h1></b></p>\n' +
+ '<p><p align=center>\n' +
+ '<a href=\"../index.html\">Up</a>\n' +
+ '</p align=center</p>\n' +
+ '<hr><p></p>\n\n';
+ return result;
+}
+
+var make_index_ender = function() {
+ var result = '<hr><p></p>\n' +
+ '<p><p align=center>\n' +
+ '<a href=\"../index.html\">Up</a>\n' +
+ '</p align=center</p>\n' +
+ '<p><b>FQTerm --- BBS client based on Qt library</b><p>\n' +
+ '<p><a href=http://code.google.com/p/fqterm>\n' +
+ 'http://code.google.com/p/fqterm</a><p>\n' +
+ '</body>\n' +
+ '</html>\n';
+ return result;
+}
+
+var get_list_num = function(str_line) {
+ // get the number
+ try{
+ var re = /[0-9]+/;
+ var num = re.exec(str_line);
+ return num[0];
+ } catch(err) {
+ return "";
+ }
+}
+
+var get_list_categary = function(str_line) {
+ try{
+ var re = /\[[^0-9]{2}\]/; //utf8!
+ var cat = re.exec(str_line);
+ return cat[0];
+ } catch(err) {
+ return "";
+ }
+}
+
+var get_list_title = function(str_line) {
+ try{
+ var re = /\[[^0-9]{2}\]/; //utf8!
+ var cat = re.exec(str_line);
+ var i = str_line.search(re);
+ return str_line.substr(i + cat[0].length);
+ } catch(err) {
+ return "";
+ }
+}
+
+var txt2html = function(txt) {
+ var result = escape(txt);
+ var re_nlchar;
+ var newline;
+ if(result.indexOf('%0D%0A') > -1){
+ re_nlchar = /%0D%0A/g ;
+ newline = "%0D%0A";
+ }else if(result.indexOf('%0A') > -1) {
+ re_nlchar = /%0A/g ;
+ newline = "%0A";
+ }else if(result.indexOf('%0D') > -1){
+ re_nlchar = /%0D/g ;
+ newline = "%0A";
+ }
+ result = result.replace(re_nlchar, newline + '<br />');
+ result = result.replace(/%20/g, '&nbsp;');
+ return unescape(result);
+}
+
+var upper_dir = function(path) {
+ var spliter;
+ if (fqterm.platform() == "Win") {
+ spliter = '\\';
+ } else {
+ spliter = '/';
+ }
+ if (path.lastIndexOf(spliter) == path.length - 1) {
+ path = path.substr(0, path.length - 1);
+ }
+ var i = path.lastIndexOf(spliter);
+
+ return path.substr(0, i + 1);
+}
+
+var lower_dir = function(path, subdir) {
+ var spliter;
+ if (fqterm.platform() == "Win") {
+ spliter = '\\';
+ } else {
+ spliter = '/';
+ }
+ if (path.lastIndexOf(spliter) != path.length - 1) {
+ path += spliter;
+ }
+ return path + subdir + spliter;
+}
+
+
+var down_folder = function() {
+ var single = true;
+ if (fqterm.caretY() > 0 && get_list_num(fqterm.getText(fqterm.caretY() - 1)) != "") {
+ single = false;
+ } else if (fqterm.caretY() < fqterm.rows() - 1 && get_list_num(fqterm.getText(fqterm.caretY() + 1)) != "") {
+ single = false;
+ }
+
+ fqterm.makePath(path);
+ var h = make_index_header();
+ fqterm.writeFile(path + 'index.html', h);
+ while (true) {
+ var line = fqterm.caretY();
+ var str_line = fqterm.getText(line);
+ var article_num = get_list_num(str_line);
+ var article_category = get_list_categary(str_line);
+ var article_title = get_list_title(str_line);
+ if (article_category == '[文件]') {
+ var a = '<p><a href=' + article_num + '.html>[文件] ' + article_title + '</a></p>\n';
+ fqterm.appendFile(path + "index.html", a);
+ var content = make_html_header(article_num) + txt2html(download()) + '\n' + make_html_ender(article_num);
+ fqterm.writeFile(path + article_num + ".html", content);
+ } else if (article_category == '[目录]') {
+ var a = '<p><a href=' + article_num + '/index.html>[目录] ' + article_title + '</a></p>\n';
+ fqterm.appendFile(path + "index.html", a);
+ path = lower_dir(path, article_num);
+ var first_line = firstline();
+ fqterm.sendString('r');
+ var n = 10;
+ while(n--) {
+ sleep(timeout / 10);
+ if (firstline() != first_line) break;
+ }
+ down_folder();
+ } else if (article_category == '[错误]') {
+ } else {
+ break;
+ }
+ //fqterm.msgBox(single);
+ if (single) break;
+ var cur_line = currentline();
+ fqterm.sendString('j');
+ var n = 10;
+ while(n--) {
+ sleep(timeout / 10);
+ if (currentline() != cur_line) break;
+ }
+ var str_next = fqterm.getText(fqterm.caretY());
+ article_num_next = get_list_num(str_next);
+ if (article_num_next == "" || parseInt(article_num_next) <= parseInt(article_num)) {
+ break;
+ }
+ }
+ var e = make_index_ender();
+ fqterm.appendFile(path + 'index.html', e);
+ path = upper_dir(path);
+
+
+ var first_line = firstline();
+ fqterm.sendString('q');
+ var n = 10;
+ while(n--) {
+ sleep(timeout / 10);
+ if (firstline() != first_line) break;
+ }
+}
+//fqterm.sendString('x');
+//sleep(timeout);
+down_folder();
diff --git a/res/script/post.js b/res/script/post.js
new file mode 100644
index 0000000..2de0f56
--- /dev/null
+++ b/res/script/post.js
@@ -0,0 +1,17 @@
+fqterm.import("utils.js");
+var path = "c:\\temp\\"; //DO NOT miss last slash here.
+var timeout = 500;
+var filelist = fqterm.readFolder(path);
+for (var i = 0; i < filelist.length; ++i)
+{
+ var filename = filelist[i];
+ var content = fqterm.readFile(path + filename);
+ fqterm.sendParsedString("^p");
+ sleep(timeout);
+ fqterm.sendString(filename);
+ fqterm.sendString("\n\n");
+ sleep(timeout);
+ fqterm.sendString(content);
+ fqterm.sendParsedString("^W\n");
+ sleep(timeout);
+} \ No newline at end of file
diff --git a/res/script/post.py b/res/script/post.py
new file mode 100644
index 0000000..27348f2
--- /dev/null
+++ b/res/script/post.py
@@ -0,0 +1,21 @@
+# coding=UTF-8
+# 连续发文
+
+import fqterm
+import sys, string, random
+
+sessionID=long(sys.argv[0])
+#print "sessionID is %s"%ID
+
+random.seed()
+for j in range(13):
+ i=random.random()*100000
+ print i
+ title='%f只青蛙%f张嘴'%(i,i)
+ content='%f只眼睛%f条腿'%(2*i,4*i)
+ #data=['^p', title, '\n', '\n', content, '^w','\n']
+ fqterm.sendParsedString(sessionID, r'^p%s\n\n%s^w\n'%(title, content) )
+ #for item in data:
+ # SendParsedString(ID, item)
+ # if dataEvents.has_key(ID):
+ # dataEvents[ID].wait()
diff --git a/res/script/postfile.py b/res/script/postfile.py
new file mode 100644
index 0000000..7de8244
--- /dev/null
+++ b/res/script/postfile.py
@@ -0,0 +1,48 @@
+# coding=UTF-8
+
+# 从硬盘文件连续发文
+# for fqterm: we need to add some status check.
+
+import fqterm
+import tools
+import sys, string, random, glob, os, time
+
+ID=long(sys.argv[0])
+#print "sessionID is %s"%ID
+
+random.seed()
+os.chdir(r'/home/dp2/') #主目录
+filenames = glob.glob(r'*.txt') #过滤条件
+#filenames.extend( )
+for n in filenames:
+ print n
+ if len(n)>=5 and n[0:5]=='album': #特例
+ continue
+ #if n[-4:len(n)]!='.txt':
+ # continue
+ f=file(n, 'r')
+ title=f.readline()
+ title=title.strip()
+ while title and title.strip()=='':
+ title=f.readline()
+ title=title.strip()
+ if not title:
+ continue
+ content=f.read()
+
+ if not title or not content:
+ continue
+
+ data=['\x10', title, '\n', '\n', content, '\x17']
+
+ for item in data:
+ fqterm.sendString(ID, item)
+ print item
+ #if dataEvents.has_key(ID):
+ #dataEvents[ID].wait()
+ fqterm.sendString(ID, '\n')
+ #WaitFor(ID, SST_LIST)
+
+ interval=random.random()*7+3
+ #print interval
+ time.sleep(interval)
diff --git a/res/script/search.js b/res/script/search.js
new file mode 100644
index 0000000..a5be08b
--- /dev/null
+++ b/res/script/search.js
@@ -0,0 +1,22 @@
+fqterm.searchSelected = function(engine) {
+
+ var text = encodeURIComponent(String(fqterm.getSelect(false)));
+ var url = "about:blank";
+ engine = engine.toLowerCase();
+ if (engine == "google") {
+ searchUrl = "http://www.google.com/search?client=fqterm&rls=en&q=" + text + "&sourceid=fqterm";
+ } else if (engine == "baidu") {
+ searchUrl = "http://www.baidu.com/s?ie=utf-8&wd=" + text;
+ } else if (engine == "bing") {
+ searchUrl = "http://www.bing.com/search?q=" + text;
+ } else if (engine == "yahoo") {
+ searchUrl = "http://search.yahoo.com/search?ei=UTF-8&p=" + text;
+ } else if (engine == "custom") {
+ fqterm.msgBox("Modify search.js to customize search engine...");
+ return false;
+ }else {
+ return false;
+ }
+ fqterm.openUrl(searchUrl);
+ return true;
+}
diff --git a/res/script/sendmsg.py b/res/script/sendmsg.py
new file mode 100644
index 0000000..4d9ef2f
--- /dev/null
+++ b/res/script/sendmsg.py
@@ -0,0 +1,33 @@
+# send current article to one assigned email address
+# 1. need CJK codec
+import smtplib
+from email.Header import Header
+from email.Message import Message
+import fqterm,sys,string
+
+lp=long(sys.argv[0])
+article=fqterm.getArticle(lp, 100)[0]
+
+from_addr = "mime@email.com"
+to_addr="yours@email.com"
+
+subject = article.split("\n")
+subject = subject[1]
+subject = subject[7:]
+
+mess = Message()
+h = Header(subject,'GB2312')
+mess['Subject']=h
+
+msg = ("Content-Type: text/plain; charset= GB2312\r\n"
+ "From: %s\r\nTo: %s\r\n%s\r\n\r\n"
+ % (from_addr,to_addr, mess.as_string()))
+msg = msg + article
+
+smtp_host = "smtp.email.com"
+server = smtplib.SMTP(smtp_host)
+server.set_debuglevel(1)
+#maybe your smtp need auth
+#server.login(usr,pwd)
+server.sendmail(from_addr,to_addr,msg)
+server.quit()
diff --git a/res/script/system.js b/res/script/system.js
new file mode 100644
index 0000000..a49df9e
--- /dev/null
+++ b/res/script/system.js
@@ -0,0 +1,48 @@
+fqterm.import("utils.js");
+fqterm.mouseEvent = function(type, states, x, y, delta) {
+ if (type == fqterm.MOUSEEVENT.MOUSE_PRESS &&
+ states & fqterm.BUTTONSTATE.LEFT_BUTTON &&
+ states & fqterm.BUTTONSTATE.CTRL) {
+ fqterm.msgBox(fqterm.getFullTextAt(y, x, 1));
+ }
+ return false;
+}
+
+fqterm.detectMenu = function() {
+ fqterm.setMenuRect(1, 3, 20);
+ return false;
+}
+
+fqterm.antiIdle = function() {
+ //fqterm.msgBox("antiIdle");
+ return false;
+}
+
+
+fqterm.onBell = function() {
+ //fqterm.msgBox("onBell");
+}
+
+fqterm.autoReply = function() {
+ //fqterm.msgBox("autoReply");
+ return false;
+}
+
+
+fqterm.dataEvent = function() {
+ //fqterm.msgBox("data event");
+}
+
+fqterm.keyEvent = function(type, states, key) {
+// if (type == fqterm.KEYEVENT.KEY_PRESS &&
+// states & fqterm.BUTTONSTATE.CTRL && key) {
+// fqterm.msgBox(key);
+// }
+}
+
+
+var timeEvent = function() {
+ //fqterm.msgBox("haha");
+}
+var id = fqterm.setInterval(1000, timeEvent);
+//fqterm.clearInterval(id); \ No newline at end of file
diff --git a/res/script/system.py b/res/script/system.py
new file mode 100644
index 0000000..5305995
--- /dev/null
+++ b/res/script/system.py
@@ -0,0 +1,103 @@
+# coding=UTF-8
+"""
+This information is used to track the changes following this format
+ dd/mm/yy Author
+ * changes
+ * ...
+
+ 10/09/04 kingson
+ * merge code for ytht.net preview by cppgx
+ 08/09/04 kingson
+ * add this changelog information
+"""
+import fqterm, string
+import re, urllib
+
+"""
+get url from ytht
+"""
+
+def previewYTHT(lp):
+ URL=fqterm.getURL(lp)
+ if(URL=='' or URL==None):
+ return
+ if re.search('http://ytht.net/Ytht.Net' \
+ '(\S+)/con\?B=(\d+)&F=M\.(\d+)\.A', URL) != None:
+ # ytht artical URL
+ print 'Analizing ytht artical URL'
+ f_con = urllib.urlopen(URL)
+ con = f_con.read()
+ f_con.close()
+ m_con = re.search('src=\"http://162.105.31.(\d+)(/|:(\d+)/)' \
+ 'Ytht.Net/boards/(\d+)/M\.(\d+)\.A\+\d+\"', con)
+ if m_con != None:
+ URL1 = con[(m_con.start() + 5):(m_con.end() - 1)]
+ print 'URL1 = %s' % URL1
+ f_con1 = urllib.urlopen(URL1)
+ con1_lines = f_con1.readlines()
+ f_con1.close()
+ x = range(0, len(con1_lines))
+ for i in x:
+ m_con1 = re.search('<a href=\'http://162.105.31.(\d+)' \
+ '(/|:(\d+)/)Ytht.Net/attach/bbscon/(\S+)\?B=(\d+)&amp;' \
+ 'F=M\.(\d+)\.A&amp;attachpos=(\d+)&amp;attachname=/(\S+)\'', \
+ con1_lines[i])
+ if m_con1 != None:
+ URL2 = con1_lines[i][(m_con1.start() + 9): \
+ (m_con1.end() - 1)].replace('&amp;', '&')
+ print 'URL2 = %s' % URL2
+ fqterm.previewImage(lp, URL2)
+
+"""
+this is called when beep received
+"""
+def onBell(lp):
+ pass
+
+"""
+this is called when ready to autoreply
+"""
+def autoReply(lp):
+ reply = "I am the auto replier, please wait..."
+ reply_key = fqterm.getReplyKey(lp)
+ if(reply_key==''):
+ fqterm.sendParsedString(lp,"^Z")
+ else:
+ fqterm.sendParsedString(lp,reply_key)
+ fqterm.sendString(lp,reply)
+ fqterm.sendParsedString(lp,"^M")
+
+"""
+this is called when no activity after certain seconds,
+which is set in AddressBook dialog
+"""
+def antiIdle(lp):
+ fqterm.sendParsedString(lp,"^@")
+ print "antiIdle"
+
+"""
+whenever there is a mouse event
+type 0-press 1-release 2-move 3-double click 4-wheel
+state 0x01-left 0x02-right 0x04-middle 0x08-alt 0x10-control 0x20-shift
+cx/cy cursor position x/y in character
+"""
+def mouseEvent(lp, type, state, x, y, delta):
+ # left click + control to preview image
+ if type==0 and state==0x11:
+ previewYTHT(lp)
+
+"""
+whenever there is a key event
+type 0-press 1-release
+state 0x08-alt 0x10-control 0x20-shift
+key refer to Qt/Doc
+"""
+def keyEvent(lp, type, state, key):
+ pass
+
+"""
+whenever there is data from server after decoding
+and displaying
+"""
+def dataEvent(lp):
+ pass
diff --git a/res/script/test.js b/res/script/test.js
new file mode 100644
index 0000000..3018d8c
--- /dev/null
+++ b/res/script/test.js
@@ -0,0 +1,4 @@
+//fqterm.msgBox(fqterm.getAddress())
+//if (!fqterm.isConnected()) fqterm.reconnect()
+//fqterm.previewImage("http://img1.kaixin001.com.cn/i2/kaixinlogo.gif")
+fqterm.msgBox(fqterm.copyArticle());
diff --git a/res/script/tools.py b/res/script/tools.py
new file mode 100644
index 0000000..65320a0
--- /dev/null
+++ b/res/script/tools.py
@@ -0,0 +1,65 @@
+# coding=UTF-8
+# various tools
+
+# Left Arrow <--
+def sendLeft(fqterm,lp):
+ fqterm.sendParsedString(lp,"^[[C")
+# Left Arrow -->
+def sendRight(fqterm,lp):
+ fqterm.sendParsedString(lp,"^[[D")
+# Up Arrow
+def sendUp(fqterm,lp):
+ fqterm.sendParsedString(lp,"^[[A")
+# Down Arrow
+def sendDown(fqterm,lp):
+ fqterm.sendParsedString(lp,"^[[B")
+# Page Up
+def sendPageUp(fqterm,lp):
+ fqterm.sendParsedString(lp,"^[[5")
+# Page Down
+def sendPageDown(fqterm,lp):
+ fqterm.sendParsedString(lp,"^[[6")
+# Enter
+def sendDown(fqterm,lp):
+ fqterm.sendParsedString(lp,"^M")
+
+# Page State
+# Firebird BBS only
+def getPageState(fqterm,lp):
+ pageState="unknown"
+ lastline=fqterm.getText(lp,fqterm.rows(lp)-1)
+ if(lastline.find("阅读文章")!=-1 or
+ lastline.find("阅读精华区")!=-1 or
+ lastline.find("下面还有")!=-1 or
+ lastline.find("回信")!=-1):
+ pageState="reading"
+ elif(lastline.find("时间")!=-1 and
+ lastline.find("使用者")!=-1):
+ pageState="list"
+
+ return pageState
+
+# analyze article list
+# return a dictionary
+# {"num":xxx,"sign":"","id":"","date":"","title":""}
+def getListInfo(text):
+ lst=text.split()
+ info["num"]=long(lst[0])
+ info["sign"]=lst[1]
+ info["id"]=lst[2]
+ info["date"]=lst[3]+lst[4]
+ info["title"]=lst[5]
+ return info
+
+# get the current user ID
+# only for FireBird BBS
+def getCurrentID(fqterm,lp):
+ text = fqterm.getText(lp,fqterm.rows(lp)-1)
+ if(text.find("使用者")==-1):
+ return
+ lst = string.split(text,"]")
+ text = lst[2]
+ lst = string.split(text,"[")
+ return lst[1]
+
+
diff --git a/res/script/utils.js b/res/script/utils.js
new file mode 100644
index 0000000..c13202c
--- /dev/null
+++ b/res/script/utils.js
@@ -0,0 +1,46 @@
+//script function names:
+//antiIdle() called on antiIdle, if this function exists, the embedded antiIdle procedure will not be called. (use fqterm.isAntiIdle() to get info.)
+//onBell() called on bell received. if this callback exists, the autoReply procedure will not be started. (use fqterm.isAutoReply() to get info.)
+//autoReply() (deprecated) called on autoReply, if this callback exists, the embedded autoReply procedure will not be called
+//dataEvent() called when contents in buffer changed. (after onBell, you will definitely receive one)
+//keyEvent(type(key event type), states (OR flags), key (key code)) called when keyevent received.
+//mouseEvent(type(mouse event type), states (OR flags), x, y, delta(for wheel)) called when mouseevent received. x, y are in term coordinates. If this callback exists, the embedded mouse/wheel support will be disabled (click to read article/enter menu), selecting/right click menu will still be there.
+//detectMenu() set menu rect here and return true to override the embedded menu selection rect. (call fqterm.setMenuRect()). and the mouse click on article, menu, ... will not take effect. you need to implement them in your mouse event.
+
+
+sleep = function(ms) {
+ var originInterval = fqterm.getUIEventInterval();
+ fqterm.setUIEventInterval(1);
+ var start = new Date().getTime();
+ while(true) {
+ if(new Date().getTime() - start > ms) break;
+ }
+ fqterm.setUIEventInterval(originInterval);
+}
+
+
+//script key event type
+fqterm.KEYEVENT = {
+ UNKNOWN : -1,
+ KEY_PRESS : 0
+}
+
+//script mouse event type
+fqterm.MOUSEEVENT = {
+ UNKNOWN : -1,
+ MOUSE_PRESS : 0,
+ MOUSE_RELEASE : 1,
+ MOUSE_MOVE : 2,
+ MOUSE_DBCLICK : 3,
+ WHEEL : 4
+}
+
+//script button state & key modifier
+fqterm.BUTTONSTATE = {
+ LEFT_BUTTON : 0x01,
+ RIGHT_BUTTON : 0x02,
+ MID_BUTTON : 0x04,
+ ALT : 0x08,
+ CTRL : 0x10,
+ SHIFT : 0x20
+}
diff --git a/res/script/weiboshare.js b/res/script/weiboshare.js
new file mode 100644
index 0000000..1ca9f92
--- /dev/null
+++ b/res/script/weiboshare.js
@@ -0,0 +1,51 @@
+
+var text = String(fqterm.getSelect(false));
+var url = String(fqterm.getURL());
+
+/*
+var sharejs = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n' +
+ '<html xmlns="http://www.w3.org/1999/xhtml">\n' +
+ '<head>\n' +
+ '<meta http-equiv="Content-type" content="text/html;charset=UTF-8">\n' +
+ '</head>\n' +
+ '<body onload="simulateclick()">\n' +
+ "<script type=\"text/javascript\" charset=\"utf-8\">\n(function(){\nvar _w = 142 , _h = 32;" +
+ "var param = {\nurl:location.href,\n" +
+ "type:'4',\n" +
+ "count:'0', \n" +
+ "appkey:'',\n" +
+ "title:'%1',\n" +
+ "pic:'%2',\n" +
+ "ralateUid:'2868108420',\n" +
+ "language:'zh_cn', \n" +
+ "rnd:new Date().valueOf()\n}\n" +
+ "var temp = [];\nfor( var p in param ){\ntemp.push(p + '=' + encodeURIComponent( param[p] || '' ) )\n}\n" +
+ "document.write('<iframe allowTransparency=\"true\" frameborder=\"0\" scrolling=\"no\" src=\"http://hits.sinajs.cn/A1/weiboshare.html?' + temp.join('&') + '\"" +
+ " width=\"'+ _w+'\" height=\"'+_h+'\"></iframe>')\n})()\n";
+ sharejs = sharejs + " </script>\n </body>\n </html>\n";
+ fqterm.writeFile("tmp.html", sharejs);
+*/
+
+var picUrl = "";
+
+var pattern = new RegExp('.+\\.(png|jpg|gif|bmp)$', 'i');
+if (pattern.test(url)) {
+ picUrl = url;
+} else {
+ text = text + ' ' + url;
+}
+
+shareurl = 'http://v.t.sina.com.cn/share/share.php?title=' + encodeURIComponent(removeSpecial(text));
+shareurl= shareurl + '&pic=' + encodeURIComponent(picUrl);
+shareurl= shareurl + '&ralateUid=2868108420&url=' + encodeURIComponent("D:\Test\test.html");
+
+
+fqterm.openUrl(shareurl);
+function removeSpecial(str) {
+ var res = str.replace(/"/g, '\\\"');
+ res = res.replace(/'/g, '\\\'');
+ res = res.replace(/\\/g, '\\\\');
+ res = res.replace(/\n/g, ' ');
+ res = res.replace(/\r/g, '');
+ return res;
+}