Subversion Repositories Kolibri OS

Rev

Rev 5825 | Rev 5981 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3067 leency 1
//HTML Viewer in C--
3987 leency 2
//Copyright 2007-2013 by Veliant & Leency
3107 leency 3
//Asper, lev, Lrz, Barsuk, Nable...
3067 leency 4
//home icon - rachel fu, GPL licence
5
 
4085 leency 6
#ifndef AUTOBUILD
7
	#include "lang.h--"
8
#endif
9
 
3107 leency 10
//libraries
3363 leency 11
#define MEMSIZE 0x100000
5499 leency 12
#include "..\lib\gui.h"
4508 leency 13
#include "..\lib\draw_buf.h"
14
#include "..\lib\list_box.h"
15
#include "..\lib\cursor.h"
5978 leency 16
#include "..\lib\collection.h"
3107 leency 17
//*.obj libraries
5499 leency 18
#include "..\lib\obj\box_lib.h"
19
#include "..\lib\obj\libio_lib.h"
20
#include "..\lib\obj\libimg_lib.h"
21
#include "..\lib\obj\http.h"
5690 leency 22
#include "..\lib\obj\iconv.h"
5408 leency 23
//useful patterns
24
#include "..\lib\patterns\libimg_load_skin.h"
5978 leency 25
#include "..\lib\patterns\history.h"
5408 leency 26
 
5493 leency 27
char homepage[] = FROM "html\\homepage.htm";
4677 leency 28
 
4026 leency 29
#ifdef LANG_RUS
5811 leency 30
	char version[]=" Текстовый браузер 1.40";
4416 leency 31
	?define IMAGES_CACHE_CLEARED "Кэш картинок очищен"
4417 leency 32
	?define T_LAST_SLIDE "Это последний слайд"
4550 leency 33
	char loading[] = "Загрузка страницы...
";
4677 leency 34
	char page_not_found[] = FROM "html\page_not_found_ru.htm";
4649 leency 35
	char accept_language[]= "Accept-Language: ru\n";
4026 leency 36
#else
5811 leency 37
	char version[]=" Text-based Browser 1.40";
4026 leency 38
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
4417 leency 39
	?define T_LAST_SLIDE "This slide is the last"
4550 leency 40
	char loading[] = "Loading...
";
4677 leency 41
	char page_not_found[] = FROM "html\page_not_found_en.htm";
4649 leency 42
	char accept_language[]= "Accept-Language: en\n";
4026 leency 43
#endif
44
 
5773 leency 45
#define URL_SERVICE_HISTORY "WebView://history"
46
#define URL_SERVICE_HOME "WebView://home"
47
#define URL_SERVICE_SOURCE "WebView://source:"
5631 pavelyakov 48
 
49
 
3067 leency 50
proc_info Form;
51
 
5772 leency 52
//char search_path[]="http://nigma.ru/index.php?s=";
4558 hidnplayr 53
int redirected = 0;
3067 leency 54
 
4074 leency 55
char stak[4096];
5640 pavelyakov 56
 
4026 leency 57
int action_buf;
58
 
4565 leency 59
dword http_transfer = 0;
4537 leency 60
dword http_buffer;
4534 leency 61
 
5772 leency 62
dword TOOLBAR_H = 33;
5519 leency 63
dword STATUSBAR_H = 15;
4718 leency 64
dword col_bg;
65
dword panel_color;
66
dword border_color;
4677 leency 67
 
5718 leency 68
progress_bar wv_progress_bar;
4718 leency 69
byte souce_mode = false;
4677 leency 70
 
5718 leency 71
enum {
72
	BACK_BUTTON=1000,
73
	FORWARD_BUTTON,
74
	REFRESH_BUTTON,
75
	GOTOURL_BUTTON,
76
	SANDWICH_BUTTON
77
};
78
 
79
enum {
5768 leency 80
	VIEW_SOURCE=1100,
5718 leency 81
	EDIT_SOURCE,
82
	VIEW_HISTORY,
83
	FREE_IMG_CACHE,
84
	DOWNLOAD_MANAGER
85
};
86
 
4411 leency 87
#include "..\TWB\TWB.c"
5768 leency 88
#include "menu.h"
4636 leency 89
#include "history.h"
4718 leency 90
#include "show_src.h"
5685 leency 91
#include "network_get.h"
5493 leency 92
#include "downloader.h"
3067 leency 93
 
4534 leency 94
char editURL[sizeof(URL)];
95
int	mouse_twb;
5772 leency 96
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
4534 leency 97
 
98
 
3067 leency 99
void main()
100
{
5711 leency 101
	dword btn;
3067 leency 102
	int half_scroll_size;
4026 leency 103
	int scroll_used=0, show_menu;
4536 leency 104
	CursorPointer.Load(#CursorFile);
5626 leency 105
	load_dll(boxlib, #box_lib_init,0);
106
	load_dll(libio, #libio_init,1);
107
	load_dll(libimg, #libimg_init,1);
108
	load_dll(libHTTP, #http_lib_init,1);
5690 leency 109
	load_dll(iconv_lib, #iconv_open,0);
5718 leency 110
	//load_dll(kmenu, #akmenu_init,0);
5408 leency 111
	Libimg_LoadImage(#skin, abspath("wv_skin.png"));
112
	SetSkinColors();
5772 leency 113
	CreateDir("/tmp0/1/downloads");
114
	if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
5678 leency 115
	WB1.DrawBuf.zoom = 1;
5712 leency 116
	WB1.list.SetFont(8, 14, 10111000b);
5779 leency 117
	WB1.list.no_selection = true;
4536 leency 118
	SetEventMask(0xa7);
5631 pavelyakov 119
	BEGIN_LOOP_APPLICATION:
3067 leency 120
		WaitEventTimeout(2);
121
		switch(EAX & 0xFF)
122
		{
123
			CASE evMouse:
4081 leency 124
				if (!CheckActiveProcess(Form.ID)) break;
3466 leency 125
				edit_box_mouse stdcall (#address_box);
5640 pavelyakov 126
				mouse.get();
5772 leency 127
				if (WB1.list.MouseOver(mouse.x, mouse.y))
3067 leency 128
				{
5825 leency 129
					PageLinks.Hover(mouse.x, WB1.list.first*WB1.list.item_h + mouse.y, link_color_inactive, link_color_active, bg_color);
5772 leency 130
					if (bufsize) && (mouse.pkm) && (mouse.up) { CreateThread(#menu_rmb,#stak+4092); break; }
131
					if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
3067 leency 132
				}
5782 leency 133
				scrollbar_v_mouse (#scroll_wv);
134
				if (WB1.list.first != scroll_wv.position)
3067 leency 135
				{
5782 leency 136
					WB1.list.first = scroll_wv.position;
137
					WB1.DrawPage();
138
					break;
3067 leency 139
				}
140
				break;
5711 leency 141
 
3067 leency 142
			case evButton:
143
				btn=GetButtonID();
4636 leency 144
				if (btn==1)	ExitProcess();
145
				Scan(btn);
3067 leency 146
				break;
5711 leency 147
 
3067 leency 148
			case evKey:
5711 leency 149
				GetKeys();
5531 leency 150
				if (address_box.flags & 0b10)
5530 leency 151
				{
5711 leency 152
					if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else
153
					if (key_ascii != 0x0d) && (key_ascii != 183) && (key_ascii != 184) {EAX = key_ascii << 8; edit_box_key stdcall(#address_box);}
5530 leency 154
				}
5711 leency 155
				else
156
				{
157
					Scan(key_scancode);
158
				}
5530 leency 159
				break;
3067 leency 160
 
161
			case evReDraw:
4636 leency 162
				if (action_buf) Scan(action_buf);
5773 leency 163
				DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0);
4725 leency 164
				GetProcessInfo(#Form, SelfInfo);
4727 leency 165
				if (Form.status_window>2) { DrawTitle(#header); break; }
5811 leency 166
				if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
167
				if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
3067 leency 168
				Draw_Window();
169
				break;
4540 leency 170
 
4536 leency 171
			case evNetwork:
4540 leency 172
				if (http_transfer > 0) {
5534 hidnplayr 173
					http_receive stdcall (http_transfer);
4677 leency 174
					$push EAX
175
					ESI = http_transfer;
5519 leency 176
					wv_progress_bar.max = ESI.http_msg.content_length;
177
					if (wv_progress_bar.value != ESI.http_msg.content_received)
4686 leency 178
					{
5519 leency 179
						wv_progress_bar.value = ESI.http_msg.content_received;
4686 leency 180
						DrawProgress();
181
					}
4677 leency 182
					$pop EAX
183
					if (EAX == 0) {
4558 hidnplayr 184
						ESI = http_transfer;
185
						// Handle redirects
4563 leency 186
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
187
						{
4558 hidnplayr 188
							redirected++;
4563 leency 189
							if (redirected<=5)
190
							{
5773 leency 191
								http_find_header_field stdcall (http_transfer, "location\0");
4558 hidnplayr 192
								if (EAX!=0) {
193
									ESI = EAX;
194
									EDI = #URL;
195
									do {
196
										$lodsb;
197
										$stosb;
198
									} while (AL != 0) && (AL != 13) && (AL != 10));
199
									DSBYTE[EDI-1]='\0';
200
								}
4563 leency 201
							}
202
							else
203
							{
5772 leency 204
								notify("Too many redirects");
205
								StopLoading();
206
								break;
4558 hidnplayr 207
							}
4563 leency 208
						}
209
						else
210
						{
4558 hidnplayr 211
							redirected = 0;
212
						}
4554 leency 213
						// Loading the page is complete, free resources
4563 leency 214
						if (redirected>0)
215
						{
4643 leency 216
							http_free stdcall (http_transfer);
217
							http_transfer=0;
4686 leency 218
							PageLinks.GetAbsoluteURL(#URL);
5978 leency 219
							History.back();
4558 hidnplayr 220
							strcpy(#editURL, #URL);
5718 leency 221
							DrawEditBox();
4558 hidnplayr 222
							OpenPage();
4563 leency 223
						}
224
						else
225
						{
5978 leency 226
							History.add(#URL);
4643 leency 227
							ESI = http_transfer;
228
							bufpointer = ESI.http_msg.content_ptr;
229
							bufsize = ESI.http_msg.content_received;
230
							http_free stdcall (http_transfer);
231
							http_transfer=0;
4645 leency 232
							SetPageDefaults();
5772 leency 233
							ShowPage();
4558 hidnplayr 234
						}
4536 leency 235
					}
236
				}
3067 leency 237
		}
5631 pavelyakov 238
	goto BEGIN_LOOP_APPLICATION;
3067 leency 239
}
240
 
241
void SetElementSizes()
242
{
5772 leency 243
	address_box.top = TOOLBAR_H/2-7;
4677 leency 244
	address_box.width = Form.cwidth - address_box.left - 25 - 22;
5678 leency 245
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom,
5711 leency 246
		Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom);
5749 leency 247
	WB1.list.wheel_size = 7;
5710 leency 248
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
5825 leency 249
	WB1.list.visible = WB1.list.h - 5 / WB1.list.item_h;
5773 leency 250
	if (WB1.list.w!=WB1.DrawBuf.bufw) WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 30);
3067 leency 251
}
252
 
253
void Draw_Window()
254
{
5772 leency 255
	DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color);
5718 leency 256
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
4677 leency 257
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
3067 leency 258
	SetElementSizes();
5772 leency 259
	DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 20,border_color);
260
	DefineButton(address_box.left-50, address_box.top-2, 23, skin.h-2, BACK_BUTTON+BT_HIDE, 0);
261
	DefineButton(address_box.left-26, address_box.top-2, 23, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0);
262
	img_draw stdcall(skin.image, address_box.left-51, address_box.top-3, 48, skin.h, 3, 0);
5718 leency 263
	DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
264
	DefineButton(Form.cwidth-24, address_box.top-3, 19, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
265
	img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-3, 16, skin.h, 85, 0);
4677 leency 266
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
267
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
5772 leency 268
	if (!header) OpenPage(); else { WB1.DrawPage(); DrawEditBox(); }
4692 leency 269
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
4693 leency 270
	DrawProgress();
3067 leency 271
}
272
 
273
 
5711 leency 274
void Scan(dword id__)
4413 leency 275
{
4636 leency 276
	action_buf=0;
5781 leency 277
	if (WB1.list.ProcessKey(id__)) WB1.DrawPage();
5779 leency 278
	else switch (id__)
4413 leency 279
	{
5711 leency 280
		case SCAN_CODE_BS:
5718 leency 281
		case BACK_BUTTON:
5978 leency 282
			if (History.back()) {
283
				strcpy(#URL, History.current());
284
				OpenPage();
285
			}
5711 leency 286
			return;
5718 leency 287
		case FORWARD_BUTTON:
5978 leency 288
			if (History.forward()) {
289
				strcpy(#URL, History.current());
290
				OpenPage();
291
			}
5711 leency 292
			return;
5718 leency 293
		case GOTOURL_BUTTON:
5772 leency 294
		case SCAN_CODE_ENTER:
295
			if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') || (!strncmp(#editURL,"WebView:",9))
296
			{
297
				strcpy(#URL, #editURL);
298
			}
5711 leency 299
			else
5772 leency 300
			{
5803 leency 301
				strlcpy(#URL,"http://",7);
5772 leency 302
				strcat(#URL, #editURL);
303
			}
5711 leency 304
			OpenPage();
305
			return;
5718 leency 306
		case 063: //F5
307
			IF(address_box.flags & 0b10) return;
308
		case REFRESH_BUTTON:
5713 leency 309
			if (http_transfer > 0)
310
			{
311
				StopLoading();
312
				Draw_Window();
313
			}
314
			else OpenPage();
315
			return;
5718 leency 316
		case SANDWICH_BUTTON:
317
			mouse.y = TOOLBAR_H-6;
318
			mouse.x = Form.cwidth - 167;
319
			CreateThread(#menu_rmb,#stak+4092);
4415 leency 320
			return;
5718 leency 321
		case VIEW_SOURCE:
322
			WB1.list.first = 0;
323
			ShowSource();
5773 leency 324
			WB1.LoadInternalPage(bufpointer, bufsize);
5718 leency 325
			break;
326
		case EDIT_SOURCE:
327
			if (!strncmp(#URL,"http:",5))
328
			{
329
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
330
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
331
			}
332
			else RunProgram("/rd/1/tinypad", #URL);
4415 leency 333
			return;
5718 leency 334
		case FREE_IMG_CACHE:
4491 leency 335
			ImgCache.Free();
4416 leency 336
			notify(IMAGES_CACHE_CLEARED);
5766 leency 337
			WB1.DrawPage();
4415 leency 338
			return;
5718 leency 339
		case VIEW_HISTORY:
4677 leency 340
			strcpy(#URL, URL_SERVICE_HISTORY);
4544 leency 341
			OpenPage();
342
			return;
5718 leency 343
		case DOWNLOAD_MANAGER:
5519 leency 344
			if (!downloader_opened) {
5803 leency 345
				strlcpy(#DL_URL, "http://",7);
5519 leency 346
				CreateThread(#Downloader,#downloader_stak+4092);
347
			}
5772 leency 348
			return; /*
4415 leency 349
		case 020:
4413 leency 350
		case NEWTAB:
351
			MoveSize(190,80,OLD,OLD);
352
			RunProgram(#program_path, #URL);
353
			return;
5718 leency 354
		case SEARCHWEB_BUTTON:
5631 pavelyakov 355
			sprintf(#URL,"%s%s",#search_path,#editURL);
4416 leency 356
			OpenPage();
5772 leency 357
			return; */
4413 leency 358
	}
359
}
360
 
361
 
4636 leency 362
void StopLoading()
363
{
5631 pavelyakov 364
	if (http_transfer)
4647 leency 365
	{
366
		EAX = http_transfer;
367
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
368
		$push	EAX							// save it on the stack
369
		http_free stdcall (http_transfer);	// abort connection
370
		$pop	EAX
5631 pavelyakov 371
		free(EAX);						// free data
4647 leency 372
		http_transfer=0;
373
		bufsize = 0;
5631 pavelyakov 374
		bufpointer = free(bufpointer);
4647 leency 375
	}
5519 leency 376
	wv_progress_bar.value = 0;
5718 leency 377
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 52, 0);
4645 leency 378
}
379
 
380
void SetPageDefaults()
381
{
382
	strcpy(#header, #version);
383
	WB1.list.count = WB1.list.first = 0;
384
	stroka = 0;
5704 leency 385
	cur_encoding = CH_NULL;
4645 leency 386
	if (o_bufpointer) o_bufpointer = free(o_bufpointer);
4636 leency 387
	anchor_line_num=WB1.list.first;
388
	anchor[0]='|';
389
}
390
 
4416 leency 391
void OpenPage()
392
{
4636 leency 393
	StopLoading();
4718 leency 394
	souce_mode = false;
4416 leency 395
	strcpy(#editURL, #URL);
5978 leency 396
	History.add(#URL);
5631 pavelyakov 397
	if (!strncmp(#URL,"WebView:",8))
4692 leency 398
	{
399
		SetPageDefaults();
5747 leency 400
		if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
5631 pavelyakov 401
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
5772 leency 402
		DrawEditBox();
4692 leency 403
		return;
404
	}
5631 pavelyakov 405
	if (!strncmp(#URL,"http:",5))
4416 leency 406
	{
5718 leency 407
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0);
5534 hidnplayr 408
		http_get stdcall (#URL, 0, 0, #accept_language);
4636 leency 409
		http_transfer = EAX;
5631 pavelyakov 410
		if (!http_transfer)
4646 leency 411
		{
412
			StopLoading();
413
			bufsize = 0;
5631 pavelyakov 414
			bufpointer = free(bufpointer);
4646 leency 415
			ShowPage();
416
			return;
417
		}
4416 leency 418
	}
4636 leency 419
	else
420
	{
421
		file_size stdcall (#URL);
422
		bufsize = EBX;
4650 leency 423
		if (bufsize)
424
		{
5631 pavelyakov 425
			free(bufpointer);
426
			bufpointer = malloc(bufsize);
4650 leency 427
			SetPageDefaults();
4718 leency 428
			ReadFile(0, bufsize, bufpointer, #URL);
4650 leency 429
		}
4645 leency 430
		ShowPage();
4636 leency 431
	}
4416 leency 432
}
4415 leency 433
 
4718 leency 434
DrawEditBox()
4508 leency 435
{
5772 leency 436
	DrawWideRectangle(address_box.left-2, address_box.top-2, address_box.width+3, 19, 2, address_box.color);
4718 leency 437
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
438
	address_box.offset = 0;
4508 leency 439
	edit_box_draw stdcall(#address_box);
5772 leency 440
	if (http_transfer > 0) EAX = 131; else EAX = 52;
441
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0);
4718 leency 442
}
4415 leency 443
 
4718 leency 444
 
445
void ShowPage()
446
{
447
	DrawEditBox();
4540 leency 448
	if (!bufsize)
4508 leency 449
	{
5773 leency 450
		if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
451
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
4508 leency 452
	}
453
	else
5768 leency 454
	{
5766 leency 455
		WB1.Prepare();
5768 leency 456
	}
5773 leency 457
	//if (!header) strcpy(#header, #version);
4508 leency 458
	if (!strcmp(#version, #header)) DrawTitle(#header);
459
}
460
 
5493 leency 461
byte UrlExtIs(dword ext)
462
{
5631 pavelyakov 463
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
464
	return false;
5493 leency 465
}
4508 leency 466
 
5772 leency 467
int SetSkinColors()
468
{
469
	dword image_data;
470
	image_data = DSDWORD[skin.image+24];
471
	col_bg = DSDWORD[image_data];
472
	panel_color  = DSDWORD[skin.w*4*4 + image_data];
473
	border_color = DSDWORD[skin.w*4*7 + image_data];
474
	wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
475
	$and col_bg, 0x00ffffff
476
	$and panel_color, 0x00ffffff
477
	$and border_color, 0x00ffffff
478
	$and wv_progress_bar.progress_color, 0x00ffffff
479
}
4544 leency 480
 
5772 leency 481
void DrawProgress()
482
{
483
	unsigned long btn;
484
	if (http_transfer == 0) return;
485
	if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
486
	DrawBar(address_box.left-2, address_box.top+15, btn, 2, wv_progress_bar.progress_color);
487
}
5746 leency 488
 
5774 leency 489
void ClickLink()
490
{
491
	if (http_transfer > 0)
492
	{
493
		StopLoading();
5978 leency 494
		History.back();
5774 leency 495
	}
5772 leency 496
 
5774 leency 497
	strcpy(#URL, PageLinks.GetURL(PageLinks.active));
498
	//#1
499
	if (URL[0] == '#')
500
	{
501
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
5978 leency 502
		strcpy(#URL, History.current());
5774 leency 503
		WB1.list.first=WB1.list.count-WB1.list.visible;
504
		ShowPage();
505
		return;
506
	}
507
	//liner.ru#1
508
	if (strrchr(#URL, '#')!=-1)
509
	{
510
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
511
		URL[strrchr(#URL, '#')-1] = 0x00;
512
	}
513
 
514
	PageLinks.GetAbsoluteURL(#URL);
515
 
516
	if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
517
	|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1)
518
	{
519
		//notify(#URL);
520
		if (!strncmp(#URL,"http://", 7))
521
		{
522
			strcpy(#DL_URL, #URL);
523
			CreateThread(#Downloader,#downloader_stak+4092);
524
		}
525
		else RunProgram("@open", #URL);
5978 leency 526
		strcpy(#editURL, History.current());
527
		strcpy(#URL, History.current());
5774 leency 528
		return;
529
	}
530
	if (!strncmp(#URL,"mailto:", 7))
531
	{
532
		notify(#URL);
5978 leency 533
		strcpy(#editURL, History.current());
534
		strcpy(#URL, History.current());
5774 leency 535
		return;
536
	}
537
	OpenPage();
538
	return;
539
}
540
 
541
 
5493 leency 542
char downloader_stak[4096];
5631 pavelyakov 543
stop: