Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for not working in semantic scholar #86

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/ccfAbbrFull.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ ccf.abbrFull = {
"CCF-THPC": "CCF TRANSACTIONS ON HIGH PERFORMANCE COMPUTING",
"TSUSC": "IEEE TRANSACTIONS ON SUSTAINABLE COMPUTING",
"PPoPP": "ACM SIGPLAN SYMPOSIUM ON PRINCIPLES & PRACTICE OF PARALLEL PROGRAMMING",
"FAST": "CONFERENCE ON FILE AND STORAGE TECHNOLOGIES",
"FAST": "USENIX CONFERENCE ON FILE AND STORAGE TECHNOLOGIES",
"DAC": "DESIGN AUTOMATION CONFERENCE",
"HPCA": "HIGH-PERFORMANCE COMPUTER ARCHITECTURE",
"HPCA": "INTERNATIONAL SYMPOSIUM ON HIGH-PERFORMANCE COMPUTER ARCHITECTURE",
"MICRO": "IEEE/ACM INTERNATIONAL SYMPOSIUM ON MICROARCHITECTURE",
"SC": "INTERNATIONAL CONFERENCE FOR HIGH PERFORMANCE COMPUTING, NETWORKING, STORAGE, AND ANALYSIS",
"ASPLOS": "INTERNATIONAL CONFERENCE ON ARCHITECTURAL SUPPORT FOR PROGRAMMING LANGUAGES AND OPERATING SYSTEMS",
Expand Down
4 changes: 2 additions & 2 deletions data/ccfFullUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ ccf.fullUrl = {
"CCF TRANSACTIONS ON HIGH PERFORMANCE COMPUTING": "/journals/ccfthpc/ccfthpc",
"IEEE TRANSACTIONS ON SUSTAINABLE COMPUTING": "/journals/tsusc/tsusc",
"ACM SIGPLAN SYMPOSIUM ON PRINCIPLES & PRACTICE OF PARALLEL PROGRAMMING": "/conf/ppopp/ppopp",
"CONFERENCE ON FILE AND STORAGE TECHNOLOGIES": "/conf/fast/fast",
"USENIX CONFERENCE ON FILE AND STORAGE TECHNOLOGIES": "/conf/fast/fast",
"DESIGN AUTOMATION CONFERENCE": "/conf/dac/dac",
"HIGH-PERFORMANCE COMPUTER ARCHITECTURE": "/conf/hpca/hpca",
"INTERNATIONAL SYMPOSIUM ON HIGH-PERFORMANCE COMPUTER ARCHITECTURE": "/conf/hpca/hpca",
"IEEE/ACM INTERNATIONAL SYMPOSIUM ON MICROARCHITECTURE": "/conf/micro/micro",
"INTERNATIONAL CONFERENCE FOR HIGH PERFORMANCE COMPUTING, NETWORKING, STORAGE, AND ANALYSIS": "/conf/sc/sc",
"INTERNATIONAL CONFERENCE ON ARCHITECTURAL SUPPORT FOR PROGRAMMING LANGUAGES AND OPERATING SYSTEMS": "/conf/asplos/asplos",
Expand Down
4 changes: 2 additions & 2 deletions data/ccfRankFull.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"/journals/ccfthpc/ccfthpc": "CCF Transactions on High Performance Computing",
"/journals/tsusc/tsusc": "IEEE Transactions on Sustainable Computing",
"/conf/ppopp/ppopp": "ACM SIGPLAN Symposium on Principles & Practice of Parallel Programming",
"/conf/fast/fast": "Conference on File and Storage Technologies",
"/conf/fast/fast": "USENIX Conference on File and Storage Technologies",
"/conf/dac/dac": "Design Automation Conference",
"/conf/hpca/hpca": "High-Performance Computer Architecture",
"/conf/hpca/hpca": "International Symposium on High-Performance Computer Architecture",
"/conf/micro/micro": "IEEE/ACM International Symposium on Microarchitecture",
"/conf/sc/sc": "International Conference for High Performance Computing, Networking, Storage, and Analysis",
"/conf/asplos/asplos": "International Conference on Architectural Support for Programming Languages and Operating Systems",
Expand Down
4 changes: 2 additions & 2 deletions data/dataGen.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const ccfRankList =
"C CCF-THPC CCF Transactions on High Performance Computing /journals/ccfthpc /journals/ccfthpc/ccfthpc\n" +
"C TSUSC IEEE Transactions on Sustainable Computing /journals/tsusc /journals/tsusc/tsusc\n" +
"A PPoPP ACM SIGPLAN Symposium on Principles & Practice of Parallel Programming /conf/ppopp /conf/ppopp/ppopp\n" +
"A FAST Conference on File and Storage Technologies /conf/fast /conf/fast/fast\n" +
"A FAST USENIX Conference on File and Storage Technologies /conf/fast /conf/fast/fast\n" +
"A DAC Design Automation Conference /conf/dac /conf/dac/dac\n" +
"A HPCA High-Performance Computer Architecture /conf/hpca /conf/hpca/hpca\n" +
"A HPCA International Symposium on High-Performance Computer Architecture /conf/hpca /conf/hpca/hpca\n" +
"A MICRO IEEE/ACM International Symposium on Microarchitecture /conf/micro /conf/micro/micro\n" +
"A SC International Conference for High Performance Computing, Networking, Storage, and Analysis /conf/sc /conf/sc/sc\n" +
"A ASPLOS International Conference on Architectural Support for Programming Languages and Operating Systems /conf/asplos /conf/asplos/asplos\n" +
Expand Down
2 changes: 1 addition & 1 deletion js/ccf.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ccf.getRankInfo = function (refine, type) {
if (full === undefined) {
refine = refine.substring(0, refine.length - 1);
var res = Object.keys(ccf.fullUrl).filter(function (k) {
return k.indexOf(refine.toUpperCase()) == 0;
return k.indexOf(refine.toUpperCase()) != -1;
});
url = res ? ccf.fullUrl[res] : false;
}
Expand Down
81 changes: 55 additions & 26 deletions js/semanticscholar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ const semanticscholar = {};

semanticscholar.rankSpanList = [];

let count = 0;
let maxCount = 5;

semanticscholar.run = function () {
let url = window.location.pathname;
setInterval(function () {
$(window).bind("popstate", function () {
$(window).on('load', function() {
let url = window.location.pathname;
let intervalId = setInterval(function () {
count++;
if (count === maxCount) {
clearInterval(intervalId);
}
semanticscholar.appendRanks();
});
semanticscholar.appendRanks();
}, 700);
}, 700);
});
};

semanticscholar.appendRanks = function () {
Expand All @@ -24,31 +30,54 @@ semanticscholar.appendRanks = function () {
let element = $(this);
let source = element[0].innerText;
if (source.length != 0 && !element.next().hasClass("ccf-rank")) {
for (let getRankSpan of semanticscholar.rankSpanList) {
if (source.includes('(')) {
source = source.substring(source.indexOf('(') + 1, source.indexOf(')'));
}
if (source.includes('\'')) {
source = source.substring(0, source.indexOf('\'')).trim();
}
element.after(getRankSpan(source, 'abbr'));
let paperNode = element.parents('.cl-paper-row').first();
// <sha> - a Semantic Scholar ID
let paperId = paperNode.attr('data-paper-id');
if (paperId == undefined) {
// In paper detail page, i.e. https://www.semanticscholar.org/paper/...
paperNode = element.parents("[data-test-id='paper-detail-page-header']").first();
paperNode = paperNode.find("[data-test-id='corpus-id']").first();
// CorpusId:<id> - a Semantic Scholar numerical ID
paperId = "CorpusId:" + paperNode.text().match(/\d+/)[0];
}
let appendRankBar = semanticscholar.appendRankBar;
semanticscholar.fetchData(paperId, element, appendRankBar);
}
});
};

semanticscholar.appendRank = function (selector) {
let element = $(selector);
let headline = window.location.pathname;
if (headline.length != 0) {
for (let getRankSpan of dblp.rankSpanList) {
let urls = headline.substring(
headline.indexOf("/db/") + 3,
headline.lastIndexOf("/")
);
url = ccf.rankDb[urls];
element.after(getRankSpan(url, "url"));
let semanticAPI = `https://api.semanticscholar.org/graph/v1/paper/{paper_id}?fields=venue`;

semanticscholar.fetchData = function (paperId, element, callback) {
let query_url = semanticAPI.replace('{paper_id}', paperId);
let cached = apiCache.getItem(query_url);
if(cached) {
venue = cached.venue;
callback(element, venue);
return;
}
// none cached
$.get(query_url)
.done(function (data) {
apiCache.setItem(query_url, data);
venue = data.venue;
callback(element, venue);
})
.fail(function () {
console.log("Request failed.");
});
}

semanticscholar.appendRankBar = function (selector, source) {
if (selector.next().hasClass("ccf-rank")) return;

for (let getRankSpan of semanticscholar.rankSpanList) {
if (source.includes('(')) {
source = source.substring(source.indexOf('(') + 1, source.indexOf(')'));
}
if (source.includes('\'')) {
source = source.substring(0, source.indexOf('\'')).trim();
}
selector.after(getRankSpan(source, 'abbr'));
}
};