101 lines
2.9 KiB
JavaScript
101 lines
2.9 KiB
JavaScript
function initializeMainMenu(menuid) {
|
|
$.ajax({ type: "GET",
|
|
dataType: "json",
|
|
url: "php/contenthandler.php?module=admin&command=getJsonMenuItemsAndVersion",
|
|
async: false,
|
|
success : function(moduleEntries)
|
|
{
|
|
$("#loggedinuser").html(moduleEntries.user);
|
|
$("#versioninfo").html("v" + moduleEntries.version);
|
|
var li='<li data-role="list-divider" data-theme="b" data-role="heading">Module</li>';
|
|
$.each(moduleEntries.menu, function (i, module) {
|
|
var name = module.name;
|
|
var link = module.link;
|
|
if (name != "Abmelden") {
|
|
li += '<li data-theme="e"><a href="' + link + '" target="_top" class="modulebutton">' + name + '</a></li>';
|
|
} else {
|
|
li += '<li data-theme="e"><a href="' + link + '" target="_top">' + name + '</a></li>';
|
|
}
|
|
});
|
|
$(menuid).empty().append(li).promise().done(function () {
|
|
$(menuid).listview("refresh");
|
|
})
|
|
},
|
|
error: function( text ) {
|
|
alert( "Kommunikationsproblem zum Server bei Modulabfrage!" );
|
|
}
|
|
});
|
|
|
|
$(".modulebutton").off("click").on("click", function (e) {
|
|
var view = $(this).attr("href");
|
|
doAjax("POST","php/contenthandler.php?module=admin&command=setLastModuleOfUser",
|
|
{ view: view}, null, "Problem Benutzerdatenpflege");
|
|
});
|
|
}
|
|
|
|
function hideMenu() {
|
|
$( "#modulepanel" ).panel( "close" );
|
|
$("#menuswitch").off("click").on("click", function (e) {
|
|
$("#menuswitch").trigger("mouseout");
|
|
e.stopImmediatePropagation();
|
|
e.preventDefault();
|
|
$( "#modulepanel" ).panel( "open" );;
|
|
});
|
|
}
|
|
|
|
// to make IE happy...
|
|
function refreshList(selector) {
|
|
if ( $(selector).hasClass('ui-listview')) {
|
|
$(selector).listview('refresh');
|
|
} else {
|
|
$(selector).trigger('create');
|
|
}
|
|
}
|
|
|
|
function doAjax(getOrPost,url,data,functionToCallIfSuccess,errorMsg) {
|
|
$.ajax({ type: getOrPost,
|
|
url: url,
|
|
dataType: "json",
|
|
data: data,
|
|
async: false,
|
|
success : function(jsonContent)
|
|
{
|
|
if (functionToCallIfSuccess != null) {
|
|
functionToCallIfSuccess(jsonContent);
|
|
}
|
|
},
|
|
error: function( text ) {
|
|
if (errorMsg != null) {
|
|
alert( "Kommunikationsfehler zum Server: " + errorMsg);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function doAjaxSuppressError(getOrPost,url,data,functionToCallIfSuccess,errorMsg) {
|
|
$.ajax({ type: getOrPost,
|
|
url: url,
|
|
dataType: "json",
|
|
data: data,
|
|
async: false,
|
|
success : function(jsonContent)
|
|
{
|
|
if (functionToCallIfSuccess != null) {
|
|
functionToCallIfSuccess(jsonContent);
|
|
}
|
|
},
|
|
error: function( text ) {
|
|
functionToCallIfSuccess("ERROR");
|
|
}
|
|
});
|
|
}
|
|
function doAjaxNonJsonNonCall(getOrPost,url,data) {
|
|
$.ajax({ type: getOrPost,
|
|
data : data,
|
|
url: url,
|
|
async: false,
|
|
error: function( text ) {
|
|
alert( "Kommunikationsproblem zum Server" );
|
|
}
|
|
});
|
|
} |