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.

57 lines
1.6KB

  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 <web@joanachicau.com>
  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. function removeRandomImage() {
  40. var elts = document.getElementsByClassName("img-fluid");
  41. var RandomImg = elts[Math.floor(Math.random() * elts.length)];
  42. RandomImg.remove();
  43. }
  44. // code adapted from w3collective
  45. function readingTime(text) {
  46. const wpm = 200;
  47. const words = text.trim().split(/\s+/).length;
  48. const time = Math.ceil(words / wpm);
  49. document.getElementById("time").innerText = time;
  50. }