Subversion Repositories Kolibri OS

Rev

Rev 7739 | Rev 7743 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7739 Rev 7742
Line 29... Line 29...
29
_http http = {0, 0, 0, 0, 0, 0, 0};
29
_http http = {0, 0, 0, 0, 0, 0, 0};
Line 30... Line 30...
30
 
30
 
Line 31... Line 31...
31
char homepage[] = FROM "html\\homepage.htm""\0";
31
char homepage[] = FROM "html\\homepage.htm""\0";
32
 
32
 
33
#ifdef LANG_RUS
33
#ifdef LANG_RUS
34
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.83";
34
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.84";
35
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
35
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
36
?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
36
?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
37
char loading[] = "‡ £à㧪  áâà ­¨æë...
";
37
char loading[] = "‡ £à㧪  áâà ­¨æë...
";
Line 44... Line 44...
44
Œ¥­¥¤¦¥à § £à㧮ª";
44
Œ¥­¥¤¦¥à § £à㧮ª";
45
char link_menu[] =
45
char link_menu[] =
46
"Š®¯¨à®¢ âì áá뫪ã
46
"Š®¯¨à®¢ âì áá뫪ã
47
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
47
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
48
#else
48
#else
49
char version[]="Text-based Browser 1.83";
49
char version[]="Text-based Browser 1.84";
50
?define IMAGES_CACHE_CLEARED "Images cache cleared"
50
?define IMAGES_CACHE_CLEARED "Images cache cleared"
51
?define T_LAST_SLIDE "This slide is the last"
51
?define T_LAST_SLIDE "This slide is the last"
52
char loading[] = "Loading...
";
52
char loading[] = "Loading...
";
53
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
53
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
54
char accept_language[]= "Accept-Language: en\n";
54
char accept_language[]= "Accept-Language: en\n";
Line 160... Line 160...
160
			ProcessEvent(GetButtonID());
160
			ProcessEvent(GetButtonID());
161
			break;
161
			break;
Line 162... Line 162...
162
 
162
 
163
		case evKey:
163
		case evKey:
-
 
164
			GetKeys();
-
 
165
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
-
 
166
				if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY);
-
 
167
				if (key_scancode == SCAN_CODE_KEY_U) ProcessEvent(VIEW_SOURCE);
-
 
168
				if (key_scancode == SCAN_CODE_KEY_T) 
-
 
169
				|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
-
 
170
				if (key_scancode == SCAN_CODE_KEY_W) ExitProcess();
-
 
171
				if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER);
164
			GetKeys();
172
			}
165
			if (address_box.flags & ed_focus)  
173
			if (address_box.flags & ed_focus)  
-
 
174
			{
166
			{
175
				if (key_scancode == SCAN_CODE_ENTER) {
-
 
176
					ProcessEvent(key_scancode); 
-
 
177
				}
167
				if (key_ascii == ASCII_KEY_ENTER) ProcessEvent(key_scancode); else {
178
				else {
168
					EAX = key_editbox; 
179
					EAX = key_editbox; 
169
					edit_box_key stdcall(#address_box);
180
					edit_box_key stdcall(#address_box);
170
				}
181
				}
171
			}
182
			}
Line 213... Line 224...
213
							GetAbsoluteURL(#http.redirect_url);
224
							GetAbsoluteURL(#http.redirect_url);
214
							history.back();
225
							history.back();
215
							strcpy(#editURL, #URL);
226
							strcpy(#editURL, #URL);
216
							DrawEditBoxWebView();
227
							DrawEditBoxWebView();
217
							OpenPage();
228
							OpenPage();
-
 
229
							//ProcessLink(history.current());
218
						}
230
						}
219
						break;
231
						break;
220
					} 
232
					} 
221
					redirected = 0;
233
					redirected = 0;
222
					// Loading the page is complete, free resources
234
					// Loading the page is complete, free resources
Line 295... Line 307...
295
				OpenPage();
307
				OpenPage();
296
			}
308
			}
297
			return;
309
			return;
298
		case GOTOURL_BUTTON:
310
		case GOTOURL_BUTTON:
299
		case SCAN_CODE_ENTER:
311
		case SCAN_CODE_ENTER:
300
			if (!editURL[0]) {
-
 
301
				strcpy(#URL, URL_SERVICE_HOME);
-
 
302
			}
-
 
303
			else if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') 
-
 
304
			|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8))
-
 
305
			{
-
 
306
				strcpy(#URL, #editURL);
-
 
307
			}
-
 
308
			else
-
 
309
			{
-
 
310
				strlcpy(#URL,"http://",7);
-
 
311
				strcat(#URL, #editURL);
312
			EventSubmitOmnibox();
312
			}
-
 
313
			OpenPage();
-
 
314
			return;
313
			return;
315
		case REFRESH_BUTTON:
314
		case REFRESH_BUTTON:
316
			if (http.transfer > 0) 
315
			if (http.transfer > 0) 
317
			{
316
			{
318
				StopLoading();
317
				StopLoading();
Line 465... Line 464...
465
		}
464
		}
466
		ShowPage();
465
		ShowPage();
467
	}
466
	}
468
}
467
}
Line 469... Line 468...
469
 
468
 
470
DrawEditBoxWebView()
469
void ProcessAnchor()
471
{
470
{
472
	int skin_x_offset;
-
 
473
	DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
-
 
474
	DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
-
 
475
	//address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
471
	char anchor[256];
476
	//address_box.offset = 0;
-
 
477
	EditBox_UpdateText(#address_box, address_box.flags);
-
 
478
	edit_box_draw stdcall(#address_box);
-
 
479
	if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
-
 
480
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
-
 
Line -... Line 472...
-
 
472
	int anchor_pos;
-
 
473
	
-
 
474
	anchor_pos = strrchr(#URL, '#')-1;
Line 481... Line -...
481
}
-
 
482
 
475
	strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor));
483
 
-
 
484
void ShowPage()
476
	URL[anchor_pos] = 0x00;
485
{
477
 
486
	DrawEditBoxWebView();
478
	//#1
487
	if (!bufsize)
479
	if (URL[0] == NULL)
488
	{
480
	{
-
 
481
		if (anchor[1] == NULL) {
-
 
482
			WB1.list.first = 0;
-
 
483
		}
-
 
484
		else {
-
 
485
			if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1);
-
 
486
		}
489
		if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
487
		strcpy(#URL, history.current());
490
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
488
	}
-
 
489
	//liner.ru#1
491
	}
490
	else
-
 
491
	{
492
	else
492
		GetAbsoluteURL(#URL);
-
 
493
		OpenPage();
-
 
494
		if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1);
-
 
495
	}
-
 
496
 
-
 
497
	WB1.DrawPage();
493
	{
498
	strcpy(#editURL, #URL);
Line 494... Line 499...
494
		WB1.Prepare();
499
	strcat(#editURL, #anchor);
495
	}
500
	DrawEditBoxWebView();
-
 
501
}
-
 
502
 
496
}
503
void EventSubmitOmnibox()
-
 
504
{
497
 
505
	if (!editURL[0]) return;
498
byte UrlExtIs(dword ext)
506
	if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') 
499
{
507
	|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8))
500
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
-
 
501
	return false;
508
	{
502
}
509
		strcpy(#URL, #editURL);
503
 
510
	}
-
 
511
	else
504
void DrawProgress()
512
	{
505
{
-
 
506
	dword persent;
513
		strlcpy(#URL,"http://",7);
Line -... Line 514...
-
 
514
		strcat(#URL, #editURL);
-
 
515
	}
-
 
516
	ProcessLink();
-
 
517
}
-
 
518
 
-
 
519
void EventClickLink()
Line 507... Line 520...
507
	if (http.transfer == 0) return;
520
{
508
	if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10;
-
 
509
	DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color);
-
 
510
}
521
	strcpy(#URL, PageLinks.GetURL(PageLinks.active));
511
 
522
	GetAbsoluteURL(#URL);
512
 
523
	ProcessLink();
513
void ClickLink()
524
}
514
char anchor[256];
525
 
515
int anchor_pos;
526
void ProcessLink()
516
{
-
 
517
	if (http.transfer > 0) 
-
 
518
	{
-
 
519
		StopLoading();
-
 
520
		history.back();
527
{
521
	}
-
 
522
	strcpy(#URL, PageLinks.GetURL(PageLinks.active));
-
 
523
	ReplaceSpaceInUrl();
-
 
524
	//#1
-
 
525
	if (URL[0] == '#')
-
 
526
	{
-
 
527
		if (URL[1] == NULL) {
-
 
528
			WB1.list.first = 0;
-
 
529
		}
-
 
530
		else {
-
 
531
			if (anchors.get_anchor_pos(#URL+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#URL+1);
-
 
532
		}
-
 
533
		strlcpy(#anchor, #URL, sizeof(anchor));
-
 
534
		strcpy(#URL, history.current());
-
 
535
		strcpy(#editURL, #URL);
-
 
536
		strcat(#editURL, #anchor);
528
	if (http.transfer > 0) 
537
		DrawEditBoxWebView();
-
 
538
		WB1.DrawPage();
-
 
539
		return;
-
 
540
	}
-
 
541
	//liner.ru#1
529
	{
542
	else if (strrchr(#URL, '#')!=0)
-
 
543
	{
-
 
544
		anchor_pos = strrchr(#URL, '#')-1;
-
 
545
		strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor));
-
 
546
		URL[anchor_pos] = 0x00;
530
		StopLoading();
547
		OpenPage();
531
		history.back();
Line 548... Line 532...
548
		strcat(#editURL, #anchor);
532
	}
549
		DrawEditBoxWebView();
533
	
550
		if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1);
534
	if (strrchr(#URL, '#')!=0) {
551
		WB1.DrawPage();
535
		ProcessAnchor();
552
		return;
536
		return;
553
	}
537
	}
554
 
538
 
Line -... Line 539...
-
 
539
	if (!strncmp(#URL,"mailto:", 7)) || (!strncmp(#URL,"tel:", 4)) 
555
	if (!strncmp(#URL,"mailto:", 7))
540
	{
-
 
541
		notify(#URL);
-
 
542
		strcpy(#editURL, history.current());
Line 556... Line 543...
556
	{
543
		strcpy(#URL, history.current());
557
		notify(#URL);
544
		return;
558
		strcpy(#editURL, history.current());
545
	}
559
		strcpy(#URL, history.current());
546
 
Line 604... Line 591...
604
		OpenPage();
591
		OpenPage();
605
	}
592
	}
606
	open_in_a_new_window = false;
593
	open_in_a_new_window = false;
607
}
594
}
Line -... Line 595...
-
 
595
 
-
 
596
void DrawEditBoxWebView()
-
 
597
{
-
 
598
	int skin_x_offset;
-
 
599
	DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
-
 
600
	DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
-
 
601
	//address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
-
 
602
	//address_box.offset = 0;
-
 
603
	EditBox_UpdateText(#address_box, address_box.flags);
-
 
604
	edit_box_draw stdcall(#address_box);
-
 
605
	if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
-
 
606
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
-
 
607
}
-
 
608
 
-
 
609
 
-
 
610
void ShowPage()
-
 
611
{
-
 
612
	DrawEditBoxWebView();
-
 
613
	if (!bufsize)
-
 
614
	{
-
 
615
		if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
-
 
616
		else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
-
 
617
	}
-
 
618
	else
-
 
619
	{
-
 
620
		WB1.Prepare();
-
 
621
	}
-
 
622
}
-
 
623
 
-
 
624
byte UrlExtIs(dword ext)
-
 
625
{
-
 
626
	if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
-
 
627
	return false;
-
 
628
}
-
 
629
 
-
 
630
void DrawProgress()
-
 
631
{
-
 
632
	dword persent;
-
 
633
	if (http.transfer == 0) return;
-
 
634
	if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10;
-
 
635
	DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color);
-
 
636
}
608
 
637
 
609
void EventShowPageMenu(dword _left, _top)
638
void EventShowPageMenu(dword _left, _top)
610
{
639
{
611
	menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE);
640
	menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE);
Line 624... Line 653...
624
		wv_progress_bar.value = http.content_received;	
653
		wv_progress_bar.value = http.content_received;	
625
		DrawProgress();
654
		DrawProgress();
626
	}
655
	}
627
}
656
}
Line 628... Line 657...
628
 
657
 
629
DrawStatusBar(dword _status_text)
658
void DrawStatusBar(dword _status_text)
630
{
659
{
631
	status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
660
	status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
632
	status_text.start_y = Form.cheight - STATUSBAR_H + 3;
661
	status_text.start_y = Form.cheight - STATUSBAR_H + 3;
633
	status_text.area_size_x = Form.cwidth - status_text.start_x -3;
662
	status_text.area_size_x = Form.cwidth - status_text.start_x -3;