Skip to content

Commit

Permalink
Merge pull request #48 from Benjadahl/development
Browse files Browse the repository at this point in the history
A bunch of bugfixes
  • Loading branch information
jbjjbjjbj authored Apr 19, 2017
2 parents 4f17026 + 9110b6a commit 7331d36
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 41 deletions.
6 changes: 3 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ chrome.runtime.onMessage.addListener(function(message,sender,sendResponse){
} else if(message.action == "deleteFilesystem"){
//Clear out storage here
debugLog("Got del message");

var dirReader = fs.root.createReader();

// Call the reader.readEntries() until no more results are returned.
Expand All @@ -154,7 +154,7 @@ chrome.runtime.onMessage.addListener(function(message,sender,sendResponse){
}, errorHandler);
}
readEntries();

}
}, errorHandler);
};
Expand Down Expand Up @@ -206,7 +206,7 @@ var weekDays = {
};

function doNothing(input) {
console.log("Doing nothing succeded");
debugLog("Doing nothing succeded");
}

function cacheYearSchedule() {
Expand Down
4 changes: 2 additions & 2 deletions dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ <h1 class="text-center">UD++ Dashboard</h1>
<div style="margin: 5px">
<h2 id='searchHeader'>Lesson files</h2>
<p id='disclaimer'>Please note that this is only the files from lessons that are cached. More files will automatically be added then you open a lesson note in uddataplus. Click to hide this message.</p>
<input type='checkbox' name='autofetch' id='autofetchbox'>
<label for='autofetch' id='autofetchtext'>Automatically fetch lesson files</label>
<input type='checkbox' name='autofetchbox' id='autofetchbox'>
<label for='autofetchbox' id='autofetchtext'>Automatically fetch lesson files</label>
<input type="text" class="form-control" id='searchBox' placeholder="If you can't read this, blame a teacher">
<ul style="height: 80%; overflow: auto;" class="list-group" id='searchResults'>
<li class="list-group-item">Loading...</li>
Expand Down
26 changes: 16 additions & 10 deletions dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,29 @@ var homeworkNoteRegex = new RegExp(/(\n|\W|quot|\d|amp)/g);

var hideNotHomework = false;

//Whetever we want to fetch files automatically
var fetchFilesAutomatically = false;
getStorage('autoFetchFiles', function(obj) {
if (!chrome.runtime.error && obj.autoFetchFiles == true) {
fetchFilesAutomatically = obj.autoFetchFiles;
$("#autofetchbox").prop('checked', fetchFilesAutomatically);
}
});

function setAutoFetch() {
var checked = $("#autofetchbox").is(":checked");
setStorage({'autoFetchFiles': checked});
if (checked) setStorage({'cacheFiles': true});
setStorage({'cacheFiles': checked});
fetchFilesAutomatically = checked;
rerenderEvents();
}

function loadOptions() {

//Whetever we want to fetch files automatically
getStorage('cacheFiles', function(obj) {
if (!chrome.runtime.error && obj.cacheFiles == true) {
fetchFilesAutomatically = obj.cacheFiles;
$("#autofetchbox").prop('checked', fetchFilesAutomatically);
}
});

}

loadOptions();
chrome.storage.onChanged.addListener(loadOptions);

$("#autofetchbox").on("click", setAutoFetch);


Expand Down
8 changes: 6 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ function loadSettings() {

getStorage('theme', function (obj) {
if (!chrome.runtime.error) {
curtheme = obj.theme;
console.log("loaded curtheme");
if (typeof obj.theme !== 'undefined') {
curtheme = obj.theme;
} else {
curtheme = 'default';
}
debugLog("loaded curtheme");
runTheme(curtheme, curPage);
}
});
Expand Down
48 changes: 30 additions & 18 deletions options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ getStorage("TooEarly", function (obj) {
}
});

getStorage("cacheFiles", function (obj) {
if (!chrome.runtime.error) {
if (typeof obj.cacheFiles !== 'undefined')
$('#cacheFiles').prop("checked", obj.cacheFiles);
}
});
function getOptions() {
getStorage("cacheFiles", function (obj) {
if (!chrome.runtime.error) {
if (typeof obj.cacheFiles !== 'undefined')
$('#cacheFiles').prop("checked", obj.cacheFiles);
}
});
}
getOptions();


getStorage({homeworkWords: "lektie,forbered"}, function (obj) {
Expand Down Expand Up @@ -167,6 +170,10 @@ $('#hideTask').change(function() {
setStorage({'hideTask' : $('#hideTask').prop("checked")});
});

getStorage('hideSidebarCollapse', function(obj) {
if (obj.hideSidebarCollapse) $("#hideSidebarCollapse").prop('checked', true);
})

$('#hideSidebarCollapse').change(function() {
hideTask = !hideTask;
setStorage({'hideSidebarCollapse' : $('#hideSidebarCollapse').prop("checked")});
Expand All @@ -177,21 +184,21 @@ $('#hideSidebarCollapse').change(function() {

//Make i more human friendly. Found here http://stackoverflow.com/questions/35623493/how-to-convert-kilobytes-to-megabytes-in-javascript
function formatSizeUnits(bytes){
if (bytes>=1073741824) {bytes=(bytes/1073741824).toFixed(2)+' GiB';}
else if (bytes>=1048576) {bytes=(bytes/1048576).toFixed(2)+' MiB';}
else if (bytes>=1024) {bytes=(bytes/1024).toFixed(2)+' KiB';}
else if (bytes>1) {bytes=bytes+' bytes';}
else if (bytes==1) {bytes=bytes+' byte';}
else {bytes='0 bytes';}
return bytes;
if (bytes>=1073741824) {bytes=(bytes/1073741824).toFixed(2)+' GiB';}
else if (bytes>=1048576) {bytes=(bytes/1048576).toFixed(2)+' MiB';}
else if (bytes>=1024) {bytes=(bytes/1024).toFixed(2)+' KiB';}
else if (bytes>1) {bytes=bytes+' bytes';}
else if (bytes==1) {bytes=bytes+' byte';}
else {bytes='0 bytes';}
return bytes;
}

navigator.webkitPersistentStorage.queryUsageAndQuota (
function(usedBytes, grantedBytes) {
$("#usedStorage").text(formatSizeUnits(usedBytes));
function(usedBytes, grantedBytes) {
$("#usedStorage").text(formatSizeUnits(usedBytes));
$("#availableStorage").text(formatSizeUnits(grantedBytes));
},
function(e) { console.log('Error', e); }
},
function(e) { console.log('Error', e); }
);

function setDevVisible(vis) {
Expand Down Expand Up @@ -232,4 +239,9 @@ $("#openUnitTest").attr("href", chrome.runtime.getURL('jasmine/SpecRunner.html')

$("#del").click(function() {
chrome.runtime.sendMessage({action: "deleteFilesystem"});
});
location.reload();
});

chrome.storage.onChanged.addListener(function () {
loadOptions();
});
7 changes: 7 additions & 0 deletions themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ var themes = {
"assignmentSetting" : "#B0053C",
//License site: http://www.uhdwallpapers.org/2014/09/summer-2014-grand-canyon.html?m=1
"mainBackImg" : "https://4.bp.blogspot.com/-Y63PB8ns7G0/VCTwQuLhZfI/AAAAAAABOmA/2ULXhjuWGMY/s0/Summer%2B2014%2BGrand%2BCanyon.jpg",
"bodyBGAttachment": "fixed",
"bodyBGPos": "center",
"bodyBGRepeat": "no-repeat",
"bogyBGSize" : "cover",
"bottomBorder": "none",
"rightBorder": "none",
"leftBorder": "none",
"homeworkMark" : "#FFB406",
"lessonStroke" : "#89042F",
"lessonOpacity" : "0.5",
Expand Down
4 changes: 2 additions & 2 deletions theming/objectDefine.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function applyCssRule(ppobject, flags) {
}
}

function applyBorderRule(flags){
function applyBorderRule(ppobject, flags) {
if(typeof flags.pixels === "undefined") flags.pixels = 1;
if(typeof flags.important === "undefined") flags.important = true;
var cssEnd = "";
Expand All @@ -43,7 +43,7 @@ function applyBorderRule(flags){



function applyImgRule(flags){
function applyImgRule(ppobject, flags){

//Adding important option
if(typeof flags.important === "undefined") flags.important = true;
Expand Down
12 changes: 10 additions & 2 deletions theming/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var PlusPlusList = {
linkLanguage:new PlusPlusObject("#language>a", applyCssRule, ["color"]),
studentInfo:new PlusPlusObject(".page-header h1 small", applyCssRule, ["color"]), //The name studentInfo refers to the schedule page, however this applies to all pages
outerBackground:new PlusPlusObject("#wrapper", applyCssRule, ["background-color"]),
wrapContent:new PlusPlusObject("#wrapcontent", applyCssRule, ["background-color"]),
schoolEdges:new PlusPlusObject(".ace-nav>li", applyBorderRule, ["border-left"]),
tableBackground:new PlusPlusObject("tr td", applyCssRule, ["background"]),
copyrightTop:new PlusPlusObject(".copyright", applyBorderRule, ["border-top"]),
Expand All @@ -40,12 +41,19 @@ var PlusPlusList = {
tableButtonsText:new PlusPlusObject(".btn", applyCssRule, ["color"]),
navbarText:new PlusPlusObject(".navbar .nav>li>a, .navbar .nav>li>a:hover, .navbar .nav>li>a:focus", applyCssRule, ["color"]),
copyRightNotice:new PlusPlusObject(".copyright>a", applyCssRule, ["color"]),
mainBackImg:new PlusPlusObject(".container-fluid", applyImgRule, ["background-image"], flags={backImg: true, elements : ["sidebarColor", "navbarIcon", "mainBackground", "mainContainer", "copyrightTop", "leftMenuLIborderBottom", "leftMenuBorder","tableBackground", "leftMenuBottom", "assignmentSetting", "tableBottom"]}),
mainBackImg:new PlusPlusObject("body", applyImgRule, ["background-image"], flags={backImg: true, elements : ["sidebarColor", "navbarIcon", "mainBackground", "mainContainer", "copyrightTop", "leftMenuLIborderBottom", "leftMenuBorder","tableBackground", "leftMenuBottom", "assignmentSetting", "tableBottom", "outerBackground", "wrapContent"]}),
mainBackImgFill:new PlusPlusObject(".container-fluid", applyCssRule, ["background-size"]),
bodyBGAttachment:new PlusPlusObject("body", applyCssRule, ["background-attachment"]),
bodyBGPos:new PlusPlusObject("body", applyCssRule, ["background-position"]),
bodyBGRepeat:new PlusPlusObject("body", applyCssRule, ["background-repeat"]),
bodyBGSize:new PlusPlusObject("body", applyCssRule, ["background-size"]),
mainBackImgNoRepeat:new PlusPlusObject(".container-fluid", applyCssRule, ["background-repeat"]),
sideBarCollpaseIcon:new PlusPlusObject('.sidebar-collapse>[class*="icon-"]', applyCssRule, ["background-color"]),
messageCounter:new PlusPlusObject('.badge', applyCssRule, ["background-color"]),
warning:new PlusPlusObject(".warning", applyCssRule, ["color"])
warning:new PlusPlusObject(".warning", applyCssRule, ["color"]),
leftBorder:new PlusPlusObject('#wrapper', applyCssRule, ["border-left"]),
rightBorder:new PlusPlusObject('#wrapper', applyCssRule, ["border-right"]),
bottomBorder:new PlusPlusObject('.sidebar-collapse', applyCssRule, ["border-bottom"])
},
start:{},
schedule:{
Expand Down
4 changes: 2 additions & 2 deletions theming/runTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

//Changes color off each element in the current theme
function runTheme(theme, page){
console.log("Loading theme: " + theme + "on page " + page);
debugLog("Loading theme: " + theme + "on page " + page);
$('.UDPPCustom').remove();
if(typeof themes[theme] != "undefined") {
for (var T in themes[theme]) {

applySelector(T, themes[theme][T], page);


}
} else {
Expand Down

0 comments on commit 7331d36

Please sign in to comment.