Is there a more efficient way of writing this? It seems like so much redundancy that this can be greatly reduced. Basically the only difference is if isNodeWebkit
is true then run a function using key code 113
or 112
if (isNodeWebkit) {
$(document).keyup(function (e) {
if (e.which == 113) {
$.ajax({
type: "POST",
url: "/submit/role/",
data: {},
dataType: "json",
success: function (admin) {
if (admin == true) {
window.location = urllink;
}
}
});
};
});
}
else {
$(document).keyup(function (e) {
if (e.which == 112) {
$.ajax({
type: "POST",
url: "/submit/role/",
data: {},
dataType: "json",
success: function (admin) {
if (admin == true) {
window.location = urllink;
}
}
});
};
});
};