2012-11-26 16:26:15 +01:00
|
|
|
|
//HTML Viewer in C--
|
2020-03-20 02:28:59 +01:00
|
|
|
|
//Copyright 2007-2020 by Veliant & Leency
|
2017-09-17 03:32:09 +02:00
|
|
|
|
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2013-10-24 23:45:17 +02:00
|
|
|
|
#ifndef AUTOBUILD
|
|
|
|
|
#include "lang.h--"
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-12-15 01:16:06 +01:00
|
|
|
|
//libraries
|
2020-03-18 01:45:36 +01:00
|
|
|
|
#define MEMSIZE 1024 * 800
|
2015-03-05 21:55:28 +01:00
|
|
|
|
#include "..\lib\gui.h"
|
2014-01-22 01:08:47 +01:00
|
|
|
|
#include "..\lib\draw_buf.h"
|
|
|
|
|
#include "..\lib\list_box.h"
|
|
|
|
|
#include "..\lib\cursor.h"
|
2015-12-16 23:44:42 +01:00
|
|
|
|
#include "..\lib\collection.h"
|
2016-12-13 23:08:14 +01:00
|
|
|
|
#include "..\lib\random.h"
|
2017-10-01 13:57:00 +02:00
|
|
|
|
#include "..\lib\clipboard.h"
|
2015-12-17 20:15:49 +01:00
|
|
|
|
|
2018-10-06 00:10:27 +02:00
|
|
|
|
// *.obj libraries
|
2015-03-05 21:55:28 +01:00
|
|
|
|
#include "..\lib\obj\box_lib.h"
|
2017-10-05 00:59:57 +02:00
|
|
|
|
#include "..\lib\obj\libio.h"
|
|
|
|
|
#include "..\lib\obj\libimg.h"
|
2015-03-05 21:55:28 +01:00
|
|
|
|
#include "..\lib\obj\http.h"
|
2015-08-07 00:37:34 +02:00
|
|
|
|
#include "..\lib\obj\iconv.h"
|
2020-03-23 02:11:31 +01:00
|
|
|
|
#include "..\lib\obj\proc_lib.h"
|
2015-02-15 11:18:26 +01:00
|
|
|
|
//useful patterns
|
2015-12-16 23:44:42 +01:00
|
|
|
|
#include "..\lib\patterns\history.h"
|
2016-01-15 00:05:51 +01:00
|
|
|
|
#include "..\lib\patterns\http_downloader.h"
|
2020-03-23 02:11:31 +01:00
|
|
|
|
#include "..\lib\patterns\simple_open_dialog.h"
|
2015-02-15 11:18:26 +01:00
|
|
|
|
|
2013-10-15 00:41:27 +02:00
|
|
|
|
#ifdef LANG_RUS
|
2020-03-26 01:12:32 +01:00
|
|
|
|
char version[]="<EFBFBD><EFBFBD><EFBFBD><EFBFBD>⮢<EFBFBD><EFBFBD> <20><><EFBFBD>㧥<EFBFBD> 2.0 beta1";
|
2020-03-23 02:11:31 +01:00
|
|
|
|
#define T_LOADING "<22><><EFBFBD><EFBFBD>㧪<EFBFBD> <20><>࠭<EFBFBD><E0A0AD><EFBFBD>..."
|
|
|
|
|
#define T_RENDERING "<22><><EFBFBD><EFBFBD><EFBFBD>ਭ<EFBFBD>..."
|
2016-11-10 18:48:36 +01:00
|
|
|
|
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
|
2020-03-21 19:49:45 +01:00
|
|
|
|
char homepage[] = FROM "html\\homepage_ru.htm""\0";
|
|
|
|
|
char help[] = FROM "html\\help_ru.htm""\0";
|
2016-01-08 03:19:41 +01:00
|
|
|
|
char accept_language[]= "Accept-Language: ru\n";
|
|
|
|
|
char rmb_menu[] =
|
|
|
|
|
"<EFBFBD><EFBFBD>ᬮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>室<EFBFBD><E5AEA4><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>室<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>㧮<EFBFBD>";
|
2017-10-01 13:57:00 +02:00
|
|
|
|
char link_menu[] =
|
2018-03-23 16:04:20 +01:00
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>뫪<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᮤ<EFBFBD>ন<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>뫪<EFBFBD>";
|
2013-10-15 00:41:27 +02:00
|
|
|
|
#else
|
2020-03-26 01:12:32 +01:00
|
|
|
|
char version[]="Text-based Browser 2.0 beta1";
|
2020-03-23 02:11:31 +01:00
|
|
|
|
#define T_LOADING "Loading..."
|
|
|
|
|
#define T_RENDERING "Rendering..."
|
2016-11-10 18:48:36 +01:00
|
|
|
|
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
|
2020-03-21 19:49:45 +01:00
|
|
|
|
char homepage[] = FROM "html\\homepage_en.htm""\0";
|
|
|
|
|
char help[] = FROM "html\\help_en.htm""\0";
|
2016-01-08 03:19:41 +01:00
|
|
|
|
char accept_language[]= "Accept-Language: en\n";
|
|
|
|
|
char rmb_menu[] =
|
|
|
|
|
"View source
|
|
|
|
|
Edit source
|
|
|
|
|
History
|
|
|
|
|
Download Manager";
|
2017-10-01 13:57:00 +02:00
|
|
|
|
char link_menu[] =
|
2018-03-23 16:04:20 +01:00
|
|
|
|
"Copy link
|
|
|
|
|
Download link contents";
|
2013-10-15 00:41:27 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2020-03-26 01:12:32 +01:00
|
|
|
|
#define URL_SIZE 4000;
|
|
|
|
|
|
2020-03-25 01:18:19 +01:00
|
|
|
|
dword col_bg = 0xE3E2E2;
|
|
|
|
|
dword panel_color = 0xE3E2E2;
|
|
|
|
|
dword border_color = 0x8C8C8C;
|
2016-12-13 23:08:14 +01:00
|
|
|
|
|
2020-03-25 01:18:19 +01:00
|
|
|
|
bool debug_mode = false;
|
|
|
|
|
bool open_in_a_new_window = false;
|
2015-07-30 17:49:09 +02:00
|
|
|
|
|
2020-03-25 01:18:19 +01:00
|
|
|
|
_http http = {0, 0, 0, 0, 0, 0, 0};
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2020-03-25 01:18:19 +01:00
|
|
|
|
#include "..\TWB\TWB.c"
|
|
|
|
|
#include "history.h"
|
|
|
|
|
#include "show_src.h"
|
|
|
|
|
#include "download_manager.h"
|
2015-08-02 00:08:58 +02:00
|
|
|
|
|
2020-03-25 01:18:19 +01:00
|
|
|
|
#define URL_SERVICE_HISTORY "WebView:history"
|
|
|
|
|
#define URL_SERVICE_HOMEPAGE "WebView:home"
|
|
|
|
|
#define URL_SERVICE_HELP "WebView:help"
|
2013-10-15 00:41:27 +02:00
|
|
|
|
|
2016-11-20 20:34:39 +01:00
|
|
|
|
dword TOOLBAR_H = 40;
|
2015-03-16 15:20:32 +01:00
|
|
|
|
dword STATUSBAR_H = 15;
|
2018-10-02 16:01:29 +02:00
|
|
|
|
|
2020-03-25 01:18:19 +01:00
|
|
|
|
int action_buf;
|
2014-03-22 11:29:29 +01:00
|
|
|
|
|
2020-03-25 01:18:19 +01:00
|
|
|
|
bool source_mode = false;
|
2018-05-20 15:40:58 +02:00
|
|
|
|
|
2015-08-13 14:23:35 +02:00
|
|
|
|
progress_bar wv_progress_bar;
|
2020-03-25 01:18:19 +01:00
|
|
|
|
char stak[4096];
|
|
|
|
|
proc_info Form;
|
2014-03-22 11:29:29 +01:00
|
|
|
|
|
2015-08-13 14:23:35 +02:00
|
|
|
|
enum {
|
|
|
|
|
BACK_BUTTON=1000,
|
|
|
|
|
FORWARD_BUTTON,
|
|
|
|
|
REFRESH_BUTTON,
|
|
|
|
|
GOTOURL_BUTTON,
|
2016-12-13 23:08:14 +01:00
|
|
|
|
SANDWICH_BUTTON,
|
2020-03-25 01:18:19 +01:00
|
|
|
|
VIEW_SOURCE,
|
2015-08-13 14:23:35 +02:00
|
|
|
|
EDIT_SOURCE,
|
|
|
|
|
VIEW_HISTORY,
|
2016-12-13 23:08:14 +01:00
|
|
|
|
DOWNLOAD_MANAGER,
|
2020-03-25 01:18:19 +01:00
|
|
|
|
COPY_LINK_URL,
|
2018-03-23 16:04:20 +01:00
|
|
|
|
DOWNLOAD_LINK_CONTENTS,
|
2015-08-13 14:23:35 +02:00
|
|
|
|
};
|
|
|
|
|
|
2020-03-23 02:11:31 +01:00
|
|
|
|
char default_dir[] = "/rd/1";
|
|
|
|
|
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
|
|
|
|
|
|
2020-03-26 01:12:32 +01:00
|
|
|
|
char URL[URL_SIZE];
|
|
|
|
|
char editURL[URL_SIZE];
|
|
|
|
|
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#editURL,0,NULL,19,19};
|
2014-01-27 03:16:25 +01:00
|
|
|
|
|
2018-10-02 22:13:25 +02:00
|
|
|
|
#define SKIN_Y 24
|
2014-03-30 13:57:13 +02:00
|
|
|
|
|
2020-03-23 02:11:31 +01:00
|
|
|
|
void LoadLibraries()
|
|
|
|
|
{
|
|
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
|
|
|
|
load_dll(libio, #libio_init,1);
|
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
|
|
|
|
load_dll(libHTTP, #http_lib_init,1);
|
|
|
|
|
load_dll(iconv_lib, #iconv_open,0);
|
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
|
|
|
|
OpenDialog_init stdcall (#o_dialog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HandleParam()
|
|
|
|
|
{
|
|
|
|
|
if (param) {
|
2020-03-25 01:18:19 +01:00
|
|
|
|
if (!strncmp(#param, "-d ", 3)) {
|
2020-03-23 02:11:31 +01:00
|
|
|
|
strcpy(#downloader_edit, #param+3);
|
|
|
|
|
CreateThread(#Downloader,#downloader_stak+4092);
|
|
|
|
|
ExitProcess();
|
2020-03-25 01:18:19 +01:00
|
|
|
|
} else if (!strncmp(#param, "-s ", 3)) {
|
|
|
|
|
source_mode = true;
|
|
|
|
|
strcpy(#URL, #param + 3);
|
2020-03-23 02:11:31 +01:00
|
|
|
|
} else {
|
|
|
|
|
strcpy(#URL, #param);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
strcpy(#URL, URL_SERVICE_HOMEPAGE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
void main()
|
|
|
|
|
{
|
2020-03-23 02:11:31 +01:00
|
|
|
|
int redirect_count = 0;
|
2018-10-01 18:41:14 +02:00
|
|
|
|
int i;
|
2020-03-23 02:11:31 +01:00
|
|
|
|
LoadLibraries();
|
|
|
|
|
CreateDir("/tmp0/1/downloads");
|
2018-10-02 22:13:25 +02:00
|
|
|
|
Libimg_LoadImage(#skin, "/sys/toolbar.png");
|
2020-03-23 02:11:31 +01:00
|
|
|
|
HandleParam();
|
2018-10-06 00:10:27 +02:00
|
|
|
|
skin.h = 26;
|
2016-01-08 03:19:41 +01:00
|
|
|
|
WB1.list.SetFont(8, 14, 10011000b);
|
2015-08-29 22:14:17 +02:00
|
|
|
|
WB1.list.no_selection = true;
|
2017-09-17 03:32:09 +02:00
|
|
|
|
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
|
|
|
|
loop() switch(WaitEvent())
|
|
|
|
|
{
|
|
|
|
|
case evMouse:
|
|
|
|
|
edit_box_mouse stdcall (#address_box);
|
|
|
|
|
mouse.get();
|
2018-05-20 15:40:58 +02:00
|
|
|
|
if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
|
|
|
|
|
&& (bufsize) && (mouse.pkm) && (mouse.up) {
|
|
|
|
|
if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y);
|
|
|
|
|
break;
|
2017-09-17 03:32:09 +02:00
|
|
|
|
}
|
2018-05-20 15:40:58 +02:00
|
|
|
|
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
|
2017-09-17 03:32:09 +02:00
|
|
|
|
scrollbar_v_mouse (#scroll_wv);
|
|
|
|
|
if (WB1.list.first != scroll_wv.position)
|
|
|
|
|
{
|
|
|
|
|
WB1.list.first = scroll_wv.position;
|
|
|
|
|
WB1.DrawPage();
|
2012-11-26 16:26:15 +01:00
|
|
|
|
break;
|
2017-09-17 03:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
break;
|
2015-08-10 17:08:16 +02:00
|
|
|
|
|
2017-09-17 03:32:09 +02:00
|
|
|
|
case evButton:
|
|
|
|
|
ProcessEvent(GetButtonID());
|
|
|
|
|
break;
|
2015-08-10 17:08:16 +02:00
|
|
|
|
|
2017-09-17 03:32:09 +02:00
|
|
|
|
case evKey:
|
|
|
|
|
GetKeys();
|
2020-03-21 15:33:54 +01:00
|
|
|
|
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
|
2020-03-26 01:12:32 +01:00
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_H) {ProcessEvent(VIEW_HISTORY);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_U) {EventViewSource();break;}
|
2020-03-21 15:33:54 +01:00
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_T)
|
2020-03-26 01:12:32 +01:00
|
|
|
|
|| (key_scancode == SCAN_CODE_KEY_N) {RunProgram(#program_path, NULL);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_J) {ProcessEvent(DOWNLOAD_MANAGER);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_R) {ProcessEvent(REFRESH_BUTTON);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_ENTER) {EventSeachWeb();break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_LEFT) {ProcessEvent(BACK_BUTTON);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_RIGHT) {ProcessEvent(FORWARD_BUTTON);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_W) {ExitProcess();break;}
|
2020-03-21 15:33:54 +01:00
|
|
|
|
}
|
2020-03-21 19:49:45 +01:00
|
|
|
|
|
|
|
|
|
if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
|
|
|
|
|
|
2018-10-29 12:39:31 +01:00
|
|
|
|
if (address_box.flags & ed_focus)
|
2017-09-17 03:32:09 +02:00
|
|
|
|
{
|
2020-03-21 15:33:54 +01:00
|
|
|
|
if (key_scancode == SCAN_CODE_ENTER) {
|
|
|
|
|
ProcessEvent(key_scancode);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2017-09-17 03:32:09 +02:00
|
|
|
|
EAX = key_editbox;
|
|
|
|
|
edit_box_key stdcall(#address_box);
|
2015-08-10 17:08:16 +02:00
|
|
|
|
}
|
2017-09-17 03:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-10-01 18:41:14 +02:00
|
|
|
|
#define KEY_SCROLL_N 11
|
|
|
|
|
if (SCAN_CODE_UP == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyUp();
|
|
|
|
|
if (SCAN_CODE_DOWN == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyDown();
|
2020-03-21 19:49:45 +01:00
|
|
|
|
if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();}
|
2017-09-17 03:32:09 +02:00
|
|
|
|
if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
|
|
|
|
|
else ProcessEvent(key_scancode);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2015-03-18 20:40:42 +01:00
|
|
|
|
|
2017-09-17 03:32:09 +02:00
|
|
|
|
case evReDraw:
|
2018-10-11 16:32:24 +02:00
|
|
|
|
if (menu.cur_y) {
|
|
|
|
|
ProcessEvent(menu.cur_y);
|
|
|
|
|
menu.cur_y = 0;
|
2017-09-17 03:32:09 +02:00
|
|
|
|
}
|
2020-03-25 01:18:19 +01:00
|
|
|
|
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
|
2017-09-17 03:32:09 +02:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2020-03-23 02:11:31 +01:00
|
|
|
|
system.color.get();
|
|
|
|
|
col_bg = system.color.work;
|
2017-09-17 03:32:09 +02:00
|
|
|
|
if (Form.status_window>2) { DrawTitle(#header); break; }
|
|
|
|
|
if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
|
|
|
|
|
if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
|
2020-03-23 02:11:31 +01:00
|
|
|
|
draw_window();
|
2017-09-17 03:32:09 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evNetwork:
|
2018-05-18 22:18:10 +02:00
|
|
|
|
if (http.transfer > 0) {
|
|
|
|
|
http.receive();
|
|
|
|
|
EventUpdateProgressBar();
|
2020-03-23 02:11:31 +01:00
|
|
|
|
DrawStatusBar(T_LOADING);
|
2018-05-18 22:18:10 +02:00
|
|
|
|
if (http.receive_result == 0) {
|
2017-09-17 03:32:09 +02:00
|
|
|
|
// Handle redirects
|
2018-05-18 22:18:10 +02:00
|
|
|
|
if (http.status_code >= 300) && (http.status_code < 400)
|
2014-03-23 18:12:21 +01:00
|
|
|
|
{
|
2020-03-23 02:11:31 +01:00
|
|
|
|
redirect_count++;
|
|
|
|
|
if (redirect_count>5)
|
2014-02-09 16:19:23 +01:00
|
|
|
|
{
|
2018-05-20 15:40:58 +02:00
|
|
|
|
notify("'Too many redirects.' -E");
|
|
|
|
|
StopLoading();
|
2014-02-09 16:19:23 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-05-20 15:40:58 +02:00
|
|
|
|
http.handle_redirect();
|
|
|
|
|
http.free();
|
|
|
|
|
GetAbsoluteURL(#http.redirect_url);
|
2020-03-23 02:11:31 +01:00
|
|
|
|
debug("Redirect: "); debugln(#http.redirect_url);
|
2018-05-20 15:40:58 +02:00
|
|
|
|
history.back();
|
2020-03-23 02:11:31 +01:00
|
|
|
|
strcpy(#URL, #http.redirect_url);
|
2018-05-20 15:40:58 +02:00
|
|
|
|
strcpy(#editURL, #URL);
|
2020-03-21 19:49:45 +01:00
|
|
|
|
DrawOmnibox();
|
2018-05-20 15:40:58 +02:00
|
|
|
|
OpenPage();
|
2020-03-21 15:33:54 +01:00
|
|
|
|
//ProcessLink(history.current());
|
2014-02-05 00:57:32 +01:00
|
|
|
|
}
|
2018-05-20 15:40:58 +02:00
|
|
|
|
break;
|
2017-09-17 03:32:09 +02:00
|
|
|
|
}
|
2020-03-23 02:11:31 +01:00
|
|
|
|
redirect_count = 0;
|
2017-09-17 03:32:09 +02:00
|
|
|
|
// Loading the page is complete, free resources
|
2018-05-20 15:40:58 +02:00
|
|
|
|
history.add(#URL);
|
|
|
|
|
bufpointer = http.content_pointer;
|
|
|
|
|
bufsize = http.content_received;
|
|
|
|
|
http.free();
|
2020-03-23 02:11:31 +01:00
|
|
|
|
DrawStatusBar(T_RENDERING);
|
2018-05-20 15:40:58 +02:00
|
|
|
|
ShowPage();
|
2020-03-23 02:11:31 +01:00
|
|
|
|
DrawStatusBar(NULL);
|
2014-01-27 20:34:00 +01:00
|
|
|
|
}
|
2017-09-17 03:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetElementSizes()
|
|
|
|
|
{
|
2016-11-20 20:34:39 +01:00
|
|
|
|
address_box.top = TOOLBAR_H/2-10;
|
2016-12-11 23:58:11 +01:00
|
|
|
|
basic_line_h = calc(WB1.list.font_h * 130) / 100;
|
2016-11-20 20:34:39 +01:00
|
|
|
|
address_box.width = Form.cwidth - address_box.left - 50;
|
2016-12-21 11:56:06 +01:00
|
|
|
|
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x,
|
2016-12-11 23:58:11 +01:00
|
|
|
|
Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h);
|
|
|
|
|
WB1.list.wheel_size = 7 * basic_line_h;
|
2020-03-22 20:50:16 +01:00
|
|
|
|
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
|
2016-12-11 23:58:11 +01:00
|
|
|
|
WB1.list.visible = WB1.list.h;
|
2016-01-08 03:19:41 +01:00
|
|
|
|
if (WB1.list.w!=WB1.DrawBuf.bufw) {
|
2020-03-18 01:45:36 +01:00
|
|
|
|
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 800*20);
|
2016-11-10 18:48:36 +01:00
|
|
|
|
ProcessEvent(REFRESH_BUTTON);
|
2016-01-08 03:19:41 +01:00
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-17 20:19:36 +01:00
|
|
|
|
|
2015-12-17 20:15:49 +01:00
|
|
|
|
|
2020-03-23 02:11:31 +01:00
|
|
|
|
void draw_window()
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
2015-08-26 21:22:20 +02:00
|
|
|
|
DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color);
|
2015-08-13 14:23:35 +02:00
|
|
|
|
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
|
2014-03-22 11:29:29 +01:00
|
|
|
|
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
SetElementSizes();
|
2016-11-20 20:34:39 +01:00
|
|
|
|
DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 25,border_color);
|
|
|
|
|
DefineButton(address_box.left-52, address_box.top-2, 24, skin.h-2, BACK_BUTTON+BT_HIDE, 0);
|
|
|
|
|
DefineButton(address_box.left-27, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0);
|
2018-10-02 22:13:25 +02:00
|
|
|
|
img_draw stdcall(skin.image, address_box.left-53, address_box.top-3, 51, skin.h, 0, SKIN_Y);
|
2015-08-13 14:23:35 +02:00
|
|
|
|
DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
|
2016-11-20 20:34:39 +01:00
|
|
|
|
DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
|
2018-10-02 22:13:25 +02:00
|
|
|
|
img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y);
|
2014-03-22 11:29:29 +01:00
|
|
|
|
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
|
|
|
|
|
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
|
2020-03-26 01:12:32 +01:00
|
|
|
|
if (!header) {
|
2018-05-20 15:40:58 +02:00
|
|
|
|
OpenPage();
|
2020-03-26 01:12:32 +01:00
|
|
|
|
WB1.DrawScroller();
|
|
|
|
|
}
|
2018-05-20 15:40:58 +02:00
|
|
|
|
else {
|
|
|
|
|
WB1.DrawPage();
|
2020-03-21 19:49:45 +01:00
|
|
|
|
DrawOmnibox();
|
2018-05-20 15:40:58 +02:00
|
|
|
|
}
|
2014-03-23 23:49:49 +01:00
|
|
|
|
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
|
2014-03-24 00:18:01 +01:00
|
|
|
|
DrawProgress();
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-11-10 18:48:36 +01:00
|
|
|
|
void ProcessEvent(dword id__)
|
2013-12-27 01:33:12 +01:00
|
|
|
|
{
|
2016-11-10 18:48:36 +01:00
|
|
|
|
switch (id__)
|
2013-12-27 01:33:12 +01:00
|
|
|
|
{
|
2016-11-10 18:48:36 +01:00
|
|
|
|
case 1:
|
|
|
|
|
ExitProcess();
|
|
|
|
|
return;
|
2015-08-10 17:08:16 +02:00
|
|
|
|
case SCAN_CODE_BS:
|
2015-08-13 14:23:35 +02:00
|
|
|
|
case BACK_BUTTON:
|
2016-01-01 17:51:53 +01:00
|
|
|
|
if (history.back()) {
|
|
|
|
|
strcpy(#URL, history.current());
|
2015-12-16 23:44:42 +01:00
|
|
|
|
OpenPage();
|
|
|
|
|
}
|
2015-08-10 17:08:16 +02:00
|
|
|
|
return;
|
2015-08-13 14:23:35 +02:00
|
|
|
|
case FORWARD_BUTTON:
|
2016-01-01 17:51:53 +01:00
|
|
|
|
if (history.forward()) {
|
|
|
|
|
strcpy(#URL, history.current());
|
2015-12-16 23:44:42 +01:00
|
|
|
|
OpenPage();
|
|
|
|
|
}
|
2015-08-10 17:08:16 +02:00
|
|
|
|
return;
|
2015-08-13 14:23:35 +02:00
|
|
|
|
case GOTOURL_BUTTON:
|
2015-08-26 21:22:20 +02:00
|
|
|
|
case SCAN_CODE_ENTER:
|
2020-03-21 15:33:54 +01:00
|
|
|
|
EventSubmitOmnibox();
|
2015-08-10 17:08:16 +02:00
|
|
|
|
return;
|
2015-08-13 14:23:35 +02:00
|
|
|
|
case REFRESH_BUTTON:
|
2018-05-18 22:18:10 +02:00
|
|
|
|
if (http.transfer > 0)
|
2015-08-10 17:59:20 +02:00
|
|
|
|
{
|
|
|
|
|
StopLoading();
|
2020-03-23 02:11:31 +01:00
|
|
|
|
draw_window();
|
2015-08-10 17:59:20 +02:00
|
|
|
|
}
|
|
|
|
|
else OpenPage();
|
|
|
|
|
return;
|
2015-08-13 14:23:35 +02:00
|
|
|
|
case SANDWICH_BUTTON:
|
2016-12-13 23:08:14 +01:00
|
|
|
|
EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6);
|
2014-01-29 01:14:09 +01:00
|
|
|
|
return;
|
2015-08-13 14:23:35 +02:00
|
|
|
|
case VIEW_SOURCE:
|
2020-03-25 01:18:19 +01:00
|
|
|
|
EventViewSource();
|
2014-03-30 13:57:13 +02:00
|
|
|
|
break;
|
2015-08-13 14:23:35 +02:00
|
|
|
|
case EDIT_SOURCE:
|
2020-03-25 01:18:19 +01:00
|
|
|
|
if (check_is_the_adress_local(#URL)) {
|
|
|
|
|
RunProgram("/rd/1/tinypad", #URL);
|
|
|
|
|
} else {
|
2018-04-16 00:44:36 +02:00
|
|
|
|
CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
|
2015-07-30 17:49:09 +02:00
|
|
|
|
if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
|
2014-03-12 23:56:28 +01:00
|
|
|
|
}
|
2013-12-27 01:33:12 +01:00
|
|
|
|
return;
|
2015-08-13 14:23:35 +02:00
|
|
|
|
case VIEW_HISTORY:
|
|
|
|
|
strcpy(#URL, URL_SERVICE_HISTORY);
|
|
|
|
|
OpenPage();
|
|
|
|
|
return;
|
|
|
|
|
case DOWNLOAD_MANAGER:
|
|
|
|
|
if (!downloader_opened) {
|
2015-12-22 19:14:35 +01:00
|
|
|
|
downloader_edit = NULL;
|
2015-08-13 14:23:35 +02:00
|
|
|
|
CreateThread(#Downloader,#downloader_stak+4092);
|
|
|
|
|
}
|
2013-12-27 01:33:12 +01:00
|
|
|
|
return;
|
2018-05-20 15:40:58 +02:00
|
|
|
|
case COPY_LINK_URL:
|
2017-10-01 13:57:00 +02:00
|
|
|
|
Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
|
|
|
|
|
notify("'URL copied to clipboard'O");
|
|
|
|
|
return;
|
2018-03-23 16:04:20 +01:00
|
|
|
|
case DOWNLOAD_LINK_CONTENTS:
|
|
|
|
|
if (!downloader_opened) {
|
|
|
|
|
strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active));
|
|
|
|
|
CreateThread(#Downloader,#downloader_stak+4092);
|
|
|
|
|
}
|
|
|
|
|
return;
|
2018-05-20 15:40:58 +02:00
|
|
|
|
case SCAN_CODE_F12:
|
|
|
|
|
debug_mode ^= 1;
|
|
|
|
|
if (debug_mode) notify("'Debug mode ON'-I");
|
|
|
|
|
else notify("'Debug mode OFF'-I");
|
|
|
|
|
return;
|
2013-12-27 01:33:12 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-12 23:56:28 +01:00
|
|
|
|
void StopLoading()
|
|
|
|
|
{
|
2018-05-18 22:18:10 +02:00
|
|
|
|
if (http.transfer)
|
2014-03-15 11:34:28 +01:00
|
|
|
|
{
|
2018-05-18 22:18:10 +02:00
|
|
|
|
EAX = http.transfer;
|
2014-03-15 11:34:28 +01:00
|
|
|
|
EAX = EAX.http_msg.content_ptr; // get pointer to data
|
|
|
|
|
$push EAX // save it on the stack
|
2018-05-18 22:18:10 +02:00
|
|
|
|
http_free stdcall (http.transfer); // abort connection
|
2014-03-15 11:34:28 +01:00
|
|
|
|
$pop EAX
|
2015-07-30 17:49:09 +02:00
|
|
|
|
free(EAX); // free data
|
2018-05-18 22:18:10 +02:00
|
|
|
|
http.transfer=0;
|
2014-03-15 11:34:28 +01:00
|
|
|
|
bufsize = 0;
|
2015-07-30 17:49:09 +02:00
|
|
|
|
bufpointer = free(bufpointer);
|
2020-03-22 20:50:16 +01:00
|
|
|
|
pause(10);
|
2014-03-15 11:34:28 +01:00
|
|
|
|
}
|
2015-03-16 15:20:32 +01:00
|
|
|
|
wv_progress_bar.value = 0;
|
2020-03-21 19:49:45 +01:00
|
|
|
|
DrawOmnibox();
|
2014-03-14 20:06:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-10 20:53:38 +01:00
|
|
|
|
void ReplaceSpaceInUrl() {
|
|
|
|
|
int i;
|
|
|
|
|
strcpy(#editURL, #URL);
|
|
|
|
|
while (i = strchr(#URL, ' '))
|
|
|
|
|
{
|
|
|
|
|
i -= #URL;
|
|
|
|
|
strlcpy(#URL+i+3, #editURL+i+1, sizeof(URL)-i-4);
|
|
|
|
|
URL[i] = '%';
|
|
|
|
|
URL[i+1] = '2';
|
|
|
|
|
URL[i+2] = '0';
|
|
|
|
|
}
|
|
|
|
|
strcpy(#editURL, #URL);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-27 13:30:42 +01:00
|
|
|
|
void OpenPage()
|
|
|
|
|
{
|
2018-05-20 15:40:58 +02:00
|
|
|
|
char getUrl[sizeof(URL)];
|
2014-03-12 23:56:28 +01:00
|
|
|
|
StopLoading();
|
2013-12-27 13:30:42 +01:00
|
|
|
|
strcpy(#editURL, #URL);
|
2016-01-01 17:51:53 +01:00
|
|
|
|
history.add(#URL);
|
2015-07-30 17:49:09 +02:00
|
|
|
|
if (!strncmp(#URL,"WebView:",8))
|
2014-03-23 23:49:49 +01:00
|
|
|
|
{
|
2020-03-26 01:12:32 +01:00
|
|
|
|
if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage));
|
|
|
|
|
else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help));
|
2015-07-30 17:49:09 +02:00
|
|
|
|
else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
|
2020-03-20 02:28:59 +01:00
|
|
|
|
else {bufsize=0; ShowPage();} //page not found
|
2020-03-21 19:49:45 +01:00
|
|
|
|
DrawOmnibox();
|
2014-03-23 23:49:49 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2018-05-20 15:40:58 +02:00
|
|
|
|
if (!strncmp(#URL,"http:",5)) || (!strncmp(#URL,"https://",8))
|
2013-12-27 13:30:42 +01:00
|
|
|
|
{
|
2020-02-10 20:53:38 +01:00
|
|
|
|
ReplaceSpaceInUrl();
|
2018-10-02 22:13:25 +02:00
|
|
|
|
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 68, SKIN_Y);
|
2018-05-20 15:40:58 +02:00
|
|
|
|
|
|
|
|
|
if (!strncmp(#URL,"http:",5)) {
|
|
|
|
|
http.get(#URL);
|
2020-03-26 01:12:32 +01:00
|
|
|
|
} else if (!strncmp(#URL,"https://",8)) {
|
2018-05-20 15:40:58 +02:00
|
|
|
|
sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL);
|
|
|
|
|
http.get(#getUrl);
|
|
|
|
|
}
|
2020-03-26 01:12:32 +01:00
|
|
|
|
|
2018-05-18 22:18:10 +02:00
|
|
|
|
if (!http.transfer)
|
2014-03-15 11:23:06 +01:00
|
|
|
|
{
|
|
|
|
|
StopLoading();
|
|
|
|
|
bufsize = 0;
|
2015-07-30 17:49:09 +02:00
|
|
|
|
bufpointer = free(bufpointer);
|
2014-03-15 11:23:06 +01:00
|
|
|
|
ShowPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-12-27 13:30:42 +01:00
|
|
|
|
}
|
2014-03-12 23:56:28 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
file_size stdcall (#URL);
|
2020-03-26 01:12:32 +01:00
|
|
|
|
if (EBX) {
|
2020-03-20 02:28:59 +01:00
|
|
|
|
bufsize = EBX;
|
2015-07-30 17:49:09 +02:00
|
|
|
|
free(bufpointer);
|
|
|
|
|
bufpointer = malloc(bufsize);
|
2014-03-30 13:57:13 +02:00
|
|
|
|
ReadFile(0, bufsize, bufpointer, #URL);
|
2020-03-26 01:12:32 +01:00
|
|
|
|
} else {
|
|
|
|
|
bufsize = bufpointer = 0;
|
2014-03-15 16:16:08 +01:00
|
|
|
|
}
|
2014-03-14 20:06:48 +01:00
|
|
|
|
ShowPage();
|
2014-03-12 23:56:28 +01:00
|
|
|
|
}
|
2013-12-27 13:30:42 +01:00
|
|
|
|
}
|
2013-12-27 12:15:17 +01:00
|
|
|
|
|
2020-03-21 15:33:54 +01:00
|
|
|
|
void ProcessAnchor()
|
2014-01-22 01:08:47 +01:00
|
|
|
|
{
|
2020-03-21 15:33:54 +01:00
|
|
|
|
char anchor[256];
|
2020-03-26 01:12:32 +01:00
|
|
|
|
dword anchor_pos;
|
2020-03-21 15:33:54 +01:00
|
|
|
|
|
|
|
|
|
anchor_pos = strrchr(#URL, '#')-1;
|
2020-03-26 01:12:32 +01:00
|
|
|
|
strlcpy(#anchors.current_anchor_name, #URL+anchor_pos, sizeof(anchor)-1);
|
2020-03-21 15:33:54 +01:00
|
|
|
|
URL[anchor_pos] = 0x00;
|
2014-03-30 13:57:13 +02:00
|
|
|
|
|
2020-03-26 01:12:32 +01:00
|
|
|
|
if (URL[0] == NULL) {
|
|
|
|
|
//case when URL consists of anchor only
|
|
|
|
|
if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1);
|
2020-03-21 15:33:54 +01:00
|
|
|
|
strcpy(#URL, history.current());
|
2020-03-26 01:12:32 +01:00
|
|
|
|
} else {
|
2020-03-21 15:33:54 +01:00
|
|
|
|
GetAbsoluteURL(#URL);
|
|
|
|
|
OpenPage();
|
2020-03-26 01:12:32 +01:00
|
|
|
|
if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1);
|
2015-08-23 21:59:44 +02:00
|
|
|
|
}
|
2020-03-21 15:33:54 +01:00
|
|
|
|
|
|
|
|
|
WB1.DrawPage();
|
|
|
|
|
strcpy(#editURL, #URL);
|
|
|
|
|
strcat(#editURL, #anchor);
|
2020-03-21 19:49:45 +01:00
|
|
|
|
DrawOmnibox();
|
2014-01-22 01:08:47 +01:00
|
|
|
|
}
|
2013-12-27 12:15:17 +01:00
|
|
|
|
|
2020-03-21 15:33:54 +01:00
|
|
|
|
void EventSubmitOmnibox()
|
2015-03-01 22:36:17 +01:00
|
|
|
|
{
|
2020-03-21 15:33:54 +01:00
|
|
|
|
if (!editURL[0]) return;
|
|
|
|
|
if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/')
|
|
|
|
|
|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8))
|
|
|
|
|
{
|
|
|
|
|
strcpy(#URL, #editURL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strlcpy(#URL,"http://",7);
|
|
|
|
|
strcat(#URL, #editURL);
|
|
|
|
|
}
|
2020-03-26 01:12:32 +01:00
|
|
|
|
OpenPage();
|
2015-03-01 22:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-21 15:33:54 +01:00
|
|
|
|
void EventClickLink()
|
2015-08-26 21:22:20 +02:00
|
|
|
|
{
|
2020-03-21 15:33:54 +01:00
|
|
|
|
strcpy(#URL, PageLinks.GetURL(PageLinks.active));
|
|
|
|
|
GetAbsoluteURL(#URL);
|
|
|
|
|
ProcessLink();
|
2015-08-26 21:22:20 +02:00
|
|
|
|
}
|
2015-08-19 14:48:31 +02:00
|
|
|
|
|
2020-03-21 15:33:54 +01:00
|
|
|
|
void ProcessLink()
|
2015-08-27 01:55:33 +02:00
|
|
|
|
{
|
2018-05-18 22:18:10 +02:00
|
|
|
|
if (http.transfer > 0)
|
2015-08-27 01:55:33 +02:00
|
|
|
|
{
|
|
|
|
|
StopLoading();
|
2016-01-01 17:51:53 +01:00
|
|
|
|
history.back();
|
2015-08-27 01:55:33 +02:00
|
|
|
|
}
|
2020-03-21 15:33:54 +01:00
|
|
|
|
|
|
|
|
|
if (strrchr(#URL, '#')!=0) {
|
|
|
|
|
ProcessAnchor();
|
2020-03-20 02:28:59 +01:00
|
|
|
|
return;
|
2015-08-27 01:55:33 +02:00
|
|
|
|
}
|
2016-11-20 12:10:10 +01:00
|
|
|
|
|
2020-03-21 15:33:54 +01:00
|
|
|
|
if (!strncmp(#URL,"mailto:", 7)) || (!strncmp(#URL,"tel:", 4))
|
2015-08-27 01:55:33 +02:00
|
|
|
|
{
|
|
|
|
|
notify(#URL);
|
2016-01-01 17:51:53 +01:00
|
|
|
|
strcpy(#editURL, history.current());
|
|
|
|
|
strcpy(#URL, history.current());
|
2015-08-27 01:55:33 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-20 12:10:10 +01:00
|
|
|
|
|
2020-03-21 15:33:54 +01:00
|
|
|
|
if (!strncmp(#URL,"WebView:",8)) {
|
|
|
|
|
OpenPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-20 12:10:10 +01:00
|
|
|
|
|
2018-05-20 15:40:58 +02:00
|
|
|
|
if (strncmp(#URL,"http://",7)!=0) && (strncmp(#URL,"https://",8)!=0)
|
2016-11-20 12:10:10 +01:00
|
|
|
|
{
|
|
|
|
|
if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true)
|
|
|
|
|
{
|
2018-10-01 18:41:14 +02:00
|
|
|
|
if (strchr(#URL, '|')) {
|
|
|
|
|
ESBYTE[strchr(#URL, '|')] = NULL;
|
|
|
|
|
RunProgram(#URL, strlen(#URL)+1+#URL);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
RunProgram("/sys/@open", #URL);
|
|
|
|
|
}
|
2016-11-20 12:10:10 +01:00
|
|
|
|
strcpy(#editURL, history.current());
|
|
|
|
|
strcpy(#URL, history.current());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (UrlExtIs(".png")==true) || (UrlExtIs(".gif")==true) || (UrlExtIs(".jpg")==true)
|
2016-12-11 23:58:11 +01:00
|
|
|
|
|| (UrlExtIs(".zip")==true) || (UrlExtIs(".kex")==true) || (UrlExtIs(".pdf")==true)
|
|
|
|
|
|| (UrlExtIs(".7z")==true) {
|
2017-09-17 14:35:45 +02:00
|
|
|
|
if (!downloader_opened) {
|
|
|
|
|
strcpy(#downloader_edit, #URL);
|
|
|
|
|
CreateThread(#Downloader,#downloader_stak+4092);
|
|
|
|
|
strcpy(#editURL, history.current());
|
|
|
|
|
strcpy(#URL, history.current());
|
|
|
|
|
}
|
|
|
|
|
else notify("'WebView\nPlease, start a new download only when previous ended.'Et");
|
2016-11-20 12:10:10 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-05 12:33:54 +02:00
|
|
|
|
if (open_in_a_new_window)
|
|
|
|
|
{
|
|
|
|
|
RunProgram(#program_path, #URL);
|
|
|
|
|
strcpy(#editURL, history.current());
|
|
|
|
|
strcpy(#URL, history.current());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OpenPage();
|
|
|
|
|
}
|
|
|
|
|
open_in_a_new_window = false;
|
2015-08-27 01:55:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-21 19:49:45 +01:00
|
|
|
|
void DrawOmnibox()
|
2020-03-21 15:33:54 +01:00
|
|
|
|
{
|
|
|
|
|
int skin_x_offset;
|
|
|
|
|
DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
|
|
|
|
|
DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
|
2020-03-25 01:18:19 +01:00
|
|
|
|
if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0;
|
2020-03-21 15:33:54 +01:00
|
|
|
|
EditBox_UpdateText(#address_box, address_box.flags);
|
|
|
|
|
edit_box_draw stdcall(#address_box);
|
|
|
|
|
if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
|
|
|
|
|
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 01:12:32 +01:00
|
|
|
|
void LoadInternalPage(dword _bufpos, _in_filesize){
|
|
|
|
|
bufsize = _in_filesize;
|
|
|
|
|
if (bufpointer!=_bufpos) free(bufpointer);
|
|
|
|
|
bufpointer = malloc(bufsize);
|
|
|
|
|
memmov(bufpointer, _bufpos, bufsize);
|
2020-03-25 01:18:19 +01:00
|
|
|
|
ShowPage();
|
|
|
|
|
}
|
2020-03-21 15:33:54 +01:00
|
|
|
|
|
|
|
|
|
void ShowPage()
|
|
|
|
|
{
|
2020-03-26 01:12:32 +01:00
|
|
|
|
WB1.list.first = 0; //scroll page to the top
|
2020-03-21 19:49:45 +01:00
|
|
|
|
DrawOmnibox();
|
2020-03-25 01:18:19 +01:00
|
|
|
|
if (!bufsize) || (!bufpointer) {
|
2020-03-26 01:12:32 +01:00
|
|
|
|
LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
2020-03-21 15:33:54 +01:00
|
|
|
|
}
|
2020-03-26 01:12:32 +01:00
|
|
|
|
WB1.ParseHtml();
|
2020-03-25 01:18:19 +01:00
|
|
|
|
if (source_mode) {
|
|
|
|
|
source_mode = false;
|
|
|
|
|
ShowSource();
|
|
|
|
|
LoadInternalPage(bufpointer, bufsize);
|
2020-03-21 15:33:54 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
byte UrlExtIs(dword ext)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawProgress()
|
|
|
|
|
{
|
|
|
|
|
dword persent;
|
|
|
|
|
if (http.transfer == 0) return;
|
|
|
|
|
if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10;
|
2020-03-23 02:11:31 +01:00
|
|
|
|
DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, 0x72B7EB);
|
2020-03-21 15:33:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-13 23:08:14 +01:00
|
|
|
|
void EventShowPageMenu(dword _left, _top)
|
2016-12-04 17:50:34 +01:00
|
|
|
|
{
|
|
|
|
|
menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-13 23:08:14 +01:00
|
|
|
|
void EventShowLinkMenu(dword _left, _top)
|
|
|
|
|
{
|
2018-05-20 15:40:58 +02:00
|
|
|
|
menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL);
|
2016-12-13 23:08:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-18 22:18:10 +02:00
|
|
|
|
void EventUpdateProgressBar()
|
|
|
|
|
{
|
|
|
|
|
wv_progress_bar.max = http.content_length;
|
|
|
|
|
if (wv_progress_bar.value != http.content_received)
|
|
|
|
|
{
|
|
|
|
|
wv_progress_bar.value = http.content_received;
|
|
|
|
|
DrawProgress();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-21 19:49:45 +01:00
|
|
|
|
void EventSeachWeb()
|
|
|
|
|
{
|
|
|
|
|
sprintf(#URL, "https://www.google.com/search?q=%s", #editURL);
|
2020-03-23 02:11:31 +01:00
|
|
|
|
replace_char(#URL, ' ', '_', sizeof(URL));
|
2020-03-21 19:49:45 +01:00
|
|
|
|
ProcessLink();
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-23 02:11:31 +01:00
|
|
|
|
void EventOpenDialog()
|
|
|
|
|
{
|
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
|
|
|
|
if (o_dialog.status) {
|
|
|
|
|
strcpy(#URL, #openfile_path);
|
|
|
|
|
OpenPage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-25 01:18:19 +01:00
|
|
|
|
void EventViewSource()
|
|
|
|
|
{
|
|
|
|
|
char source_view_param[sizeof(URL)+4];
|
|
|
|
|
strcpy(#source_view_param, "-s ");
|
|
|
|
|
strcat(#source_view_param, #URL);
|
|
|
|
|
RunProgram(#program_path, #source_view_param);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-21 15:33:54 +01:00
|
|
|
|
void DrawStatusBar(dword _status_text)
|
2016-12-13 23:08:14 +01:00
|
|
|
|
{
|
2020-03-23 02:11:31 +01:00
|
|
|
|
status_text.start_x = 10;
|
2016-12-13 23:08:14 +01:00
|
|
|
|
status_text.start_y = Form.cheight - STATUSBAR_H + 3;
|
|
|
|
|
status_text.area_size_x = Form.cwidth - status_text.start_x -3;
|
|
|
|
|
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
|
|
|
|
|
status_text.text_pointer = _status_text;
|
|
|
|
|
PathShow_prepare stdcall(#status_text);
|
|
|
|
|
PathShow_draw stdcall(#status_text);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-30 17:49:09 +02:00
|
|
|
|
stop:
|