Skip to content

Instantly share code, notes, and snippets.

@fraktik
Created August 27, 2019 07:54
Show Gist options
  • Save fraktik/36ee5fc75490b215b737eda87c0329ea to your computer and use it in GitHub Desktop.
Save fraktik/36ee5fc75490b215b737eda87c0329ea to your computer and use it in GitHub Desktop.
IntranetUserJS - jablonne navíc
/* Statistiky návštěv a internetu */
$(document).ready(function(){
var statUrl = "/cgi-bin/koha/svc/localstat";
var hideTime = 2000;
var anonymBorrower = 307;
var visitItem = 32056;
var statButtonsHtml = "<ul class='nav navbar-nav pull-right'><li><a href='' id='stat-visit'>Návštěva</a></li></ul>";
var messageHtml = "<div style='display: none; position: absolute; right: 20px; bottom: 50px; font-weight: bold; color: #00CC00;' id='stat-message'>Zaznamenáno</div>";
var errorMessageHtml = "<div style='display: none; position: absolute; right: 20px; bottom: 50px; font-weight: bold; color: #CC0000;' id='error-message'>Chyba při ukládání</div>";
$("#changelanguage .container-fluid").append(statButtonsHtml);
$("body").append(messageHtml);
var messageObj = $("#stat-message");
var errorMessageObj = $("#error-message");
function recordStat(item) {
$.getJSON(statUrl, {
borrowernumber: anonymBorrower,
itemnumber: item
}, function(data) {
if(data["status"] = 1) {
messageObj.show(0).fadeOut(hideTime);
} else {
errorMessageObj.show(0).fadeOut(hideTime);
}
}
);
}
$("#stat-visit").click(function(event) {
event.preventDefault();
recordStat(visitItem);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment