Skip to content

Commit

Permalink
Set default settings
Browse files Browse the repository at this point in the history
Former-commit-id: cfc24b1 [formerly 67e8d82]
Former-commit-id: bbf3e31
  • Loading branch information
Alex Epstein committed May 4, 2017
1 parent 596e991 commit c6fa3dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 8 additions & 8 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ function setTime() { //called when set wakeup time button is pressed

function readPreferences()
{
if (settings.get('militaryTime') === "true") //if militaryTime preference is set to true
if (settings.get('militaryTime','false') === "true") //if militaryTime preference is set to true
{
militaryTime = true; //set the preference in the code
}
else //if standard time preference
{
militaryTime = false; //set the military time perference in the code to false
}
time = settings.get('defaultTime'); //set time variable
appVersion = settings.get('Version');
time = settings.get('defaultTime','08:30'); //set time variable
appVersion = settings.get('Version','v1.3.0');
document.getElementById('alarmTime').value = time; //set the time on the DOM
setTime(); //run the main function to generate and show sleep time
}

function loadPreferences()
{
appVersion = settings.get('Version');
if (settings.get('militaryTime') === "true") //mySettings[0] is where the military time setting is stored
appVersion = settings.get('Version','v1.3.0');
if (settings.get('militaryTime','false') === "true") //mySettings[0] is where the military time setting is stored
{
militaryTime = true; //set prefrence to military time
}
Expand All @@ -69,15 +69,15 @@ function loadPreferences()
document.getElementById('timeType').checked = false; //dont set this button
document.getElementById('timeType2').checked = true; //set radio button
}
if (settings.get('closeOnX') === "true") //mySettings[2] is where the closeOnX setting is stored
if (settings.get('closeOnX','true') === "true") //mySettings[2] is where the closeOnX setting is stored
{
document.getElementById('closeOnXcheck').checked = true; //set checkbox
}
else
{
document.getElementById('closeOnXcheck').checked = false; //set check box
}
document.getElementById('defaultTime').value = settings.get('defaultTime'); //set time to preference time
document.getElementById('defaultTime').value = settings.get('defaultTime','08:30'); //set time to preference time
}


Expand Down Expand Up @@ -218,7 +218,7 @@ function getLatestReleaseInfo() {
$.getJSON("https://api.github.com/repos/alexanderepstein/Insomnia/tags").done(function (json) { //grab the latest release information
var release = json[0].name; //get the newest app version
release = release.split("");
var myversion = settings.get('Version').split("");
var myversion = settings.get('Version','v1.3.0').split("");

if (release[1] > myversion[1] || (release[1]==myversion[1] && release[3] > myversion[3])) //check if it matches current app version
{
Expand Down
7 changes: 4 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const {app, Tray, Menu, shell, BrowserWindow} = require('electron'); //electron application stuff
const path = require('path'); //allows for use of path
const filePath = path.join(__dirname, 'settings.txt');
const url = require('url'); //allows for loadURL and url.format
const iconPath = path.join(__dirname, 'icon.png'); //grab the icon
const settings = require('electron-settings');
Expand All @@ -22,7 +21,9 @@ app.on('ready', function(){
slashes: true
}))

//settings.set('Version','v1.3.0')



//console.log(settings.getAll());
//win.openDevTools(); //starts the application with developer tools open

Expand Down Expand Up @@ -87,7 +88,7 @@ if (!closeOnX)

function getCloseOnXPref()
{
if (settings.get('closeOnX')==="true")
if (settings.get('closeOnX','true')==="true")
{
closeOnX = true;
}
Expand Down

0 comments on commit c6fa3dd

Please sign in to comment.