Subversion Repositories Kolibri OS

Rev

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