-
Notifications
You must be signed in to change notification settings - Fork 0
/
jbrowser
executable file
·99 lines (79 loc) · 2.49 KB
/
jbrowser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/jjs -Dnashorn.args=-fx -cp ./java
// Get java stuff
var Scene = Java.type("javafx.scene.Scene");
var File = Java.type("java.io.File");
var FXMLLoader = Java.type("javafx.fxml.FXMLLoader");
var ChangeListener = javafx.beans.value.ChangeListener;
load("fx:base.js");
load("fx:controls.js");
load("fx:graphics.js");
load("fx:web.js");
load("fx:fxml.js");
load("nashorn:mozilla_compat.js");
// Get custom stuff
var home = $ENV.PWD;
var content_dir = "${home}/html/";
var script_dir = "${home}/script/";
var fxml_dir = "${home}/interface/";
var css_dir = "${home}/css/";
load("file://${script_dir}/webview.js");
load("file://${script_dir}/minivents.js");
load("file://${script_dir}/utility.js");
//preferece values
var historyLimit = 25;
var mainStage = $STAGE;
/*************************************
######## GUI Layout Section ##########
**************************************/
// master layout
var masterPane = new BorderPane();
/******** Browser Control **************/
// Instantiate container browser window
var engine = new WebViewWrapper(
function(){
if(engine.backBtn && engine.forwardBtn){
engine.backBtn.setDisable(!engine.canGoBack());
engine.forwardBtn.setDisable(!engine.canGoForward());
}
}
);
// make it an event emitter
Events(engine);
/******** End Browser Control *********/
/******** Load Top Browser Bar ********/
var barFile = "interface/topbar.fxml"
var nav = FXMLLoader.load(new File(barFile).toURL());
engine.setBackButton(nav.lookup('#backBtn'));
engine.setForwardButton(nav.lookup('#forwardBtn'));
engine.setStopReloadButton(nav.lookup('#stopReloadBtn'));
engine.setURLField(nav.lookup('#URLField'));
var tstbtn = new Button("test");
tstbtn.onAction = function(){
engine.showHistory();
}
//nav.getChildren().addAll(tstbtn);
masterPane.setTop(nav);
/******** End Top Browser Bar **********/
masterPane.setCenter(engine.webview);
/******* Status Bar *********/
var status = new HBox();
status.setPrefHeight(30);
status.setStyle("-fx-padding:12px;-fx-background-color:#CCCCCC");
var statusText = new Text();
engine.on("statuschange",function(value){
statusText.setText(value);
});
status.getChildren().add(statusText);
masterPane.setBottom(status);
mainStage.setWidth(1400);
mainStage.setHeight(800);
/**********************************
########### end layout ############
**********************************/
// HTML page
var page = 'file://' + content_dir + 'index.html';
engine.load(page);
mainStage.scene=new Scene(masterPane);
function stop(){
engine.saveHistory();
}