Subversion Repositories Kolibri OS

Rev

Rev 5685 | Rev 5704 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5685 Rev 5690
1
//HTML Viewer in C--
1
//HTML Viewer in C--
2
//Copyright 2007-2013 by Veliant & Leency
2
//Copyright 2007-2013 by Veliant & Leency
3
//Asper, lev, Lrz, Barsuk, Nable...
3
//Asper, lev, Lrz, Barsuk, Nable...
4
//home icon - rachel fu, GPL licence
4
//home icon - rachel fu, GPL licence
5
 
5
 
6
#ifndef AUTOBUILD
6
#ifndef AUTOBUILD
7
	#include "lang.h--"
7
	#include "lang.h--"
8
#endif
8
#endif
9
 
9
 
10
//libraries
10
//libraries
11
#define MEMSIZE 0x100000
11
#define MEMSIZE 0x100000
12
#include "..\lib\strings.h"
12
#include "..\lib\strings.h"
13
#include "..\lib\gui.h"
13
#include "..\lib\gui.h"
14
#include "..\lib\encoding.h"
-
 
15
#include "..\lib\file_system.h"
14
#include "..\lib\file_system.h"
16
#include "..\lib\mem.h"
15
#include "..\lib\mem.h"
17
#include "..\lib\draw_buf.h"
16
#include "..\lib\draw_buf.h"
18
#include "..\lib\list_box.h"
17
#include "..\lib\list_box.h"
19
#include "..\lib\cursor.h"
18
#include "..\lib\cursor.h"
20
 
19
 
21
//*.obj libraries
20
//*.obj libraries
22
#include "..\lib\obj\box_lib.h"
21
#include "..\lib\obj\box_lib.h"
23
#include "..\lib\obj\libio_lib.h"
22
#include "..\lib\obj\libio_lib.h"
24
#include "..\lib\obj\libimg_lib.h"
23
#include "..\lib\obj\libimg_lib.h"
25
#include "..\lib\obj\http.h"
24
#include "..\lib\obj\http.h"
-
 
25
#include "..\lib\obj\iconv.h"
26
 
26
 
27
//useful patterns
27
//useful patterns
28
#include "..\lib\patterns\libimg_load_skin.h"
28
#include "..\lib\patterns\libimg_load_skin.h"
29
 
29
 
30
char homepage[] = FROM "html\\homepage.htm";
30
char homepage[] = FROM "html\\homepage.htm";
31
 
31
 
32
#ifdef LANG_RUS
32
#ifdef LANG_RUS
33
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.15";
33
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.16";
34
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
34
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
35
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
35
	?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
36
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
36
	char loading[] = "‡ £à㧪  áâà ­¨æë...
";
37
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
37
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
38
	char accept_language[]= "Accept-Language: ru\n";
38
	char accept_language[]= "Accept-Language: ru\n";
39
#else
39
#else
40
	char version[]=" Text-based Browser 1.15";
40
	char version[]=" Text-based Browser 1.16";
41
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
41
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
42
	?define T_LAST_SLIDE "This slide is the last"
42
	?define T_LAST_SLIDE "This slide is the last"
43
	char loading[] = "Loading...
";
43
	char loading[] = "Loading...
";
44
	char page_not_found[] = FROM "html\page_not_found_en.htm";
44
	char page_not_found[] = FROM "html\page_not_found_en.htm";
45
	char accept_language[]= "Accept-Language: en\n";	
45
	char accept_language[]= "Accept-Language: en\n";	
46
#endif
46
#endif
47
 
47
 
48
 
48
 
49
 
49
 
50
proc_info Form;
50
proc_info Form;
51
#define WIN_W 799
51
#define WIN_W 799
52
#define WIN_H 559
52
#define WIN_H 559
53
 
53
 
54
char search_path[]="http://nigma.ru/index.php?s=";
54
char search_path[]="http://nigma.ru/index.php?s=";
55
char str_location[]="location\0";
55
char str_location[]="location\0";
56
int redirected = 0;
56
int redirected = 0;
57
 
57
 
58
char stak[4096];
58
char stak[4096];
59
 
59
 
60
int action_buf;
60
int action_buf;
61
 
61
 
62
dword http_transfer = 0;
62
dword http_transfer = 0;
63
dword http_buffer;
63
dword http_buffer;
64
 
64
 
65
dword TAB_H = false; //19;
65
dword TAB_H = false; //19;
66
dword TAB_W = 150;
66
dword TAB_W = 150;
67
dword TOOLBAR_H = 31; //50;
67
dword TOOLBAR_H = 31; //50;
68
dword STATUSBAR_H = 15;
68
dword STATUSBAR_H = 15;
69
dword col_bg;
69
dword col_bg;
70
dword panel_color;
70
dword panel_color;
71
dword border_color;
71
dword border_color;
72
 
72
 
73
progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
73
progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
74
byte souce_mode = false;
74
byte souce_mode = false;
75
 
75
 
76
#include "..\TWB\TWB.c"
76
#include "..\TWB\TWB.c"
77
#include "menu_rmb.h"
77
#include "menu_rmb.h"
78
#include "history.h"
78
#include "history.h"
79
#include "show_src.h"
79
#include "show_src.h"
80
#include "network_get.h"
80
#include "network_get.h"
81
#include "downloader.h"
81
#include "downloader.h"
82
 
82
 
83
char editURL[sizeof(URL)];
83
char editURL[sizeof(URL)];
84
int	mouse_twb;
84
int	mouse_twb;
85
edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
85
edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
86
 
86
 
87
#define URL_SERVICE_HISTORY "WebView://history"
87
#define URL_SERVICE_HISTORY "WebView://history"
88
#define URL_SERVICE_HOME "WebView://home"
88
#define URL_SERVICE_HOME "WebView://home"
89
#define URL_SERVICE_SOURCE "WebView://source:"
89
#define URL_SERVICE_SOURCE "WebView://source:"
90
 
90
 
91
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
91
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
92
 
92
 
93
libimg_image skin;
93
libimg_image skin;
94
 
94
 
95
int SetSkinColors()
95
int SetSkinColors()
96
{
96
{
97
	dword image_data;
97
	dword image_data;
98
	image_data = DSDWORD[skin.image+24];
98
	image_data = DSDWORD[skin.image+24];
99
	col_bg = DSDWORD[image_data];
99
	col_bg = DSDWORD[image_data];
100
	panel_color  = DSDWORD[skin.w*4*4 + image_data];
100
	panel_color  = DSDWORD[skin.w*4*4 + image_data];
101
	border_color = DSDWORD[skin.w*4*7 + image_data];
101
	border_color = DSDWORD[skin.w*4*7 + image_data];
102
	wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
102
	wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
103
	$and col_bg, 0x00ffffff
103
	$and col_bg, 0x00ffffff
104
	$and panel_color, 0x00ffffff
104
	$and panel_color, 0x00ffffff
105
	$and border_color, 0x00ffffff
105
	$and border_color, 0x00ffffff
106
	$and wv_progress_bar.progress_color, 0x00ffffff
106
	$and wv_progress_bar.progress_color, 0x00ffffff
107
}
107
}
108
 
108
 
109
void DrawProgress()
109
void DrawProgress()
110
{
110
{
111
	unsigned long btn;
111
	unsigned long btn;
112
	//progressbar_draw stdcall(#wv_progress_bar);
112
	//progressbar_draw stdcall(#wv_progress_bar);
113
	wv_progress_bar.width = wv_progress_bar.left = 0;
113
	wv_progress_bar.width = wv_progress_bar.left = 0;
114
	if (http_transfer == 0) return;
114
	if (http_transfer == 0) return;
115
	if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
115
	if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
116
	DrawBar(address_box.left-1, address_box.top+14, btn, 2, wv_progress_bar.progress_color);
116
	DrawBar(address_box.left-1, address_box.top+14, btn, 2, wv_progress_bar.progress_color);
117
}
117
}
118
 
118
 
119
 
119
 
120
void main()
120
void main()
121
{
121
{
122
	unsigned long key, btn;
122
	unsigned long key, btn;
123
	int half_scroll_size;
123
	int half_scroll_size;
124
	int scroll_used=0, show_menu;
124
	int scroll_used=0, show_menu;
125
	
125
	
126
	CursorPointer.Load(#CursorFile);
126
	CursorPointer.Load(#CursorFile);
127
	load_dll(boxlib, #box_lib_init,0);
127
	load_dll(boxlib, #box_lib_init,0);
128
	load_dll(libio, #libio_init,1);
128
	load_dll(libio, #libio_init,1);
129
	load_dll(libimg, #libimg_init,1);
129
	load_dll(libimg, #libimg_init,1);
130
	load_dll(libHTTP, #http_lib_init,1);
130
	load_dll(libHTTP, #http_lib_init,1);
-
 
131
	load_dll(iconv_lib, #iconv_open,0);
131
	Libimg_LoadImage(#skin, abspath("wv_skin.png"));
132
	Libimg_LoadImage(#skin, abspath("wv_skin.png"));
132
	SetSkinColors();
133
	SetSkinColors();
133
	
134
	
134
	WB1.DrawBuf.zoom = 1;
135
	WB1.DrawBuf.zoom = 1;
135
	Form.width=WIN_W;
136
	Form.width=WIN_W;
136
	Form.height=WIN_H;
137
	Form.height=WIN_H;
137
	SetElementSizes();
138
	SetElementSizes();
138
	if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
139
	if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
139
	OpenPage();
140
	OpenPage();
140
 
141
 
141
	CreateDir("/tmp0/1/downloads");
142
	CreateDir("/tmp0/1/downloads");
142
 
143
 
143
	SetEventMask(0xa7);
144
	SetEventMask(0xa7);
144
	BEGIN_LOOP_APPLICATION:
145
	BEGIN_LOOP_APPLICATION:
145
		WaitEventTimeout(2);
146
		WaitEventTimeout(2);
146
		switch(EAX & 0xFF)
147
		switch(EAX & 0xFF)
147
		{
148
		{
148
			CASE evMouse:
149
			CASE evMouse:
149
				if (!CheckActiveProcess(Form.ID)) break;
150
				if (!CheckActiveProcess(Form.ID)) break;
150
				//Edit URL
151
				//Edit URL
151
				edit_box_mouse stdcall (#address_box);
152
				edit_box_mouse stdcall (#address_box);
152
				mouse.get();
153
				mouse.get();
153
				//Links hover
154
				//Links hover
154
				if (mouse.y>WB1.list.y) PageLinks.Hover(mouse.x, mouse.y, link_color_inactive, link_color_active, bg_color);
155
				if (mouse.y>WB1.list.y) PageLinks.Hover(mouse.x, mouse.y, link_color_inactive, link_color_active, bg_color);
155
				//Menu
156
				//Menu
156
				if (mouse.y>WB1.list.y) && (mouse.y
157
				if (mouse.y>WB1.list.y) && (mouse.y
157
				{
158
				{
158
					if (mouse.pkm) && (mouse.up)
159
					if (mouse.pkm) && (mouse.up)
159
					{
160
					{
160
						SwitchToAnotherThread();
161
						SwitchToAnotherThread();
161
						CreateThread(#menu_rmb,#stak+4092);
162
						CreateThread(#menu_rmb,#stak+4092);
162
						break; 
163
						break; 
163
					}
164
					}
164
				}
165
				}
165
				//Mouse scroll
166
				//Mouse scroll
166
				if (mouse.vert)
167
				if (mouse.vert)
167
				{
168
				{
168
					if (WB1.list.MouseScroll(mouse.vert)) WB1.Parse();
169
					if (WB1.list.MouseScroll(mouse.vert)) WB1.Parse();
169
				}
170
				}
170
				//Drag scroller
171
				//Drag scroller
171
				scroll_wv.all_redraw = 0;
172
				scroll_wv.all_redraw = 0;
172
				if (!mouse.lkm) scroll_used=0;
173
				if (!mouse.lkm) scroll_used=0;
173
				if (mouse.x>=scroll_wv.start_x) && (mouse.x<=scroll_wv.start_x+scroll_wv.size_x) 
174
				if (mouse.x>=scroll_wv.start_x) && (mouse.x<=scroll_wv.start_x+scroll_wv.size_x) 
174
				&& (mouse.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>mouse.y)
175
				&& (mouse.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>mouse.y)
175
				&& (WB1.list.count>WB1.list.visible) && (mouse.lkm)
176
				&& (WB1.list.count>WB1.list.visible) && (mouse.lkm)
176
				{
177
				{
177
					scroll_used=1;
178
					scroll_used=1;
178
				}				
179
				}				
179
				if (scroll_used)
180
				if (scroll_used)
180
				{
181
				{
181
					mouse.y = mouse.y + 5;
182
					mouse.y = mouse.y + 5;
182
					half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
183
					half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
183
					if (half_scroll_size+WB1.list.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=half_scroll_size+WB1.list.y;
184
					if (half_scroll_size+WB1.list.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=half_scroll_size+WB1.list.y;
184
					btn=WB1.list.first;
185
					btn=WB1.list.first;
185
					WB1.list.first = mouse.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
186
					WB1.list.first = mouse.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
186
					if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
187
					if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
187
					if (btn!=WB1.list.first) WB1.Parse();
188
					if (btn!=WB1.list.first) WB1.Parse();
188
				}
189
				}
189
				break;
190
				break;
190
			case evButton:
191
			case evButton:
191
				btn=GetButtonID();
192
				btn=GetButtonID();
192
				if (btn==1)	ExitProcess();
193
				if (btn==1)	ExitProcess();
193
				Scan(btn);
194
				Scan(btn);
194
				break;
195
				break;
195
			case evKey:
196
			case evKey:
196
				key = GetKey();		
197
				key = GetKey();		
197
				if (address_box.flags & 0b10)  
198
				if (address_box.flags & 0b10)  
198
				{
199
				{
199
					if (key==ASCII_KEY_ENTER) Scan(key); else
200
					if (key==ASCII_KEY_ENTER) Scan(key); else
200
					if (key!=0x0d) && (key!=183) && (key!=184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
201
					if (key!=0x0d) && (key!=183) && (key!=184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
201
				}
202
				}
202
				else Scan(key);
203
				else Scan(key);
203
				break;
204
				break;
204
 
205
 
205
			case evReDraw:
206
			case evReDraw:
206
				if (action_buf) Scan(action_buf);
207
				if (action_buf) Scan(action_buf);
207
				DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0);
208
				DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0);
208
				GetProcessInfo(#Form, SelfInfo);
209
				GetProcessInfo(#Form, SelfInfo);
209
				if (Form.status_window>2) { DrawTitle(#header); break; }
210
				if (Form.status_window>2) { DrawTitle(#header); break; }
210
				if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
211
				if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
211
				if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
212
				if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
212
				Draw_Window();
213
				Draw_Window();
213
				break;
214
				break;
214
				
215
				
215
			case evNetwork:
216
			case evNetwork:
216
				if (http_transfer > 0) {
217
				if (http_transfer > 0) {
217
					http_receive stdcall (http_transfer);
218
					http_receive stdcall (http_transfer);
218
					$push EAX
219
					$push EAX
219
					ESI = http_transfer;
220
					ESI = http_transfer;
220
					wv_progress_bar.max = ESI.http_msg.content_length;
221
					wv_progress_bar.max = ESI.http_msg.content_length;
221
					if (wv_progress_bar.value != ESI.http_msg.content_received)
222
					if (wv_progress_bar.value != ESI.http_msg.content_received)
222
					{
223
					{
223
						wv_progress_bar.value = ESI.http_msg.content_received;	
224
						wv_progress_bar.value = ESI.http_msg.content_received;	
224
						DrawProgress();
225
						DrawProgress();
225
					}
226
					}
226
					$pop EAX
227
					$pop EAX
227
					if (EAX == 0) {
228
					if (EAX == 0) {
228
						ESI = http_transfer;
229
						ESI = http_transfer;
229
						// Handle redirects
230
						// Handle redirects
230
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
231
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
231
						{
232
						{
232
							redirected++;
233
							redirected++;
233
							if (redirected<=5)
234
							if (redirected<=5)
234
							{
235
							{
235
								http_find_header_field stdcall (http_transfer, #str_location);
236
								http_find_header_field stdcall (http_transfer, #str_location);
236
								if (EAX!=0) {
237
								if (EAX!=0) {
237
									ESI = EAX;
238
									ESI = EAX;
238
									EDI = #URL;
239
									EDI = #URL;
239
									do {
240
									do {
240
										$lodsb;
241
										$lodsb;
241
										$stosb;
242
										$stosb;
242
									} while (AL != 0) && (AL != 13) && (AL != 10));
243
									} while (AL != 0) && (AL != 13) && (AL != 10));
243
									DSBYTE[EDI-1]='\0';
244
									DSBYTE[EDI-1]='\0';
244
								}
245
								}
245
							}
246
							}
246
							else
247
							else
247
							{
248
							{
248
							//TODO: display error (too many redirects)
249
							//TODO: display error (too many redirects)
249
							}
250
							}
250
						} 
251
						} 
251
						else
252
						else
252
						{
253
						{
253
							redirected = 0;
254
							redirected = 0;
254
						}
255
						}
255
						// Loading the page is complete, free resources
256
						// Loading the page is complete, free resources
256
						if (redirected>0)
257
						if (redirected>0)
257
						{
258
						{
258
							http_free stdcall (http_transfer);
259
							http_free stdcall (http_transfer);
259
							http_transfer=0;
260
							http_transfer=0;
260
							PageLinks.GetAbsoluteURL(#URL);
261
							PageLinks.GetAbsoluteURL(#URL);
261
							BrowserHistory.current--;
262
							BrowserHistory.current--;
262
							strcpy(#editURL, #URL);
263
							strcpy(#editURL, #URL);
263
							OpenPage();
264
							OpenPage();
264
						}
265
						}
265
						else
266
						else
266
						{
267
						{
267
							BrowserHistory.AddUrl();
268
							BrowserHistory.AddUrl();
268
							ESI = http_transfer;
269
							ESI = http_transfer;
269
							bufpointer = ESI.http_msg.content_ptr;
270
							bufpointer = ESI.http_msg.content_ptr;
270
							bufsize = ESI.http_msg.content_received;
271
							bufsize = ESI.http_msg.content_received;
271
							http_free stdcall (http_transfer);
272
							http_free stdcall (http_transfer);
272
							http_transfer=0;
273
							http_transfer=0;
273
							SetPageDefaults();
274
							SetPageDefaults();
274
							Draw_Window();		// stop button => refresh button
275
							Draw_Window();		// stop button => refresh button
275
						}
276
						}
276
					}
277
					}
277
				}
278
				}
278
		}
279
		}
279
	goto BEGIN_LOOP_APPLICATION;
280
	goto BEGIN_LOOP_APPLICATION;
280
}
281
}
281
 
282
 
282
void SetElementSizes()
283
void SetElementSizes()
283
{
284
{
284
	address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H;
285
	address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H;
285
	address_box.width = Form.cwidth - address_box.left - 25 - 22;
286
	address_box.width = Form.cwidth - address_box.left - 25 - 22;
286
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, 
287
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, 
287
		Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 11*WB1.DrawBuf.zoom);
288
		Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 11*WB1.DrawBuf.zoom);
288
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
289
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
289
	WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
290
	WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
290
	WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
291
	WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
291
}
292
}
292
 
293
 
293
void Draw_Window()
294
void Draw_Window()
294
{
295
{
295
	int img_off;
296
	int img_off;
296
	// tab {
297
	// tab {
297
	if (TAB_H)
298
	if (TAB_H)
298
	{
299
	{
299
		DrawBar(0, 0, TAB_W, TAB_H+1, panel_color);
300
		DrawBar(0, 0, TAB_W, TAB_H+1, panel_color);
300
		WriteText(5, 7, 0x80, 0xfdfdFd, "Index.htm");
301
		WriteText(5, 7, 0x80, 0xfdfdFd, "Index.htm");
301
		WriteText(4, 6, 0x80, 0, "Index.htm");		
302
		WriteText(4, 6, 0x80, 0, "Index.htm");		
302
		DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg);
303
		DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg);
303
		DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color);
304
		DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color);
304
		img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0);
305
		img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0);
305
	} 
306
	} 
306
	else DrawBar(0,0, Form.cwidth,1, col_bg);
307
	else DrawBar(0,0, Form.cwidth,1, col_bg);
307
	// }
308
	// }
308
	DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color);
309
	DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color);
309
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xe9e9e9);
310
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xe9e9e9);
310
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
311
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
311
	SetElementSizes();
312
	SetElementSizes();
312
	DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color);
313
	DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color);
313
	DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color);
314
	DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color);
314
	// < / >
315
	// < / >
315
	DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, 300+BT_HIDE, 0);
316
	DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, 300+BT_HIDE, 0);
316
	DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, 301+BT_HIDE, 0);
317
	DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, 301+BT_HIDE, 0);
317
	img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0);
318
	img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0);
318
	// refrash
319
	// refrash
319
	DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0);
320
	DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0);
320
	if (http_transfer > 0) img_off = 131; else img_off = 52;
321
	if (http_transfer > 0) img_off = 131; else img_off = 52;
321
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, img_off, 0);
322
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, img_off, 0);
322
	// config
323
	// config
323
	DefineButton(Form.cwidth-23, address_box.top-2, 17, skin.h-1, 312+BT_HIDE, 0);
324
	DefineButton(Form.cwidth-23, address_box.top-2, 17, skin.h-1, 312+BT_HIDE, 0);
324
	img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-2, 16, skin.h, 85, 0);
325
	img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-2, 16, skin.h, 85, 0);
325
	//status bar
326
	//status bar
326
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
327
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
327
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
328
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
328
	wv_progress_bar.top = Form.cheight - STATUSBAR_H + 4;
329
	wv_progress_bar.top = Form.cheight - STATUSBAR_H + 4;
329
	ShowPage();
330
	ShowPage();
330
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
331
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
331
	DrawProgress();
332
	DrawProgress();
332
}
333
}
333
 
334
 
334
 
335
 
335
void ChangeCharset(byte new_charset)
336
void ChangeCharset1(byte new_charset)
336
{
337
{
337
	BufEncode(new_charset);
338
	BufEncode(new_charset);
338
	WB1.Parse();	
339
	WB1.Parse();	
339
}
340
}
340
 
341
 
341
void Scan(int id)
342
void Scan(int id)
342
{
343
{
343
	action_buf=0;
344
	action_buf=0;
344
	if (id >= 400) 
345
	if (id >= 400) 
345
	{
346
	{
346
		ProcessLinks(id);
347
		ProcessLinks(id);
347
		return;
348
		return;
348
	}
349
	}
349
	switch (id)
350
	switch (id)
350
	{
351
	{
351
		case 011: //Ctrk+K 
352
		case 011: //Ctrk+K 
352
			ChangeCharset(_KOI);
353
			ChangeCharset1(_KOI);
353
			return;
354
			return;
354
 
355
 
355
		case 021: //Ctrl+U
356
		case 021: //Ctrl+U
356
			ChangeCharset(_UTF);
357
			ChangeCharset1(_UTF);
357
			return;
358
			return;
358
 
359
 
359
		case 004: //Ctrl+D
360
		case 004: //Ctrl+D
360
			ChangeCharset(_DOS);
361
			ChangeCharset1(_DOS);
361
			return;
362
			return;
362
 
363
 
363
		case 005: //Win encoding
364
		case 005: //Win encoding
364
			ChangeCharset(_WIN);
365
			ChangeCharset1(_WIN);
365
			return;
366
			return;
366
 
367
 
367
		case 009: //free img cache
368
		case 009: //free img cache
368
			ImgCache.Free();
369
			ImgCache.Free();
369
			notify(IMAGES_CACHE_CLEARED);
370
			notify(IMAGES_CACHE_CLEARED);
370
			WB1.Parse();
371
			WB1.Parse();
371
			return;
372
			return;
372
 
373
 
373
		case 003: //history
374
		case 003: //history
374
			strcpy(#URL, URL_SERVICE_HISTORY);
375
			strcpy(#URL, URL_SERVICE_HISTORY);
375
			OpenPage();
376
			OpenPage();
376
			return;
377
			return;
377
 
378
 
378
		case 006: //download manager
379
		case 006: //download manager
379
			if (!downloader_opened) {
380
			if (!downloader_opened) {
380
				strncpy(#DL_URL, "http://",7);
381
				strncpy(#DL_URL, "http://",7);
381
				CreateThread(#Downloader,#downloader_stak+4092);
382
				CreateThread(#Downloader,#downloader_stak+4092);
382
			}
383
			}
383
			return;
384
			return;
384
 
385
 
385
		case ASCII_KEY_BS:
386
		case ASCII_KEY_BS:
386
		case BACK:
387
		case BACK:
387
			if (!BrowserHistory.GoBack()) return;
388
			if (!BrowserHistory.GoBack()) return;
388
			OpenPage();
389
			OpenPage();
389
			return;
390
			return;
390
		case FORWARD:
391
		case FORWARD:
391
			if (!BrowserHistory.GoForward()) return;
392
			if (!BrowserHistory.GoForward()) return;
392
			OpenPage();
393
			OpenPage();
393
			return;
394
			return;
394
		case 052: //F3
395
		case 052: //F3
395
			WB1.list.first = 0;
396
			WB1.list.first = 0;
396
			ShowSource();
397
			ShowSource();
397
			WB1.Parse();
398
			WB1.Parse();
398
			break;
399
			break;
399
		case 053: //F4
400
		case 053: //F4
400
			if (!strncmp(#URL,"http:",5)) 
401
			if (!strncmp(#URL,"http:",5)) 
401
			{
402
			{
402
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
403
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
403
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
404
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
404
			}
405
			}
405
			else RunProgram("/rd/1/tinypad", #URL);
406
			else RunProgram("/rd/1/tinypad", #URL);
406
			return;
407
			return;
407
		case 054: //F5
408
		case 054: //F5
408
			IF(address_box.flags & 0b10) return;
409
			IF(address_box.flags & 0b10) return;
409
		case REFRESH:
410
		case REFRESH:
410
			if (http_transfer > 0) 
411
			if (http_transfer > 0) 
411
			{
412
			{
412
				StopLoading();
413
				StopLoading();
413
				Draw_Window();
414
				Draw_Window();
414
			}
415
			}
415
			else OpenPage();
416
			else OpenPage();
416
			return;
417
			return;
417
		case 014:
418
		case 014:
418
		case 020:
419
		case 020:
419
		case NEWTAB:
420
		case NEWTAB:
420
			MoveSize(190,80,OLD,OLD);
421
			MoveSize(190,80,OLD,OLD);
421
			RunProgram(#program_path, #URL);
422
			RunProgram(#program_path, #URL);
422
			return;
423
			return;
423
		case GOTOURL:
424
		case GOTOURL:
424
		case 0x0D: //enter
425
		case 0x0D: //enter
425
			if (!editURL[0]) return;
426
			if (!editURL[0]) return;
426
			if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7);
427
			if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7);
427
			else
428
			else
428
				URL[0] = 0;
429
				URL[0] = 0;
429
			strcat(#URL, #editURL);
430
			strcat(#URL, #editURL);
430
			OpenPage();
431
			OpenPage();
431
			return;
432
			return;
432
		case SEARCHWEB:
433
		case SEARCHWEB:
433
			sprintf(#URL,"%s%s",#search_path,#editURL);
434
			sprintf(#URL,"%s%s",#search_path,#editURL);
434
			OpenPage();
435
			OpenPage();
435
			return;
436
			return;
436
 
437
 
437
		case 183: //PgDown
438
		case 183: //PgDown
438
			if (WB1.list.count < WB1.list.visible) return;
439
			if (WB1.list.count < WB1.list.visible) return;
439
			IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
440
			IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
440
			WB1.list.first += WB1.list.visible + 2;
441
			WB1.list.first += WB1.list.visible + 2;
441
			IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
442
			IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
442
			WB1.Parse();
443
			WB1.Parse();
443
			return;
444
			return;
444
 
445
 
445
		case 184: //PgUp
446
		case 184: //PgUp
446
			if (WB1.list.count < WB1.list.visible) return;
447
			if (WB1.list.count < WB1.list.visible) return;
447
			IF(WB1.list.first == 0) return;
448
			IF(WB1.list.first == 0) return;
448
			WB1.list.first -= WB1.list.visible - 2;
449
			WB1.list.first -= WB1.list.visible - 2;
449
			IF(WB1.list.first < 0) WB1.list.first = 0;
450
			IF(WB1.list.first < 0) WB1.list.first = 0;
450
			WB1.Parse();
451
			WB1.Parse();
451
			return;
452
			return;
452
 
453
 
453
		case 178:
454
		case 178:
454
		case BTN_UP:
455
		case BTN_UP:
455
			if (WB1.list.first <= 0) return;
456
			if (WB1.list.first <= 0) return;
456
			WB1.list.first--;
457
			WB1.list.first--;
457
			WB1.Parse();
458
			WB1.Parse();
458
			return;
459
			return;
459
 
460
 
460
		case 177: 
461
		case 177: 
461
		case BTN_DOWN:
462
		case BTN_DOWN:
462
			if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
463
			if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
463
			WB1.list.first++;
464
			WB1.list.first++;
464
			WB1.Parse();
465
			WB1.Parse();
465
			return;
466
			return;
466
 
467
 
467
		case 180: //home
468
		case 180: //home
468
			if (WB1.list.KeyHome()) WB1.Parse();
469
			if (WB1.list.KeyHome()) WB1.Parse();
469
			return; 
470
			return; 
470
 
471
 
471
		case 181: //end
472
		case 181: //end
472
			if (WB1.list.count < WB1.list.visible) return;
473
			if (WB1.list.count < WB1.list.visible) return;
473
			if (WB1.list.KeyEnd()) WB1.Parse();
474
			if (WB1.list.KeyEnd()) WB1.Parse();
474
			return;
475
			return;
475
		case 312:
476
		case 312:
476
			SwitchToAnotherThread();
477
			SwitchToAnotherThread();
477
			mouse.y = TOOLBAR_H-6;
478
			mouse.y = TOOLBAR_H-6;
478
			mouse.x = Form.cwidth - 167;
479
			mouse.x = Form.cwidth - 167;
479
			CreateThread(#menu_rmb,#stak+4092);
480
			CreateThread(#menu_rmb,#stak+4092);
480
			return;
481
			return;
481
		case 122:
482
		case 122:
482
			if (WB1.DrawBuf.zoom==1) WB1.DrawBuf.zoom=2; else WB1.DrawBuf.zoom=1;
483
			if (WB1.DrawBuf.zoom==1) WB1.DrawBuf.zoom=2; else WB1.DrawBuf.zoom=1;
483
			Draw_Window(); 
484
			Draw_Window(); 
484
	}
485
	}
485
}
486
}
486
 
487
 
487
 
488
 
488
 
489
 
489
void ProcessLinks(int id)
490
void ProcessLinks(int id)
490
{
491
{
491
	if (http_transfer > 0) 
492
	if (http_transfer > 0) 
492
	{
493
	{
493
		StopLoading();
494
		StopLoading();
494
		BrowserHistory.current--;
495
		BrowserHistory.current--;
495
	}
496
	}
496
 
497
 
497
	strcpy(#URL, PageLinks.GetURL(id-401));	
498
	strcpy(#URL, PageLinks.GetURL(id-401));	
498
	//$1 - Condition Script
499
	//$1 - Condition Script
499
	if (URL[0] == '$')
500
	if (URL[0] == '$')
500
	{
501
	{
501
		if (URL[1]=='-') && (condition_href) condition_href--;
502
		if (URL[1]=='-') && (condition_href) condition_href--;
502
		else if (URL[1]=='+') 
503
		else if (URL[1]=='+') 
503
		{
504
		{
504
			if (condition_href
505
			if (condition_href
505
		}
506
		}
506
		else condition_href = atoi(#URL+1);
507
		else condition_href = atoi(#URL+1);
507
		strcpy(#URL, BrowserHistory.CurrentUrl());
508
		strcpy(#URL, BrowserHistory.CurrentUrl());
508
		ShowPage();
509
		ShowPage();
509
		return;
510
		return;
510
	}
511
	}
511
	//#1
512
	//#1
512
	if (URL[0] == '#')
513
	if (URL[0] == '#')
513
	{
514
	{
514
		strcpy(#anchor, #URL+strrchr(#URL, '#'));		
515
		strcpy(#anchor, #URL+strrchr(#URL, '#'));		
515
		strcpy(#URL, BrowserHistory.CurrentUrl());
516
		strcpy(#URL, BrowserHistory.CurrentUrl());
516
		WB1.list.first=WB1.list.count-WB1.list.visible;
517
		WB1.list.first=WB1.list.count-WB1.list.visible;
517
		ShowPage();
518
		ShowPage();
518
		return;
519
		return;
519
	}
520
	}
520
	//liner.ru#1
521
	//liner.ru#1
521
	if (strrchr(#URL, '#')!=-1)
522
	if (strrchr(#URL, '#')!=-1)
522
	{
523
	{
523
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
524
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
524
		URL[strrchr(#URL, '#')-1] = 0x00;
525
		URL[strrchr(#URL, '#')-1] = 0x00;
525
	}
526
	}
526
	
527
	
527
	PageLinks.GetAbsoluteURL(#URL);
528
	PageLinks.GetAbsoluteURL(#URL);
528
	
529
	
529
	if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
530
	if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
530
	|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) 
531
	|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) 
531
	{
532
	{
532
		//notify(#URL);
533
		//notify(#URL);
533
		if (!strncmp(#URL,"http://", 7))
534
		if (!strncmp(#URL,"http://", 7))
534
		{
535
		{
535
			strcpy(#DL_URL, #URL);
536
			strcpy(#DL_URL, #URL);
536
			CreateThread(#Downloader,#downloader_stak+4092);
537
			CreateThread(#Downloader,#downloader_stak+4092);
537
		}
538
		}
538
		else RunProgram("@open", #URL);
539
		else RunProgram("@open", #URL);
539
		strcpy(#editURL, BrowserHistory.CurrentUrl());
540
		strcpy(#editURL, BrowserHistory.CurrentUrl());
540
		strcpy(#URL, BrowserHistory.CurrentUrl());
541
		strcpy(#URL, BrowserHistory.CurrentUrl());
541
		return;
542
		return;
542
	}
543
	}
543
	if (!strncmp(#URL,"mailto:", 7))
544
	if (!strncmp(#URL,"mailto:", 7))
544
	{
545
	{
545
		notify(#URL);
546
		notify(#URL);
546
		strcpy(#editURL, BrowserHistory.CurrentUrl());
547
		strcpy(#editURL, BrowserHistory.CurrentUrl());
547
		strcpy(#URL, BrowserHistory.CurrentUrl());
548
		strcpy(#URL, BrowserHistory.CurrentUrl());
548
		return;
549
		return;
549
	}
550
	}
550
	OpenPage();
551
	OpenPage();
551
	return;
552
	return;
552
}
553
}
553
 
554
 
554
void StopLoading()
555
void StopLoading()
555
{
556
{
556
	if (http_transfer)
557
	if (http_transfer)
557
	{
558
	{
558
		EAX = http_transfer;
559
		EAX = http_transfer;
559
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
560
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
560
		$push	EAX							// save it on the stack
561
		$push	EAX							// save it on the stack
561
		http_free stdcall (http_transfer);	// abort connection
562
		http_free stdcall (http_transfer);	// abort connection
562
		$pop	EAX							
563
		$pop	EAX							
563
		free(EAX);						// free data
564
		free(EAX);						// free data
564
		http_transfer=0;
565
		http_transfer=0;
565
		bufsize = 0;
566
		bufsize = 0;
566
		bufpointer = free(bufpointer);
567
		bufpointer = free(bufpointer);
567
	}
568
	}
568
	wv_progress_bar.value = 0;
569
	wv_progress_bar.value = 0;
569
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0);
570
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0);
570
}
571
}
571
 
572
 
572
void SetPageDefaults()
573
void SetPageDefaults()
573
{
574
{
574
	strcpy(#header, #version);
575
	strcpy(#header, #version);
575
	pre_text = 0;
576
	pre_text = 0;
576
	WB1.list.count = WB1.list.first = 0;
577
	WB1.list.count = WB1.list.first = 0;
577
	stroka = 0;
578
	stroka = 0;
578
	cur_encoding = _DEFAULT;
579
	cur_encoding = _DEFAULT;
579
	if (o_bufpointer) o_bufpointer = free(o_bufpointer);
580
	if (o_bufpointer) o_bufpointer = free(o_bufpointer);
580
	anchor_line_num=WB1.list.first;
581
	anchor_line_num=WB1.list.first;
581
	anchor[0]='|';
582
	anchor[0]='|';
582
}
583
}
583
 
584
 
584
void OpenPage()
585
void OpenPage()
585
{
586
{
586
	StopLoading();
587
	StopLoading();
587
	souce_mode = false;
588
	souce_mode = false;
588
	strcpy(#editURL, #URL);
589
	strcpy(#editURL, #URL);
589
	BrowserHistory.AddUrl();
590
	BrowserHistory.AddUrl();
590
	if (!strncmp(#URL,"WebView:",8))
591
	if (!strncmp(#URL,"WebView:",8))
591
	{
592
	{
592
		SetPageDefaults();
593
		SetPageDefaults();
593
		if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.Prepare(#homepage, sizeof(homepage));
594
		if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.Prepare(#homepage, sizeof(homepage));
594
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
595
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
595
		return;
596
		return;
596
	}
597
	}
597
	if (!strncmp(#URL,"http:",5))
598
	if (!strncmp(#URL,"http:",5))
598
	{
599
	{
599
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0);
600
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0);
600
		http_get stdcall (#URL, 0, 0, #accept_language);
601
		http_get stdcall (#URL, 0, 0, #accept_language);
601
		http_transfer = EAX;
602
		http_transfer = EAX;
602
		if (!http_transfer)
603
		if (!http_transfer)
603
		{
604
		{
604
			StopLoading();
605
			StopLoading();
605
			bufsize = 0;
606
			bufsize = 0;
606
			bufpointer = free(bufpointer);
607
			bufpointer = free(bufpointer);
607
			ShowPage();
608
			ShowPage();
608
			return;
609
			return;
609
		}
610
		}
610
	}
611
	}
611
	else
612
	else
612
	{
613
	{
613
		file_size stdcall (#URL);
614
		file_size stdcall (#URL);
614
		bufsize = EBX;
615
		bufsize = EBX;
615
		if (bufsize)
616
		if (bufsize)
616
		{
617
		{
617
			free(bufpointer);
618
			free(bufpointer);
618
			bufpointer = malloc(bufsize);
619
			bufpointer = malloc(bufsize);
619
			SetPageDefaults();
620
			SetPageDefaults();
620
			ReadFile(0, bufsize, bufpointer, #URL);
621
			ReadFile(0, bufsize, bufpointer, #URL);
621
			//ShowSource();
622
			//ShowSource();
622
		}
623
		}
623
		ShowPage();
624
		ShowPage();
624
	}
625
	}
625
}
626
}
626
 
627
 
627
DrawEditBox()
628
DrawEditBox()
628
{
629
{
629
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
630
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
630
	address_box.offset = 0;
631
	address_box.offset = 0;
631
	edit_box_draw stdcall(#address_box);
632
	edit_box_draw stdcall(#address_box);
632
}
633
}
633
 
634
 
634
 
635
 
635
void ShowPage()
636
void ShowPage()
636
{
637
{
637
	DrawEditBox();
638
	DrawEditBox();
638
	if (!bufsize)
639
	if (!bufsize)
639
	{
640
	{
640
		PageLinks.Clear();
641
		PageLinks.Clear();
641
		if (http_transfer)
642
		if (http_transfer)
642
		{
643
		{
643
			WB1.Prepare(#loading, sizeof(loading));
644
			WB1.Prepare(#loading, sizeof(loading));
644
		}
645
		}
645
		else
646
		else
646
			WB1.Prepare(#page_not_found, sizeof(page_not_found));
647
			WB1.Prepare(#page_not_found, sizeof(page_not_found));
647
	}
648
	}
648
	else
649
	else
649
		WB1.Parse();
650
		WB1.Parse();
650
 
651
 
651
	if (!header) strcpy(#header, #version);
652
	if (!header) strcpy(#header, #version);
652
	if (!strcmp(#version, #header)) DrawTitle(#header);
653
	if (!strcmp(#version, #header)) DrawTitle(#header);
653
}
654
}
654
 
655
 
655
byte UrlExtIs(dword ext)
656
byte UrlExtIs(dword ext)
656
{
657
{
657
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
658
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
658
	return false;
659
	return false;
659
}
660
}
660
 
661
 
661
 
662
 
662
char downloader_stak[4096];
663
char downloader_stak[4096];
663
stop:
664
stop:
664
>

665
>