summaryrefslogtreecommitdiff
path: root/js/index.js
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-03-15 17:42:05 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2016-08-15 19:46:43 +0200
commit92b5734a0da5a714b94d3d93e9596d1d01d220ed (patch)
tree5dfa5d7995a9ab1f42713967b2dbe9c2a6452a10 /js/index.js
parenta7313ac8956afdf31fdc921b08b85687665384ce (diff)
downloadwvs-vplan-92b5734a0da5a714b94d3d93e9596d1d01d220ed.tar.gz
wvs-vplan-92b5734a0da5a714b94d3d93e9596d1d01d220ed.zip
erweitere regex und Requests
Diffstat (limited to 'js/index.js')
-rw-r--r--js/index.js43
1 files changed, 42 insertions, 1 deletions
diff --git a/js/index.js b/js/index.js
index 5ef44b7..d78c6ea 100644
--- a/js/index.js
+++ b/js/index.js
@@ -16,14 +16,55 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+function download_pdf(link){
+ var request = $.fileDownload(link);
+
+ request.done(function(result){
+ // TODO
+ console.log('Plan heruntergeladen');
+ });
+
+ request.fail(function(jqXHR, textStatus){
+ alert("Etwas ist schiefgelaufen: " + textStatus);
+ });
+}
+
+function get_plan(link){
+ var request = $.ajax({
+ type: "GET",
+ url: link
+ });
+
+ request.done(function(result){
+ var pdf_re = new RegExp("http://***REMOVED***\\.de/moodle/pluginfile\\.php/\\d+/mod_resource/content/\\d+.*?\\.pdf");
+ var pdflink = pdf_re.exec(result)[1];
+
+ console.log('Plan gefunden: ' + pdflink);
+
+ download_pdf(pdflink);
+ });
+
+ request.fail(function(jqXHR, textStatus){
+ alert("Etwas ist schiefgelaufen: " + textStatus);
+ });
+}
+
function get_overview(link){
var request = $.ajax({
type: "GET",
url: link
});
- request.done(function(msg){
+ request.done(function(result){
+ var plans_re = new RegExp("window\\.open\\&#039;(http://***REMOVED***\\.de/moodle/mod/resource/view\\.php\\?id=\\d+)&amp;redirect=1&#039;\\)");
+ var links = plans_re.exec(result);
+
+ for(var i = 1; i < links.length; i += 2){
+ get_plan(links[i]);
+ }
+
console.log('Übersichts-Request erfolgreich');
+
location.href = '#overview';
});