Subversion Repositories Kolibri OS

Rev

Rev 6058 | Rev 6366 | 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
				{
5711 leency 168
					if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else
169
					if (key_ascii != 0x0d) && (key_ascii != 183) && (key_ascii != 184) {EAX = key_ascii << 8; edit_box_key stdcall(#address_box);}
5530 leency 170
				}
5711 leency 171
				else
172
				{
173
					Scan(key_scancode);
174
				}
5530 leency 175
				break;
3067 leency 176
 
177
			case evReDraw:
6045 leency 178
				if (menu.list.cur_y) {
179
					Scan(menu.list.cur_y);
180
					menu.list.cur_y = 0;
181
				}
5773 leency 182
				DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0);
4725 leency 183
				GetProcessInfo(#Form, SelfInfo);
4727 leency 184
				if (Form.status_window>2) { DrawTitle(#header); break; }
5811 leency 185
				if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
186
				if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
3067 leency 187
				Draw_Window();
188
				break;
4540 leency 189
 
4536 leency 190
			case evNetwork:
4540 leency 191
				if (http_transfer > 0) {
5534 hidnplayr 192
					http_receive stdcall (http_transfer);
4677 leency 193
					$push EAX
194
					ESI = http_transfer;
5519 leency 195
					wv_progress_bar.max = ESI.http_msg.content_length;
196
					if (wv_progress_bar.value != ESI.http_msg.content_received)
4686 leency 197
					{
5519 leency 198
						wv_progress_bar.value = ESI.http_msg.content_received;
4686 leency 199
						DrawProgress();
200
					}
4677 leency 201
					$pop EAX
202
					if (EAX == 0) {
4558 hidnplayr 203
						ESI = http_transfer;
204
						// Handle redirects
4563 leency 205
						if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400)
206
						{
4558 hidnplayr 207
							redirected++;
4563 leency 208
							if (redirected<=5)
209
							{
5773 leency 210
								http_find_header_field stdcall (http_transfer, "location\0");
4558 hidnplayr 211
								if (EAX!=0) {
212
									ESI = EAX;
213
									EDI = #URL;
214
									do {
215
										$lodsb;
216
										$stosb;
217
									} while (AL != 0) && (AL != 13) && (AL != 10));
218
									DSBYTE[EDI-1]='\0';
219
								}
4563 leency 220
							}
221
							else
222
							{
5772 leency 223
								notify("Too many redirects");
224
								StopLoading();
225
								break;
4558 hidnplayr 226
							}
4563 leency 227
						}
228
						else
229
						{
4558 hidnplayr 230
							redirected = 0;
231
						}
4554 leency 232
						// Loading the page is complete, free resources
4563 leency 233
						if (redirected>0)
234
						{
4643 leency 235
							http_free stdcall (http_transfer);
236
							http_transfer=0;
5990 leency 237
							GetAbsoluteURL(#URL);
6021 leency 238
							history.back();
4558 hidnplayr 239
							strcpy(#editURL, #URL);
6278 leency 240
							DrawEditBoxWebView();
4558 hidnplayr 241
							OpenPage();
4563 leency 242
						}
243
						else
244
						{
6021 leency 245
							history.add(#URL);
4643 leency 246
							ESI = http_transfer;
247
							bufpointer = ESI.http_msg.content_ptr;
248
							bufsize = ESI.http_msg.content_received;
249
							http_free stdcall (http_transfer);
250
							http_transfer=0;
4645 leency 251
							SetPageDefaults();
5772 leency 252
							ShowPage();
4558 hidnplayr 253
						}
4536 leency 254
					}
255
				}
3067 leency 256
		}
5631 pavelyakov 257
	goto BEGIN_LOOP_APPLICATION;
3067 leency 258
}
259
 
260
void SetElementSizes()
261
{
5772 leency 262
	address_box.top = TOOLBAR_H/2-7;
4677 leency 263
	address_box.width = Form.cwidth - address_box.left - 25 - 22;
5678 leency 264
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom,
5711 leency 265
		Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom);
5749 leency 266
	WB1.list.wheel_size = 7;
5710 leency 267
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
5825 leency 268
	WB1.list.visible = WB1.list.h - 5 / WB1.list.item_h;
6045 leency 269
	if (WB1.list.w!=WB1.DrawBuf.bufw) {
270
		WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 30);
271
		Scan(REFRESH_BUTTON);
272
	}
3067 leency 273
}
274
 
5981 leency 275
 
5982 leency 276
 
3067 leency 277
void Draw_Window()
278
{
5987 leency 279
	int list__w, list__h;
5772 leency 280
	DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color);
5718 leency 281
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
4677 leency 282
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
3067 leency 283
	SetElementSizes();
5772 leency 284
	DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 20,border_color);
285
	DefineButton(address_box.left-50, address_box.top-2, 23, skin.h-2, BACK_BUTTON+BT_HIDE, 0);
286
	DefineButton(address_box.left-26, address_box.top-2, 23, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0);
287
	img_draw stdcall(skin.image, address_box.left-51, address_box.top-3, 48, skin.h, 3, 0);
5718 leency 288
	DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
289
	DefineButton(Form.cwidth-24, address_box.top-3, 19, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
290
	img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-3, 16, skin.h, 85, 0);
4677 leency 291
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
292
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
6278 leency 293
	if (!header) OpenPage(); else { WB1.DrawPage(); DrawEditBoxWebView(); }
4692 leency 294
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
4693 leency 295
	DrawProgress();
5981 leency 296
 
5982 leency 297
	/*
5981 leency 298
	list__w = 200;
5987 leency 299
	list__h = 200;
300
	label.raw_size = 0;
301
	label.write_buf(10,10, list__w, list__h, 0xFFFFFF, 0, 11, "Hello World!");
302
	label.write_buf(10,23, list__w, list__h, 0xFFFFFF, 0xFF00FF, 12, "How are you?");
303
	label.write_buf(11,40, list__w, list__h, 0xFFFFFF, 0x2E74BB, 15, "Fine");
304
	label.apply_smooth();
305
	label.show_buf(0,0);
5982 leency 306
	*/
3067 leency 307
}
308
 
309
 
5711 leency 310
void Scan(dword id__)
4413 leency 311
{
4636 leency 312
	action_buf=0;
5781 leency 313
	if (WB1.list.ProcessKey(id__)) WB1.DrawPage();
5779 leency 314
	else switch (id__)
4413 leency 315
	{
5711 leency 316
		case SCAN_CODE_BS:
5718 leency 317
		case BACK_BUTTON:
6021 leency 318
			if (history.back()) {
319
				strcpy(#URL, history.current());
5978 leency 320
				OpenPage();
321
			}
5711 leency 322
			return;
5718 leency 323
		case FORWARD_BUTTON:
6021 leency 324
			if (history.forward()) {
325
				strcpy(#URL, history.current());
5978 leency 326
				OpenPage();
327
			}
5711 leency 328
			return;
5718 leency 329
		case GOTOURL_BUTTON:
5772 leency 330
		case SCAN_CODE_ENTER:
331
			if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') || (!strncmp(#editURL,"WebView:",9))
332
			{
333
				strcpy(#URL, #editURL);
334
			}
5711 leency 335
			else
5772 leency 336
			{
5803 leency 337
				strlcpy(#URL,"http://",7);
5772 leency 338
				strcat(#URL, #editURL);
339
			}
5711 leency 340
			OpenPage();
341
			return;
5718 leency 342
		case 063: //F5
343
			IF(address_box.flags & 0b10) return;
344
		case REFRESH_BUTTON:
5713 leency 345
			if (http_transfer > 0)
346
			{
347
				StopLoading();
348
				Draw_Window();
349
			}
350
			else OpenPage();
351
			return;
5718 leency 352
		case SANDWICH_BUTTON:
353
			mouse.y = TOOLBAR_H-6;
354
			mouse.x = Form.cwidth - 167;
6045 leency 355
			menu.show(Form.left+mouse.x-6,Form.top+mouse.y+skin_height+3, 180, #rmb_menu, VIEW_SOURCE);
4415 leency 356
			return;
5718 leency 357
		case VIEW_SOURCE:
358
			WB1.list.first = 0;
359
			ShowSource();
5773 leency 360
			WB1.LoadInternalPage(bufpointer, bufsize);
5718 leency 361
			break;
362
		case EDIT_SOURCE:
363
			if (!strncmp(#URL,"http:",5))
364
			{
365
				WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
366
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
367
			}
368
			else RunProgram("/rd/1/tinypad", #URL);
4415 leency 369
			return;
5718 leency 370
		case FREE_IMG_CACHE:
4491 leency 371
			ImgCache.Free();
4416 leency 372
			notify(IMAGES_CACHE_CLEARED);
5766 leency 373
			WB1.DrawPage();
4415 leency 374
			return;
5718 leency 375
		case VIEW_HISTORY:
4677 leency 376
			strcpy(#URL, URL_SERVICE_HISTORY);
4544 leency 377
			OpenPage();
378
			return;
5718 leency 379
		case DOWNLOAD_MANAGER:
5519 leency 380
			if (!downloader_opened) {
6001 leency 381
				downloader_edit = NULL;
5519 leency 382
				CreateThread(#Downloader,#downloader_stak+4092);
383
			}
4413 leency 384
			return;
385
	}
386
}
387
 
388
 
4636 leency 389
void StopLoading()
390
{
5631 pavelyakov 391
	if (http_transfer)
4647 leency 392
	{
393
		EAX = http_transfer;
394
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
395
		$push	EAX							// save it on the stack
396
		http_free stdcall (http_transfer);	// abort connection
397
		$pop	EAX
5631 pavelyakov 398
		free(EAX);						// free data
4647 leency 399
		http_transfer=0;
400
		bufsize = 0;
5631 pavelyakov 401
		bufpointer = free(bufpointer);
4647 leency 402
	}
5519 leency 403
	wv_progress_bar.value = 0;
5718 leency 404
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 52, 0);
4645 leency 405
}
406
 
407
void SetPageDefaults()
408
{
409
	strcpy(#header, #version);
410
	WB1.list.count = WB1.list.first = 0;
411
	stroka = 0;
5704 leency 412
	cur_encoding = CH_NULL;
4645 leency 413
	if (o_bufpointer) o_bufpointer = free(o_bufpointer);
4636 leency 414
	anchor_line_num=WB1.list.first;
415
	anchor[0]='|';
416
}
417
 
4416 leency 418
void OpenPage()
419
{
4636 leency 420
	StopLoading();
4718 leency 421
	souce_mode = false;
4416 leency 422
	strcpy(#editURL, #URL);
6021 leency 423
	history.add(#URL);
5631 pavelyakov 424
	if (!strncmp(#URL,"WebView:",8))
4692 leency 425
	{
426
		SetPageDefaults();
5747 leency 427
		if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
5631 pavelyakov 428
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
6278 leency 429
		DrawEditBoxWebView();
4692 leency 430
		return;
431
	}
5631 pavelyakov 432
	if (!strncmp(#URL,"http:",5))
4416 leency 433
	{
5718 leency 434
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0);
5534 hidnplayr 435
		http_get stdcall (#URL, 0, 0, #accept_language);
4636 leency 436
		http_transfer = EAX;
5631 pavelyakov 437
		if (!http_transfer)
4646 leency 438
		{
439
			StopLoading();
440
			bufsize = 0;
5631 pavelyakov 441
			bufpointer = free(bufpointer);
4646 leency 442
			ShowPage();
443
			return;
444
		}
4416 leency 445
	}
4636 leency 446
	else
447
	{
448
		file_size stdcall (#URL);
449
		bufsize = EBX;
4650 leency 450
		if (bufsize)
451
		{
5631 pavelyakov 452
			free(bufpointer);
453
			bufpointer = malloc(bufsize);
4650 leency 454
			SetPageDefaults();
4718 leency 455
			ReadFile(0, bufsize, bufpointer, #URL);
4650 leency 456
		}
4645 leency 457
		ShowPage();
4636 leency 458
	}
4416 leency 459
}
4415 leency 460
 
6278 leency 461
DrawEditBoxWebView()
4508 leency 462
{
5772 leency 463
	DrawWideRectangle(address_box.left-2, address_box.top-2, address_box.width+3, 19, 2, address_box.color);
4718 leency 464
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
465
	address_box.offset = 0;
4508 leency 466
	edit_box_draw stdcall(#address_box);
5772 leency 467
	if (http_transfer > 0) EAX = 131; else EAX = 52;
468
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0);
4718 leency 469
}
4415 leency 470
 
4718 leency 471
 
472
void ShowPage()
473
{
6278 leency 474
	DrawEditBoxWebView();
4540 leency 475
	if (!bufsize)
4508 leency 476
	{
5773 leency 477
		if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
478
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
4508 leency 479
	}
480
	else
5768 leency 481
	{
5766 leency 482
		WB1.Prepare();
5768 leency 483
	}
5773 leency 484
	//if (!header) strcpy(#header, #version);
4508 leency 485
	if (!strcmp(#version, #header)) DrawTitle(#header);
486
}
487
 
5493 leency 488
byte UrlExtIs(dword ext)
489
{
5631 pavelyakov 490
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
491
	return false;
5493 leency 492
}
4508 leency 493
 
5772 leency 494
int SetSkinColors()
495
{
496
	dword image_data;
497
	image_data = DSDWORD[skin.image+24];
498
	col_bg = DSDWORD[image_data];
499
	panel_color  = DSDWORD[skin.w*4*4 + image_data];
500
	border_color = DSDWORD[skin.w*4*7 + image_data];
501
	wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
502
	$and col_bg, 0x00ffffff
503
	$and panel_color, 0x00ffffff
504
	$and border_color, 0x00ffffff
505
	$and wv_progress_bar.progress_color, 0x00ffffff
506
}
4544 leency 507
 
5772 leency 508
void DrawProgress()
509
{
510
	unsigned long btn;
511
	if (http_transfer == 0) return;
512
	if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30;
513
	DrawBar(address_box.left-2, address_box.top+15, btn, 2, wv_progress_bar.progress_color);
514
}
5746 leency 515
 
5774 leency 516
void ClickLink()
517
{
518
	if (http_transfer > 0)
519
	{
520
		StopLoading();
6021 leency 521
		history.back();
5774 leency 522
	}
5772 leency 523
 
5774 leency 524
	strcpy(#URL, PageLinks.GetURL(PageLinks.active));
525
	//#1
526
	if (URL[0] == '#')
527
	{
528
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
6021 leency 529
		strcpy(#URL, history.current());
5774 leency 530
		WB1.list.first=WB1.list.count-WB1.list.visible;
531
		ShowPage();
532
		return;
533
	}
534
	//liner.ru#1
535
	if (strrchr(#URL, '#')!=-1)
536
	{
537
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
538
		URL[strrchr(#URL, '#')-1] = 0x00;
539
	}
540
 
5990 leency 541
	GetAbsoluteURL(#URL);
5774 leency 542
 
543
	if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
544
	|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1)
545
	{
546
		//notify(#URL);
547
		if (!strncmp(#URL,"http://", 7))
548
		{
6001 leency 549
			strcpy(#downloader_edit, #URL);
5774 leency 550
			CreateThread(#Downloader,#downloader_stak+4092);
551
		}
552
		else RunProgram("@open", #URL);
6021 leency 553
		strcpy(#editURL, history.current());
554
		strcpy(#URL, history.current());
5774 leency 555
		return;
556
	}
557
	if (!strncmp(#URL,"mailto:", 7))
558
	{
559
		notify(#URL);
6021 leency 560
		strcpy(#editURL, history.current());
561
		strcpy(#URL, history.current());
5774 leency 562
		return;
563
	}
564
	OpenPage();
565
	return;
566
}
567
 
568
 
5493 leency 569
char downloader_stak[4096];
5631 pavelyakov 570
stop: