1(function($) { 2 3 $.fn.addEntityViewModal = function(options) { 4 5 // support multiple elements 6 if (this.length > 1) { 7 this.each(function() { 8 $(this).addEntityViewModal(options); 9 }); 10 return this; 11 } 12 13 var settings = $.extend({ 14 entityResultClass : null, 15 entityResultLinkClass : null 16 }, options); 17 18 this.click(function(event) { 19 showViewModal($(this), settings.entityResultClass, 20 settings.entityResultLinkClass); 21 }); 22 }; 23 24 var refreshViewModal = function(refreshLink, entityResultClass, 25 entityResultLinkClass) { 26 27 var theURL = refreshLink.attr('data-url'); 28 var modalId = refreshLink.attr('data-modal-id'); 29 var entityName = refreshLink.attr('data-entity-name'); 30 var entityIdentifier = refreshLink.attr('data-entity-identifier'); 31 if (entityName != null ) { 32 $("#" + modalId).find(".modal-title").text( 33 messages[entityName]); 34 } 35 $.ajax({ 36 type : 'GET', 37 url : theURL, 38 success : function(html) { 39 40 var content = html; 41 var modal = $("#" + modalId); 42 modal.find(".modal-body").html(''); 43 modal.find(".modal-body").append($(content)); 44 45 46 47 modal.find(".nav-entity").addClass('disabled'); 48 modal.find(".nav-entity").unbind( "click" ); 49 if (entityResultClass) { 50 var viewLink = $('a.' + entityResultLinkClass 51 + '[data-url="' + theURL + '"]'); 52 viewLink.closest('.' + entityResultClass).next( 53 '.' + entityResultClass).find( 54 'a.' + entityResultLinkClass).each( 55 function() { 56 var nextBtn = modal.find('.next'); 57 nextBtn.attr('data-url', $(this).attr( 58 'data-url')); 59 nextBtn.attr('data-modal-id', $(this).attr( 60 'data-modal-id')); 61 nextBtn.attr('data-entity-name', $(this).attr( 62 'data-entity-name')); 63 nextBtn.attr('data-entity-identifier', $(this) 64 .attr('data-entity-identifier')); 65 nextBtn.removeClass('disabled'); 66 nextBtn.click( 67 function(event) { 68 69 refreshViewModal($(this), 70 entityResultClass, 71 entityResultLinkClass); 72 }); 73 74 }); 75 76 viewLink.closest('.' + entityResultClass).prev( 77 '.' + entityResultClass).find( 78 'a.' + entityResultLinkClass).each( 79 function() { 80 var prevBtn = modal.find('.prev'); 81 prevBtn.attr('data-url', $(this).attr( 82 'data-url')); 83 prevBtn.attr('data-modal-id', $(this).attr( 84 'data-modal-id')); 85 prevBtn.attr('data-entity-name', $(this).attr( 86 'data-entity-name')); 87 prevBtn.attr('data-entity-identifier', $(this) 88 .attr('data-entity-identifier')); 89 prevBtn.removeClass('disabled'); 90 prevBtn.click( 91 function(event) { 92 93 refreshViewModal($(this), 94 entityResultClass, 95 entityResultLinkClass); 96 }); 97 }); 98 } else { 99 modal.find(".nav-entity").hide(100); 100 } 101 102 } 103 }); 104 105 }; 106 107 var showViewModal = function(viewLink, entityResultClass, 108 entityResultLinkClass) { 109 110 var theURL = viewLink.attr('data-url'); 111 var modalId = viewLink.attr('data-modal-id'); 112 var entityName = viewLink.attr('data-entity-name'); 113 var entityIdentifier = viewLink.attr('data-entity-identifier'); 114 if (entityName != null ) { 115 $("#" + modalId).find(".modal-title").text( 116 messages[entityName] ); 117 } 118 $.ajax({ 119 type : 'GET', 120 url : theURL, 121 success : function(html) { 122 123 var content = html; 124 var modal = $("#" + modalId); 125 modal.find(".modal-body").html(''); 126 modal.find(".modal-body").append($(content)); 127 128 modal.find(".nav-entity").addClass('disabled'); 129 modal.find(".nav-entity").unbind( "click" ); 130 if (entityResultClass) { 131 var next = viewLink.closest('.' + entityResultClass).next( 132 '.' + entityResultClass).find( 133 'a.' + entityResultLinkClass).each( 134 function() { 135 var nextBtn = modal.find('.next'); 136 nextBtn.attr('data-url', $(this).attr( 137 'data-url')); 138 nextBtn.attr('data-modal-id', $(this).attr( 139 'data-modal-id')); 140 nextBtn.attr('data-entity-name', $(this).attr( 141 'data-entity-name')); 142 nextBtn.attr('data-entity-identifier', $(this) 143 .attr('data-entity-identifier')); 144 nextBtn.removeClass('disabled'); 145 146 nextBtn.click( 147 function(event) { 148 149 refreshViewModal($(this), 150 entityResultClass, 151 entityResultLinkClass); 152 });
153 }); 154 155 var prev = viewLink.closest('.' + entityResultClass).prev( 156 '.' + entityResultClass).find( 157 'a.' + entityResultLinkClass).each( 158 function() { 159 var prevBtn = modal.find('.prev'); 160 prevBtn.attr('data-url', $(this).attr( 161 'data-url')); 162 prevBtn.attr('data-modal-id', $(this).attr( 163 'data-modal-id')); 164 prevBtn.attr('data-entity-name', $(this).attr( 165 'data-entity-name')); 166 prevBtn.attr('data-entity-identifier', $(this) 167 .attr('data-entity-identifier')); 168 prevBtn.removeClass('disabled'); 169 170 prevBtn.click( 171 function(event) { 172 173 refreshViewModal($(this), 174 entityResultClass, 175 entityResultLinkClass); 176 }); 177 }); 178 } else { 179 modal.find(".nav-entity").hide(100); 180 } 181 modal.modal('show'); 182 183 184 } 185 }); 186 187 }; 188 189 190 $.fn.removeEmptyInputsFromPersonSearchForm = function() { 191 192 // support multiple elements 193 if (this.length > 1) { 194 this.each(function() { 195 $(this).addClearForm(); 196 }); 197 return this; 198 } 199 200 this.submit( 201 function() { 202 203 $("#scrollPositionX").val( 204 Math.round($(document) 205 .scrollTop())); 206 207 $('.facet-value-checked').each(function() { 208 if (!$(this).prop('checked')) { 209 210 $(this).closest('.facet-value').remove(); 211 } 212 }); 213 214 $('.search-facets input').each(function() { 215 if( !$(this).val() ) { 216 $(this).remove(); 217 } 218 }); 219 220 var thematicCollectionShortName = "${thematicCollectionShortName}"; 221 222 if (thematicCollectionShortName.length === 0) { 223 var resultsMode = $('.resultsMode:checked').val(); 224 if (resultsMode == 'LIST') { 225 $('#resultsMode-div').remove(); 226 } 227 228 $('.select-sorting-results').each(function() { 229 if ($(this).val() == 'NUMBER_OF_ITEMS_DESC') { 230 231 $(this).remove(); 232 } 233 });
234 235 $('.strictPeriods-check:not(:checked)').each( 236 function() { 237 $(this).next().remove(); 238 $(this).remove(); 239 }); 240 241 } 242 243 var faceischecked = false; 244 var set1 = new Set(); 245 $(this) 246 .find(':input') 247 .each( 248 function() { 249 var inp = $(this); 250 if (inp.attr('name') 251 && inp 252 .attr('name') 253 .startsWith( 254 "facets") 255 && inp.is(':checked')) { 256 var nameOfCheckedBox = inp 257 .attr('name'); 258 var nameOfCheckedBox = nameOfCheckedBox 259 .substr( 260 0, 261 nameOfCheckedBox 262 .lastIndexOf('.')); 263 set1.add(inp.attr('name')); 264 set1.add('_'.concat(inp 265 .attr('name'))); 266 set1.add(nameOfCheckedBox 267 .concat('.value')); 268 set1.add(nameOfCheckedBox 269 .concat('.year')); 270 set1.add(nameOfCheckedBox 271 .concat('.yearTo')); 272 set1.add(inp.attr('name')); 273 } 274 }); 275 276 $(this) 277 .find(':input') 278 .each( 279 function() { 280 var inp = $(this); 281 if (inp.attr('name') 282 && (inp 283 .attr('name') 284 .startsWith( 285 "facets") || inp 286 .attr('name') 287 .startsWith( 288 "_facets")) 289 && (!inp 290 .attr('name') 291 .endsWith( 292 ".field"))) { 293 if (!set1.has(inp 294 .attr('name'))) { 295 inp.remove(); 296 } 297 298 } 299 if (inp.attr('name') 300 && !(inp 301 .attr('name') 302 .startsWith( 303 "facets") || inp 304 .attr('name') 305 .startsWith( 306 "_facets")) 307 && (!inp.val())) { 308 inp.remove(); 309 } 310 }); 311 }); 312 313 } 314 315 $.fn.removeEmptyInputsFromEdmSearchForm = function() { 316 317 // support multiple elements 318 if (this.length > 1) { 319 this.each(function() { 320 $(this).removeEmptyInputsFromEdmSearchForm(); 321 }); 322 return this; 323 } 324 325 326 this 327 .submit( 328 function() { 329 330 $("#scrollPositionX").val( 331 Math.round($(document) 332 .scrollTop())); 333 334 $('.facet-value-checked').each(function() { 335 if (!$(this).prop('checked')) { 336 337 $(this).closest('.facet-value').remove(); 338 } 339 }); 340 341 $('.portalSearches-booleanOperator').each( 342 function() { 343 if ($(this).val() == 'OR') { 344 345 $(this).remove(); 346 } 347 }); 348 349 $('.portalSearches-keywordsBooleanOperator').each( 350 function() { 351 if ($(this).val() == 'AND') { 352 353 $(this).remove(); 354 } 355 }); 356 357 $('.portalSearches-ekt-booleanOperator').each( 358 function() { 359 if ($(this).val() == 'OR') { 360 361 $(this).remove(); 362 } 363 }); 364 365 $('.temporalSearchMode').each(function() { 366 if ($(this).val() == 'EKT_HISTORICAL_PERIOD') { 367 368 $(this).remove(); 369 } 370 }); 371 372 373 $('#select-personRelation') 374 .each( 375 function() { 376 if ($(this).val() == 'AS_REFERENCES_OR_CREATORS') { 377 378 $(this).remove(); 379 } 380 }); 381 382 $( 383 '.ekt-type-select, .ekt-subject-select, .ekt-person-select, .ekt-professionOrOccupations-select, .ekt-historical-period-select, .ekt-place-select, .providerShortName-select') 384 .each( 385 function() { 386 if ($(this).find( 387 'option:selected').length == 0) { 388 $(this).nextAll('input') 389 .first().remove(); 390 } 391 }); 392 393 $('.select-rights') 394 .each( 395 function() { 396 if ($(this).find( 397 'option:selected').length == 0) { 398 $(this).nextAll('input') 399 .first().remove(); 400 } 401 });
402 403 $('.search-facets input').each(function() { 404 if( !$(this).val() ) { 405 $(this).remove(); 406 } 407 }); 408 409 $('.search-facets') 410 .each( 411 function() { 412 413 if ($(this) 414 .find( 415 '.facet-value-checked:checked').length == 0) { 416 $(this).find( 417 '.accordion-body') 418 .remove(); 419 } 420 }); 421 422 $( 423 '.ektProfessionOrOccupationsReferences-check:checked') 424 .each(function() { 425 $(this).next().remove(); 426 $(this).remove(); 427 }); 428 429 $( 430 '.ektProfessionOrOccupationsCreators-check:checked') 431 .each(function() { 432 $(this).next().remove(); 433 $(this).remove(); 434 }); 435 436 $( 437 '.ektProfessionOrOccupationsContributors-check:checked') 438 .each(function() { 439 $(this).next().remove(); 440 $(this).remove(); 441 }); 442 443 444 445 var facetSort = $('.facet-sort:checked').val(); 446 if (facetSort == 'false') { 447 $('#facet-config-div').remove(); 448 } 449 450 var thematicCollectionShortName = "${thematicCollectionShortName}"; 451 452 if (thematicCollectionShortName.length === 0) { 453 var resultsMode = $('.resultsMode:checked').val(); 454 if (resultsMode == 'GRID') { 455 $('#resultsMode-div').remove(); 456 } 457 458 $('.select-sorting-results').each(function() { 459 if ($(this).val() == 'SCORE') { 460 461 $(this).remove(); 462 } 463 });
464 465 $('.strictPeriods-check:not(:checked)').each( 466 function() { 467 $(this).next().remove(); 468 $(this).remove(); 469 }); 470 471 } 472 473 474 $('.search-labels-input').remove(); 475 476 var faceischecked = false; 477 var set1 = new Set(); 478 $(this) 479 .find(':input') 480 .each( 481 function() { 482 var inp = $(this); 483 if (inp.attr('name') 484 && inp 485 .attr('name') 486 .startsWith( 487 "facets") 488 && inp.is(':checked')) { 489 var nameOfCheckedBox = inp 490 .attr('name'); 491 var nameOfCheckedBox = nameOfCheckedBox 492 .substr( 493 0, 494 nameOfCheckedBox 495 .lastIndexOf('.')); 496 set1.add(inp.attr('name')); 497 set1.add('_'.concat(inp 498 .attr('name'))); 499 set1.add(nameOfCheckedBox 500 .concat('.value')); 501 set1.add(nameOfCheckedBox 502 .concat('.year')); 503 set1.add(nameOfCheckedBox 504 .concat('.yearTo')); 505 set1.add(inp.attr('name')); 506 } 507 }); 508 509 $(this) 510 .find(':input') 511 .each( 512 function() { 513 var inp = $(this); 514 if (inp.attr('name') 515 && (inp 516 .attr('name') 517 .startsWith( 518 "facets") || inp 519 .attr('name') 520 .startsWith( 521 "_facets")) 522 && (!inp 523 .attr('name') 524 .endsWith( 525 ".field"))) { 526 if (!set1.has(inp 527 .attr('name'))) { 528 inp.remove(); 529 } 530 531 } 532 if (inp.attr('name') 533 && !(inp 534 .attr('name') 535 .startsWith( 536 "facets") || inp 537 .attr('name') 538 .startsWith( 539 "_facets")) 540 && (!inp.val())) { 541 inp.remove(); 542 } 543 }); 544 545 }); 546 547 } 548 549 550 $.fn.addXMLEntityViewModal = function() { 551 if (this.length > 1) { 552 this.each(function() { 553 $(this).addXMLEntityViewModal(); 554 }); 555 return this; 556 } 557 558 var $self = $(this) 559 $self 560 .click(function(event) { 561 var theURL = $self.attr('data-url'); 562 var modalId = $self.attr('data-modal-id'); 563 var entityName = $self.attr('data-entity-name'); 564 var entityIdentifier = $self.attr('data-entity-identifier'); 565 if (entityName != null && entityIdentifier != null) { 566 $("#" + modalId).find(".modal-title").text( 567 messages[entityName] + ' ' + entityIdentifier); 568 } 569 $ 570 .ajax({ 571 type : 'GET', 572 url : theURL, 573 dataType : 'xml', 574 success : function(html) { 575 576 var modal = $("#" + modalId); 577 var content = vkbeautify 578 .xml((new XMLSerializer()) 579 .serializeToString(html)) 580 modal.find(".modal-body").html(''); 581 582 modal 583 .find(".modal-body") 584 .append( 585 "<pre class=\"prettyprint lang-xml xml-content\"></pre>"); 586 587 modal.find(".modal-body").find('pre').text( 588 content); 589 // modal.modal('show'); 590 modal.modal('toggle'); 591 592 modal.find(".modal-body").css('max-height', 593 $(window).height() * 0.7); 594 prettyPrint(); 595 } 596 }); 597 }); 598 }; 599 600 601 $.fn.addJSONEntityViewModal = function() { 602 if (this.length > 1) { 603 this.each(function() { 604 $(this).addJSONEntityViewModal(); 605 }); 606 return this; 607 } 608 609 var $self = $(this) 610 $self 611 .click(function(event) { 612 var theURL = $self.attr('data-url'); 613 var modalId = $self.attr('data-modal-id'); 614 var entityName = $self.attr('data-entity-name'); 615 var entityIdentifier = $self.attr('data-entity-identifier'); 616 if (entityName != null && entityIdentifier != null) {
617 $("#" + modalId).find(".modal-title").text( 618 messages[entityName] + ' ' + entityIdentifier); 619 } 620 $ 621 .ajax({ 622 type : 'GET', 623 url : theURL, 624 dataType : 'json', 625 success : function(json) { 626 627 var modal = $("#" + modalId); 628 var content = JSON.stringify(json, undefined, 2); 629 console.log(JSON.stringify(json, undefined, 2)); 630 modal.find(".modal-body").html(''); 631 632 modal 633 .find(".modal-body") 634 .append( 635 "<div style='white-space: pre-wrap;'></div>"); 636 637 modal.find(".modal-body").find('div').text( 638 content); 639 // modal.modal('show'); 640 modal.modal('toggle'); 641 642 modal.find(".modal-body").css('max-height', 643 $(window).height() * 0.7); 644 645 } 646 }); 647 }); 648 }; 649})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.