Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env elev8
var elm = require('elm');
var EXPAND_BOTH = { x: 1.0, y: 1.0 };
var FILL_BOTH = { x: -1.0, y: -1.0 };
var entry_text = "This is an entry widget in this window.";
var entry = elm.Entry({
text: entry_text,
weight: EXPAND_BOTH,
align: FILL_BOTH,
line_wrap: 3,
single_line: 1,
editable: true
});
var win = elm.realise(elm.Window({
title: "Notify Example",
width: 320,
height: 480,
weight: EXPAND_BOTH,
align: FILL_BOTH,
elements: {
background: elm.Background({
width : 320,
height : 480,
weight : EXPAND_BOTH,
align : FILL_BOTH,
elements : {
the_background : elm.Background ({
weight : EXPAND_BOTH,
align : FILL_BOTH,
resize : true,
}),
the_box1 : elm.Box ({
weight : EXPAND_BOTH,
align : FILL_BOTH,
resize : true,
elements : {
the_entry : elm.Entry ({
text : entry_text,
weight : EXPAND_BOTH,
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
icon_no_scale : elm.Button ({
label : "Clear",
weight : { x : -1.0, y : -1.0 },
on_click : function(arg) {
my_window.elements.the_box1.elements.the_entry.text = "";
}
}),
},
}),
},
});
}
op_button.prototype = new any_button;
var calc = elm.realise(elm.Window({
title : "Calculator demo",
elements : {
the_background : elm.Background ({
weight : EXPAND_BOTH,
resize : true,
}),
vbox : elm.Box ({
resize : true,
elements : {
entry : elm.Entry ({
label : "0",
align : { x : -1, y : 0 },
}),
hbox1 : elm.Box ({
horizontal : true,
homogeneous : true,
elements : {
b7 : number_button("7"),
b8 : number_button("8"),
b9 : number_button("9"),
divide : op_button("/", divide),
},
}),
hbox2 : elm.Box ({
horizontal : true,
homogeneous : true,
width: 320,
height: 480,
weight: EXPAND_BOTH,
align: FILL_BOTH,
elements: {
the_background: elm.Background({
weight: EXPAND_BOTH,
align: FILL_BOTH,
resize: true
}),
the_box: elm.Box({
weight: EXPAND_BOTH,
align: FILL_BOTH,
resize: true,
elements: {
the_entry: elm.Entry({
text: entry_text,
weight: EXPAND_BOTH,
align: FILL_BOTH,
line_wrap: 3,
single_line: 1,
editable: true,
on_change: function() {
print("changed");
}
}),
the_pass: elm.Entry({
text: "Password",
weight: EXPAND_BOTH,
editable: false,
password: true,
}),
align: FILL_BOTH,
resize: true,
}),
box: elm.Box({
weight: EXPAND_BOTH,
align: FILL_BOTH,
resize: true,
elements: {
first_name : elm.Entry ({
text : "First Name",
weight : EXPAND_BOTH,
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
last_name : elm.Entry ({
text : "Last Name",
weight : EXPAND_BOTH,
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
phone_number : elm.Entry ({
text : "Phone Number",
weight : EXPAND_BOTH,
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
but_box: elm.Box({
horizontal: true,
elements: {
elements: {
first_name : elm.Entry ({
text : "First Name",
weight : EXPAND_BOTH,
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
last_name : elm.Entry ({
text : "Last Name",
weight : EXPAND_BOTH,
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
phone_number : elm.Entry ({
text : "Phone Number",
weight : EXPAND_BOTH,
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
but_box: elm.Box({
horizontal: true,
elements: {
save: elm.Button({
label: "Save ",
weight: EXPAND_BOTH,
on_click: function() { saveItems(); }
}),
load: elm.Button({
label: "Load",
weight: EXPAND_BOTH,
align: FILL_BOTH,
resize: true,
elements: {
the_entry: elm.Entry({
text: entry_text,
weight: EXPAND_BOTH,
align: FILL_BOTH,
line_wrap: 3,
single_line: 1,
editable: true,
on_change: function() {
print("changed");
}
}),
the_pass: elm.Entry({
text: "Password",
weight: EXPAND_BOTH,
editable: false,
password: true,
}),
icon_no_scale: elm.Button({
label: "Icon no scale",
weight: { x: -1.0, y: -1.0 },
})
}
})
}
});
var e = elm.realise(w);
window.elements.vbox.elements.webpage.elements.web.reload();
}
},
'page-is-loading': {
icon: 'process-stop',
label: 'Stop',
on_select: function() {
window.elements.vbox.elements.webpage.elements.web.stop();
}
}
},
priority: 200
},
{ separator: true },
{
element: elm.Entry({
align: FILL_BOTH,
weight: EXPAND_BOTH,
single_line: true,
scrollable: true,
hint_min: {width: 250, height: 30},
on_activate: function(text) {
window.elements.vbox.elements.webpage.elements.web.uri = text;
}
}),
priority: 400
},
{ separator: true },
{
icon: 'go-home',
label: 'Home',
priority: 50,
var win = elm.realise(elm.Window({
title : "Storage",
width : 320,
height : 530,
elements : {
background: elm.Background({
weight: EXPAND_BOTH,
align: FILL_BOTH,
resize: true,
}),
box: elm.Box({
weight: EXPAND_BOTH,
align: FILL_BOTH,
resize: true,
elements: {
first_name : elm.Entry ({
text : "First Name",
weight : EXPAND_BOTH,
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
last_name : elm.Entry ({
text : "Last Name",
weight : EXPAND_BOTH,
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
phone_number : elm.Entry ({
text : "Phone Number",
weight : EXPAND_BOTH,
weight : EXPAND_BOTH,
align : FILL_BOTH,
resize : true,
elements : {
the_entry : elm.Entry ({
text : entry_text,
weight : {x:-1.0, y:0.0},
align : FILL_BOTH,
line_wrap : 3,
editable : true,
}),
icon_no_scale : elm.Button ({
label : "Icon no scale",
weight : { x : -1.0, y : -1.0 },
}),
the_pass : elm.Entry ({
text : "Password",
weight : {x:-1.0, y:0.0},
editable : false,
password : true,
}),
},
}),
}),
},
}));