Skip to content

Commit b4db5ad

Browse files
committed
[feat] New stratified Journal Explorer
1 parent c56c380 commit b4db5ad

12 files changed

+440
-181
lines changed

.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
# API to Database connection
22
api/secret.php
33

4-
# JS to API connection
5-
www/api.js
6-
www/extras/api.js
7-
84
www/bower_components

api/getJournalsForJournalExplorer.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
// connect to mysql
3+
include ('secret.php');
4+
include ('cors.php');
5+
6+
$journalsArray = array();
7+
$resJ = $mysqli->query("
8+
SELECT
9+
j.*, r.listing_count
10+
FROM litfam_journals j
11+
JOIN v_litbaskets_rankings r ON r.journal_id = j.journal_id
12+
WHERE j.scopus_sourceid IS NOT NULL
13+
");
14+
15+
while ($row = $resJ->fetch_assoc()) {
16+
array_push($journalsArray, $row);
17+
}
18+
$resJ->close();
19+
20+
$mysqli->close();
21+
22+
header('Content-type: application/json');
23+
echo json_encode($journalsArray, JSON_PRETTY_PRINT);
24+
?>

api/newVisit.php api/newSearch.php

File renamed without changes.

www/extras/index.controller.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ var GLOBAL_SOURCES_TOPBAR_CONTROLLER = Object.create(LitbasketsSourcesTopbarCont
66
var GLOBAL_SOURCES_CONTROLLER = Object.create(LitbasketsSourcesController);
77
var GLOBAL_FILTERS_CONTROLLER = Object.create(LitbasketsFiltersController);
88

9+
var current_task = null;
910

1011
function body_did_load() {
12+
$("#loading_modal").on("shown.bs.modal", function () {
13+
console.log("shown.bs.modal loading_modal with current_task = " + current_task);
14+
if (current_task == "JOURNAL_EXPLORER") GLOBAL_SOURCES_TOPBAR_CONTROLLER.stage2();
15+
});
16+
17+
do_long_task("BODY_DID_LOAD");
1118
userDidSelectTab('litbaskets-search');
1219

1320
// Initialize the vertical navigation
@@ -30,11 +37,6 @@ function body_did_load() {
3037
window.setTimeout(lbl_copy_to_clipboard_fadeout, 2000); //2 seconds
3138
});
3239

33-
// lock subdivision operation buttons
34-
$("#current_subdivision_select_all").prop("disabled", true);
35-
$("#current_subdivision_select_none").prop("disabled", true);
36-
$("#current_subdivision_select_default").prop("disabled", true);
37-
3840
// ready
3941
$("#litbaskets_search_textbox").focus();
4042

@@ -47,4 +49,14 @@ function body_did_load() {
4749
function update_sidebar_badges() {
4850
GLOBAL_SOURCES_CONTROLLER.update_sidebar_sources_count();
4951
GLOBAL_FILTERS_CONTROLLER.update_sidebar_filter_count();
50-
}
52+
}
53+
54+
function do_long_task(task_name) {
55+
current_task = task_name;
56+
$('#loading_modal').modal('show');
57+
}
58+
59+
function finished_long_task(task_name) {
60+
current_task = null;
61+
$('#loading_modal').modal('hide');
62+
}

www/extras/index.controller.search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function perform_search_with_journals(search_mode, list_of_journals) {
167167
"year_limit_data": GLOBAL_FILTERS_CONTROLLER.limit_years_data,
168168

169169
};
170-
$.post(API_ROOT + "newVisit.php", formdata, function(result) {
170+
$.post(API_ROOT + "newSearch.php", formdata, function(result) {
171171
console.log(result);
172172
});
173173
}
+121-112
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,122 @@
1-
/*
2-
* LitbasketsSourcesTopbarController
3-
* Instantiated in index.controller.js as GLOBAL_SOURCES_TOPBAR_CONTROLLER
4-
*/
5-
LitbasketsSourcesTopbarController = {
6-
/*
7-
* Inserts rows into the listview on screen 'Sources'
8-
*/
9-
populate_journals_in_listview_for_section: function(given_section) {
10-
// clear model and view
11-
user_selected_journal_ids_to_inspect = [];
12-
$("#journalsListView").html("");
13-
14-
for (var i = 0; i < saved_journals_by_subdivisions.length; i++) {
15-
var this_subdivision = saved_journals_by_subdivisions[i];
16-
17-
// if user selected this subdivision
18-
if (this.user_selected_subdivision_ids.includes(this_subdivision.bsd_id)) {
19-
for (var j = 0; j < this_subdivision.journals.length; j++) {
20-
user_selected_journal_ids_to_inspect.push(this_subdivision.journals[j].journal_id);
21-
}
22-
}
23-
}
24-
25-
user_selected_journal_ids_to_inspect = _.uniq(user_selected_journal_ids_to_inspect);
26-
27-
for (var i = 0; i < user_selected_journal_ids_to_inspect.length; i++) {
28-
var this_journal_id = user_selected_journal_ids_to_inspect[i];
29-
var journal_record = GLOBAL_MODEL_HELPER.get_master_record_by_journal_id(this_journal_id);
30-
31-
// ISSN details
32-
var coverage_text = journal_record.scopus_coverage;
33-
if (coverage_text.includes(",")) {
34-
coverage_text = "See Scopus";
35-
}
36-
var col3 = GLOBAL_EXTERNAL_LOGIC_HELPER.generate_url_html(
37-
"SCOPUS_SOURCE_LOOKUP",
38-
journal_record.scopus_sourceid,
39-
coverage_text + "<img src='images/external-link.png' />"
40-
);
41-
42-
var col2 = "<strong>" + journal_record.journal_name + "</strong>";
43-
col2 += "<a href='" + journal_record.url + "' target='_blank'><img src='images/external-link.png' /></a>"
44-
45-
var is_selected = user_selected_journal_ids_to_include.includes(journal_record.journal_id);
46-
var col1 = '<input style="width: 100%;" id="switch_for_journal_'+ journal_record.journal_id +'" class="bootstrap-switch" ';
47-
col1 += 'onchange="GLOBAL_SOURCES_CONTROLLER.toggle_inclusion_of_journal_with_id(' + journal_record.journal_id + ')" type="checkbox">';
48-
49-
var html_string = '<tr>';
50-
html_string += "<td style='padding: 0px;'>" + col1 + "&nbsp;" + col2 + "</td>"
51-
html_string += "<td>" + col3 + "</td>"
52-
html_string += '</td>';
53-
54-
$("#journalsListView").append(html_string);
55-
$("#switch_for_journal_" + journal_record.journal_id).bootstrapSwitch();
56-
if (is_selected) {
57-
$("#switch_for_journal_" + journal_record.journal_id).bootstrapSwitch('state', true);
58-
}
59-
}
60-
}
61-
62-
, download_csv: function() {
63-
var prepared_return = [
64-
[
65-
"Scopus Source ID",
66-
"Scopus Coverage",
67-
"Journal Name",
68-
"Journal ISSN",
69-
"Journal ISSN (e)",
70-
"Journal Website",
71-
"Listing Count"
72-
]
73-
];
74-
for (var i = 0; i < user_selected_journal_ids_to_include.length; i++) {
75-
var journal_id = user_selected_journal_ids_to_include[i];
76-
var journal_record = GLOBAL_MODEL_HELPER.get_master_record_by_journal_id(journal_id);
77-
prepared_return.push([
78-
nvl(journal_record["scopus_sourceid"], ""),
79-
nvl(journal_record["scopus_coverage"], ""),
80-
nvl(journal_record["journal_name"], ""),
81-
nvl(journal_record["issn"], ""),
82-
nvl(journal_record["issne"], ""),
83-
nvl(journal_record["url"], ""),
84-
nvl(journal_record["listing_count"], "")
85-
]);
86-
}
87-
console.log(prepared_return);
88-
89-
// source: https://stackoverflow.com/a/24922761
90-
var processRow = function (row) {
91-
var finalVal = '';
92-
for (var j = 0; j < row.length; j++) {
93-
var innerValue = row[j] === null ? '' : row[j].toString();
94-
if (row[j] instanceof Date) {
95-
innerValue = row[j].toLocaleString();
96-
};
97-
var result = innerValue.replace(/"/g, '""');
98-
if (result.search(/("|,|\n)/g) >= 0)
99-
result = '"' + result + '"';
100-
if (j > 0)
101-
finalVal += ',';
102-
finalVal += result;
103-
}
104-
return finalVal + '\n';
105-
};
106-
107-
var csvContent = '';
108-
for (var i = 0; i < prepared_return.length; i++) {
109-
csvContent += processRow(prepared_return[i]);
110-
}
111-
download(csvContent, "Litbaskets Export "+ (new Date().toISOString().replace(':','_')) +".csv", "text/csv");
112-
}
1+
/*
2+
* LitbasketsSourcesTopbarController
3+
* Instantiated in index.controller.js as GLOBAL_SOURCES_TOPBAR_CONTROLLER
4+
*/
5+
LitbasketsSourcesTopbarController = {
6+
/*
7+
* Inserts rows into the listview on screen 'Sources'
8+
*/
9+
has_been_init: false
10+
11+
, init: function(beforeStarting, afterStarting) {
12+
beforeStarting();
13+
14+
if (!GLOBAL_SOURCES_TOPBAR_CONTROLLER.has_been_init) {
15+
do_long_task("JOURNAL_EXPLORER");
16+
17+
window.setTimeout(function() {
18+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.populate_journals_in_listview_for_section("journalsListView_2xs");
19+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.populate_journals_in_listview_for_section("journalsListView_xs");
20+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.populate_journals_in_listview_for_section("journalsListView_s");
21+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.populate_journals_in_listview_for_section("journalsListView_m");
22+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.populate_journals_in_listview_for_section("journalsListView_l");
23+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.populate_journals_in_listview_for_section("journalsListView_xl");
24+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.populate_journals_in_listview_for_section("journalsListView_2xl");
25+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.populate_journals_in_listview_for_section("journalsListView_3xl");
26+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.has_been_init = true;
27+
finished_long_task("JOURNAL_EXPLORER");
28+
}, 300);
29+
}
30+
31+
afterStarting();
32+
}
33+
34+
, populate_journals_in_listview_for_section: function(given_section) {
35+
console.log("populate_journals_in_listview_for_section: " + given_section);
36+
// clear model and view
37+
journals_to_include = [];
38+
39+
for (var i = 0; i < saved_journals_master_data.length; i++) {
40+
var this_journal = saved_journals_master_data[i];
41+
var include_this_journal = false;
42+
var this_listing_count = parseInt(this_journal.listing_count);
43+
44+
if (given_section == "journalsListView_2xs" && parseInt(this_journal.is_bo8) == 1) include_this_journal = true;
45+
if (given_section == "journalsListView_xs" && this_listing_count >= 7 && parseInt(this_journal.is_bo8) != 1) include_this_journal = true;
46+
if (given_section == "journalsListView_s" && this_listing_count == 6) include_this_journal = true;
47+
if (given_section == "journalsListView_m" && this_listing_count == 5) include_this_journal = true;
48+
if (given_section == "journalsListView_l" && this_listing_count == 4) include_this_journal = true;
49+
if (given_section == "journalsListView_xl" && this_listing_count == 3) include_this_journal = true;
50+
if (given_section == "journalsListView_2xl" && this_listing_count == 2) include_this_journal = true;
51+
if (given_section == "journalsListView_3xl" && this_listing_count == 1) include_this_journal = true;
52+
53+
if (include_this_journal) {
54+
journals_to_include.push(this_journal);
55+
}
56+
}
57+
58+
for (var i = 0; i < journals_to_include.length; i++) {
59+
var journal_record = journals_to_include[i];
60+
var is_selected = user_selected_journal_ids_to_include.includes(journal_record.journal_id);
61+
62+
console.log("bootstrapSwitch: " + journal_record.journal_id);
63+
if (is_selected) {
64+
$("#switch_for_journal_" + journal_record.journal_id).bootstrapSwitch('state', true);
65+
} else {
66+
$("#switch_for_journal_" + journal_record.journal_id).bootstrapSwitch('state', false);
67+
}
68+
}
69+
}
70+
71+
, download_csv: function() {
72+
var prepared_return = [
73+
[
74+
"Scopus Source ID",
75+
"Scopus Coverage",
76+
"Journal Name",
77+
"Journal ISSN",
78+
"Journal ISSN (e)",
79+
"Journal Website",
80+
"Listing Count"
81+
]
82+
];
83+
for (var i = 0; i < user_selected_journals_to_include.length; i++) {
84+
var journal_id = user_selected_journals_to_include[i];
85+
var journal_record = GLOBAL_MODEL_HELPER.get_master_record_by_journal_id(journal_id);
86+
prepared_return.push([
87+
nvl(journal_record["scopus_sourceid"], ""),
88+
nvl(journal_record["scopus_coverage"], ""),
89+
nvl(journal_record["journal_name"], ""),
90+
nvl(journal_record["issn"], ""),
91+
nvl(journal_record["issne"], ""),
92+
nvl(journal_record["url"], ""),
93+
nvl(journal_record["listing_count"], "")
94+
]);
95+
}
96+
console.log(prepared_return);
97+
98+
// source: https://stackoverflow.com/a/24922761
99+
var processRow = function (row) {
100+
var finalVal = '';
101+
for (var j = 0; j < row.length; j++) {
102+
var innerValue = row[j] === null ? '' : row[j].toString();
103+
if (row[j] instanceof Date) {
104+
innerValue = row[j].toLocaleString();
105+
};
106+
var result = innerValue.replace(/"/g, '""');
107+
if (result.search(/("|,|\n)/g) >= 0)
108+
result = '"' + result + '"';
109+
if (j > 0)
110+
finalVal += ',';
111+
finalVal += result;
112+
}
113+
return finalVal + '\n';
114+
};
115+
116+
var csvContent = '';
117+
for (var i = 0; i < prepared_return.length; i++) {
118+
csvContent += processRow(prepared_return[i]);
119+
}
120+
download(csvContent, "Litbaskets Export "+ (new Date().toISOString().replace(':','_')) +".csv", "text/csv");
121+
}
113122
};

www/extras/index.model.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ LitbasketsModelHelper = {
3535
, load_objects: function() {
3636
$.get(API_ROOT + "getSubdivisionsByBaskets.php", function(x) {
3737
GLOBAL_MODEL_HELPER.final_subdivisions_by_baskets = x;
38-
3938
$.get(API_ROOT + "getJournalsBySubdivisions.php", function(y) {
4039
GLOBAL_MODEL_HELPER.final_journals_by_subdivisions = y;
41-
4240
GLOBAL_MODEL_HELPER.launch_sequence_after_api_load();
41+
42+
finished_long_task("BODY_DID_LOAD");
4343
});
4444
});
4545
}

www/extras/sidebar-tab-switcher.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ function userDidSelectTab(tabId) {
77
* because the init() function only works if the slider
88
* is visible.
99
*/
10-
if (tabId == "litbaskets-filters")
10+
if (tabId == "litbaskets-sources")
1111
{
12-
GLOBAL_FILTERS_CONTROLLER.init(
12+
GLOBAL_SOURCES_TOPBAR_CONTROLLER.init(
1313
function() {
1414
$("#litbaskets-container > div").css("display", "none");
15-
$("#litbaskets-filters").css("display", "block");
15+
$("#litbaskets-sources").css("display", "block");
1616
},
17-
function(){}
17+
function(){
18+
}
1819
);
1920
}
2021
else

0 commit comments

Comments
 (0)