Skip to content

Commit 2d3a68e

Browse files
committed
webui.js - Adding allowNavigation
More inf: #541
1 parent 1eb06bb commit 2d3a68e

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

bridge/webui.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,17 @@ class WebuiBridge {
847847
if (this.#log) console.log(`Core Response: [${response}]`);
848848
return response;
849849
}
850+
/**
851+
* When binding all events on the backend, WebUI blocks all navigation events
852+
* and sends them to the backend. This API allows you to control that behavior.
853+
*
854+
* @param status - Boolean `True` means WebUI will allow navigations
855+
* @example - webui.allowNavigation(true); // Allow navigation
856+
* window.location.replace('www.test.com'); // This will now proceed as usual
857+
*/
858+
allowNavigation(status: boolean): void {
859+
this.#allowNavigation = status;
860+
}
850861
}
851862
// Export
852863
type webui = WebuiBridge;

bridge/webui_bridge.h

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ unsigned char webui_javascript_bridge[] = {
2222
0x2d, 0x64, 0x65, 0x76, 0x2f, 0x77, 0x65, 0x62, 0x75, 0x69,
2323
0x0a, 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69,
2424
0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20, 0x32, 0x30,
25-
0x32, 0x30, 0x2d, 0x32, 0x30, 0x32, 0x34, 0x20, 0x48, 0x61,
25+
0x32, 0x30, 0x2d, 0x32, 0x30, 0x32, 0x35, 0x20, 0x48, 0x61,
2626
0x73, 0x73, 0x61, 0x6e, 0x20, 0x44, 0x72, 0x61, 0x67, 0x61,
2727
0x2e, 0x0a, 0x2f, 0x2f, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e,
2828
0x73, 0x65, 0x64, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x20,
@@ -1526,28 +1526,33 @@ unsigned char webui_javascript_bridge[] = {
15261526
0x6f, 0x72, 0x65, 0x20, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
15271527
0x73, 0x65, 0x3a, 0x20, 0x5b, 0x24, 0x7b, 0x72, 0x65, 0x73,
15281528
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x7d, 0x5d, 0x60, 0x29, 0x2c,
1529-
0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x7d, 0x7d,
1530-
0x3b, 0x61, 0x64, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c,
1531-
0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x28, 0x22, 0x6c,
1532-
0x6f, 0x61, 0x64, 0x22, 0x2c, 0x28, 0x29, 0x3d, 0x3e, 0x7b,
1533-
0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x62,
1534-
0x6f, 0x64, 0x79, 0x2e, 0x61, 0x64, 0x64, 0x45, 0x76, 0x65,
1529+
0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x7d, 0x61,
1530+
0x6c, 0x6c, 0x6f, 0x77, 0x4e, 0x61, 0x76, 0x69, 0x67, 0x61,
1531+
0x74, 0x69, 0x6f, 0x6e, 0x28, 0x73, 0x74, 0x61, 0x74, 0x75,
1532+
0x73, 0x29, 0x7b, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x61,
1533+
0x6c, 0x6c, 0x6f, 0x77, 0x4e, 0x61, 0x76, 0x69, 0x67, 0x61,
1534+
0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x73, 0x74, 0x61, 0x74, 0x75,
1535+
0x73, 0x7d, 0x7d, 0x3b, 0x61, 0x64, 0x64, 0x45, 0x76, 0x65,
15351536
0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72,
1536-
0x28, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x6d,
1537-
0x65, 0x6e, 0x75, 0x22, 0x2c, 0x65, 0x76, 0x65, 0x6e, 0x74,
1538-
0x3d, 0x3e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72,
1539-
0x65, 0x76, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75,
1540-
0x6c, 0x74, 0x28, 0x29, 0x29, 0x2c, 0x61, 0x64, 0x64, 0x52,
1541-
0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x61, 0x62, 0x6c, 0x65,
1537+
0x28, 0x22, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x2c, 0x28, 0x29,
1538+
0x3d, 0x3e, 0x7b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e,
1539+
0x74, 0x2e, 0x62, 0x6f, 0x64, 0x79, 0x2e, 0x61, 0x64, 0x64,
15421540
0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x65,
1543-
0x6e, 0x65, 0x72, 0x28, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65,
1544-
0x6e, 0x74, 0x2e, 0x62, 0x6f, 0x64, 0x79, 0x2c, 0x22, 0x69,
1545-
0x6e, 0x70, 0x75, 0x74, 0x22, 0x2c, 0x22, 0x63, 0x6f, 0x6e,
1546-
0x74, 0x65, 0x78, 0x74, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x2c,
1547-
0x65, 0x76, 0x65, 0x6e, 0x74, 0x3d, 0x3e, 0x65, 0x76, 0x65,
1548-
0x6e, 0x74, 0x2e, 0x73, 0x74, 0x6f, 0x70, 0x50, 0x72, 0x6f,
1549-
0x70, 0x61, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29,
1550-
0x29, 0x7d, 0x29, 0x3b, 0x0a,
1541+
0x6e, 0x65, 0x72, 0x28, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65,
1542+
0x78, 0x74, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x2c, 0x65, 0x76,
1543+
0x65, 0x6e, 0x74, 0x3d, 0x3e, 0x65, 0x76, 0x65, 0x6e, 0x74,
1544+
0x2e, 0x70, 0x72, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x44, 0x65,
1545+
0x66, 0x61, 0x75, 0x6c, 0x74, 0x28, 0x29, 0x29, 0x2c, 0x61,
1546+
0x64, 0x64, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x61,
1547+
0x62, 0x6c, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69,
1548+
0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x28, 0x64, 0x6f, 0x63,
1549+
0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x62, 0x6f, 0x64, 0x79,
1550+
0x2c, 0x22, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x22, 0x2c, 0x22,
1551+
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x6d, 0x65, 0x6e,
1552+
0x75, 0x22, 0x2c, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x3d, 0x3e,
1553+
0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x73, 0x74, 0x6f, 0x70,
1554+
0x50, 0x72, 0x6f, 0x70, 0x61, 0x67, 0x61, 0x74, 0x69, 0x6f,
1555+
0x6e, 0x28, 0x29, 0x29, 0x7d, 0x29, 0x3b, 0x0a,
15511556
0x00
15521557
};
15531558

0 commit comments

Comments
 (0)