Subversion Repositories Kolibri OS

Rev

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