Subversion Repositories Kolibri OS

Rev

Rev 7293 | Rev 7425 | 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--
7422 leency 2
//Copyright 2007-2018 by Veliant & Leency
6978 leency 3
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
3067 leency 4
 
4085 leency 5
#ifndef AUTOBUILD
6
	#include "lang.h--"
7
#endif
8
 
3107 leency 9
//libraries
6738 leency 10
#define MEMSIZE 4096 * 200
5499 leency 11
#include "..\lib\gui.h"
4508 leency 12
#include "..\lib\draw_buf.h"
13
#include "..\lib\list_box.h"
14
#include "..\lib\cursor.h"
5978 leency 15
#include "..\lib\collection.h"
6045 leency 16
#include "..\lib\menu.h"
6795 leency 17
#include "..\lib\random.h"
7037 leency 18
#include "..\lib\clipboard.h"
5981 leency 19
 
3107 leency 20
//*.obj libraries
5499 leency 21
#include "..\lib\obj\box_lib.h"
7049 leency 22
#include "..\lib\obj\libio.h"
23
#include "..\lib\obj\libimg.h"
5499 leency 24
#include "..\lib\obj\http.h"
5690 leency 25
#include "..\lib\obj\iconv.h"
5408 leency 26
//useful patterns
5978 leency 27
#include "..\lib\patterns\history.h"
6058 leency 28
#include "..\lib\patterns\http_downloader.h"
5408 leency 29
 
7281 leency 30
_http http = {0, 0, 0, 0, 0, 0, 0};
31
 
6698 leency 32
char homepage[] = FROM "html\\homepage.htm""\0";
4677 leency 33
 
4026 leency 34
#ifdef LANG_RUS
7422 leency 35
char version[]="Текстовый браузер 1.8b";
6045 leency 36
?define IMAGES_CACHE_CLEARED "Кэш картинок очищен"
37
?define T_LAST_SLIDE "Это последний слайд"
38
char loading[] = "Загрузка страницы...
";
6698 leency 39
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
6045 leency 40
char accept_language[]= "Accept-Language: ru\n";
41
char rmb_menu[] =
42
"Посмотреть исходник
43
Редактировать исходник
44
История
45
Менеджер загрузок";
7037 leency 46
char link_menu[] =
7208 leency 47
"Копировать ссылку
48
Скачать содержимое ссылки";
4026 leency 49
#else
7282 leency 50
char version[]="Text-based Browser 1.8";
6045 leency 51
?define IMAGES_CACHE_CLEARED "Images cache cleared"
52
?define T_LAST_SLIDE "This slide is the last"
53
char loading[] = "Loading...
";
6698 leency 54
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
6045 leency 55
char accept_language[]= "Accept-Language: en\n";
56
char rmb_menu[] =
57
"View source
58
Edit source
59
History
60
Download Manager";
7037 leency 61
char link_menu[] =
7208 leency 62
"Copy link
63
Download link contents";
4026 leency 64
#endif
65
 
6795 leency 66
 
5773 leency 67
#define URL_SERVICE_HISTORY "WebView://history"
68
#define URL_SERVICE_HOME "WebView://home"
69
#define URL_SERVICE_SOURCE "WebView://source:"
5631 pavelyakov 70
 
3067 leency 71
proc_info Form;
72
 
5772 leency 73
//char search_path[]="http://nigma.ru/index.php?s=";
4558 hidnplayr 74
int redirected = 0;
3067 leency 75
 
4074 leency 76
char stak[4096];
5640 pavelyakov 77
 
4026 leency 78
int action_buf;
79
 
6731 leency 80
dword TOOLBAR_H = 40;
5519 leency 81
dword STATUSBAR_H = 15;
4718 leency 82
dword col_bg;
83
dword panel_color;
84
dword border_color;
4677 leency 85
 
7282 leency 86
bool debug_mode = false;
87
bool old_tag_parser_mode = false;
88
 
5718 leency 89
progress_bar wv_progress_bar;
6931 leency 90
bool souce_mode = false;
91
bool open_in_a_new_window = false;
4677 leency 92
 
5718 leency 93
enum {
94
	BACK_BUTTON=1000,
95
	FORWARD_BUTTON,
96
	REFRESH_BUTTON,
97
	GOTOURL_BUTTON,
6795 leency 98
	SANDWICH_BUTTON,
5768 leency 99
	VIEW_SOURCE=1100,
5718 leency 100
	EDIT_SOURCE,
101
	VIEW_HISTORY,
7037 leency 102
	//FREE_IMG_CACHE,
6795 leency 103
	DOWNLOAD_MANAGER,
7282 leency 104
	COPY_LINK_URL=1200,
7208 leency 105
	DOWNLOAD_LINK_CONTENTS,
5718 leency 106
};
107
 
4411 leency 108
#include "..\TWB\TWB.c"
4636 leency 109
#include "history.h"
4718 leency 110
#include "show_src.h"
6001 leency 111
#include "download_manager.h"
3067 leency 112
 
4534 leency 113
char editURL[sizeof(URL)];
114
int	mouse_twb;
6731 leency 115
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL),#editURL,#mouse_twb,2,19,19};
4534 leency 116
 
117
 
3067 leency 118
void main()
119
{
7422 leency 120
	int i;
5626 leency 121
	load_dll(boxlib, #box_lib_init,0);
122
	load_dll(libio, #libio_init,1);
123
	load_dll(libimg, #libimg_init,1);
124
	load_dll(libHTTP, #http_lib_init,1);
5690 leency 125
	load_dll(iconv_lib, #iconv_open,0);
5408 leency 126
	Libimg_LoadImage(#skin, abspath("wv_skin.png"));
127
	SetSkinColors();
5772 leency 128
	CreateDir("/tmp0/1/downloads");
129
	if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
6045 leency 130
	WB1.list.SetFont(8, 14, 10011000b);
5779 leency 131
	WB1.list.no_selection = true;
6978 leency 132
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
133
	loop() switch(WaitEvent())
134
	{
135
		case evMouse:
136
			edit_box_mouse stdcall (#address_box);
137
			mouse.get();
7282 leency 138
			if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
139
			&& (bufsize) && (mouse.pkm) && (mouse.up) {
140
				if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y);
141
				break;
6978 leency 142
			}
7282 leency 143
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
6978 leency 144
			scrollbar_v_mouse (#scroll_wv);
145
			if (WB1.list.first != scroll_wv.position)
146
			{
147
				WB1.list.first = scroll_wv.position;
148
				WB1.DrawPage();
3067 leency 149
				break;
6978 leency 150
			}
151
			break;
5711 leency 152
 
6978 leency 153
		case evButton:
154
			ProcessEvent(GetButtonID());
155
			break;
5711 leency 156
 
6978 leency 157
		case evKey:
158
			GetKeys();
159
			if (address_box.flags & 0b10)
160
			{
161
				if (key_ascii == ASCII_KEY_ENTER) ProcessEvent(key_scancode); else {
162
					EAX = key_editbox;
163
					edit_box_key stdcall(#address_box);
5530 leency 164
				}
6978 leency 165
			}
166
			else
167
			{
7422 leency 168
				#define KEY_SCROLL_N 11
169
				if (SCAN_CODE_UP   == key_scancode) for (i=0;i
170
				if (SCAN_CODE_DOWN == key_scancode) for (i=0;i
6978 leency 171
				if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
172
				else ProcessEvent(key_scancode);
173
			}
174
			break;
175
 
176
		case evReDraw:
177
			if (menu.list.cur_y) {
178
				ProcessEvent(menu.list.cur_y);
179
				menu.list.cur_y = 0;
180
			}
181
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0);
182
			GetProcessInfo(#Form, SelfInfo);
183
			if (Form.status_window>2) { DrawTitle(#header); break; }
184
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
185
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
186
			Draw_Window();
187
			break;
188
 
189
		case evNetwork:
7281 leency 190
			if (http.transfer > 0) {
191
				http.receive();
192
				EventUpdateProgressBar();
193
				if (http.receive_result == 0) {
6978 leency 194
					// Handle redirects
7281 leency 195
					if (http.status_code >= 300) && (http.status_code < 400)
4686 leency 196
					{
6978 leency 197
						redirected++;
7282 leency 198
						if (redirected>5)
4563 leency 199
						{
7282 leency 200
							notify("'Too many redirects.' -E");
201
							StopLoading();
4558 hidnplayr 202
						}
4563 leency 203
						else
204
						{
7282 leency 205
							http.handle_redirect();
206
							http.free();
207
							GetAbsoluteURL(#http.redirect_url);
208
							history.back();
209
							strcpy(#editURL, #URL);
210
							DrawEditBoxWebView();
211
							OpenPage();
4558 hidnplayr 212
						}
7282 leency 213
						break;
6978 leency 214
					}
7282 leency 215
					redirected = 0;
6978 leency 216
					// Loading the page is complete, free resources
7282 leency 217
					history.add(#URL);
218
					bufpointer = http.content_pointer;
219
					bufsize = http.content_received;
220
					http.free();
221
					SetPageDefaults();
222
					ShowPage();
4536 leency 223
				}
6978 leency 224
			}
225
	}
3067 leency 226
}
227
 
228
void SetElementSizes()
229
{
6731 leency 230
	address_box.top = TOOLBAR_H/2-10;
6794 leency 231
	basic_line_h = calc(WB1.list.font_h * 130) / 100;
6731 leency 232
	address_box.width = Form.cwidth - address_box.left - 50;
6803 leency 233
	WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x,
6794 leency 234
		Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h);
235
	WB1.list.wheel_size = 7 * basic_line_h;
5710 leency 236
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
6794 leency 237
	WB1.list.visible = WB1.list.h;
6045 leency 238
	if (WB1.list.w!=WB1.DrawBuf.bufw) {
6803 leency 239
		WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700);
6698 leency 240
		ProcessEvent(REFRESH_BUTTON);
6045 leency 241
	}
3067 leency 242
}
243
 
5981 leency 244
 
5982 leency 245
 
3067 leency 246
void Draw_Window()
247
{
5772 leency 248
	DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color);
5718 leency 249
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
4677 leency 250
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
3067 leency 251
	SetElementSizes();
6731 leency 252
	DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 25,border_color);
253
	DefineButton(address_box.left-52, address_box.top-2, 24, skin.h-2, BACK_BUTTON+BT_HIDE, 0);
254
	DefineButton(address_box.left-27, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0);
255
	img_draw stdcall(skin.image, address_box.left-53, address_box.top-3, 51, skin.h, 3, 0);
5718 leency 256
	DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
6731 leency 257
	DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
258
	img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 87, 0);
4677 leency 259
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
260
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
7282 leency 261
	if (!header)
262
		OpenPage();
263
	else {
264
		WB1.DrawPage();
265
		DrawEditBoxWebView();
266
	}
4692 leency 267
	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
4693 leency 268
	DrawProgress();
3067 leency 269
}
270
 
271
 
6698 leency 272
void ProcessEvent(dword id__)
4413 leency 273
{
6698 leency 274
	switch (id__)
4413 leency 275
	{
6698 leency 276
		case 1:
277
			ExitProcess();
278
			return;
5711 leency 279
		case SCAN_CODE_BS:
5718 leency 280
		case BACK_BUTTON:
6021 leency 281
			if (history.back()) {
282
				strcpy(#URL, history.current());
5978 leency 283
				OpenPage();
284
			}
5711 leency 285
			return;
5718 leency 286
		case FORWARD_BUTTON:
6021 leency 287
			if (history.forward()) {
288
				strcpy(#URL, history.current());
5978 leency 289
				OpenPage();
290
			}
5711 leency 291
			return;
5718 leency 292
		case GOTOURL_BUTTON:
5772 leency 293
		case SCAN_CODE_ENTER:
7282 leency 294
			if (!editURL[0]) {
295
				strcpy(#URL, URL_SERVICE_HOME);
296
			}
297
			else if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/')
6730 leency 298
			|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8))
5772 leency 299
			{
300
				strcpy(#URL, #editURL);
301
			}
5711 leency 302
			else
5772 leency 303
			{
5803 leency 304
				strlcpy(#URL,"http://",7);
5772 leency 305
				strcat(#URL, #editURL);
306
			}
5711 leency 307
			OpenPage();
308
			return;
7293 leency 309
		case SCAN_CODE_F5:
5718 leency 310
			IF(address_box.flags & 0b10) return;
311
		case REFRESH_BUTTON:
7281 leency 312
			if (http.transfer > 0)
5713 leency 313
			{
314
				StopLoading();
315
				Draw_Window();
316
			}
317
			else OpenPage();
318
			return;
5718 leency 319
		case SANDWICH_BUTTON:
6795 leency 320
			EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6);
4415 leency 321
			return;
5718 leency 322
		case VIEW_SOURCE:
323
			WB1.list.first = 0;
324
			ShowSource();
5773 leency 325
			WB1.LoadInternalPage(bufpointer, bufsize);
5718 leency 326
			break;
327
		case EDIT_SOURCE:
7282 leency 328
			if (!strncmp(#URL,"http",4))
5718 leency 329
			{
7227 leency 330
				CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
5718 leency 331
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
332
			}
333
			else RunProgram("/rd/1/tinypad", #URL);
4415 leency 334
			return;
7037 leency 335
		// case FREE_IMG_CACHE:
336
		// 	ImgCache.Free();
337
		// 	notify(IMAGES_CACHE_CLEARED);
338
		// 	WB1.DrawPage();
339
		// 	return;
5718 leency 340
		case VIEW_HISTORY:
4677 leency 341
			strcpy(#URL, URL_SERVICE_HISTORY);
4544 leency 342
			OpenPage();
343
			return;
5718 leency 344
		case DOWNLOAD_MANAGER:
5519 leency 345
			if (!downloader_opened) {
6001 leency 346
				downloader_edit = NULL;
5519 leency 347
				CreateThread(#Downloader,#downloader_stak+4092);
348
			}
4413 leency 349
			return;
7282 leency 350
		case COPY_LINK_URL:
7037 leency 351
			Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
352
			notify("'URL copied to clipboard'O");
353
			return;
7208 leency 354
		case DOWNLOAD_LINK_CONTENTS:
355
			if (!downloader_opened) {
356
				strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active));
357
				CreateThread(#Downloader,#downloader_stak+4092);
358
			}
359
			return;
7282 leency 360
		case SCAN_CODE_F12:
361
			debug_mode ^= 1;
362
			if (debug_mode) notify("'Debug mode ON'-I");
363
			else notify("'Debug mode OFF'-I");
364
			return;
365
		case SCAN_CODE_F11:
366
			old_tag_parser_mode ^= 1;
367
			if (old_tag_parser_mode) notify("'Old tag parser ON'-I");
368
			else notify("'Old tag parser OFF'-I");
369
			return;
4413 leency 370
	}
371
}
372
 
4636 leency 373
void StopLoading()
374
{
7281 leency 375
	if (http.transfer)
4647 leency 376
	{
7281 leency 377
		EAX = http.transfer;
4647 leency 378
		EAX = EAX.http_msg.content_ptr;		// get pointer to data
379
		$push	EAX							// save it on the stack
7281 leency 380
		http_free stdcall (http.transfer);	// abort connection
4647 leency 381
		$pop	EAX
5631 pavelyakov 382
		free(EAX);						// free data
7281 leency 383
		http.transfer=0;
4647 leency 384
		bufsize = 0;
5631 pavelyakov 385
		bufpointer = free(bufpointer);
4647 leency 386
	}
5519 leency 387
	wv_progress_bar.value = 0;
6731 leency 388
	DrawEditBoxWebView();
4645 leency 389
}
390
 
391
void SetPageDefaults()
392
{
393
	strcpy(#header, #version);
394
	WB1.list.count = WB1.list.first = 0;
5704 leency 395
	cur_encoding = CH_NULL;
4645 leency 396
	if (o_bufpointer) o_bufpointer = free(o_bufpointer);
4636 leency 397
}
398
 
4416 leency 399
void OpenPage()
400
{
7282 leency 401
	char getUrl[sizeof(URL)];
4636 leency 402
	StopLoading();
4718 leency 403
	souce_mode = false;
4416 leency 404
	strcpy(#editURL, #URL);
6021 leency 405
	history.add(#URL);
5631 pavelyakov 406
	if (!strncmp(#URL,"WebView:",8))
4692 leency 407
	{
408
		SetPageDefaults();
5747 leency 409
		if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
5631 pavelyakov 410
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
6278 leency 411
		DrawEditBoxWebView();
4692 leency 412
		return;
413
	}
7282 leency 414
	if (!strncmp(#URL,"http:",5)) || (!strncmp(#URL,"https://",8))
4416 leency 415
	{
5718 leency 416
		img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0);
7282 leency 417
 
418
		if (!strncmp(#URL,"http:",5)) {
419
			http.get(#URL);
420
		}
421
		if (!strncmp(#URL,"https://",8)) {
422
			sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL);
423
			http.get(#getUrl);
424
		}
425
		//http.get(#URL);
7281 leency 426
		if (!http.transfer)
4646 leency 427
		{
428
			StopLoading();
429
			bufsize = 0;
5631 pavelyakov 430
			bufpointer = free(bufpointer);
4646 leency 431
			ShowPage();
432
			return;
433
		}
4416 leency 434
	}
4636 leency 435
	else
436
	{
437
		file_size stdcall (#URL);
438
		bufsize = EBX;
4650 leency 439
		if (bufsize)
440
		{
5631 pavelyakov 441
			free(bufpointer);
442
			bufpointer = malloc(bufsize);
4650 leency 443
			SetPageDefaults();
4718 leency 444
			ReadFile(0, bufsize, bufpointer, #URL);
4650 leency 445
		}
4645 leency 446
		ShowPage();
4636 leency 447
	}
4416 leency 448
}
4415 leency 449
 
6278 leency 450
DrawEditBoxWebView()
4508 leency 451
{
6731 leency 452
	DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
453
	DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
4718 leency 454
	address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
455
	address_box.offset = 0;
4508 leency 456
	edit_box_draw stdcall(#address_box);
7281 leency 457
	if (http.transfer > 0) EAX = 131; else EAX = 54;
5772 leency 458
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0);
4718 leency 459
}
4415 leency 460
 
4718 leency 461
 
462
void ShowPage()
463
{
6278 leency 464
	DrawEditBoxWebView();
4540 leency 465
	if (!bufsize)
4508 leency 466
	{
7281 leency 467
		if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
5773 leency 468
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
4508 leency 469
	}
470
	else
5768 leency 471
	{
5766 leency 472
		WB1.Prepare();
5768 leency 473
	}
4508 leency 474
}
475
 
5493 leency 476
byte UrlExtIs(dword ext)
477
{
5631 pavelyakov 478
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
479
	return false;
5493 leency 480
}
4508 leency 481
 
5772 leency 482
int SetSkinColors()
483
{
484
	dword image_data;
485
	image_data = DSDWORD[skin.image+24];
486
	col_bg = DSDWORD[image_data];
487
	panel_color  = DSDWORD[skin.w*4*4 + image_data];
488
	border_color = DSDWORD[skin.w*4*7 + image_data];
489
	wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
490
	$and col_bg, 0x00ffffff
491
	$and panel_color, 0x00ffffff
492
	$and border_color, 0x00ffffff
493
	$and wv_progress_bar.progress_color, 0x00ffffff
494
}
4544 leency 495
 
5772 leency 496
void DrawProgress()
497
{
7282 leency 498
	dword persent;
7281 leency 499
	if (http.transfer == 0) return;
7282 leency 500
	if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10;
501
	DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color);
5772 leency 502
}
5746 leency 503
 
6931 leency 504
 
6803 leency 505
char anchor[256];
5774 leency 506
void ClickLink()
507
{
7281 leency 508
	if (http.transfer > 0)
5774 leency 509
	{
510
		StopLoading();
6021 leency 511
		history.back();
5774 leency 512
	}
7282 leency 513
	strcpy(#URL, PageLinks.GetURL(PageLinks.active));
5774 leency 514
	//#1
515
	if (URL[0] == '#')
516
	{
6730 leency 517
		if (URL[1] == NULL) {
518
			WB1.list.first = 0;
519
			strcpy(#URL, history.current());
520
		}
521
		else {
522
			strlcpy(#anchor, #URL+strrchr(#URL, '#'), sizeof(anchor));
523
			strcpy(#URL, history.current());
524
		}
525
		ShowPage();
5774 leency 526
		return;
527
	}
528
	//liner.ru#1
6730 leency 529
	if (strrchr(#URL, '#')!=0)
5774 leency 530
	{
6803 leency 531
		strlcpy(#anchor, #URL+strrchr(#URL, '#'), sizeof(anchor));
5774 leency 532
		URL[strrchr(#URL, '#')-1] = 0x00;
533
	}
6730 leency 534
 
535
	if (!strncmp(#URL,"mailto:", 7))
536
	{
537
		notify(#URL);
538
		strcpy(#editURL, history.current());
539
		strcpy(#URL, history.current());
540
		return;
541
	}
542
 
5990 leency 543
	GetAbsoluteURL(#URL);
6730 leency 544
 
7282 leency 545
	if (strncmp(#URL,"http://",7)!=0) && (strncmp(#URL,"https://",8)!=0)
5774 leency 546
	{
6730 leency 547
		if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true)
548
		{
7422 leency 549
			if (strchr(#URL, '|')) {
550
				ESBYTE[strchr(#URL, '|')] = NULL;
551
				RunProgram(#URL, strlen(#URL)+1+#URL);
552
			}
553
			else {
554
				RunProgram("/sys/@open", #URL);
555
			}
6730 leency 556
			strcpy(#editURL, history.current());
557
			strcpy(#URL, history.current());
558
			return;
559
		}
560
	}
561
	else
562
	{
563
		if (UrlExtIs(".png")==true) || (UrlExtIs(".gif")==true) || (UrlExtIs(".jpg")==true)
6794 leency 564
		|| (UrlExtIs(".zip")==true) || (UrlExtIs(".kex")==true) || (UrlExtIs(".pdf")==true)
565
		|| (UrlExtIs(".7z")==true) {
6986 leency 566
			if (!downloader_opened) {
567
				strcpy(#downloader_edit, #URL);
568
				CreateThread(#Downloader,#downloader_stak+4092);
569
				strcpy(#editURL, history.current());
570
				strcpy(#URL, history.current());
571
			}
572
			else notify("'WebView\nPlease, start a new download only when previous ended.'Et");
6730 leency 573
			return;
5774 leency 574
		}
575
	}
6931 leency 576
	if (open_in_a_new_window)
577
	{
578
		RunProgram(#program_path, #URL);
579
		strcpy(#editURL, history.current());
580
		strcpy(#URL, history.current());
581
	}
582
	else
583
	{
584
		OpenPage();
585
	}
586
	open_in_a_new_window = false;
5774 leency 587
}
588
 
6795 leency 589
void EventShowPageMenu(dword _left, _top)
6782 leency 590
{
591
	menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE);
592
}
593
 
6795 leency 594
void EventShowLinkMenu(dword _left, _top)
595
{
7282 leency 596
	menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL);
6795 leency 597
}
598
 
7281 leency 599
void EventUpdateProgressBar()
600
{
601
	wv_progress_bar.max = http.content_length;
602
	if (wv_progress_bar.value != http.content_received)
603
	{
604
		wv_progress_bar.value = http.content_received;
605
		DrawProgress();
606
	}
607
}
6795 leency 608
 
609
DrawStatusBar(dword _status_text)
610
{
611
	status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
612
	status_text.start_y = Form.cheight - STATUSBAR_H + 3;
613
	status_text.area_size_x = Form.cwidth - status_text.start_x -3;
614
	DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
615
	status_text.text_pointer = _status_text;
616
	PathShow_prepare stdcall(#status_text);
617
	PathShow_draw stdcall(#status_text);
618
}
619
 
5631 pavelyakov 620
stop: