HTMLv 0.99.5: Condition Script

git-svn-id: svn://kolibrios.org@4417 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-12-29 12:48:06 +00:00
parent 3fe0fbddb3
commit bcb5772288
5 changed files with 122 additions and 38 deletions

View File

@ -1,10 +1,9 @@
int downloader_id; int downloader_id;
dword dword buf;
buf, dword filesize;
filesize, dword blink;
blink;
#define URL param #define URL param
@ -12,9 +11,9 @@ int mouse_twb;
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
scroll_bar scroll_wv = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; scroll_bar scroll_wv = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
char editURL[sizeof(URL)], char editURL[sizeof(URL)];
page_links[12000], char page_links[12000];
header[2048]; char header[2048];
@ -33,27 +32,28 @@ struct TWebBrowser {
}; };
TWebBrowser WB1; TWebBrowser WB1;
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
link, ignor_text, li_tab, cur_encoding, text_align; link, ignor_text, cur_encoding, text_align;
byte condition_text_active, condition_text_val, condition_href, condition_max;
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
dword text_colors[300], dword text_colors[300];
text_color_index, dword text_color_index;
link_color, dword link_color;
bg_color; dword bg_color;
int stroka, int stroka;
stolbec, int stolbec;
tab_len, int tab_len;
anchor_line_num; int anchor_line_num;
char line[500], char line[500];
tag[100], char tag[100];
tagparam[10000], char tagparam[10000];
parametr[1200], char parametr[1200];
options[4096], char options[4096];
anchor[256]; char anchor[256];
#include "..\TWB\history.h" #include "..\TWB\history.h"
#include "..\TWB\colors.h" #include "..\TWB\colors.h"
@ -202,7 +202,9 @@ void TWebBrowser::ParseHTML(dword bword){
if (blink<400) blink=400; else for ( ; blink>400; blink--;) DeleteButton(blink); if (blink<400) blink=400; else for ( ; blink>400; blink--;) DeleteButton(blink);
b_text = i_text = u_text = s_text = blq_text = b_text = i_text = u_text = s_text = blq_text =
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab =
condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
condition_max = 10;
text_align = ALIGN_LEFT; text_align = ALIGN_LEFT;
link_color = 0x0000FF; link_color = 0x0000FF;
bg_color = 0xFFFFFF; bg_color = 0xFFFFFF;
@ -223,7 +225,8 @@ void TWebBrowser::ParseHTML(dword bword){
for ( ; buf+filesize > bword; bword++;) for ( ; buf+filesize > bword; bword++;)
{ {
bukva = ESBYTE[bword]; bukva = ESBYTE[bword];
if (ignor_text) && (bukva<>'<') continue; if (ignor_text) && (bukva!='<') continue;
if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
switch (bukva) switch (bukva)
{ {
case 0x0a: case 0x0a:
@ -263,8 +266,7 @@ void TWebBrowser::ParseHTML(dword bword){
bukva = ESBYTE[bword]; bukva = ESBYTE[bword];
chrcat(#tag, bukva); chrcat(#tag, bukva);
} }
bukva = GetUnicodeSymbol(); if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
if (bukva) goto DEFAULT_MARK;
break; break;
case '<': case '<':
bword++; //ïðîìîòàåì ñèìâîë < bword++; //ïðîìîòàåì ñèìâîë <
@ -304,6 +306,10 @@ void TWebBrowser::ParseHTML(dword bword){
strlwr(#tag); strlwr(#tag);
strlwr(#tagparam); strlwr(#tagparam);
if (condition_text_active) && (condition_text_val != condition_href)
{
if (strcmp(#tag, "/condition")!=0) break;
}
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
@ -410,6 +416,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
if (!chTag("body")) if (!chTag("body"))
{ {
do{ do{
if (!strcmp(#parametr, "condition_max=")) { condition_max = options[0]-'0'; debugi(condition_max); }
if (!strcmp(#parametr, "link=")) link_color = GetColor(#options); if (!strcmp(#parametr, "link=")) link_color = GetColor(#options);
if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options); if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
if (!strcmp(#parametr, "bgcolor=")) if (!strcmp(#parametr, "bgcolor="))
@ -544,6 +551,12 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
TextGoDown(left1, top1, width1); TextGoDown(left1, top1, width1);
return; return;
} }
if (!chTag("condition"))
{
condition_text_active = rez;
if (rez) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
return;
}
if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
{ {
li_text = rez; li_text = rez;

View File

@ -73,6 +73,13 @@
òàáû. Êîå-êàêèå ñèìâîëû: &quot; &amp; &lt; &gt; &#149; òàáû. Êîå-êàêèå ñèìâîëû: &quot; &amp; &lt; &gt; &#149;
&nbsp; &copy; &reg; &bdquo; &ldquo; &#151; ¯æà÷îê ³íøîãî áîêó ð. ªâôðàò ç'¿â ´ðóíò òà ºâðåéñüêèé ´åðáàëàéô. &nbsp; &copy; &reg; &bdquo; &ldquo; &#151; ¯æà÷îê ³íøîãî áîêó ð. ªâôðàò ç'¿â ´ðóíò òà ºâðåéñüêèé ´åðáàëàéô.
<condition show_if=1>
<p>61055,&nbsp; &#1075;.
&#1061;&#1072;&#1088;&#1100;&#1082;&#1086;&#1074;, &#1091;&#1083;.&nbsp; &#1050;&#1088;&#1072;&#1089;&#1085;&#1086;&#1079;&#1085;&#1072;&#1084;&#1077;&#1085;&#1085;&#1072;&#1103;, 16</SPAN>,&nbsp; &#1088;&#1072;&#1076;&#1080;&#1086;&#1092;&#1080;&#1079;&#1080;&#1095;&#1077;&#1089;&#1082;&#1080;&#1081;
&#1082;&#1086;&#1088;&#1087;&#1091;&#1089; &#1085;&#1072; &#1090;&#1077;&#1088;&#1088;&#1080;&#1090;&#1086;&#1088;&#1080;&#1080; &#1053;&#1058;&#1059; «&#1061;&#1055;&#1048;»
</p>
</condition>
<hr color="#758999"> <hr color="#758999">
<center>Zhitomyr 2008-2014</center> <center>Zhitomyr 2008-2014</center>

View File

@ -26,11 +26,13 @@
#include "img\URLgoto.txt"; #include "img\URLgoto.txt";
#ifdef LANG_RUS #ifdef LANG_RUS
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.31"; char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.5";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­" ?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
#else #else
char version[]=" Text-based Browser 0.99.31"; char version[]=" Text-based Browser 0.99.5";
?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last"
#endif #endif
proc_info Form; proc_info Form;
@ -338,19 +340,30 @@ void ProcessLinks(int id)
{ {
GetURLfromPageLinks(id); GetURLfromPageLinks(id);
//$1 - Condition Script
if (URL[0] == '$')
{
if (URL[1]=='-') && (condition_href) condition_href--;
if (URL[1]=='+')
{
if (condition_href<condition_max) condition_href++; else notify(T_LAST_SLIDE);
}
if (URL[1]!='-') && (URL[1]!='+') condition_href = atoi(#URL+1);
strcpy(#URL, BrowserHistory.CurrentUrl());
WB1.ShowPage();
return;
}
//#1 //#1
if (URL[0] == '#') if (URL[0] == '#')
{ {
strcpy(#anchor, #URL+strrchr(#URL, '#')); strcpy(#anchor, #URL+strrchr(#URL, '#'));
strcpy(#URL, BrowserHistory.CurrentUrl()); strcpy(#URL, BrowserHistory.CurrentUrl());
WB1.list.first=WB1.list.count-WB1.list.visible; WB1.list.first=WB1.list.count-WB1.list.visible;
WB1.ShowPage(); WB1.ShowPage();
return; return;
} }
//liner.ru#1 //liner.ru#1
if (strrchr(#URL, '#')<>-1) if (strrchr(#URL, '#')!=-1)
{ {
strcpy(#anchor, #URL+strrchr(#URL, '#')); strcpy(#anchor, #URL+strrchr(#URL, '#'));
URL[strrchr(#URL, '#')-1] = 0x00; URL[strrchr(#URL, '#')-1] = 0x00;

View File

@ -84,6 +84,11 @@ llist letter_view;
#include "parselist.c" #include "parselist.c"
/* TWB integration */
char version[]=" WebView 0.1";
#include "../TWB/TWB.c"
void main() void main()
{ {
mem_Init(); mem_Init();

View File

@ -5,8 +5,9 @@ void ParseMail()
dword line_off, new_buf; dword line_off, new_buf;
char tline[256]; char tline[256];
if ( mailend-mailstart > 9) && (strncmp(mailend-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a if ( mailend-mailstart > 9) if (strncmp(mailend-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a
{ {
aim = STOP;
mailend -= 5; mailend -= 5;
DSBYTE[mailend] = '\0'; DSBYTE[mailend] = '\0';
if (strstr(mailstart, "+OK")!=mailstart) if (strstr(mailstart, "+OK")!=mailstart)
@ -16,9 +17,7 @@ void ParseMail()
debug("GET_ANSWER_RETR != +OK, retry GET_ANSWER_RETR"); debug("GET_ANSWER_RETR != +OK, retry GET_ANSWER_RETR");
return; return;
} }
aim=NULL;
mailsize = mailend - mailstart; mailsize = mailend - mailstart;
debug("Getting QP"); debug("Getting QP");
if (strstri(mailstart, "quoted-printable")!=0) if (strstri(mailstart, "quoted-printable")!=0)
{ {
@ -33,13 +32,15 @@ void ParseMail()
mailend = mailsize + mailstart; mailend = mailsize + mailstart;
} }
} }
debug("ProcessBase64");
ProcessBase64();
debug("GetHeaders: From, To, Date, Subject"); debug("GetHeaders: From, To, Date, Subject");
GetHeader(#from, "\nFrom:"); GetHeader(#from, "\nFrom:");
GetHeader(#to, "\nTo:"); GetHeader(#to, "\nTo:");
GetHeader(#date, "\nDate:"); GetHeader(#date, "\nDate:");
GetHeader(#subj, "\nSubject:"); GetHeader(#subj, "\nSubject:");
debug("Get mdata"); debug("Get mdata");
mdata = strstr(mailstart, "\x0a\x0d") + 3; // 0x0d 0x0a, 0x0a mdata = strstr(mailstart, "\x0a\x0d") + 3;
debug("ConvertToDOS"); debug("ConvertToDOS");
ConvertToDOS(mdata, mailstart); ConvertToDOS(mdata, mailstart);
debug("FromHTMLtoTXT"); debug("FromHTMLtoTXT");
@ -151,6 +152,7 @@ void GetHeader(dword workstr, searchstr)
int q_start, b_start; int q_start, b_start;
strcpyb(mailstart, workstr, searchstr, "\n"); strcpyb(mailstart, workstr, searchstr, "\n");
/*
debug(searchstr); debug(searchstr);
debug(workstr); debug(workstr);
if (strlen(workstr)<8) return; if (strlen(workstr)<8) return;
@ -173,4 +175,48 @@ void GetHeader(dword workstr, searchstr)
strcpy(workstr, #tmpbuf); strcpy(workstr, #tmpbuf);
} }
if (strlen(workstr)+10*6-Form.cwidth>0) { workstr=Form.cwidth/6+workstr-12; DSBYTE[workstr]='\0';} if (strlen(workstr)+10*6-Form.cwidth>0) { workstr=Form.cwidth/6+workstr-12; DSBYTE[workstr]='\0';}
*/
} }
void ProcessBase64()
{
int b_start, b_end, b_size, b_buf;
int clean_mailstart;
b_start = strstr(mailstart, "?B?");
debug("b_size");
debugi(b_start);
if (b_start)
{
b_end = strstr(b_start, "?=");
debug("b_end");
debugi(b_end);
b_size = b_end - b_start;
debug("b_size");
debugi(b_size);
b_buf = malloc(b_size);
strcpyb(mailstart, b_buf, "?B?", "?=");
debug("b_buf");
debug(b_buf);
base64_decode stdcall (b_buf, b_buf, b_size-3);
ConvertToDOS(b_buf, mailstart);
if (b_size<strlen(b_buf)) notify("base64 overflow");
clean_mailstart = malloc(strlen(mailstart));
strlcpy(clean_mailstart, mailstart, b_start-mailstart);
strcat(clean_mailstart, b_buf);
strcat(clean_mailstart, b_end+2);
free(b_buf);
free(mailstart);
mailsize = strlen(clean_mailstart);
mailstart = clean_mailstart;
mailend = mailstart + mailsize;
ProcessBase64();
}
}
//