Permalink
Browse files

Week 7 updates, new menu and starting on the settings screen.

  • Loading branch information...
roncli committed May 2, 2017
1 parent 9a33e1a commit 1350be62be45956613dfdbf9acb74278c3bbf3f8
@@ -41,6 +41,3 @@ jspm_packages

# Electron
dist

# Settings
settings.js
@@ -1,11 +1,11 @@
const {app, BrowserWindow} = require("electron");
const {app, BrowserWindow, Menu} = require("electron");

var win,
createWindow = () => {
win = new BrowserWindow({show: false, width: 800, height: 600, minWidth: 800, minHeight: 600, icon: __dirname + "/../logo/logo.ico", title: "Hyperdrive Toolkit"}); // TODO: Get the right icon.
win.loadURL(`file://${__dirname}/site/index.htm`);
win.setMenu(null);
win.maximize();
win.maximize(); // TODO: Remember previous window position?
win.toggleDevTools(); // TODO: Remove for release.

win.once("ready-to-show", () => {
@@ -15,6 +15,8 @@ var win,
win.on("closed", () => {
win = null;
});

require("./mainmenu");
};

app.on("ready", createWindow);
@@ -0,0 +1,80 @@
var settingsWin;

const {Menu, BrowserWindow} = require("electron"),
isMac = process.platform === "darwin",
template = [
{
label: "&File",
submenu: [
{
label: "&Settings",
click: (menuItem, browserWindow, ev) => {
if (settingsWin) {
// TODO: Focus settings window.
} else {
settingsWin = new BrowserWindow({show: false, width: 800, height: 600, icon: __dirname + "/../logo/logo.ico", title: "Settings - Hyperdrive Toolkit"}); // TODO: Get the right icon, setup proper dimensions, don't allow change in size.

settingsWin.loadURL(`file://${__dirname}/site/settings.htm`);
settingsWin.setMenu(null);
settingsWin.toggleDevTools(); // TODO: Remove for release.

settingsWin.once("ready-to-show", () => {
settingsWin.show();
});

settingsWin.on("closed", () => {
settingsWin = null;
});
}
}
},
{
type: "separator"
},
{
label: isMac ? "&Quit" : "E&xit",
accelerator: isMac ? "Cmd+Q" : "Alt+F4",
role: "quit"
}
]
},
{
label: "&Edit",
submenu: [
{
label: "&Undo",
accelerator: "CmdOrCtrl+Z"
},
{
label: "&Redo",
accelerator: "CmdOrCtrl+Y"
},
{
type: "separator"
},
{
label: "Cu&t",
accelerator: "CmdOrCtrl+X"
},
{
label: "&Copy",
accelerator: "CmdOrCtrl+C"
},
{
label: "&Paste",
accelerator: "CmdOrCtrl+V"
},
{
label: "&Delete",
accelerator: "Delete"
},
{
label: "Select A&ll",
accelerator: "CmdOrCtrl+A"
}
]
}
],
menu = Menu.buildFromTemplate(template);

Menu.setApplicationMenu(menu);
@@ -5,10 +5,6 @@ body {
height: 100%;
}

#menu {

}

#channels {

}
No changes.
@@ -9,7 +9,6 @@
<link href="css/index.css" rel="stylesheet"></link>
</head>
<body>
<div id="menu">Menu</div>
<ul id="channels" class="nav nav-tabs"></ul>
<div id="display" class="tab-content panel"></div>
<div id="input">
@@ -0,0 +1,16 @@
module.exports = {
tmi: {
options: {
clientId: "xetz9cvboym6sr1iz19qr0kubr2nl1"
},
connection: {
reconnect: true
}
},
twitch: {
clientId: "xetz9cvboym6sr1iz19qr0kubr2nl1",
clientSecret: undefined,
redirectUri: "http://127.0.0.1:65100/token",
scopes: ["chat_login", "channel_editor", "channel_commercial", "user_read", "channel_subscriptions", "user_follows_edit"]
}
};
@@ -1,10 +1,10 @@
var electron = require("electron"),
path = require("path"),
Twitch = require("./modules/chat/twitch"), // TODO: Load modules
File = require("./modules/datastore/file"),
settings = require("./js/settings"),
settings = require("./js/apiSettings"),
client = new Twitch(settings),
userSettings = new File(path.join(electron.remote.app.getPath("userData"), "userSettings.js"));
File = require("./modules/datastore/file"),
userSettings = new File(path.join(electron.remote.app.getPath("userData"), "userSettings.js")),
channels = {},
getTab = (username) => {
return `<li id="tab-${username}" class="channel-tab"><a data-toggle="tab" href="#channel-${username}">#${username}</a></li>`;
@@ -134,7 +134,7 @@ userSettings.load().then(() => {
}
}).then(() => {
client.connect().then(() => {
client.join("#roncli");
client.join("#roncli"); // TODO: Ask to join a channel?
});
});
});
@@ -152,6 +152,7 @@ $(document).ready(() => {
}, 0);
};

// Setup input box resizing
$inputbox.on("keypress", (ev) => {
if (ev.keyCode === 13 && client.connected) {
let input = $inputbox.val(),
@@ -180,11 +181,13 @@ $(document).ready(() => {
$inputbox.on("keydown", () => setSize($inputbox));
$inputbox.on("keyup", () => setSize($inputbox));

// Setup channel tabs.
$("#channels").on("click", "a", (ev) => {
ev.preventDefault();
$(this).tab("show");
});

// Setup user list divider.
$("#display").on("mousedown", "div.divider", (ev) => {
var pageX = ev.pageX,
$users = $(ev.target).next("div.users"),
@@ -0,0 +1,35 @@
var electron = require("electron"),
path = require("path"),
File = require("./modules/datastore/file"),
appSettings = new File(path.join(electron.remote.app.getPath("userData"), "appSettings.js"));

$(document).ready(() => {
appSettings.load().then(() => {
if (!appSettings.data.chat) {
appSettings.data.chat = {
font: {
face: "",
size: 12
},
colors: {
chat: {
foreground: "#000000",
background: "#ffffff",
info: "#8000ff",
join: "#333333",
part: "#333333",
highlight: "#ff0000"
},
input: {
foreground: "#000000",
background: "#ffffff"
},
userList: {
foreground: "#000000",
background: "#ffffff"
}
}
};
}
});
});
@@ -27,3 +27,5 @@ window.addEventListener("beforeunload", function(ev) {
window.addEventListener("unload", function() {
server.close();
});

electron.remote.getCurrentWindow().setMenu(null);
@@ -44,7 +44,7 @@ class File extends DataStore {

resolve();
});
}).then(outerResolve).catch(outerReject);
}).then(outerResolve).catch(outerReject); // TODO: Handle rejection better.
});
});
}
@@ -71,7 +71,7 @@ class File extends DataStore {
resolve();
});
});
}).then(outerResolve).catch(outerReject);
}).then(outerResolve).catch(outerReject); // TODO: Handle rejection better.
});
} else {
outerResolve();
@@ -0,0 +1,25 @@
<html>
<head>
<script src="../node_modules/jquery/dist/jquery.min.js"></script>
<script>$ = jQuery = require("jquery")</script>
<script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="js/settings.js"></script>
<link href="../node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"></link>
<link href="../node_modules/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet"></link>
<link href="css/settings.css" rel="stylesheet"></link>
</head>
<body>
<ul id="categories" class="nav nav-tabs">
<li id="tab-chat" class="active"><a data-toggle="tab" href="#chat">Chat</a></li>
<li id="tab-huh"><a data-toggle="tab" href="#huh">Some other settings</a></li>
</ul>
<div id="display" class="tab-content panel">
<div role="tabpanel" class="tab-pane active" id="chat">
I am the chat settings! \o/
</div>
<div role="tabpanel" class="tab-pane" id="huh">
I don't know what I am! /o\
</div>
</div>
</body>
</html>

0 comments on commit 1350be6

Please sign in to comment.