Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
function replaceDots(id) {
return id.replace(/./g,'\\.');
}
//Called from anywhere where needs name lookup
//title is not used in search
function showMintNlaLookupDialog(e, lookup_source) {
var input_sibs = $(e).parent().find('input');
var ids = new Array();
for (i = 0; i < input_sibs.length; i++) {
if (input_sibs[i].type == 'text' || input_sibs[i].type == 'hidden') {
ids.push(input_sibs[i].id);
}
}
NameLookUp(ids, lookup_source.split(','))
}
function NameLookUp(ids, lookup_source) {
var queryTerm = document.getElementById(ids[1]).value;
for (var i = 2; i< ids.length-1; i++) { // skip the last hidden field: dcIdentifier
queryTerm += " " + document.getElementById(ids[i]).value;
}
queryTerm = queryTerm.trim();
var mintUrl = $(".nameLookup-url").val();
var nlaUrl = $(".nlaLookup-url").val();
var loaderGif = $("").html();
var mintDiv = $("");
var nlaDiv = $("
Searching National Library. Please wait... "+loaderGif+"
").dialog({
title: "Name lookup",
height: 450,
maxHeight: 600,
width: 450,
modal: true,
resizable: true,
position: "center",
draggable: true,
autoOpen: false
});
detailDialog = $("").dialog({
title: "Detail information",
height: "auto",
width: 400,
modal: true,
resizable: true,
position: "center",
draggable: true,
autoOpen: false
});
dlgMint.dialog("option", "buttons", {
"OK": function() {
var value = mintDiv.find("input[name=name]:checked").val();
if (value == null || value == "") {
value = nlaDiv.find("input[name=name]:checked").val();
}
dlgMint.dialog("close");
detailDialog.dialog("close");
if (value) {
btn_callback(true, JSON.parse(value));
} else {
btn_callback(false);
}
},
"Cancel": function() {
dlgMint.dialog("close");
detailDialog.dialog("close");
btn_callback(false);
}
});
var myTable; // For mint results
var nlaFirstname, nlaSurname
var nlaResultsDiv = $("");
search_show();
function getJson(queryUrl, timeoutSec, callback) {
$.ajax({
url: queryUrl,
dataType: "json",
timeout: timeoutSec * 1000,
success: callback,
error: function(x, s, e) {
callback({
error: s
});
}
});
}
// ids[0]: title; ids[1]: firstName; ids[2]: surName; ids[3]: mintId
function btn_callback(ok, result) {
if (ok) {
var selectedFunc = 'lookupDone';
try {
var nlaId = result["nlaId"];
if (nlaId != null) {
document.getElementById(ids[0]).value = "";
$(document.getElementById(ids[0])).change();
document.getElementById(ids[1]).value = result["firstName"];
$(document.getElementById(ids[1])).change();
document.getElementById(ids[2]).value = result["surname"];
$(document.getElementById(ids[2])).change();
// Mint Identity
} else {
// Mint Only
var lookupData=result["result-metadata"].all;
document.getElementById(ids[0]).value = lookupData["Honorific"];
$(document.getElementById(ids[0])).change();
document.getElementById(ids[1]).value = lookupData["Given_Name"];
$(document.getElementById(ids[1])).change();
document.getElementById(ids[2]).value = lookupData["Family_Name"];
$(document.getElementById(ids[2])).change();
document.getElementById(ids[3]).value = lookupData["dc_identifier"];
$(document.getElementById(ids[3])).change();
}
} catch(e) {
alert("Error executing selected-func. " + e.message);
}
}
};
function makeWnd(queryTerm) {
// tab view
// tabbedDiv.append(mintDiv);
// tabbedDiv.append(nlaDiv);
//
// dlgMint.html(tabbedDiv);
// tabbedDiv.tabs();
if(lookup_source.length == 1) {
if (lookup_source.indexOf('mint') != -1) {
dlgMint.html(mintDiv);
} else {
dlgMint.html(nlaDiv);
}
} else {
tabbedDiv.append(mintDiv);
tabbedDiv.append(nlaDiv);
dlgMint.html(tabbedDiv);
tabbedDiv.tabs();
}
var tbody, tr, td, label, id;
mintDiv.html("");
if (queryTerm) mintDiv.text("Search result for '" + queryTerm + "'");
var i, s;
mintDiv.append(" ");
i = $("");
i.val(queryTerm);
mintDiv.append(i);
s = $("");
mintDiv.append(s);
i.keypress(function(e) {
if (e.which == 13) s.click();
});
s.click(function() {
queryTerm = $.trim(i.val());
if (queryTerm) {
getJson(constructQueryUrl(queryTerm), 6, function(jdata) {
if (jdata.error) {
alert(jdata.error);
} else {
json = jdata;
updateTable(json);
setTimeout(function() {
try {
i.focus();
} catch(e) {
// IE7?
}
}, 10);
}
});
}
});
mintDiv.append("");
mintDiv.append(myTable = $("
"));
myTable.html($("
No results
"));
}
function updateTable(searchResults) {
var tr;
myTable.html("");
$.each(searchResults.results, function(c, result) {
var r, a, name;
id = "rId" + c;
tr = $("
").append(td = $("
"));
r = $("").attr("id", id);
r.val(JSON.stringify(result));
label = $("").attr("for", id);
name = result["rdfs:label"] || result["foaf:name"];
label.append(name);
if (result["dc:description"]) {
label.append(" - " + result["dc:description"]);
}
//
td.append(r);
td.append(label);
//
tr.append(td=$("
"));
a = $("details");
td.append(a);
myTable.append(tr);
label.dblclick(function() {
dlgMint.dialog("option", "buttons").OK();
});
a.click(function(e) {
var pos = dlgMint.parent().position();
pos.left += 10;
pos.top += 20;
displayDetails(name, result, pos, r);
return false;
});
});
}
function displayNLA(data) {
// National Library Integration
$(".nameLookup-waiting").hide();
$(".nlaLookup-progress").hide();
var searchMetadata = data.metadata;
var pageStart = searchMetadata.startRecord-0;
var pageRows = searchMetadata.rowsReturned-0;
var pageTotal = searchMetadata.totalHits-0;
var pageLast = (pageStart+pageRows-1);
if (pageTotal == 0) {
pageStart = 0;
}
// Construct Search Form
var nlaTbody, nlaTrow, nlaTcell;
nlaResultsDiv.append($("
"));
nlaTcell.append(nlaSurnameInput);
nlaFirstnameInput.keypress(function(e) {
if (e.which == 13) nlaSearch.click();
});
nlaSurnameInput.keypress(function(e) {
if (e.which == 13) nlaSearch.click();
});
var nlaSearch = $("");
nlaSearch.click(function() {
pagedNlaSearch(1, 10);
});
nlaResultsDiv.append(nlaSearch);
nlaResultsDiv.append("");
nlaResultsDiv.append($("
Showing "+pageStart+"-"+pageLast+" records of "+pageTotal+" total.
"));
// Pagination
var hasPrev = pageStart > 1;
var hasNext = pageLast < pageTotal;
var nlaPagination;
if (hasPrev || hasNext) {
nlaResultsDiv.append(nlaPagination = $(""));
}
if (pageStart > 1) {
var prevLink = $("« prev ("+pageRows+")");
nlaPagination.append(prevLink);
if (hasNext) {
nlaPagination.append(" | ");
}
prevLink.click(function() {
var newStart = pageStart - pageRows;
if (newStart < 1) {
newStart = 1;
}
pagedNlaSearch(newStart, pageRows);
});
}
if (pageLast < pageTotal) {
var nextLink = $("next ("+pageRows+") »");
nlaPagination.append(nextLink);
nextLink.click(function() {
pagedNlaSearch(pageLast+1, pageRows);
});
}
nlaResultsDiv.append("");
nlaResultsDiv.append($("
").append(tbody = $("")));
$.each(data.results, function(c, result) {
var radio, detailLink, name;
// Radio input for each row
id = "rId" + c;
tr = $("
").append(td = $("
"));
radio = $("").attr("id", id);
radio.val(JSON.stringify(result));
label = $("").attr("for", id);
name = result["displayName"];
label.append(name);
if (result["institution"]) {
label.append(" - " + result["institution"]);
}
td.append(radio);
td.append(label);
// Show more details
tr.append(td=$("