Subversion Repositories Kolibri OS

Rev

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

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

662
>