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.

main.js 2.3KB

2 years ago
2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. document.querySelector('#notes-operations').style.boxShadow = 'inset 0.1rem 0.1rem 0.5rem var(--color-pink)';
  16. }
  17. else { iDiv[i].style.display = 'none';
  18. document.querySelector('#notes-operations').style.boxShadow = 'initial';
  19. }
  20. }
  21. }
  22. function toggleMenu(){
  23. var iDiv = document.querySelectorAll('.interferences'), i;
  24. for (i = 0; i < iDiv.length; ++i) {
  25. if ( iDiv[i].style.display == 'none') {
  26. iDiv[i].style.display = 'flex';
  27. document.querySelector('#interfere').style.boxShadow = '0.25rem 0.25rem 0.5rem var(--color-dark)';
  28. }
  29. else { iDiv[i].style.display = 'none';
  30. document.querySelector('#interfere').style.boxShadow = 'initial';
  31. }
  32. }
  33. }
  34. function refresh(){
  35. window.location.reload("Refresh")
  36. }
  37. function highlightSearchTerms(search){
  38. let search_string = search;
  39. const search_array = search_string.split(" ");
  40. for (const term of search_array){
  41. $("span[class=result-entry]:contains('" + term + "')").html(function(_, html) {
  42. var replace = "(" + term + ")";
  43. var re = new RegExp(replace, "g");
  44. return html.replace(re, '<span class="search_term">$1</span>');
  45. });
  46. }
  47. }
  48. function removeRandomTitle() {
  49. var elts = document.getElementsByClassName("title");
  50. var RandomSpan = elts[Math.floor(Math.random() * elts.length)];
  51. RandomSpan.innerHTML = "";
  52. RandomSpan.style.width = "16rem";
  53. RandomSpan.style.display = "inline-block";
  54. }
  55. function removeRandomImage() {
  56. var elts = document.getElementsByClassName("img-fluid");
  57. var RandomImg = elts[Math.floor(Math.random() * elts.length)];
  58. RandomImg.remove();
  59. }
  60. // code adapted from w3collective
  61. function readingTime(text) {
  62. const wpm = 200;
  63. const words = text.trim().split(/\s+/).length;
  64. const time = Math.ceil(words / wpm);
  65. document.getElementById("time").innerText = time;
  66. }