adds development mode integration into the application. First version is finished

This commit is contained in:
julien lengrand-lambert
2014-03-11 06:59:46 +01:00
parent d9f1025fb1
commit 2101930c88
2 changed files with 34 additions and 10 deletions

View File

@@ -1,3 +1,7 @@
function isDevMode(){
return chrome.storage.sync.get("devMode");
}
function saveChromeStorage(key, value){
var pair = new Object();
pair[key] = value;
@@ -15,14 +19,26 @@ if (document.title.indexOf("Fortnox") != -1) {
saveStatistics();
};
//TODO: Remove when finished with development
document.getElementById("button_save_and_group").onclick= function(event) {
// When clicked on save, we want to trigger the overTime calculation
saveStatistics();
};
//In dev mode, actions should be triggered y pressing on save as well
chrome.storage.sync.get("devMode", function(result){
var devMode = result["devMode"];
// Checking for possible problems
if(devMode){
console.log("currently in dev mode");
document.getElementById("button_save_and_group").onclick= function(event) {
// When clicked on save, we want to trigger the overTime calculation
saveStatistics();
};
}
else{
console.log("currently not in dev mode");
}
});
}
else{
alert("Problem with the current webpage!");
alert("Problem processing the current webpage!");
}
////////////////////////////////

View File

@@ -67,10 +67,15 @@ function sleep(millis, callback) {
function setDevMode(){
var state = document.getElementById("devMode").checked;
alert(state);
saveChromeStorage("dev", state);
saveChromeStorage("devMode", state);
}
function setCheckBoxState(){
chrome.storage.sync.get("devMode", function(result){
state = result["devMode"];
document.getElementById("devMode").checked = state;
});
}
document.addEventListener('DOMContentLoaded', function () {
@@ -79,8 +84,11 @@ document.addEventListener('DOMContentLoaded', function () {
button.onclick = alterOvertime;
// adding event to the checkbox
button = document.getElementById("devMode");
button.onclick = setDevMode;
box = document.getElementById("devMode");
box.onclick = setDevMode;
// checking the checkbox if needed
setCheckBoxState();
showOvertime();