A search interface for the Performing Patents Otherwise publication as part of the Politics of Patents case study (part of Copim WP6): this parses data from the archive of RTF files and provides additional data from the European Patent Office OPS API. https://patents.copim.ac.uk
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4KB

  1. /*
  2. # @name: main.js
  3. # @creation_date: 2022-09-07
  4. # @license: The MIT License <https://opensource.org/licenses/MIT>
  5. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  6. # @author: Joana Chicau
  7. # @purpose: JavaScript functions for various functions
  8. # @acknowledgements:
  9. */
  10. function hideShowInfo(){
  11. var iDiv = document.querySelectorAll('.info'), i;
  12. for (i = 0; i < iDiv.length; ++i) {
  13. if ( iDiv[i].style.display == 'none') {
  14. iDiv[i].style.display = 'initial'; }
  15. else { iDiv[i].style.display = 'none'; }
  16. }
  17. }
  18. function refresh(){
  19. window.location.reload("Refresh")
  20. }
  21. function highlightSearchTerms(search){
  22. let search_string = search;
  23. const search_array = search_string.split(" ");
  24. for (const term of search_array){
  25. $("span[class=result-entry]:contains('" + term + "')").html(function(_, html) {
  26. var replace = "(" + term + ")";
  27. var re = new RegExp(replace, "g");
  28. return html.replace(re, '<span class="search_term">$1</span>');
  29. });
  30. }
  31. }
  32. function removeRandomTitle() {
  33. var elts = document.getElementsByClassName("title");
  34. var RandomSpan = elts[Math.floor(Math.random() * elts.length)];
  35. RandomSpan.innerHTML = "";
  36. RandomSpan.style.width = "16rem";
  37. RandomSpan.style.display = "inline-block";
  38. }
  39. // code adapted from w3collective
  40. function readingTime(text) {
  41. const wpm = 200;
  42. const words = text.trim().split(/\s+/).length;
  43. const time = Math.ceil(words / wpm);
  44. document.getElementById("time").innerText = time;
  45. }