Subversion Repositories Kolibri OS

Rev

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