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 <galen.charlton@liblime.com>
This commit is contained in:
parent
aea15bca2a
commit
1c14654c8e
2 changed files with 36 additions and 9 deletions
|
@ -395,9 +395,8 @@ sub create_input {
|
|||
size=\"67\"
|
||||
maxlength=\"$max_length\"
|
||||
readonly=\"readonly\"
|
||||
\/>
|
||||
<a href=\"#\" class=\"buttonDot\"
|
||||
onclick=\"Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$subfield_data{id}','$subfield_data{id}'); return false;\" title=\"Tag Editor\">...</a>
|
||||
\/><a href=\"#\" class=\"buttonDot\"
|
||||
onclick=\"openAuth('".$subfield_data{id}."','".$tagslib->{$tag}->{$subfield}->{authtypecode}."'); return false;\" title=\"Tag Editor\">...</a>
|
||||
";
|
||||
}
|
||||
# it's a plugin field
|
||||
|
|
|
@ -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<inputs.length;myindex++){
|
||||
if (inputs[myindex].name && inputs[myindex].name.match(tagsubfield)){
|
||||
var subfieldcode=getSubfieldcode(inputs[myindex].name);
|
||||
if (isNaN(parseInt(subfieldcode)) && inputs[myindex].value != "" && subfieldcode!=elementsubfcode){
|
||||
mainstring=inputs[myindex].value+" "+mainstring;
|
||||
}
|
||||
}
|
||||
}
|
||||
newin=window.open("../authorities/auth_finder.pl?authtypecode="+ authtype+ "&index="+tagsubfieldid+"&mainmainstring="+encodeURI(mainmainstring)+"&mainstring="+encodeURI(mainstring), "value builder",'width=700,height=550,toolbar=false,scrollbars=yes');
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue