1 if (typeof KOHA == "undefined" || !KOHA) {
6 * A namespace for Tags related functions.
7 * readCookie is expected to already be declared. That's why the assignment below is unscoped.
8 * readCookie should be from basket.js or undefined.
11 url: "/cgi-bin/koha/opac-tags.pl",
16 if (typeof(readCookie) == "undefined") {
17 readCookie = function (name) { // from http://www.quirksmode.org/js/cookies.html
18 var nameEQ = name + "=";
19 var ca = document.cookie.split(';');
20 for(var i=0;i < ca.length;i++) {
22 while (c.charAt(0)==' '){ c = c.substring(1,c.length); }
23 if (c.indexOf(nameEQ) == 0){ return c.substring(nameEQ.length,c.length); }
29 add_tag_button: function(){
30 var mybibnum = $(this).attr("title");
31 var mynewtag = "newtag" + mybibnum;
32 var mytagid = "#" + mynewtag;
33 var mydata = {CGISESSID: readCookie('CGISESSID')}; // Someday this should be OPACSESSID
34 mydata[mynewtag] = $(mytagid).val(); // need [bracket] for variable property id
35 var response; // AJAX from server will assign value to response.
37 "/cgi-bin/koha/opac-tags.pl",
40 // alert("AJAX Response: " + data);
42 // alert("counts: " + response["added"] + response["deleted"] + response["errors"]);
43 KOHA.Tags.set_tag_status(
45 KOHA.Tags.common_status(response["added"], response["deleted"], response["errors"])
47 if (response.alerts) {
48 alert(response.alerts.join("\n\n"));
55 common_status : function(addcount, delcount, errcount) {
57 if (addcount && addcount > 0) {cstat += "Added " + addcount + (addcount==1 ? " tag" : " tags") + ". " ;}
58 if (delcount && delcount > 0) {cstat += "Deleted " + delcount + (delcount==1 ? " tag" : " tags") + ". " ;}
59 if (errcount && errcount > 0) {cstat += (errcount==1 ? "ERROR" : errcount + " ERRORS") + " during operation.";}
62 set_tag_status : function(tagid, newstatus) {
63 $(tagid).html(newstatus);
64 $(tagid).css({display:"inline"});
68 tagsdisabled : function(arg) {return (_("Sorry, tags are not enabled on this system."));},
69 scrubbed_all_bad : function(arg) {return (_("Error! Your tag was entirely markup code. It was NOT added. Please try again with plain text."));},
70 badparam : function(arg) {return (_("Error! Illegal parameter '" +arg+ "'."));},
71 scrubbed : function(arg) {return (_("Note: your tag contained markup code that was removed. The tag was added as '" +arg+ "'."));},
72 failed_add_tag : function(arg) {return (_("Error! The add_tag operation failed on '" +arg+ "'. Note: you can only tag an item with a given term once. Check 'My Tags' to see your current tags."));},
73 failed_delete : function(arg) {return (_("Error! You cannot delete the tag '" +arg+ "'. Note: you can only delete your own tags."));}