Skip to content

Commit

Permalink
Fix style to make modern xo happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
parro-it committed Mar 24, 2018
1 parent 2d4e2a4 commit 177b53d
Show file tree
Hide file tree
Showing 35 changed files with 591 additions and 587 deletions.
34 changes: 17 additions & 17 deletions examples/check-memory.js
@@ -1,19 +1,20 @@
var humanize = require('humanize');
var procStats = require('proc-stats');
var libui = require('../index.js');
'use strict';
const libui = require('..');
const humanize = require('humanize');
const procStats = require('proc-stats');

function openBigWindow() {
var win = new libui.UiWindow('Forms window', 80, 60, false);
const win = new libui.UiWindow('Forms window', 80, 60, false);
win.margined = 1;
win.onClosing(function () {
win.onClosing(() => {
win.close();
});

var vBox = new libui.UiVerticalBox();
const vBox = new libui.UiVerticalBox();
vBox.padded = true;

var entries = [];
for (var i = 0; i < 300; i++) {
const entries = [];
for (let i = 0; i < 300; i++) {
entries[i] = new libui.UiEntry();
entries[i].text = i;
vBox.append(entries[i], 1);
Expand All @@ -23,12 +24,12 @@ function openBigWindow() {
win.show();
}

var winCheckMem = new libui.UiWindow('Memory', 200, 100, true);
var label = new libui.UiLabel();
var btn = new libui.UiButton();
const winCheckMem = new libui.UiWindow('Memory', 200, 100, true);
const label = new libui.UiLabel();
const btn = new libui.UiButton();
btn.text = 'Open';
btn.onClicked(openBigWindow);
var vBox2 = new libui.UiVerticalBox();
const vBox2 = new libui.UiVerticalBox();
vBox2.padded = true;

vBox2.append(label, true);
Expand All @@ -37,12 +38,12 @@ vBox2.append(btn, false);
winCheckMem.setChild(vBox2);
winCheckMem.show();

var interval = setInterval(function () {
procStats.stats(function (err, result) {
const interval = setInterval(() => {
procStats.stats((err, result) => {
if (err) {
label.text = err.message;
} else {
var text = `
const text = `
Memory: ${humanize.filesize(result.memory)}
Heap: ${humanize.filesize(result.memoryInfo.heapUsed)}
CPU: ${result.cpu} %
Expand All @@ -52,10 +53,9 @@ CPU: ${result.cpu} %
});
}, 1000);

winCheckMem.onClosing(function () {
winCheckMem.onClosing(() => {
clearInterval(interval);
libui.stopLoop();
});

libui.startLoop();

125 changes: 68 additions & 57 deletions examples/control-gallery.js
@@ -1,6 +1,7 @@
var os = require("os");
'use strict';
const os = require('os');

const libui = require("../index.js");
const libui = require('..');

const {
size,
Expand All @@ -27,9 +28,8 @@ const {
editableCombobox,
radioButtons,
tab,
menu /* ,
multilineEntry*/
} = require("./utils.js");
menu
} = require('./utils.js');

const lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Expand All @@ -38,7 +38,7 @@ nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit
`;

let win;
let win = null;
let spin;
let slide;
let progress;
Expand Down Expand Up @@ -69,29 +69,29 @@ const updateValue = value => {
};

const changeTitle = () => {
win.title = "Title changed";
win.title = 'Title changed';
colorBtn.color = colors.red;
};

const areaHandler = {
drawCb() {
console.log("drawCb");
console.log('drawCb');
},

mouseEventCb() {
console.log("mouseEventCb");
console.log('mouseEventCb');
},

mouseCrossedCb() {
console.log("mouseCrossedCb");
console.log('mouseCrossedCb');
},

dragBrokenCb() {
console.log("dragBrokenCb");
console.log('dragBrokenCb');
},

keyEventCb() {
console.log("keyEventCb");
console.log('keyEventCb');
}
};

Expand All @@ -106,97 +106,97 @@ const area = new libui.UiArea(
);

area.props = {
tabTitle: "Area",
tabTitle: 'Area',
stretchy: true
};

menu([
{
label: "File",
label: 'File',
submenu: [
{
label: "Open",
label: 'Open',
click: () => {
const filename = libui.UiDialogs.openFile(win);
if (filename) {
libui.UiDialogs.msgBox(win, "File selected", filename);
libui.UiDialogs.msgBox(win, 'File selected', filename);
} else {
libui.UiDialogs.msgBox(
win,
"No file selected",
"Don't be alarmed!"
'No file selected',
`Don't be alarmed!`
);
}
}
},
{
label: "Save",
label: 'Save',
click: () => {
const filename = libui.UiDialogs.saveFile(win);
if (filename) {
libui.UiDialogs.msgBox(win, "File selected", filename);
libui.UiDialogs.msgBox(win, 'File selected', filename);
} else {
libui.UiDialogs.msgBox(
win,
"No file selected",
"Don't be alarmed!"
'No file selected',
`Don't be alarmed!`
);
}
}
},
{
role: "quit"
role: 'quit'
}
]
},
{
label: "Edit",
label: 'Edit',
submenu: [
{
label: "Checkable Item",
type: "checkbox"
label: 'Checkable Item',
type: 'checkbox'
},
{
type: "separator"
type: 'separator'
},
{
label: "Disabled Item",
label: 'Disabled Item',
disabled: true
},
{
role: "preferences"
role: 'preferences'
}
]
},
{
label: "Help",
label: 'Help',
submenu: [
{
label: "Help",
label: 'Help',
click: () => {}
},
{
role: "about"
role: 'about'
}
]
},
{
label: "Window",
label: 'Window',
submenu: [
{
label: "Full screen",
label: 'Full screen',
click: () => {
win.fullscreen = !win.fullscreen;
}
},
{
label: "Borderless",
label: 'Borderless',
click: () => {
win.borderless = !win.borderless;
}
},
{
label: "Reset size",
label: 'Reset size',
click: () => {
win.contentSize = size(800, 600);
}
Expand All @@ -207,28 +207,29 @@ menu([

const winProps = {
hasMenubar: true,
title: "Control Gallery",
title: 'Control Gallery',
width: 640,
height: 480,
onClosing,
onContentSizeChanged: onPositionChanged
};

const onDarwin = os.platform() === 'darwin';
const searchText = {text: 'Search Entry'};

win = window(
winProps,
hBox(
{padded: true},
group(
{margined: true, title: "Basic Controls"},
button({text: "Button", onClicked: changeTitle}),
{margined: true, title: 'Basic Controls'},
button({text: 'Button', onClicked: changeTitle}),
(colorBtn = colorButton({})),
checkBox({text: "Checkbox"}),
entry({text: "Entry"}),
os.platform() === "darwin" ?
entry({text: "Search Entry"}) :
searchEntry({text: "Search Entry"}),
passwordEntry({text: "Password Entry"}),
label({text: "Label"}),
checkBox({text: 'Checkbox'}),
entry({text: 'Entry'}),
onDarwin ? entry(searchText) : searchEntry(searchText),
passwordEntry({text: 'Password Entry'}),
label({text: 'Label'}),
separator({}),
datePicker({}),
dateTimePicker({}),
Expand All @@ -238,45 +239,55 @@ win = window(
vBox(
{padded: true},
group(
{margined: true, title: "Numbers"},
{margined: true, title: 'Numbers'},
(spin = spinbox({onChanged: () => updateValue(spin.value)})),
(slide = slider({onChanged: () => updateValue(slide.value)})),
(progress = progressBar({}))
),

group(
{margined: true, title: "Lists", stretchy: true},
combobox({}, "Combobox Item 1", "Combobox Item 2", "Combobox Item 3"),
{margined: true, title: 'Lists', stretchy: true},
combobox(
{},
'Combobox Item 1',
'Combobox Item 2',
'Combobox Item 3'
),
editableCombobox(
{},
"Editable Item 1",
"Editable Item 2",
"Editable Item 3"
'Editable Item 1',
'Editable Item 2',
'Editable Item 3'
),
radioButtons(
{},
'Radio Button 1',
'Radio Button 2',
'Radio Button 3'
),
radioButtons({}, "Radio Button 1", "Radio Button 2", "Radio Button 3"),
tab(
{stretchy: true},
entry({
text: lorem.slice(5),
tabTitle: "Page 1",
tabTitle: 'Page 1',
stretchy: true
}),
entry({
text: lorem.slice(10),
tabTitle: "Page 2",
tabTitle: 'Page 2',
stretchy: true
}),
entry({
text: lorem.slice(20),
tabTitle: "Page 3",
tabTitle: 'Page 3',
stretchy: true
}),
area
)
)
)
),
(status = label({stretchy: true, text: "(0, 0)"}))
(status = label({stretchy: true, text: '(0, 0)'}))
);

win.show();
Expand Down

0 comments on commit 177b53d

Please sign in to comment.