Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed menubar is not defined #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 107 additions & 96 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -1,151 +1,162 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">

<title> Pomolectron </title>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">

<title> Pomolectron </title>

<!-- Bootstrap core styles -->
<link href="styles/bootstrap.min.css" rel="stylesheet" id="light" class='alternate'>
<link href="styles/bootstrap.dark.min.css" rel="stylesheet" id="dark" class='alternate' disabled>
<!-- Bootstrap core styles -->
<link href="styles/bootstrap.min.css" rel="stylesheet" id="light" class='alternate'>
<link href="styles/bootstrap.dark.min.css" rel="stylesheet" id="dark" class='alternate' disabled>

<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="styles/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="styles/ie10-viewport-bug-workaround.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="styles/starter-template.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="styles/starter-template.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
p src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle custom-btn" onclick="closeApp();" title="Close Pomolectron">
<i class="glyphicon glyphicon-off"></i>
</button>
<a href="https://github.com/amitmerchant1990/pomolectron" type="button" class="navbar-toggle custom-btn" title="About">
<i class="glyphicon glyphicon-info-sign"></i>
</a>
<button type="button" class="navbar-toggle custom-btn" onclick="toggleTheme();" title="Toggle theme">
<i class="glyphicon glyphicon-refresh"></i>
</button>
<a class="navbar-brand" href="#">Pomolectron</a>
</div>

</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle custom-btn" onclick="closeApp();" title="Close Pomolectron">
<i class="glyphicon glyphicon-off"></i>
</button>
<a href="https://github.com/amitmerchant1990/pomolectron" type="button" class="navbar-toggle custom-btn"
title="About">
<i class="glyphicon glyphicon-info-sign"></i>
</a>
<button type="button" class="navbar-toggle custom-btn" onclick="toggleTheme();" title="Toggle theme">
<i class="glyphicon glyphicon-refresh"></i>
</button>
<a class="navbar-brand" href="#">Pomolectron</a>
</div>
</nav>

<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#pomodoro">Pomodoro</a></li>
<li><a data-toggle="tab" href="#short">Short break</a></li>
<li><a data-toggle="tab" href="#long">Long break</a></li>
</div>
</nav>

</ul>
<div class="tab-content">
<div id="pomodoro" class="tab-pane fade in active">
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#pomodoro">Pomodoro</a></li>
<li><a data-toggle="tab" href="#short">Short break</a></li>
<li><a data-toggle="tab" href="#long">Long break</a></li>

<div class="starter-template">
<h1 id="time">25:00</h1>
</div>
</ul>
<div class="tab-content">
<div id="pomodoro" class="tab-pane fade in active">
<div class="container">

<div class="starter-template">
<h1 id="time">25:00</h1>
</div>

<div class="container">
</div>

<div class="container">

<div class="starter-template">
<div class="row">
<div>
<button type="button" class="btn btn-large btn-primary full-width" id="start"><span class="glyphicon glyphicon-play"></span></button>
<div class="starter-template">
<div class="row">
<div>
<button type="button" class="btn btn-large btn-primary full-width" id="start"><span
class="glyphicon glyphicon-play"></span></button>

<button type="button" id="stop" class="btn btn-large btn-success full-width"><span class="glyphicon glyphicon-pause"></span></button>
<button type="button" id="stop" class="btn btn-large btn-success full-width"><span
class="glyphicon glyphicon-pause"></span></button>

<button type="button" class="btn btn-large btn-danger full-width" id="reset"><span class="glyphicon glyphicon-repeat"></span></button>
</div>
<button type="button" class="btn btn-large btn-danger full-width" id="reset"><span
class="glyphicon glyphicon-repeat"></span></button>
</div>
</div>

</div>
</div>

<div id="short" class="tab-pane fade in">
<div class="container">
</div>
</div>

<div class="starter-template">
<h1 id="time_short">05:00</h1>
</div>
<div id="short" class="tab-pane fade in">
<div class="container">

<div class="starter-template">
<h1 id="time_short">05:00</h1>
</div>

<div class="container">
</div>

<div class="container">

<div class="starter-template">
<div class="row">
<div>
<button type="button" class="btn btn-large btn-primary full-width" id="short_start"><span class="glyphicon glyphicon-play"></span></button>
<div class="starter-template">
<div class="row">
<div>
<button type="button" class="btn btn-large btn-primary full-width" id="short_start"><span
class="glyphicon glyphicon-play"></span></button>

<button type="button" class="btn btn-large btn-success full-width" id="short_stop"><span class="glyphicon glyphicon-pause"></span></button>
<button type="button" class="btn btn-large btn-success full-width" id="short_stop"><span
class="glyphicon glyphicon-pause"></span></button>

<button type="button" class="btn btn-large btn-danger full-width" id="short_reset"><span class="glyphicon glyphicon-repeat"></span></button>
</div>
<button type="button" class="btn btn-large btn-danger full-width" id="short_reset"><span
class="glyphicon glyphicon-repeat"></span></button>
</div>
</div>

</div>
</div>

<div id="long" class="tab-pane fade in">
<div class="container">
</div>
</div>

<div class="starter-template">
<h1 id="time_long">10:00</h1>
</div>
<div id="long" class="tab-pane fade in">
<div class="container">

<div class="starter-template">
<h1 id="time_long">10:00</h1>
</div>

<div class="container">
</div>

<div class="container">

<div class="starter-template">
<div class="row">
<div>
<button type="button" class="btn btn-large btn-primary full-width" id="long_start"><span class="glyphicon glyphicon-play"></span></button>
<div class="starter-template">
<div class="row">
<div>
<button type="button" class="btn btn-large btn-primary full-width" id="long_start"><span
class="glyphicon glyphicon-play"></span></button>

<button type="button" class="btn btn-large btn-success full-width" id="long_stop"><span class="glyphicon glyphicon-pause"></span></button>
<button type="button" class="btn btn-large btn-success full-width" id="long_stop"><span
class="glyphicon glyphicon-pause"></span></button>

<button type="button" class="btn btn-large btn-danger full-width" id="long_reset"><span class="glyphicon glyphicon-repeat"></span></button>
</div>
<button type="button" class="btn btn-large btn-danger full-width" id="long_reset"><span
class="glyphicon glyphicon-repeat"></span></button>
</div>
</div>

</div>

</div>
</div>
</div>

<audio id='notiSound' src='audio/alert.wav' loop/>
<audio id='notiSound' src='audio/alert.wav' loop />

<script type="text/javascript">
<script type="text/javascript">
if (typeof module === 'object') {
var electron = require('electron');
// Require in any additional modules that are Node.js only
window.module = module;
module = undefined;
}
</script>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/bootstrap.min.js"></script>
<script src="scripts/notification.js"></script>
<script src="scripts/app.js"></script>
</body>
</script>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/bootstrap.min.js"></script>
<script src="scripts/notification.js"></script>
<script src="scripts/app.js"></script>
</body>

</html>
100 changes: 45 additions & 55 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,54 @@
'use strict';
const electron = require('electron');
const menubar = require('menubar');
const ipcMain = require('electron').ipcMain;

var mb = menubar({
dir:__dirname,
tooltip: "Pomolectron",
icon:__dirname + "/res/tomato.png",
width:300, height:250,
resizable: false,
alwaysOnTop :true
});

const contextMenu = electron.Menu.buildFromTemplate([
{
label: 'About',
click() {
electron.dialog.showMessageBox({title: "Pomolectron", type:"info", message: "A pomodoro app in your menubar/tray. \nMIT Copyright (c) 2017 Amit Merchant <[email protected]>", buttons: ["Close"] });
}
},
{
label: 'Website',
click() {
electron.shell.openExternal("https://github.com/amitmerchant1990/pomolectron");
let tray = null
let window = null
electron.app.whenReady().then(() => {
tray = new electron.Tray(__dirname + "/res/tomato.png")
const contextMenu = electron.Menu.buildFromTemplate([
{
label: 'Open interface',
click() {
window = new electron.BrowserWindow({
width: 300,
height: 250,
x: electron.screen.getPrimaryDisplay().workAreaSize.width - 300,
y: 0,
webPreferences: { nodeIntegration: true },
frame: false
})
window.loadURL(`file://${__dirname}/index.html`)
}
},
{
label: 'About',
click() {
electron.dialog.showMessageBox({ title: "Pomolectron", type: "info", message: "A pomodoro app in your menubar/tray. \nMIT Copyright (c) 2017 Amit Merchant <[email protected]>", buttons: ["Close"] });
}
},
{
label: 'Website',
click() {
electron.shell.openExternal("https://github.com/amitmerchant1990/pomolectron");
}
},
{
type: 'separator'
},
{
label: 'Quit',
click() {
electron.app.quit();
}
}
},
{
type: 'separator'
},
{
label: 'Quit',
click() {
mb.app.quit();
}
}

]);

ipcMain.on('closeApp', (event, close) => {
mb.app.quit();
});

mb.on('ready', function ready () {
global.sharedObj = {
hide: mb.hideWindow,
quit: mb.app.quit,
pinned: false
}
]);
tray.setToolTip('Pomolectron')
tray.setContextMenu(contextMenu)
})

console.log('Pomolectron is ready to serve in the menubar.');

if (process.platform == 'win32') {
mb.tray.setContextMenu(contextMenu);
}else{
mb.tray.on("right-click", () => {
mb.tray.popUpContextMenu(contextMenu);
});
}
ipcMain.on('closeApp', (event, close) => {
electron.app.quit();
});

mb.on('after-create-window', function(){
//mb.window.openDevTools()
})
Loading