check session in lib/ajax if we're going to do more than just reading the newsfeed

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-02-19 13:58:12 +01:00
parent 90d2333eef
commit d5e53cc7db
2 changed files with 74 additions and 6 deletions

View File

@@ -4,6 +4,17 @@ import 'bootstrap';
// load jquery
window.$ = window.jQuery = require('jquery');
function getUrlVars() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
$(document).ready(function () {
const mytheme = 'Froxlor';
@@ -15,14 +26,15 @@ $(document).ready(function () {
if (typeof $("#newsfeed").data("role") !== "undefined") {
role = "&role=" + $("#newsfeed").data("role");
}
var s = getUrlVars()["s"];
$.ajax({
url : "lib/ajax.php?action=newsfeed" + role + "&theme=" + mytheme,
type : "GET",
success : function(data) {
url: "lib/ajax.php?action=newsfeed" + role + "&theme=" + mytheme + "&s=" + s,
type: "GET",
success: function (data) {
$("#newsfeeditems").html(data);
},
error : function(a, b) {
error: function (a, b) {
$("#newsfeeditems").html('<div class="alert alert-warning" role="alert">Error loading newsfeed</div>');
}
});