From cb57ec90fc3ae16d956b7921287b89876cf6c127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 10 Mar 2020 21:01:45 +0100 Subject: started rewriting gsec to JS --- js/gsec.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 js/gsec.js (limited to 'js') diff --git a/js/gsec.js b/js/gsec.js new file mode 100644 index 0000000..ecc156b --- /dev/null +++ b/js/gsec.js @@ -0,0 +1,40 @@ +// tab = 2 || any spaces; use tabs +const GSE_URL = "https://zgimsis.gimb.tk/gse/" +class gsec { + constructor(gseuser = null, gsepass = null) { + this.gseuser = gseuser; + this.gsepass = gsepass; + } + postback(theUrl, params, formId = null) { + return Promise( (resolve, reject) => { + $.ajax({ + crossDomain: true, + url: theUrl, + cache: false, + type: "GET", + dataType: "html", + success: (getData) => { + var parsed = document.createElement("html"); + parsed.innerHTML = getData; + if(formId == null) { + var form = parsed.getElementsByTagName("form")[0]; + } else { + var form = parsed.getElementById(formId); + } + var otherParams = $(form).serializeArray(); + var action = form.getAttribute("action"); // absolute url + $.ajax({ + crossDomain: true, + url: action, + cache: false, + type: "POST", + dataType: "text", + success: (postData) { + resolve(postData); + } + }); + } + }); + } + } +} -- cgit v1.2.3