diff --git a/icons/load.gif b/icons/load.gif new file mode 100644 index 0000000..a718bd8 Binary files /dev/null and b/icons/load.gif differ diff --git a/index.html b/index.html index 637b1e5..1958a20 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,9 @@
+
🎓️ No evaluation yet
@@ -31,12 +34,14 @@ + diff --git a/popup.js b/popup.js index f02b9ee..b14978e 100644 --- a/popup.js +++ b/popup.js @@ -1,13 +1,10 @@ -// Copyright 2022 Maastricht University Library +// Copyright 2023 Maastricht University Library // Use of this source code is governed by an Apache 2.0-style // license that can be found in the LICENSE file or at // https://github.com/MaastrichtU-Library/the-FAIR-extension/blob/main/LICENSE -// Original version of bundle.js - -var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; - +//var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; function fair(id){ // posts evaluation using the doi and the FAIR api @@ -19,10 +16,12 @@ function fair(id){ xhr.setRequestHeader("Content-Type", "application/json"); xhr.onreadystatechange = function () { + console.log(xhr.status, xhr.responseText); //If response is successful if (xhr.readyState === 4) { var data=xhr.responseText; var jsonResponse = JSON.parse(data); + console.log(jsonResponse); //Add evaluation score document.getElementById("evaluation").innerHTML = "
🎓️ Evaluation score:

"+jsonResponse["score"]+"/22"; //Add score percentage @@ -38,58 +37,42 @@ function fair(id){ var find = ["f1-data-identifier-persistent","f1-metadata-identifier-persistent","f1-metadata-identifier-unique","f2-grounded-metadata" ,"f2-structured-metadata" , "f3-data-identifier-in-metadata" ,"f3-metadata-identifier-in-metadata","f4-searchable" ] var findStatement = ["F1 - Data identifier is persistent", "F1 - Resource identifier is persistent", "F1 - Resource metadata identifier is unique", "F2 - Metadata is grounded and machine-readable" , "F2 - Metadata is structured" , "F3 - Data identifier explicitly in metadata", "F3 - Metadata identifier explicitly in metadata", "F4 - The resource is indexed in a searchable resource"]; - - var access = ["a1-metadata-protocol","a1-data-protocol","a1-data-authorization","a1-metadata-authorization","a2-metadata-persistent"] - var accessState = ["A1.1 - Metadata uses an open free protocol for metadata retrieval", "A1.1 - Uses an open free protocol for data retrieval", "A1.2 - Data authentication and authorization" , "A1.2 - Metadata authentication and authorization", "A2 - Metadata is persistent"] - var inter = ["i1-data-knowledge-representation-semantic", "i1-data-knowledge-representation-structured" , "i1-metadata-knowledge-representation-semantic", "i1-metadata-knowledge-representation-structured","i2-fair-vocabularies-known","i2-fair-vocabularies-resolve","i3-metadata-contains-outward-links"] - var interState = ["I1 - Data uses a formal semantic knowledge representation language", "I1 - Data uses a formal structured knowledge representation language", "I1 - Metadata uses a formal semantic knowledge representation language", "I1 - Metadata uses a formal structured knowledge representation language", "I2 - Metadata uses FAIR Vocabularies registered in known repositories", "I2 - Metadata uses resolvable FAIR Vocabularies", "I3 - Metadata contains outward references"] var reuse = ["r1-includes-license","r1-includes-standard-license"] - var reuseState = ["R2 - Metadata include a License","R1 - Metadata includes a standard License"] - - - - - - + //Findable for(let i=0;i  ✅  " + findStatement[i]+"" - } } //accessible for(let i=0;i  ✅  " + accessState[i]+"" - } } //inetroperable for(let i=0;i  ✅  " + interState[i]+"" - } } //Reusable for(let i=0;i  ✅  " + reuseState[i]+"" - } } //Clear storage when done to avoid wrong results in different pages chrome.storage.local.clear() return [0,1]; - }}; // data used to post request var data = `{ @@ -98,34 +81,41 @@ function fair(id){ }`; xhr.send(data); - } - - - - - -function getDoi() { - // Retreive the DOI indicated by the user from chrome storage - chrome.storage.local.get(['key'], async function(result) { +// function getDoi() { +// // Retreive the DOI indicated by the user from chrome storage +// chrome.storage.local.get(['key'], async function(result) { +// //Check if there are any DOI's in the storage +// if(result.key != null){ +// //Let the user know evaluation is under process +// document.getElementById("evaluation").innerText = "🎓️Evaluation under process"; +// //Start the evaluation +// const results = await fair(result.key); +// } +// }); +// } + function getDoi() { + // Retrieve the DOI indicated by the user from chrome storage + chrome.storage.local.get(['key'], async function(result) { //Check if there are any DOI's in the storage if(result.key != null){ - //Let the user know evaluation is under process - document.getElementById("evaluation").innerText = "🎓️Evaluation under process"; - //Start the evaluation - const results = await fair(result.key); - + //Let the user know evaluation is under process + document.getElementById("evaluation").innerText = "🎓️Evaluation under process"; + // Show spinner + document.getElementById('spinner').style.display = 'block'; + // Start the evaluation + await fair(result.key); + // Hide spinner + document.getElementById('spinner').style.display = 'none'; } - - - - - }); - - } - + } // initiates popup functions -getDoi(); \ No newline at end of file +//getDoi(); + +document.addEventListener('DOMContentLoaded', (event) => { + // The DOM is fully loaded. You can safely manipulate it here. + getDoi(); +}); diff --git a/styles.css b/styles.css index 3de408f..e6e1e36 100644 --- a/styles.css +++ b/styles.css @@ -53,6 +53,7 @@ body, html { border: 0.01px solid lightgray; padding: 1em; flex-shrink: 0; + font-size: 9px; } #find { @@ -161,3 +162,10 @@ div[role="progressbar"]::before { counter-reset: percentage var(--value); content: counter(percentage) '%'; } + +#spinner { + display: flex; + justify-content: center; + align-items: center; + } + \ No newline at end of file