Subversion Repositories Kolibri OS

Rev

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