From 1c14654c8e7d9c4af6dfe23ea1a79cd02d27a4e1 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 19 Nov 2008 14:58:11 +0100 Subject: [PATCH] Using openAuth function for authorities Searching Adding two js functions : getSubfieldcode(tagsubfieldid) returns the subfieldcode from tagsubfieldid (tag_XXX_subfield_Y_WWWW_TTTT returns Y) getTagInputnameFilter(tagsubfieldid) (tag_XXX_subfield_Y_WWWW_TTTT returns tag_XXX_subfield_._WWWW) I think those two functions are much useful when cataloguing. openAuth now takes all the information for Heading search of authorities. TODO A javascript DOM Navigation would be better. This js works, but is surely slower than DOM would be. Still, it seems that our DOM tree is quite hard to decode. Signed-off-by: Galen Charlton --- cataloguing/addbiblio.pl | 5 +-- .../en/modules/cataloguing/addbiblio.tmpl | 40 ++++++++++++++++--- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index f218ca1629..32ca3577bd 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -395,9 +395,8 @@ sub create_input { size=\"67\" maxlength=\"$max_length\" readonly=\"readonly\" - \/> - {$tag}->{$subfield}->{authtypecode}."&index=$subfield_data{id}','$subfield_data{id}'); return false;\" title=\"Tag Editor\">... + \/>{$tag}->{$subfield}->{authtypecode}."'); return false;\" title=\"Tag Editor\">... "; } # it's a plugin field diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl index 131c4e2318..2356132a5e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl @@ -138,12 +138,40 @@ function Changefwk(FwkList) { } -function openAuth(tagid,authtype,X) { -// defaultid=document.getElementById(subfieldid); -// alert("X"+X); - Y=X.parentNode.getAttribute("id"); -// alert("tagid"+Y); - newin=window.open("../authorities/auth_finder.pl?authtypecode="+ authtype+ "&tagid="+Y, "value builder",'width=700,height=550,toolbar=false,scrollbars=yes'); +// returns the subfieldcode based upon subfieldid writing +function getSubfieldcode(tagsubfieldid){ + // 3 : tag +3 : tagnumber +4 : number of _ +8 subfield -1 begins at 0 + return tagsubfieldid.substr(3+3+4+8-1,1); +} + +// Take the base of tagsubfield information (removing the subfieldcodes and subfieldindexes) +// returns the filter +function getTagInputnameFilter(tagsubfieldid){ + var tagsubfield=tagsubfieldid.substr(0,tagsubfieldid.lastIndexOf("_")); + var tagcode=tagsubfield.substr(tagsubfield.lastIndexOf("_")); + tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_")); + tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_")); + tagsubfield=tagsubfield+"_."+tagcode; + return tagsubfield; +} + +function openAuth(tagsubfieldid,authtype) { + // let's take the base of tagsubfield information (removing the indexes and the codes + var element=document.getElementById(tagsubfieldid); + var tagsubfield=getTagInputnameFilter(tagsubfieldid); + var elementsubfcode=getSubfieldcode(element.name); + var mainmainstring=element.value; + var mainstring=""; + var inputs = document.getElementsByTagName("input"); + for (var myindex =0; myindex