Skip to content

Commit

Permalink
Merge pull request #4 from agautheron/main
Browse files Browse the repository at this point in the history
add Patent type + a collapsed onLoad option
  • Loading branch information
tschmoderer authored Aug 8, 2023
2 parents 40acda9 + 1e5ac80 commit 65dd268
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ package-lock.json

.DS_Store

dist/
dist/
/.idea
8 changes: 4 additions & 4 deletions docs/assets/js/hal-wordcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function init_wordcloud(container, debug) {
container.appendChild(spinner);
}

function HALwordcloud(hal_wordcloud_div, debug) {
function HALwordcloud(hal_wordcloud_div, idhal, debug) {
if (debug) {
console.log(globalHalData);
}
Expand Down Expand Up @@ -50,14 +50,14 @@ function HALwordcloud(hal_wordcloud_div, debug) {
var word = Object.keys(wordFreq)[suffle[i]];
var freq = Object.values(wordFreq)[suffle[i]];
var new_freq = (9 * freq + max - 10 * min) / (max - min);
wordcloud_container.appendChild(keywordElement(word, new_freq));
wordcloud_container.appendChild(keywordElement(word, idhal, new_freq));
};

hal_wordcloud_div.appendChild(wordcloud_container);
document.getElementById("hal-wordcloud-spinner").style.display = "none";
}

function keywordElement(keyw, freq) {
function keywordElement(keyw, idhal, freq) {
var container = document.createElement("a");
container.classList = "keyword keyword-" + freq;
container.setAttribute("href", "https://hal.science/search/?q=*&authIdHal_s=" + idhal + "&keyword_s=" + keyw);
Expand Down Expand Up @@ -99,6 +99,6 @@ document.addEventListener("halMainDone", () => {
console.log(hal_wordcloud_div);
}

HALwordcloud(hal_wordcloud_div, debug);
HALwordcloud(hal_wordcloud_div,hal_integrator_config["id"], debug);
}
});
11 changes: 10 additions & 1 deletion docs/assets/js/hal.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ const hal_helpers = {
"title_en": "Lectures",
},

"PATENT": {
"icon": "fa-lightbulb",
"title_en": "Patents",
},

"SOFTWARE": {
"icon": "fa-microchip",
"title_en": "Softwares",
Expand Down Expand Up @@ -155,6 +160,7 @@ function initialHTML(type) {
container.id = `hal-${type}`;

const button = document.createElement("button");
button.id=`hal-btn-${type}`;
button.classList.add("hal-btn");
button.setAttribute("data-target", `#${type}`);

Expand Down Expand Up @@ -343,7 +349,10 @@ async function genListPubli(id, type, debug = false) {
// Remove loader
document.getElementById("hal-" + type + "-spinner").style.display = "none";
document.getElementById("hal-" + type).style.display = "block";

if(hal_integrator_config["onLoad"].toLowerCase() === "collapsed"){
document.getElementById(type).style.display = "none";
document.getElementById("hal-btn-" + type).querySelector(".icon-drop_down").classList.add("fa-rotate-by");
}
// Update mathjax
MathJax.typeset([document.getElementById(type)]);

Expand Down
13 changes: 13 additions & 0 deletions docs/pages/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@
<legend>Documents Types</legend>
</fieldset>

<fieldset>
<legend>Display</legend>
<div>
<input type="checkbox" id="toggle-display" name="toggle-display">
<label for="toggle-display">Collapsed Articles Data onLoad</label>
</div>
</fieldset>
<button type="submit">Submit</button>
</form>
</aside>
Expand Down Expand Up @@ -140,6 +147,7 @@
// Reset variables
hal_integrator_config = {
"id": "",
"onLoad":"collapsed",
"typeList": [],
"doit": true,
"debug": false,
Expand Down Expand Up @@ -182,6 +190,11 @@
hal_integrator_config["plugins"]["wordcloud"]["doit"] = false;
}

if (form.querySelector("#toggle-display").checked) {
hal_integrator_config["onLoad"] = "collapsed";
} else {
hal_integrator_config["onLoad"] = "expanded";
}
if (form.querySelector("#toggle-artdat").checked) {
hal_integrator_config["plugins"]["artscore"]["doit"] = true;
} else {
Expand Down
5 changes: 5 additions & 0 deletions src/js/hal_publications.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function initialHTML(type) {
container.id = `hal-${type}`;

const button = document.createElement("button");
button.id=`hal-btn-${type}`;
button.classList.add("hal-btn");
button.setAttribute("data-target", `#${type}`);

Expand Down Expand Up @@ -228,6 +229,10 @@ async function genListPubli(id, type, debug = false) {
// Remove loader
document.getElementById("hal-" + type + "-spinner").style.display = "none";
document.getElementById("hal-" + type).style.display = "block";
if(hal_integrator_config["onLoad"].toLowerCase() === "collapsed"){
document.getElementById(type).style.display = "none";
document.getElementById("hal-btn-" + type).querySelector(".icon-drop_down").classList.add("fa-rotate-by");
}

// Update mathjax
MathJax.typeset([document.getElementById(type)]);
Expand Down
5 changes: 5 additions & 0 deletions src/js/hal_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export const hal_helpers = {
"title_en": "Lectures",
},

"PATENT": {
"icon": "fa-lightbulb",
"title_en": "Patents",
},

"SOFTWARE": {
"icon": "fa-microchip",
"title_en": "Softwares",
Expand Down

0 comments on commit 65dd268

Please sign in to comment.