Subversion Repositories Kolibri OS

Rev

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