diff --git a/base.js b/base.js
index df30da1..041e14e 100644
--- a/base.js
+++ b/base.js
@@ -1,3 +1,4 @@
+$(function(){
function enableStudentPhotos() {
var rows = $('table.wrnav tr td a.wrgrey');
var personRegexp = new RegExp("pokazOsobe\\(os_id:([0-9]*)\\)");
@@ -23,4 +24,5 @@ function enableStudentPhotos() {
}
}
-enableStudentPhotos();
\ No newline at end of file
+enableStudentPhotos();
+});
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 9d97dcd..822b8e3 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,15 +1,15 @@
{
"content_scripts": [
{
- "js": [ "jquery.min.js", "base.js", "mimuw.js" ],
+ "js": [ "jquery.min.js", "base.js", "mimuw.js", "tests.js" ],
"matches": [ "https://usosweb.mimuw.edu.pl/*" ]
},
{
- "js": [ "jquery.min.js", "base.js" ],
+ "js": [ "jquery.min.js", "base.js", "tests.js" ],
"matches": [ "https://usosweb.wne.uw.edu.pl/*" ]
}
],
"description": "Dodatek modyfikujący działanie usosweba.",
"name": "USOSweb ++",
-"version": "0.1.2"
+"version": "0.2.3"
}
diff --git a/mimuw.js b/mimuw.js
index 53dc93c..adb356f 100644
--- a/mimuw.js
+++ b/mimuw.js
@@ -1,13 +1,16 @@
-function enableWikispaces() {
- var h2 = $('h2')
- if(h2) {
- if(h2[0].innerHTML == 'Informacje o pracowniku') {
- var h1 = $('h1')[0];
- var name = h1.childNodes[2].nodeValue.split(' ');
- var url = 'http://mimuw.wikispaces.com/' + name[2] + ', ' + name[0];
- $(h2[0].parentNode).append('
Przejdź do wikispaces');
+$(function(){
+ function enableWikispaces() {
+ var h2 = $('h2')
+ if(h2) {
+ if(h2[0].innerHTML == 'Informacje o pracowniku') {
+ var h1 = $('h1')[0];
+ var name = h1.childNodes[2].nodeValue.split(' ');
+ var url = 'http://mimuw.wikispaces.com/' + name[2] + ', ' + name[0];
+ $(h2[0].parentNode).append('
Przejdź do wikispaces');
+ }
}
}
-}
-enableWikispaces();
\ No newline at end of file
+
+ enableWikispaces();
+});
\ No newline at end of file
diff --git a/tests.js b/tests.js
new file mode 100644
index 0000000..9619a2a
--- /dev/null
+++ b/tests.js
@@ -0,0 +1,67 @@
+$(function(){
+ /*
+ Podglad punktow ze sprawdzianow na glownej (Moim Usoswebie)
+ W localstorage zapisuje poprzednio sprawdzona sume, jezeli sie rozni
+ to wyswietla roznice
+
+ By pyetras
+ */
+ function lookupTests(){
+ var url_exp = "kontroler.php?_action=actionx:dla_stud/studia/sprawdziany/pokaz(wez_id:"
+ var alrdy_checked = [];
+ $('a[href]').each(function(i){
+ if ($(this).attr("href").indexOf(url_exp) == -1) return;
+ var url = $(this).attr('href');
+ if (alrdy_checked[url]){
+ return;
+ }else{
+ alrdy_checked[url] = true;
+ }
+
+ var link = this;
+ $.get(url, function(data){
+ var re = /wez_id:(\d+)/;
+ var id = re.exec(url)[1];
+ var wynik = 0.0;
+ var nullCount = 0;
+
+ var rec_find = function(table){
+ $(table).each(function(i){
+ if ($($(this).find('td')[1]).text().search('ocena') != -1)
+ return;
+
+ var pkt_txt = $($(this).find('td')[2]).text();
+ pkt = parseFloat(pkt_txt.replace('pkt', ''));
+ if (!isNaN(pkt)){
+ wynik += pkt;
+ }else{
+ nullCount++;
+ //nie ma punktu, sprawdzam poddrzewo
+ rec_find($(this).next('div[id^=childrenof]').children('table'));
+ }
+ });
+ }
+
+ rec_find($('div#childrenof'+id+' > table', data));
+ $(link).after(' ' + wynik + ' pkt ');
+ var data;
+
+ if (!(data = localStorage[id])){
+ data = [0, 0];
+ }else{
+ data = JSON.parse(data);
+ data = [parseFloat(data[0]), parseInt([data[1]])];
+ }
+ if (data[0] != wynik || data[1] != nullCount){
+ var dif = wynik - data[0];
+ $(link).next().append(' (' + ((dif >= 0)?'+':'') + dif +')');
+ $(link).next().css('font-weight', 'bold');
+ localStorage[id] = JSON.stringify([wynik, nullCount]);
+ }
+
+ });
+ });
+ }
+
+ lookupTests();
+})
\ No newline at end of file