Subversion Repositories Kolibri OS

Rev

Rev 8444 | Rev 8451 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8444 Rev 8445
1
//Copyright 2007-2020 by Veliant & Leency
1
//Copyright 2007-2020 by Veliant & Leency
2
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
2
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
3
 
3
 
4
#ifndef AUTOBUILD
4
#ifndef AUTOBUILD
5
	#include "lang.h--"
5
	#include "lang.h--"
6
#endif
6
#endif
7
 
7
 
8
//===================================================//
8
//===================================================//
9
//                                                   //
9
//                                                   //
10
//                       LIB                         //
10
//                       LIB                         //
11
//                                                   //
11
//                                                   //
12
//===================================================//
12
//===================================================//
13
 
13
 
14
#define MEMSIZE 1024 * 130
14
#define MEMSIZE 1024 * 130
15
#include "..\lib\gui.h"
15
#include "..\lib\gui.h"
16
#include "..\lib\draw_buf.h"
16
#include "..\lib\draw_buf.h"
17
#include "..\lib\list_box.h"
17
#include "..\lib\list_box.h"
18
#include "..\lib\cursor.h"
18
#include "..\lib\cursor.h"
19
#include "..\lib\collection.h"
19
#include "..\lib\collection.h"
20
#include "..\lib\random.h"
20
#include "..\lib\random.h"
21
#include "..\lib\clipboard.h"
21
#include "..\lib\clipboard.h"
22
 
22
 
23
#include "..\lib\obj\box_lib.h"
23
#include "..\lib\obj\box_lib.h"
24
#include "..\lib\obj\libimg.h"
24
#include "..\lib\obj\libimg.h"
25
#include "..\lib\obj\http.h"
25
#include "..\lib\obj\http.h"
26
#include "..\lib\obj\iconv.h"
26
#include "..\lib\obj\iconv.h"
27
#include "..\lib\obj\proc_lib.h"
27
#include "..\lib\obj\proc_lib.h"
28
#include "..\lib\obj\netcode.h"
28
#include "..\lib\obj\netcode.h"
29
 
29
 
30
#include "..\lib\patterns\history.h"
30
#include "..\lib\patterns\history.h"
31
#include "..\lib\patterns\simple_open_dialog.h"
31
#include "..\lib\patterns\simple_open_dialog.h"
32
#include "..\lib\patterns\toolbar_button.h"
32
#include "..\lib\patterns\toolbar_button.h"
33
#include "..\lib\patterns\restart_process.h"
33
#include "..\lib\patterns\restart_process.h"
34
 
34
 
35
#include "const.h"
35
#include "const.h"
36
#include "cache.h"
36
#include "cache.h"
37
#include "show_src.h"
37
#include "show_src.h"
38
 
38
 
39
//===================================================//
39
//===================================================//
40
//                                                   //
40
//                                                   //
41
//                       DATA                        //
41
//                       DATA                        //
42
//                                                   //
42
//                                                   //
43
//===================================================//
43
//===================================================//
44
char version[]="WebView 3.14";
44
char version[]="WebView 3.15";
45
 
45
 
46
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
46
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
47
 
47
 
48
bool debug_mode = false;
48
bool debug_mode = false;
49
bool show_images = true;
49
bool show_images = true;
50
 
50
 
51
_history history;
51
_history history;
52
 
52
 
53
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
53
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
54
 
54
 
55
#include "TWB\TWB.c" //HTML Parser, a core component
55
#include "TWB\TWB.c" //HTML Parser, a core component
56
 
56
 
57
TWebBrowser WB1;
57
TWebBrowser WB1;
58
 
58
 
59
#include "history.h"
59
#include "history.h"
60
 
60
 
61
#define PADDING 9
61
#define PADDING 9
62
#define TSZE 25
62
#define TSZE 25
63
#define STATUSBAR_H 15
63
#define STATUSBAR_H 15
64
#define TAB_H 20
64
#define TAB_H 20
65
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
65
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
66
 
66
 
67
_http http = 0;
67
_http http = 0;
68
 
68
 
69
bool source_mode = false;
69
bool source_mode = false;
70
 
70
 
71
progress_bar prbar;
71
progress_bar prbar;
72
proc_info Form;
72
proc_info Form;
73
 
73
 
74
#include "tabs.h"
74
#include "tabs.h"
75
 
75
 
76
dword cur_img_url;
76
dword cur_img_url;
77
dword shared_url;
77
dword shared_url;
78
dword http_get_type;
78
dword http_get_type=PAGE;
79
dword render_start_time;
79
dword render_start_time;
80
int menu_id=NULL;
80
int menu_id=NULL;
81
 
81
 
82
char default_dir[] = "/rd/1";
82
char default_dir[] = "/rd/1";
83
od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" };
83
od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" };
84
 
84
 
85
char editURL[URL_SIZE+1];
85
char editURL[URL_SIZE+1];
86
edit_box omnibox_edit = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff,
86
edit_box omnibox_edit = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff,
87
	0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
87
	0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
88
 
88
 
89
//===================================================//
89
//===================================================//
90
//                                                   //
90
//                                                   //
91
//                       CODE                        //
91
//                       CODE                        //
92
//                                                   //
92
//                                                   //
93
//===================================================//
93
//===================================================//
94
 
94
 
95
void LoadLibraries()
95
void LoadLibraries()
96
{
96
{
97
	load_dll(boxlib,      #box_lib_init,0);
97
	load_dll(boxlib,      #box_lib_init,0);
98
	load_dll(libimg,      #libimg_init,1);
98
	load_dll(libimg,      #libimg_init,1);
99
	load_dll(libHTTP,     #http_lib_init,1);
99
	load_dll(libHTTP,     #http_lib_init,1);
100
	load_dll(iconv_lib,   #iconv_open,0);
100
	load_dll(iconv_lib,   #iconv_open,0);
101
	load_dll(netcode_lib, #base64_encode,0);
101
	load_dll(netcode_lib, #base64_encode,0);
102
	load_dll(Proc_lib,    #OpenDialog_init,0);
102
	load_dll(Proc_lib,    #OpenDialog_init,0);
103
	OpenDialog_init stdcall (#o_dialog);	
103
	OpenDialog_init stdcall (#o_dialog);	
104
}
104
}
105
 
105
 
106
void HandleParam()
106
void HandleParam()
107
{
107
{
108
	if (!param) {
108
	if (!param) {
109
		history.add(DEFAULT_URL);
109
		history.add(DEFAULT_URL);
110
	} else {
110
	} else {
111
		if (!strncmp(#param, "-source ", 8)) {
111
		if (!strncmp(#param, "-source ", 8)) {
112
			source_mode = true;
112
			source_mode = true;
113
			history.add(#param + 8);
113
			history.add(#param + 8);
114
		} else if (!strncmp(#param, "-new ", 5)) {
114
		} else if (!strncmp(#param, "-new ", 5)) {
115
			history.add(#param + 5);
115
			history.add(#param + 5);
116
		} else {
116
		} else {
117
			if (GetProcessesCount("WEBVIEW") == 1) {
117
			if (GetProcessesCount("WEBVIEW") == 1) {
118
				history.add(#param);
118
				history.add(#param);
119
			} else {
119
			} else {
120
				shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
120
				shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
121
				strncpy(shared_url, #param, URL_SIZE);
121
				strncpy(shared_url, #param, URL_SIZE);
122
				ExitProcess();
122
				ExitProcess();
123
			}
123
			}
124
		}
124
		}
125
	}
125
	}
126
	shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE);
126
	shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE);
127
	ESDWORD[shared_url] = '\0';
127
	ESDWORD[shared_url] = '\0';
128
}
128
}
129
 
129
 
130
void main()
130
void main()
131
{
131
{
132
	int redirect_count=0;
132
	int redirect_count=0;
133
	LoadLibraries();
133
	LoadLibraries();
134
	HandleParam();
134
	HandleParam();
135
	WB1.list.SetFont(8, 14, 10011000b);
135
	WB1.list.SetFont(8, 14, 10011000b);
136
	WB1.list.no_selection = true;
136
	WB1.list.no_selection = true;
137
	WB1.custom_encoding = -1;
137
	WB1.custom_encoding = -1;
138
	@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
138
	@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
139
	loop() switch(@WaitEventTimeout(30))
139
	loop() switch(@WaitEventTimeout(30))
140
	{
140
	{
141
		case evMouse:
141
		case evMouse:
142
			edit_box_mouse stdcall (#omnibox_edit);
142
			edit_box_mouse stdcall (#omnibox_edit);
143
			mouse.get();
143
			mouse.get();
144
 
144
 
145
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
145
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
146
 
146
 
147
			scrollbar_v_mouse (#scroll_wv);
147
			scrollbar_v_mouse (#scroll_wv);
148
			if (scroll_wv.delta2) {
148
			if (scroll_wv.delta2) {
149
				WB1.list.first = scroll_wv.position;
149
				WB1.list.first = scroll_wv.position;
150
				WB1.DrawPage();
150
				WB1.DrawPage();
151
				break;
151
				break;
152
			}
152
			}
153
 
153
 
154
			if (links.hover(WB1.list.y, WB1.list.first))
154
			if (links.hover(WB1.list.y, WB1.list.first))
155
			{
155
			{
156
				if (mouse.key&MOUSE_MIDDLE) && (mouse.up) {
156
				if (mouse.key&MOUSE_MIDDLE) && (mouse.up) {
157
					if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
157
					if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
158
						EventClickLink(TARGET_NEW_WINDOW);
158
						EventClickLink(TARGET_NEW_WINDOW);
159
					} else {
159
					} else {
160
						EventClickLink(TARGET_NEW_TAB);
160
						EventClickLink(TARGET_NEW_TAB);
161
					}
161
					}
162
				}
162
				}
163
				if (mouse.key&MOUSE_LEFT) && (mouse.up) { 
163
				if (mouse.key&MOUSE_LEFT) && (mouse.up) { 
164
					CursorPointer.Restore();
164
					CursorPointer.Restore();
165
					EventClickLink(TARGET_SAME_TAB);
165
					EventClickLink(TARGET_SAME_TAB);
166
				}
166
				}
167
				if (mouse.key&MOUSE_RIGHT) && (mouse.up) {
167
				if (mouse.key&MOUSE_RIGHT) && (mouse.up) {
168
					CursorPointer.Restore();
168
					CursorPointer.Restore();
169
					EventShowLinkMenu();
169
					EventShowLinkMenu();
170
				}
170
				}
171
			} else {
171
			} else {
172
				CursorPointer.Restore();
172
				CursorPointer.Restore();
173
				if (mouse.key&MOUSE_RIGHT) && (mouse.up) && (WB1.list.MouseOver(mouse.x, mouse.y)) {
173
				if (mouse.key&MOUSE_RIGHT) && (mouse.up) && (WB1.list.MouseOver(mouse.x, mouse.y)) {
174
					EventShowPageMenu();
174
					EventShowPageMenu();
175
				}
175
				}
176
			}
176
			}
177
			break;
177
			break;
178
 
178
 
179
		case evButton:
179
		case evButton:
180
			ProcessButtonClick( @GetButtonID() );
180
			ProcessButtonClick( @GetButtonID() );
181
			break;
181
			break;
182
 
182
 
183
		case evKey:
183
		case evKey:
184
			@GetKeys();
184
			@GetKeys();
185
			edit_box_key stdcall(#omnibox_edit);
185
			edit_box_key stdcall(#omnibox_edit);
186
			ProcessKeyEvent();
186
			ProcessKeyEvent();
187
			break;
187
			break;
188
 
188
 
189
		case evReDraw:
189
		case evReDraw:
190
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),
190
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),
191
				GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
191
				GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
192
			GetProcessInfo(#Form, SelfInfo);
192
			GetProcessInfo(#Form, SelfInfo);
193
			ProcessMenuClick();
193
			ProcessMenuClick();
194
			sc.get();
194
			sc.get();
195
			if (Form.status_window>2) break;
195
			if (Form.status_window>2) break;
196
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
196
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
197
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
197
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
198
			draw_window();
198
			draw_window();
199
			break;
199
			break;
200
			
200
			
201
		case evNetwork:
201
		case evNetwork:
202
			if (http.transfer <= 0) break;
202
			if (http.transfer <= 0) break;
203
			http.receive();
203
			http.receive();
204
 
204
 
205
			if (http_get_type==PAGE) {
205
			if (http_get_type==PAGE) {
206
				CheckContentType();				
206
				CheckContentType();				
207
				prbar.max = http.content_length;
207
				prbar.max = http.content_length;
208
				if (prbar.value != http.content_received) {
208
				if (prbar.value != http.content_received) {
209
					prbar.value = http.content_received;	
209
					prbar.value = http.content_received;	
210
					DrawProgress();
210
					DrawProgress();
211
				}
211
				}
212
			}
212
			}
213
 
213
 
214
			if (http.receive_result != 0) break;
214
			if (http.receive_result != 0) break;
215
			if (debug_mode) debugval("HTTP", http.status_code);
215
			if (debug_mode) debugval("HTTP", http.status_code);
216
			if (http.status_code >= 300) && (http.status_code < 400)
216
			if (http.status_code >= 300) && (http.status_code < 400)
217
			{
217
			{
218
				// Handle redirects
218
				// Handle redirects
219
				if (redirect_count<=5) {
219
				if (redirect_count<=5) {
220
					redirect_count++;
220
					redirect_count++;
221
					HandleRedirect();
221
					HandleRedirect();
222
				} else {
222
				} else {
223
					notify("'Too many redirects.' -E");
223
					notify("'Too many redirects.' -E");
224
					StopLoading();
224
					StopLoading();
225
					redirect_count = 0;
225
					redirect_count = 0;
226
					if (http_get_type==IMG) goto _IMG_RES;
226
					if (http_get_type==IMG) goto _IMG_RES;
227
				}
227
				}
228
			} else {
228
			} else {
229
				// Loading the page is complete, free resources
229
				// Loading the page is complete, free resources
230
				redirect_count = 0;
230
				redirect_count = 0;
231
				http.hfree();
231
				http.hfree();
232
				if (http_get_type==PAGE) {
232
				if (http_get_type==PAGE) {
233
					history.add(http.cur_url);
233
					history.add(http.cur_url);
234
					cache.add(http.cur_url, http.content_pointer, http.content_received, PAGE);
234
					cache.add(http.cur_url, http.content_pointer, http.content_received, PAGE);
235
					free(http.content_pointer);
235
					free(http.content_pointer);
236
					LoadInternalPage(cache.current_buf, cache.current_size);
236
					LoadInternalPage(cache.current_buf, cache.current_size);
237
				}
237
				}
238
				else if (http_get_type==IMG) {
238
				else if (http_get_type==IMG) {
239
					_IMG_RES:
239
					_IMG_RES:
240
					cache.add(cur_img_url, http.content_pointer, http.content_received, IMG);
240
					cache.add(cur_img_url, http.content_pointer, http.content_received, IMG);
241
					free(http.content_pointer);
241
					free(http.content_pointer);
242
					GetImg(false);
242
					GetImg(false);
243
				}
243
				}
244
			}
244
			}
245
			break;
245
			break;
246
		default:
246
		default:
247
			if (ESDWORD[shared_url] != '\0') {
247
			if (ESDWORD[shared_url] != '\0') {
248
				EventOpenNewTab(shared_url);
248
				EventOpenNewTab(shared_url);
249
				ESDWORD[shared_url] = '\0';
249
				ESDWORD[shared_url] = '\0';
250
				ActivateWindow(GetProcessSlot(Form.ID));
250
				ActivateWindow(GetProcessSlot(Form.ID));
251
			}
251
			}
252
	}
252
	}
253
}
253
}
254
 
254
 
255
 
255
 
256
//===================================================//
256
//===================================================//
257
//                                                   //
257
//                                                   //
258
//                      EVENTS                       //
258
//                      EVENTS                       //
259
//                                                   //
259
//                                                   //
260
//===================================================//
260
//===================================================//
261
 
261
 
262
void ProcessButtonClick(dword id__)
262
void ProcessButtonClick(dword id__)
263
{
263
{
264
	switch (id__)
264
	switch (id__)
265
	{
265
	{
266
		case 1: ExitProcess();
266
		case 1: ExitProcess();
267
		case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX: EventTabClose(id__ - TAB_CLOSE_ID); return;
267
		case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX: EventTabClose(id__ - TAB_CLOSE_ID); return;
268
		case TAB_ID...TAB_ID+TABS_MAX: EventAllTabsClick(id__ - TAB_ID); return;
268
		case TAB_ID...TAB_ID+TABS_MAX: EventAllTabsClick(id__ - TAB_ID); return;
269
		case ENCODINGS...ENCODINGS+6: EventChangeEncodingAndLoadPage(id__-ENCODINGS); return;
269
		case ENCODINGS...ENCODINGS+6: EventChangeEncodingAndLoadPage(id__-ENCODINGS); return;
270
		case NEW_WINDOW:       RunProgram(#program_path, NULL); return;
270
		case NEW_WINDOW:       RunProgram(#program_path, NULL); return;
271
		case NEW_TAB:          if (!http.transfer) EventOpenNewTab(URL_SERVICE_HOMEPAGE); return;
271
		case NEW_TAB:          if (!http.transfer) EventOpenNewTab(URL_SERVICE_HOMEPAGE); return;
272
		case SCAN_CODE_BS:
272
		case SCAN_CODE_BS:
273
		case BACK_BUTTON:      if (history.back()) OpenPage(history.current()); return;
273
		case BACK_BUTTON:      if (history.back()) OpenPage(history.current()); return;
274
		case FORWARD_BUTTON:   if (history.forward()) OpenPage(history.current()); return;
274
		case FORWARD_BUTTON:   if (history.forward()) OpenPage(history.current()); return;
275
		case GOTOURL_BUTTON:   EventSubmitOmnibox();	return;
275
		case GOTOURL_BUTTON:   EventSubmitOmnibox();	return;
276
		case REFRESH_BUTTON:   EventRefreshPage(); return;
276
		case REFRESH_BUTTON:   EventRefreshPage(); return;
277
		case CHANGE_ENCODING:  EventShowEncodingsList(); return;
277
		case CHANGE_ENCODING:  EventShowEncodingsList(); return;
278
		case SANDWICH_BUTTON:  EventShowMainMenu(); return;
278
		case SANDWICH_BUTTON:  EventShowMainMenu(); return;
279
		case VIEW_SOURCE:      EventViewSource(); return;
279
		case VIEW_SOURCE:      EventViewSource(); return;
280
		case EDIT_SOURCE:      EventEditSource(); return;
280
		case EDIT_SOURCE:      EventEditSource(); return;
281
		case VIEW_HISTORY:     OpenPage(URL_SERVICE_HISTORY); return;
281
		case VIEW_HISTORY:     OpenPage(URL_SERVICE_HISTORY); return;
282
		case DOWNLOAD_MANAGER: EventOpenDownloader(""); return;
282
		case DOWNLOAD_MANAGER: EventOpenDownloader(""); return;
283
		case UPDATE_BROWSER:   EventUpdateBrowser(); return;
283
		case UPDATE_BROWSER:   EventUpdateBrowser(); return;
284
		case CLEAR_CACHE:      EventClearCache(); return;
284
		case CLEAR_CACHE:      EventClearCache(); return;
285
		case IN_NEW_TAB:       EventClickLink(TARGET_NEW_TAB); return;
285
		case IN_NEW_TAB:       EventClickLink(TARGET_NEW_TAB); return;
286
		case IN_NEW_WINDOW:    EventClickLink(TARGET_NEW_WINDOW); return;
286
		case IN_NEW_WINDOW:    EventClickLink(TARGET_NEW_WINDOW); return;
287
		case COPY_LINK_URL:    EventCopyLinkToClipboard(); return;
287
		case COPY_LINK_URL:    EventCopyLinkToClipboard(); return;
288
		case DOWNLOAD_LINK_CT: EventOpenDownloader( GetAbsoluteActiveURL() ); return;
288
		case DOWNLOAD_LINK_CT: EventOpenDownloader( GetAbsoluteActiveURL() ); return;
289
		case OPEN_FILE:        EventOpenDialog(); return;
289
		case OPEN_FILE:        EventOpenDialog(); return;
290
	}
290
	}
291
}
291
}
292
 
292
 
293
bool ProcessKeyEvent()
293
bool ProcessKeyEvent()
294
{
294
{
295
	if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) 
295
	if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) 
296
	{
296
	{
297
		if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();return;}
297
		if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();return;}
298
	}
298
	}
299
 
299
 
300
	if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode) 
300
	if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode) 
301
	{
301
	{
302
		case SCAN_CODE_KEY_O: EventOpenDialog(); return true;
302
		case SCAN_CODE_KEY_O: EventOpenDialog(); return true;
303
		case SCAN_CODE_KEY_H: ProcessButtonClick(VIEW_HISTORY); return true;
303
		case SCAN_CODE_KEY_H: ProcessButtonClick(VIEW_HISTORY); return true;
304
		case SCAN_CODE_KEY_U: EventViewSource(); return true;
304
		case SCAN_CODE_KEY_U: EventViewSource(); return true;
305
		case SCAN_CODE_KEY_T: EventOpenNewTab(URL_SERVICE_HOMEPAGE); return true;
305
		case SCAN_CODE_KEY_T: EventOpenNewTab(URL_SERVICE_HOMEPAGE); return true;
306
		case SCAN_CODE_KEY_N: RunProgram(#program_path, NULL); return true;
306
		case SCAN_CODE_KEY_N: RunProgram(#program_path, NULL); return true;
307
		case SCAN_CODE_KEY_J: ProcessButtonClick(DOWNLOAD_MANAGER); return true;
307
		case SCAN_CODE_KEY_J: ProcessButtonClick(DOWNLOAD_MANAGER); return true;
308
		case SCAN_CODE_KEY_R: ProcessButtonClick(REFRESH_BUTTON); return true;
308
		case SCAN_CODE_KEY_R: ProcessButtonClick(REFRESH_BUTTON); return true;
309
		case SCAN_CODE_ENTER: EventSeachWeb(); return true;
309
		case SCAN_CODE_ENTER: EventSeachWeb(); return true;
310
		case SCAN_CODE_LEFT:  ProcessButtonClick(BACK_BUTTON); return true;
310
		case SCAN_CODE_LEFT:  ProcessButtonClick(BACK_BUTTON); return true;
311
		case SCAN_CODE_RIGHT: ProcessButtonClick(FORWARD_BUTTON); return true;
311
		case SCAN_CODE_RIGHT: ProcessButtonClick(FORWARD_BUTTON); return true;
312
		case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true;
312
		case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true;
313
		case SCAN_CODE_TAB:   EventActivateNextTab(); return true;
313
		case SCAN_CODE_TAB:   EventActivateNextTab(); return true;
314
		case SCAN_CODE_F5:    EventClearCache(); return;
314
		case SCAN_CODE_F5:    EventClearCache(); return;
315
		default: return false;
315
		default: return false;
316
	}
316
	}
317
 
317
 
318
	switch(key_scancode) 
318
	switch(key_scancode) 
319
	{
319
	{
320
		case SCAN_CODE_UP:    EventScrollUpAndDown(SCAN_CODE_UP); return;
320
		case SCAN_CODE_UP:    EventScrollUpAndDown(SCAN_CODE_UP); return;
321
		case SCAN_CODE_DOWN:  EventScrollUpAndDown(SCAN_CODE_DOWN); return;
321
		case SCAN_CODE_DOWN:  EventScrollUpAndDown(SCAN_CODE_DOWN); return;
322
		case SCAN_CODE_F6:    {omnibox_edit.flags=ed_focus; DrawOmnibox();} return;
322
		case SCAN_CODE_F6:    {omnibox_edit.flags=ed_focus; DrawOmnibox();} return;
323
		case SCAN_CODE_F5:    EventRefreshPage(); return;
323
		case SCAN_CODE_F5:    EventRefreshPage(); return;
324
		case SCAN_CODE_ENTER: if (omnibox_edit.flags & ed_focus) EventSubmitOmnibox(); return;
324
		case SCAN_CODE_ENTER: if (omnibox_edit.flags & ed_focus) EventSubmitOmnibox(); return;
325
		case SCAN_CODE_F12:   EventToggleDebugMode(); return;
325
		case SCAN_CODE_F12:   EventToggleDebugMode(); return;
326
		case SCAN_CODE_F11:   show_images^=1; EventClearCache(); return;
326
		case SCAN_CODE_F11:   show_images^=1; EventClearCache(); return;
327
		default:              if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); return;
327
		default:              if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); return;
328
	}
328
	}
329
}
329
}
330
 
330
 
331
void SetElementSizes()
331
void SetElementSizes()
332
{
332
{
333
	omnibox_edit.width = Form.cwidth - omnibox_edit.left - 52 - 16;
333
	omnibox_edit.width = Form.cwidth - omnibox_edit.left - 52 - 16;
334
	WB1.list.SetSizes(0, TOOLBAR_H+TAB_H, Form.width - 10 - scroll_wv.size_x, 
334
	WB1.list.SetSizes(0, TOOLBAR_H+TAB_H, Form.width - 10 - scroll_wv.size_x, 
335
		Form.cheight - TOOLBAR_H - STATUSBAR_H - TAB_H, BASIC_LINE_H);
335
		Form.cheight - TOOLBAR_H - STATUSBAR_H - TAB_H, BASIC_LINE_H);
336
	WB1.list.wheel_size = 7 * BASIC_LINE_H;
336
	WB1.list.wheel_size = 7 * BASIC_LINE_H;
337
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
337
	WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
338
	WB1.list.visible = WB1.list.h;
338
	WB1.list.visible = WB1.list.h;
339
}
339
}
340
 
340
 
341
 
341
 
342
void draw_window()
342
void draw_window()
343
{
343
{
344
	bool burger_active = false;
344
	bool burger_active = false;
345
	if (menu_id == OPEN_FILE) burger_active = true;
345
	if (menu_id == OPEN_FILE) burger_active = true;
346
 
346
 
347
	SetElementSizes();
347
	SetElementSizes();
348
 
348
 
349
	DrawBar(0,0, Form.cwidth,PADDING, sc.work);
349
	DrawBar(0,0, Form.cwidth,PADDING, sc.work);
350
	DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work);
350
	DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work);
351
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.work_dark, sc.work, 180));
351
	DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.work_dark, sc.work, 180));
352
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph);
352
	DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph);
353
	DrawBar(0, PADDING, omnibox_edit.left-2, TSZE+1, sc.work);
353
	DrawBar(0, PADDING, omnibox_edit.left-2, TSZE+1, sc.work);
354
	DrawBar(omnibox_edit.left+omnibox_edit.width+18, PADDING, Form.cwidth-omnibox_edit.left-omnibox_edit.width-18, TSZE+1, sc.work);
354
	DrawBar(omnibox_edit.left+omnibox_edit.width+18, PADDING, Form.cwidth-omnibox_edit.left-omnibox_edit.width-18, TSZE+1, sc.work);
355
 
355
 
356
	DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30, false);
356
	DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30, false);
357
	DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31, false);
357
	DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31, false);
358
	DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, PADDING, -1, burger_active); //burger menu
358
	DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, PADDING, -1, burger_active); //burger menu
359
 
359
 
360
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph);
360
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph);
361
 
361
 
362
	DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, 
362
	DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, 
363
		WB1.list.h-1, scroll_wv.bckg_col);
363
		WB1.list.h-1, scroll_wv.bckg_col);
364
 
364
 
365
	if (!BrowserWidthChanged()) { 
365
	if (!BrowserWidthChanged()) { 
366
		WB1.DrawPage(); 
366
		WB1.DrawPage(); 
367
		DrawOmnibox(); 
367
		DrawOmnibox(); 
368
	}
368
	}
369
	DrawProgress();
369
	DrawProgress();
370
	DrawStatusBar(NULL);
370
	DrawStatusBar(NULL);
371
	DrawTabsBar();
371
	DrawTabsBar();
372
}
372
}
373
 
373
 
374
bool BrowserWidthChanged()
374
bool BrowserWidthChanged()
375
{
375
{
376
	dword source_mode_holder;
376
	dword source_mode_holder;
377
	if (WB1.list.w!=canvas.bufw) {
377
	if (WB1.list.w!=canvas.bufw) {
378
		canvas.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
378
		canvas.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
379
		if (!strncmp(history.current(),"http",4)) {
379
		if (!strncmp(history.current(),"http",4)) {
380
			//nihuya ne izyashnoe reshenie, no pust' poka butet tak
380
			//nihuya ne izyashnoe reshenie, no pust' poka butet tak
381
			source_mode_holder = source_mode;
381
			source_mode_holder = source_mode;
382
			LoadInternalPage(#loading_text, sizeof(loading_text));
382
			LoadInternalPage(#loading_text, sizeof(loading_text));
383
			source_mode = source_mode_holder;
383
			source_mode = source_mode_holder;
384
		}
384
		}
385
		OpenPage(history.current());
385
		OpenPage(history.current());
386
		return true;
386
		return true;
387
	}
387
	}
388
	return false;
388
	return false;
389
}
389
}
390
 
390
 
391
 
391
 
392
void EventChangeEncodingAndLoadPage(int _new_encoding)
392
void EventChangeEncodingAndLoadPage(int _new_encoding)
393
{
393
{
394
	dword newbuf, newsize;
394
	dword newbuf, newsize;
395
	WB1.custom_encoding = _new_encoding;
395
	WB1.custom_encoding = _new_encoding;
396
	newsize = strlen(WB1.o_bufpointer);
396
	newsize = strlen(WB1.o_bufpointer);
397
	newbuf = malloc(newsize);
397
	newbuf = malloc(newsize);
398
	memmov(newbuf, WB1.o_bufpointer, newsize);
398
	memmov(newbuf, WB1.o_bufpointer, newsize);
399
	LoadInternalPage(newbuf, newsize);
399
	LoadInternalPage(newbuf, newsize);
400
	free(newbuf);
400
	free(newbuf);
401
}
401
}
402
 
402
 
403
 
403
 
404
void EventScrollUpAndDown(int _direction)
404
void EventScrollUpAndDown(int _direction)
405
{
405
{
406
	int i;
406
	int i;
407
	for (i=0;i
407
	for (i=0;i
408
		if (_direction == SCAN_CODE_UP) WB1.list.KeyUp(); 
408
		if (_direction == SCAN_CODE_UP) WB1.list.KeyUp(); 
409
		if (_direction == SCAN_CODE_DOWN) WB1.list.KeyDown(); 
409
		if (_direction == SCAN_CODE_DOWN) WB1.list.KeyDown(); 
410
	} 
410
	} 
411
	WB1.DrawPage();
411
	WB1.DrawPage();
412
}
412
}
413
 
413
 
414
void EventToggleDebugMode()
414
void EventToggleDebugMode()
415
{
415
{
416
	debug_mode ^= 1;
416
	debug_mode ^= 1;
417
	if (debug_mode) notify("'Debug mode ON'-I");
417
	if (debug_mode) notify("'Debug mode ON'-I");
418
	else notify("'Debug mode OFF'-I");
418
	else notify("'Debug mode OFF'-I");
419
}
419
}
420
 
420
 
421
void EventAllTabsClick(dword _n)
421
void EventAllTabsClick(dword _n)
422
{
422
{
423
	if (http.transfer) return;
423
	if (http.transfer) return;
424
	if (mouse.mkm) {
424
	if (mouse.mkm) {
425
		EventTabClose(_n);
425
		EventTabClose(_n);
426
	} else {
426
	} else {
427
		EventTabClick(_n);
427
		EventTabClick(_n);
428
	}
428
	}
429
}
429
}
430
 
430
 
431
void EventEditSource()
431
void EventEditSource()
432
{
432
{
433
	if (check_is_the_adress_local(history.current())) {
433
	if (check_is_the_adress_local(history.current())) {
434
		RunProgram("/rd/1/quark", history.current());
434
		RunProgram("/rd/1/quark", history.current());
435
	} else {
435
	} else {
436
		CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm");
436
		CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm");
437
		if (!EAX) RunProgram("/rd/1/quark", "/tmp0/1/WebView_tmp.htm");
437
		if (!EAX) RunProgram("/rd/1/quark", "/tmp0/1/WebView_tmp.htm");
438
	}
438
	}
439
}
439
}
440
 
440
 
441
void EventClearCache()
441
void EventClearCache()
442
{
442
{
443
	cache.clear();
443
	cache.clear();
444
	notify(#clear_cache_ok);
444
	notify(#clear_cache_ok);
445
	EventRefreshPage();
445
	EventRefreshPage();
446
}
446
}
447
 
447
 
448
void EventCopyLinkToClipboard()
448
void EventCopyLinkToClipboard()
449
{
449
{
450
	Clipboard__CopyText(GetAbsoluteActiveURL()); 
450
	Clipboard__CopyText(GetAbsoluteActiveURL()); 
451
	notify("'URL copied to clipboard'O");
451
	notify("'URL copied to clipboard'O");
452
}
452
}
453
 
453
 
454
void StopLoading()
454
void StopLoading()
455
{
455
{
456
	if (http.stop()) pause(10);
456
	if (http.stop()) pause(10);
457
	prbar.value = 0;
457
	prbar.value = 0;
458
}
458
}
459
 
459
 
460
//rewrite into 
460
//rewrite into 
461
//bool strrpl(dword dst, from, into, dst_len);
461
//bool strrpl(dword dst, from, into, dst_len);
462
bool ReplaceSpaceInUrl(dword url, size) {
462
bool ReplaceSpaceInUrl(dword url, size) {
463
	unsigned int i, j;
463
	unsigned int i, j;
464
	bool was_changed=false;
464
	bool was_changed=false;
465
	for (i=url+size-3; i>url; i--)
465
	for (i=url+size-3; i>url; i--)
466
	{
466
	{
467
		if (ESBYTE[i]!=' ') continue;
467
		if (ESBYTE[i]!=' ') continue;
468
		for (j=url+size-3; j>=i; j--) {
468
		for (j=url+size-3; j>=i; j--) {
469
			ESBYTE[j+3]=ESBYTE[j+2];
469
			ESBYTE[j+3]=ESBYTE[j+2];
470
			ESBYTE[j+2]=ESBYTE[j+1];
470
			ESBYTE[j+2]=ESBYTE[j+1];
471
			ESBYTE[j+1]=ESBYTE[j];
471
			ESBYTE[j+1]=ESBYTE[j];
472
		}
472
		}
473
		ESBYTE[i] = '%';
473
		ESBYTE[i] = '%';
474
		ESBYTE[i+1] = '2';
474
		ESBYTE[i+1] = '2';
475
		ESBYTE[i+2] = '0';
475
		ESBYTE[i+2] = '0';
476
		was_changed = true;
476
		was_changed = true;
477
	}
477
	}
478
	return was_changed;
478
	return was_changed;
479
}
479
}
480
 
480
 
481
bool HandleUrlFiles(dword _path, _data)
481
bool HandleUrlFiles(dword _path, _data)
482
{
482
{
483
	dword url_from_file;
483
	dword url_from_file;
484
	if (!UrlExtIs(_path, "url")) return false;
484
	if (!UrlExtIs(_path, "url")) return false;
485
	if (! url_from_file = strstri(_data, "URL=")) return false;
485
	if (! url_from_file = strstri(_data, "URL=")) return false;
486
	replace_char(url_from_file, '\n', '\0', strlen(url_from_file));
486
	replace_char(url_from_file, '\n', '\0', strlen(url_from_file));
487
	OpenPage(url_from_file); 	
487
	OpenPage(url_from_file); 	
488
	return true;	
488
	return true;	
489
}
489
}
490
 
490
 
491
bool GetLocalFileData(dword _path)
491
bool GetLocalFileData(dword _path)
492
{
492
{
493
	dword data, size;
493
	dword data, size;
494
	read_file(_path, #data, #size);
494
	read_file(_path, #data, #size);
495
	if (!HandleUrlFiles(_path, data)) {
495
	if (!HandleUrlFiles(_path, data)) {
496
		LoadInternalPage(data, size);
496
		LoadInternalPage(data, size);
497
	}
497
	}
498
	free(data);
498
	free(data);
499
	return true;
499
	return true;
500
}
500
}
501
 
501
 
502
bool GetUrl(dword _http_url)
502
bool GetUrl(dword _http_url)
503
{
503
{
504
	char new_url_full[URL_SIZE+1];
504
	char new_url_full[URL_SIZE+1];
505
 
505
 
506
	if (!strncmp(_http_url,"http:",5)) {
506
	if (!strncmp(_http_url,"http:",5)) {
507
		http.get(_http_url);
507
		http.get(_http_url);
508
		return true;
508
		return true;
509
	} else if (!strncmp(_http_url,"https://",8)) {
509
	} else if (!strncmp(_http_url,"https://",8)) {
510
		strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
510
		strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
511
		strncat(#new_url_full, _http_url, URL_SIZE);
511
		strncat(#new_url_full, _http_url, URL_SIZE);
512
		http.get(#new_url_full);
512
		http.get(#new_url_full);
513
		return true;
513
		return true;
514
	}
514
	}
515
	return false;
515
	return false;
516
}
516
}
517
 
517
 
518
void OpenPage(dword _open_URL)
518
void OpenPage(dword _open_URL)
519
{
519
{
520
	char new_url[URL_SIZE+1];
520
	char new_url[URL_SIZE+1];
521
	int unz_id;
521
	int unz_id;
522
 
522
 
523
	StopLoading();
523
	StopLoading();
524
 
524
 
525
	SetOmniboxText(_open_URL);
525
	SetOmniboxText(_open_URL);
526
 
526
 
527
	strncpy(#new_url, _open_URL, URL_SIZE);
527
	strncpy(#new_url, _open_URL, URL_SIZE);
528
 
528
 
529
	//Exclude # from the URL to the load page
529
	//Exclude # from the URL to the load page
530
	//We will bring it back when we get the buffer
530
	//We will bring it back when we get the buffer
531
	if (strrchr(#new_url, '#')) {
531
	if (strrchr(#new_url, '#')) {
532
		anchors.take_anchor_from(#new_url);
532
		anchors.take_anchor_from(#new_url);
533
	}
533
	}
534
 
534
 
535
	/*
535
	/*
536
	There could be several possible types of addresses:
536
	There could be several possible types of addresses:
537
	- cached page (only http/https)
537
	- cached page (only http/https)
538
	- internal page
538
	- internal page
539
	- web page
539
	- web page
540
	- local file
540
	- local file
541
	So we need to detect what incoming address is
541
	So we need to detect what incoming address is
542
	and then halndle it in the propper way.
542
	and then halndle it in the propper way.
543
	*/
543
	*/
544
 
544
 
545
	if (cache.has(#new_url)) {
545
	if (cache.has(#new_url)) {
546
		//CACHED PAGE
546
		//CACHED PAGE
547
		if (cache.current_type==PAGE) {
547
		if (cache.current_type==PAGE) {
548
			history.add(#new_url);
548
			history.add(#new_url);
549
			LoadInternalPage(cache.current_buf, cache.current_size);
549
			LoadInternalPage(cache.current_buf, cache.current_size);
550
		}
550
		}
551
		else {
551
		else {
552
			EventDownloadAndOpenImage(#new_url);
552
			EventDownloadAndOpenImage(#new_url);
553
		}
553
		}
554
 
554
 
555
	} else if (!strncmp(#new_url,"WebView:",8)) {
555
	} else if (!strncmp(#new_url,"WebView:",8)) {
556
		//INTERNAL PAGE
556
		//INTERNAL PAGE
557
		history.add(#new_url);
557
		history.add(#new_url);
558
		if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buildin_page_home, sizeof(buildin_page_home));
558
		if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buildin_page_home, sizeof(buildin_page_home));
559
		else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buildin_page_help, sizeof(buildin_page_help));
559
		else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buildin_page_help, sizeof(buildin_page_help));
560
		else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
560
		else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
561
		else LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
561
		else LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
562
 
562
 
563
	} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
563
	} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
564
		//WEB PAGE
564
		//WEB PAGE
565
		if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
565
		if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
566
			strcpy(#editURL, #new_url);
566
			strcpy(#editURL, #new_url);
567
		}
567
		}
568
 
568
 
569
		http_get_type = PAGE;
569
		http_get_type = PAGE;
570
		GetUrl(#new_url);
570
		GetUrl(#new_url);
571
 
571
 
572
		DrawOmnibox();
572
		DrawOmnibox();
573
 
573
 
574
		if (!http.transfer) {
574
		if (!http.transfer) {
575
			history.add(#new_url);
575
			history.add(#new_url);
576
			LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
576
			LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
577
		}
577
		}
578
	} else {
578
	} else {
579
		//LOCAL PAGE
579
		//LOCAL PAGE
580
		history.add(#new_url);
580
		history.add(#new_url);
581
		if (UrlExtIs(#new_url,".docx")) {
581
		if (UrlExtIs(#new_url,".docx")) {
582
			DeleteFile("/tmp0/1/temp/word/document.xml");
582
			DeleteFile("/tmp0/1/temp/word/document.xml");
583
			CreateDir("/tmp0/1/temp");
583
			CreateDir("/tmp0/1/temp");
584
			unz_id = RunProgram("/sys/unz", sprintf(#param, "-o \"/tmp0/1/temp\" -h \"%s\"", #new_url));
584
			unz_id = RunProgram("/sys/unz", sprintf(#param, "-o \"/tmp0/1/temp\" -h \"%s\"", #new_url));
585
			while (GetProcessSlot(unz_id)) pause(2);
585
			while (GetProcessSlot(unz_id)) pause(2);
586
			strcpy(#new_url, "/tmp0/1/temp/word/document.xml");
586
			strcpy(#new_url, "/tmp0/1/temp/word/document.xml");
587
		} 
587
		} 
588
		if (!GetLocalFileData(#new_url)) {
588
		if (!GetLocalFileData(#new_url)) {
589
			LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
589
			LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
590
		}
590
		}
591
	}
591
	}
592
}
592
}
593
 
593
 
594
dword EventOpenDownloader(dword _url)
594
dword EventOpenDownloader(dword _url)
595
{
595
{
596
	//char download_params[URL_SIZE+50];
596
	//char download_params[URL_SIZE+50];
597
	return RunProgram("/sys/network/dl", _url);
597
	return RunProgram("/sys/network/dl", _url);
598
}
598
}
599
 
599
 
600
bool EventClickAnchor()
600
bool EventClickAnchor()
601
{
601
{
602
	dword aURL = links.active_url;
602
	dword aURL = links.active_url;
603
 
603
 
604
	if (anchors.get_pos_by_name(aURL+1)!=-1) {
604
	if (anchors.get_pos_by_name(aURL+1)!=-1) {
605
		WB1.list.first = anchors.get_pos_by_name(aURL+1);
605
		WB1.list.first = anchors.get_pos_by_name(aURL+1);
606
		WB1.list.CheckDoesValuesOkey();
606
		WB1.list.CheckDoesValuesOkey();
607
		strcpy(#editURL, history.current());
607
		strcpy(#editURL, history.current());
608
		strcat(#editURL, aURL);
608
		strcat(#editURL, aURL);
609
		DrawOmnibox();
609
		DrawOmnibox();
610
		WB1.DrawPage();
610
		WB1.DrawPage();
611
		return true;
611
		return true;
612
	}
612
	}
613
	return false;
613
	return false;
614
}
614
}
615
 
615
 
616
void EventClickLink(dword _target)
616
void EventClickLink(dword _target)
617
{
617
{
618
	char new_url[URL_SIZE+1];
618
	char new_url[URL_SIZE+1];
619
	char new_url_full[URL_SIZE+1];
619
	char new_url_full[URL_SIZE+1];
620
	dword aURL = GetAbsoluteActiveURL();
620
	dword aURL = GetAbsoluteActiveURL();
621
	if (!aURL) return;
621
	if (!aURL) return;
622
 
622
 
623
	strcpy(#new_url, aURL);
623
	strcpy(#new_url, aURL);
624
 
624
 
625
	if (ESBYTE[aURL]=='#') {
625
	if (ESBYTE[aURL]=='#') {
626
		if (_target == TARGET_SAME_TAB) {
626
		if (_target == TARGET_SAME_TAB) {
627
			EventClickAnchor(); 
627
			EventClickAnchor(); 
628
			return;
628
			return;
629
		} else {
629
		} else {
630
			strcpy(#new_url, history.current());
630
			strcpy(#new_url, history.current());
631
			strcat(#new_url, aURL);
631
			strcat(#new_url, aURL);
632
		}
632
		}
633
	}
633
	}
634
 
634
 
635
	if (_target == TARGET_NEW_TAB) {
635
	if (_target == TARGET_NEW_TAB) {
636
		EventOpenNewTab(#new_url);
636
		EventOpenNewTab(#new_url);
637
		return;
637
		return;
638
	}
638
	}
639
 
639
 
640
	if (_target == TARGET_NEW_WINDOW) {
640
	if (_target == TARGET_NEW_WINDOW) {
641
		strcpy(#new_url_full, "-new ");
641
		strcpy(#new_url_full, "-new ");
642
		strncat(#new_url_full, #new_url, URL_SIZE);
642
		strncat(#new_url_full, #new_url, URL_SIZE);
643
		RunProgram(#program_path, #new_url_full);
643
		RunProgram(#program_path, #new_url_full);
644
		return;
644
		return;
645
	}
645
	}
646
 
646
 
647
	if (!strncmp(#new_url,"mailto:", 7)) || (!strncmp(#new_url,"tel:", 4)) {
647
	if (!strncmp(#new_url,"mailto:", 7)) || (!strncmp(#new_url,"tel:", 4)) {
648
		notify(#new_url);
648
		notify(#new_url);
649
		return;
649
		return;
650
	}
650
	}
651
 
651
 
652
	if (http.transfer) {
652
	if (http.transfer) {
653
		StopLoading();
653
		StopLoading();
654
	}
654
	}
655
 
655
 
656
	if (strrchr(#new_url, '#')!=0) {
656
	if (strrchr(#new_url, '#')!=0) {
657
		anchors.take_anchor_from(#new_url);
657
		anchors.take_anchor_from(#new_url);
658
		OpenPage(#new_url);
658
		OpenPage(#new_url);
659
		return;
659
		return;
660
	}
660
	}
661
 
661
 
662
	if (!strncmp(#new_url,"WebView:",8)) {
662
	if (!strncmp(#new_url,"WebView:",8)) {
663
		OpenPage(#new_url);
663
		OpenPage(#new_url);
664
		return;
664
		return;
665
	}
665
	}
666
 
666
 
667
	if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0)
667
	if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0)
668
	{
668
	{
669
		if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true)
669
		if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true)
670
		{	
670
		{	
671
			if (strchr(#new_url, '|')) {
671
			if (strchr(#new_url, '|')) {
672
				ESBYTE[strchr(#new_url, '|')] = NULL;
672
				ESBYTE[strchr(#new_url, '|')] = NULL;
673
				RunProgram(#new_url, strlen(#new_url)+1+#new_url);
673
				RunProgram(#new_url, strlen(#new_url)+1+#new_url);
674
			} else {
674
			} else {
675
				RunProgram("/sys/@open", #new_url);
675
				RunProgram("/sys/@open", #new_url);
676
			}
676
			}
677
			return;
677
			return;
678
		}
678
		}
679
	}
679
	}
680
	OpenPage(#new_url);
680
	OpenPage(#new_url);
681
}
681
}
682
 
682
 
683
void EventSubmitOmnibox()
683
void EventSubmitOmnibox()
684
{
684
{
685
	char new_url[URL_SIZE+1];
685
	char new_url[URL_SIZE+1];
686
	if (!editURL[0]) return;
686
	if (!editURL[0]) return;
687
	if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') 
687
	if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') 
688
	|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) {
688
	|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) {
689
		OpenPage(#editURL);
689
		OpenPage(#editURL);
690
	} else {
690
	} else {
691
		strcpy(#new_url, "http://");
691
		strcpy(#new_url, "http://");
692
		strncat(#new_url, #editURL, URL_SIZE-1);
692
		strncat(#new_url, #editURL, URL_SIZE-1);
693
		OpenPage(#new_url);
693
		OpenPage(#new_url);
694
	}
694
	}
695
}
695
}
696
 
696
 
697
void LoadInternalPage(dword _bufdata, _in_bufsize){
697
void LoadInternalPage(dword _bufdata, _in_bufsize){
698
	if (!_bufdata) || (!_in_bufsize) {
698
	if (!_bufdata) || (!_in_bufsize) {
699
		LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
699
		LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
700
	} else {
700
	} else {
701
		WB1.list.first = 0; //scroll page to the top
701
		WB1.list.first = 0; //scroll page to the top
702
		DrawOmnibox();
702
		DrawOmnibox();
703
		if(!strrchr(#editURL, '#')) {
703
		if(!strrchr(#editURL, '#')) {
704
			strcat(#editURL, #anchors.current);
704
			strcat(#editURL, #anchors.current);
705
			DrawOmnibox();
705
			DrawOmnibox();
706
		}
706
		}
707
		render_start_time = GetStartTime();
707
		render_start_time = GetStartTime();
708
		WB1.ParseHtml(_bufdata, _in_bufsize);
708
		WB1.ParseHtml(_bufdata, _in_bufsize);
709
		// REJECTED. Reason: infinite redirect at Google Results.
709
		// REJECTED. Reason: infinite redirect at Google Results.
710
		/*
710
		/*
711
		if (WB1.redirect) { //
711
		if (WB1.redirect) { //
712
			get_absolute_url(#WB1.redirect, history.current());
712
			get_absolute_url(#WB1.redirect, history.current());
713
			history.back();
713
			history.back();
714
			OpenPage(#WB1.redirect);
714
			OpenPage(#WB1.redirect);
715
		}
715
		}
716
		*/
716
		*/
717
		DrawStatusBar(NULL);
717
		DrawStatusBar(NULL);
718
		DrawActiveTab();
718
		DrawActiveTab();
719
		if (source_mode) {
719
		if (source_mode) {
720
			source_mode = false;
720
			source_mode = false;
721
			WB1.custom_encoding = CH_CP866;
721
			WB1.custom_encoding = CH_CP866;
722
			ShowSource(WB1.bufpointer, _in_bufsize);
722
			ShowSource(WB1.bufpointer, _in_bufsize);
723
		} else {
723
		} else {
724
			WB1.DrawPage();
724
			WB1.DrawPage();
725
		}
725
		}
726
		if (WB1.img_url.count) GetImg(true);
726
		if (WB1.img_url.count) { GetImg(true); DrawOmnibox(); }
727
	}
727
	}
728
}
728
}
729
 
729
 
730
bool UrlExtIs(dword base, ext)
730
bool UrlExtIs(dword base, ext)
731
{
731
{
732
	if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true;
732
	if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true;
733
	return false;
733
	return false;
734
}
734
}
735
 
735
 
736
void DrawProgress()
736
void DrawProgress()
737
{
737
{
738
	dword pct;
738
	dword pct;
739
	if (!http.transfer) return;
739
	if (!http.transfer) return;
740
	if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10;
740
	if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10;
741
	if (http_get_type==IMG) pct = prbar.value * 70 / prbar.max + 30;
741
	if (http_get_type==IMG) pct = prbar.value * 70 / prbar.max + 30;
742
	DrawBar(omnibox_edit.left-1, omnibox_edit.top+20, pct*omnibox_edit.width+16/100, 2, 0x72B7EB);
742
	DrawBar(omnibox_edit.left-1, omnibox_edit.top+20, pct*omnibox_edit.width+16/100, 2, 0x72B7EB);
743
}
743
}
744
 
744
 
745
void EventShowPageMenu()
745
void EventShowPageMenu()
746
{
746
{
747
	open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu);
747
	open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu);
748
	menu_id = VIEW_SOURCE;
748
	menu_id = VIEW_SOURCE;
749
}
749
}
750
 
750
 
751
void EventShowLinkMenu()
751
void EventShowLinkMenu()
752
{
752
{
753
	open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #link_menu);
753
	open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #link_menu);
754
	menu_id = IN_NEW_TAB;
754
	menu_id = IN_NEW_TAB;
755
}
755
}
756
 
756
 
757
void EventShowMainMenu()
757
void EventShowMainMenu()
758
{
758
{
759
	open_lmenu(Form.cwidth - PADDING -4, PADDING + TSZE + 3, 
759
	open_lmenu(Form.cwidth - PADDING -4, PADDING + TSZE + 3, 
760
		MENU_TOP_RIGHT, NULL, #main_menu);
760
		MENU_TOP_RIGHT, NULL, #main_menu);
761
	menu_id = OPEN_FILE;
761
	menu_id = OPEN_FILE;
762
}
762
}
763
 
763
 
764
void EventShowEncodingsList()
764
void EventShowEncodingsList()
765
{
765
{
766
	open_lmenu(Form.cwidth-4, Form.cheight - STATUSBAR_H + 12, 
766
	open_lmenu(Form.cwidth-4, Form.cheight - STATUSBAR_H + 12, 
767
		MENU_BOT_RIGHT, WB1.cur_encoding + 1, 
767
		MENU_BOT_RIGHT, WB1.cur_encoding + 1, 
768
		"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
768
		"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
769
	menu_id = ENCODINGS;
769
	menu_id = ENCODINGS;
770
}
770
}
771
 
771
 
772
void ProcessMenuClick()
772
void ProcessMenuClick()
773
{
773
{
774
	int click_id;
774
	int click_id;
775
	if (menu_id) {
775
	if (menu_id) {
776
		if (click_id = get_menu_click()) {
776
		if (click_id = get_menu_click()) {
777
			click_id += menu_id - 1;
777
			click_id += menu_id - 1;
778
			ProcessButtonClick(click_id);
778
			ProcessButtonClick(click_id);
779
		}
779
		}
780
		if (!menu_process_id) menu_id = NULL;
780
		if (!menu_process_id) menu_id = NULL;
781
	}
781
	}
782
}
782
}
783
 
783
 
784
void EventSeachWeb()
784
void EventSeachWeb()
785
{
785
{
786
	char new_url[URL_SIZE+1];
786
	char new_url[URL_SIZE+1];
787
	replace_char(#editURL, ' ', '_', URL_SIZE);
787
	replace_char(#editURL, ' ', '_', URL_SIZE);
788
	strcpy(#new_url, "https://www.google.com/search?q=");
788
	strcpy(#new_url, "https://www.google.com/search?q=");
789
	strncat(#new_url, #editURL, URL_SIZE);
789
	strncat(#new_url, #editURL, URL_SIZE);
790
	OpenPage(#new_url);
790
	OpenPage(#new_url);
791
}
791
}
792
 
792
 
793
void EventOpenDialog()
793
void EventOpenDialog()
794
{
794
{
795
	OpenDialog_start stdcall (#o_dialog);
795
	OpenDialog_start stdcall (#o_dialog);
796
	if (o_dialog.status) {
796
	if (o_dialog.status) {
797
		OpenPage(#openfile_path);
797
		OpenPage(#openfile_path);
798
	}
798
	}
799
}
799
}
800
 
800
 
801
void EventViewSource()
801
void EventViewSource()
802
{
802
{
803
	source_mode = true;
803
	source_mode = true;
804
	EventOpenNewTab(history.current());
804
	EventOpenNewTab(history.current());
805
}
805
}
806
 
806
 
807
void EventRefreshPage()
807
void EventRefreshPage()
808
{
808
{
809
	if (http.transfer) {
809
	if (http.transfer) {
810
		StopLoading();
810
		StopLoading();
811
		draw_window();
811
		draw_window();
812
	} else {
812
	} else {
813
		OpenPage(history.current());
813
		OpenPage(history.current());
814
	}
814
	}
815
}
815
}
816
 
816
 
817
void EventUpdateBrowser()
817
void EventUpdateBrowser()
818
{
818
{
819
	dword downloader_id, slot_n;
819
	dword downloader_id, slot_n;
820
	dword current_size;
820
	dword current_size;
821
	dword new_size;
821
	dword new_size;
822
 
822
 
823
	draw_window();
823
	draw_window();
824
 
824
 
825
	downloader_id = EventOpenDownloader(#update_param);
825
	downloader_id = EventOpenDownloader(#update_param);
826
	do {
826
	do {
827
		slot_n = GetProcessSlot(downloader_id);
827
		slot_n = GetProcessSlot(downloader_id);
828
		pause(10);
828
		pause(10);
829
	} while (slot_n!=0);
829
	} while (slot_n!=0);
830
 
830
 
831
	current_size = get_file_size(#program_path);
831
	current_size = get_file_size(#program_path);
832
	new_size = get_file_size("/tmp0/1/Downloads/WebView.com");
832
	new_size = get_file_size("/tmp0/1/Downloads/WebView.com");
833
 
833
 
834
	if (!new_size) || (new_size<5000) { notify(#update_download_error); return; }
834
	if (!new_size) || (new_size<5000) { notify(#update_download_error); return; }
835
	if (current_size == new_size) { notify(#update_is_current);	return; }
835
	if (current_size == new_size) { notify(#update_is_current);	return; }
836
 
836
 
837
	if (CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) {
837
	if (CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) {
838
		notify(#update_can_not_copy);
838
		notify(#update_can_not_copy);
839
	} else {
839
	} else {
840
		notify(#update_ok);
840
		notify(#update_ok);
841
		RunProgram(#program_path, history.current());
841
		RunProgram(#program_path, history.current());
842
		ExitProcess();
842
		ExitProcess();
843
	}
843
	}
844
}
844
}
845
 
845
 
846
void DrawStatusBar(dword _msg)
846
void DrawStatusBar(dword _msg)
847
{
847
{
848
	dword status_y = Form.cheight - STATUSBAR_H + 4;
848
	dword status_y = Form.cheight - STATUSBAR_H + 4;
849
	dword status_w = Form.cwidth - 90;
849
	dword status_w = Form.cwidth - 90;
850
	if (Form.status_window>2) return;
850
	if (Form.status_window>2) return;
851
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
851
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
852
	if (_msg) {
852
	if (_msg) {
853
		ESI = math.min(status_w/6, strlen(_msg));
853
		ESI = math.min(status_w/6, strlen(_msg));
854
		WriteText(10, status_y, 0, sc.work_text, _msg);
854
		WriteText(10, status_y, 0, sc.work_text, _msg);
855
	}
855
	}
856
	DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING);
856
	DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING);
857
	WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
857
	WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
858
}
858
}
859
 
859
 
860
void DrawOmnibox()
860
void DrawOmnibox()
861
{
861
{
862
	int imgxoff;
862
	int imgxoff;
863
	
863
	
864
	DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+18, 24, sc.work_graph, 
864
	DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+18, 24, sc.work_graph, 
865
		sc.work_graph, sc.work_graph, sc.work_dark);
865
		sc.work_graph, sc.work_graph, sc.work_dark);
866
	DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+18, 1, 0xD8DCD8);
866
	DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+18, 1, 0xD8DCD8);
867
	DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+18, 1, omnibox_edit.color);
867
	DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+18, 1, omnibox_edit.color);
868
	DrawBar(omnibox_edit.left-1, omnibox_edit.top, 1, 22, omnibox_edit.color);
868
	DrawBar(omnibox_edit.left-1, omnibox_edit.top, 1, 22, omnibox_edit.color);
869
 
869
 
870
	if (omnibox_edit.flags & ed_focus) omnibox_edit.flags = ed_focus; else omnibox_edit.flags = 0;
870
	if (omnibox_edit.flags & ed_focus) omnibox_edit.flags = ed_focus; else omnibox_edit.flags = 0;
871
	EditBox_UpdateText(#omnibox_edit, omnibox_edit.flags);
871
	EditBox_UpdateText(#omnibox_edit, omnibox_edit.flags);
872
	edit_box_draw stdcall(#omnibox_edit);
872
	edit_box_draw stdcall(#omnibox_edit);
873
	if (http.transfer) imgxoff = 16*23*3; else imgxoff = 0;
873
	if (http.transfer) imgxoff = 16*23*3; else imgxoff = 0;
874
	_PutImage(omnibox_edit.left+omnibox_edit.width+1, omnibox_edit.top-1, 16, 23, imgxoff + #editbox_icons);
874
	_PutImage(omnibox_edit.left+omnibox_edit.width+1, omnibox_edit.top-1, 16, 23, imgxoff + #editbox_icons);
875
	DefineHiddenButton(omnibox_edit.left+omnibox_edit.width-1, omnibox_edit.top-2, 17, 23, REFRESH_BUTTON);
875
	DefineHiddenButton(omnibox_edit.left+omnibox_edit.width-1, omnibox_edit.top-2, 17, 23, REFRESH_BUTTON);
876
 
876
 
877
	DrawProgress();
877
	DrawProgress();
878
}
878
}
879
 
879
 
880
void SetOmniboxText(dword _text)
880
void SetOmniboxText(dword _text)
881
{
881
{
882
	edit_box_set_text stdcall (#omnibox_edit, _text);
882
	edit_box_set_text stdcall (#omnibox_edit, _text);
883
	omnibox_edit.pos = omnibox_edit.flags = 0;
883
	omnibox_edit.pos = omnibox_edit.flags = 0;
884
	DrawOmnibox();
884
	DrawOmnibox();
885
}
885
}
886
 
886
 
887
dword GetAbsoluteActiveURL()
887
dword GetAbsoluteActiveURL()
888
{
888
{
889
	char abs_url[URL_SIZE];
889
	char abs_url[URL_SIZE];
890
	if (links.active_url) {
890
	if (links.active_url) {
891
		strncpy(#abs_url, links.active_url, URL_SIZE);
891
		strncpy(#abs_url, links.active_url, URL_SIZE);
892
		get_absolute_url(#abs_url, history.current());		
892
		get_absolute_url(#abs_url, history.current());		
893
		return #abs_url;
893
		return #abs_url;
894
	}
894
	}
895
	return 0;
895
	return 0;
896
}
896
}
897
 
897
 
898
void CheckContentType()
898
void CheckContentType()
899
{
899
{
900
	char content_type[64];
900
	char content_type[64];
901
	if (http.header_field("content-type", #content_type, sizeof(content_type))) // application || image
901
	if (http.header_field("content-type", #content_type, sizeof(content_type))) // application || image
902
 
902
 
903
	if (content_type[0] == 'i') {
903
	if (content_type[0] == 'i') {
904
		EventDownloadAndOpenImage(http.cur_url);
904
		EventDownloadAndOpenImage(http.cur_url);
905
		StopLoading();
905
		StopLoading();
906
	}if (content_type[0] == 'a') { 
906
	}if (content_type[0] == 'a') { 
907
		EventOpenDownloader(http.cur_url);
907
		EventOpenDownloader(http.cur_url);
908
		StopLoading();
908
		StopLoading();
909
	}
909
	}
910
}
910
}
911
 
911
 
912
void EventDownloadAndOpenImage(dword _url)
912
void EventDownloadAndOpenImage(dword _url)
913
{
913
{
914
	char image_download_url[URL_SIZE];
914
	char image_download_url[URL_SIZE];
915
	strcpy(#image_download_url, "-eo ");
915
	strcpy(#image_download_url, "-eo ");
916
	strncat(#image_download_url, _url, URL_SIZE);
916
	strncat(#image_download_url, _url, URL_SIZE);
917
	EventOpenDownloader(#image_download_url);
917
	EventOpenDownloader(#image_download_url);
918
}
918
}
919
 
919
 
920
void HandleRedirect()
920
void HandleRedirect()
921
{
921
{
922
	char redirect_url[URL_SIZE];
922
	char redirect_url[URL_SIZE];
923
	http.header_field("location", #redirect_url, URL_SIZE);
923
	http.header_field("location", #redirect_url, URL_SIZE);
924
	get_absolute_url(#redirect_url, http.cur_url);
924
	get_absolute_url(#redirect_url, http.cur_url);
925
	http.hfree();
925
	http.hfree();
926
	if (http_get_type==PAGE) OpenPage(#redirect_url);
926
	if (http_get_type==PAGE) OpenPage(#redirect_url);
927
	else if (http_get_type==IMG) GetUrl(#redirect_url);
927
	else if (http_get_type==IMG) GetUrl(#redirect_url);
928
}
928
}
929
 
929
 
930
dword GetImg(bool _new)
930
dword GetImg(bool _new)
931
{
931
{
932
	int i;
932
	int i;
933
	if (!show_images) return;
933
	if (!show_images) return;
934
	http_get_type = IMG;
934
	http_get_type = IMG;
935
 
935
 
936
	for (i = 0; i < WB1.img_url.count; i++)
936
	for (i = 0; i < WB1.img_url.count; i++)
937
	{
937
	{
938
		cur_img_url = WB1.img_url.get(i);
938
		cur_img_url = WB1.img_url.get(i);
939
		if (debug_mode) {debug("get img: ");debugln(cur_img_url);}
939
		if (debug_mode) {debug("get img: ");debugln(cur_img_url);}
940
		if (cache.has(cur_img_url)==false) {
940
		if (cache.has(cur_img_url)==false) {
941
			prbar.max = WB1.img_url.count;
941
			prbar.max = WB1.img_url.count;
942
			prbar.value = i;
942
			prbar.value = i;
943
			if (GetUrl(cur_img_url)) {DrawStatusBar(cur_img_url); DrawProgress(); return;}
943
			if (GetUrl(cur_img_url)) {DrawStatusBar(cur_img_url); DrawProgress(); return;}
944
		}
944
		}
945
	}
945
	}
946
	if (_new) return;
946
	if (_new) return;
947
	DrawOmnibox();
947
	DrawOmnibox();
948
	DrawStatusBar(T_RENDERING);
948
	DrawStatusBar(T_RENDERING);
949
	WB1.ParseHtml(WB1.o_bufpointer, WB1.bufsize);
949
	WB1.ParseHtml(WB1.o_bufpointer, WB1.bufsize);
950
	WB1.DrawPage();
950
	WB1.DrawPage();
951
	debugln(sprintf(#param, T_DONE_IN_SEC, GetStartTime()-render_start_time/100));
951
	debugln(sprintf(#param, T_DONE_IN_SEC, GetStartTime()-render_start_time/100));
952
	DrawStatusBar(NULL);
952
	DrawStatusBar(NULL);
953
}
953
}
954
 
954
 
955
stop:
955
stop: