forked from emeryberger/CSrankings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
csrankings.js
1039 lines (1034 loc) · 42.8 KB
/
csrankings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
CSrankings.ts
@author Emery Berger <[email protected]> http://www.emeryberger.com
*/
/// <reference path="./typescript/jquery.d.ts" />
/// <reference path="./typescript/papaparse.d.ts" />
/// <reference path="./typescript/set.d.ts" />
/// <reference path="./typescript/d3.d.ts" />
/// <reference path="./typescript/d3pie.d.ts" />
/// <reference path="./typescript/navigo.d.ts" />
;
;
;
;
;
;
;
;
var CSRankings = (function () {
function CSRankings() {
/* Build the areaDict dictionary: areas -> names used in pie charts
and areaPosition dictionary: areas -> position in area array
*/
CSRankings.geoCheck();
for (var position = 0; position < CSRankings.areaMap.length; position++) {
var _a = CSRankings.areaMap[position], area = _a.area, title = _a.title;
CSRankings.areas[position] = area;
CSRankings.areaNames[position] = title;
CSRankings.fields[position] = area;
CSRankings.areaDict[area] = CSRankings.areaNames[position];
CSRankings.areaPosition[area] = position;
}
for (var _i = 0, _b = CSRankings.aiAreas; _i < _b.length; _i++) {
var area = _b[_i];
CSRankings.aiFields.push(CSRankings.areaPosition[area]);
}
for (var _c = 0, _d = CSRankings.systemsAreas; _c < _d.length; _c++) {
var area = _d[_c];
CSRankings.systemsFields.push(CSRankings.areaPosition[area]);
}
for (var _e = 0, _f = CSRankings.theoryAreas; _e < _f.length; _e++) {
var area = _f[_e];
CSRankings.theoryFields.push(CSRankings.areaPosition[area]);
}
for (var _g = 0, _h = CSRankings.interdisciplinaryAreas; _g < _h.length; _g++) {
var area = _h[_g];
CSRankings.otherFields.push(CSRankings.areaPosition[area]);
}
// CSRankings.setAllCheckboxes();
var next = function () {
CSRankings.loadAliases(CSRankings.aliases, function () {
CSRankings.loadHomepages(CSRankings.homepages, function () {
CSRankings.loadAuthorInfo(function () {
CSRankings.loadCountryInfo(CSRankings.countryInfo, function () {
CSRankings.loadScholarInfo(CSRankings.scholarInfo, CSRankings.rank);
});
});
});
});
};
CSRankings.activateAll();
next();
CSRankings.navigoRouter = new Navigo(null, true);
CSRankings.navigoRouter.on('/index', function (params, query) {
var par = params;
// Clear everything.
for (var a in CSRankings.areas) {
jQuery("input[name=" + CSRankings.areas[a] + "]").prop('checked', false);
}
// Now check everything listed in the query string.
query.split('&').forEach(function (item) {
if (item != "none") {
jQuery("input[name=" + item + "]").prop('checked', true);
}
});
}).resolve();
}
CSRankings.translateNameToDBLP = function (name) {
// Ex: "Emery D. Berger" -> "http://dblp.uni-trier.de/pers/hd/b/Berger:Emery_D="
// First, replace spaces and non-ASCII characters (not complete).
// Known issue: does not properly handle suffixes like Jr., III, etc.
name = name.replace(/'|\-|\./g, "=");
// name = name.replace(/\-/g, "=");
// name = name.replace(/\./g, "=");
name = name.replace(/Á/g, "=Aacute=");
name = name.replace(/á/g, "=aacute=");
name = name.replace(/è/g, "=egrave=");
name = name.replace(/é/g, "=eacute=");
name = name.replace(/ï/g, "=iuml=");
name = name.replace(/ó/g, "=oacute=");
name = name.replace(/ç/g, "=ccedil=");
name = name.replace(/ä/g, "=auml=");
name = name.replace(/ö/g, "=ouml=");
name = name.replace(/ø/g, "=oslash=");
name = name.replace(/Ö/g, "=Ouml=");
name = name.replace(/ü/g, "=uuml=");
var splitName = name.split(" ");
var lastName = splitName[splitName.length - 1];
var disambiguation = "";
if (parseInt(lastName) > 0) {
// this was a disambiguation entry; go back.
disambiguation = lastName;
splitName.pop();
lastName = splitName[splitName.length - 1] + "_" + disambiguation;
}
splitName.pop();
var newName = splitName.join(" ");
newName = newName.replace(/\s/g, "_");
newName = newName.replace(/\-/g, "=");
var str = "http://dblp.uni-trier.de/pers/hd";
var lastInitial = lastName[0].toLowerCase();
str += "/" + lastInitial + "/" + lastName + ":" + newName;
return str;
};
/* Create the prologue that we preface each generated HTML page with (the results). */
CSRankings.makePrologue = function () {
var s = "<html>"
+ "<head>"
+ '<style type="text/css">'
+ ' body { font-family: "Helvetica", "Arial"; }'
+ " table td { vertical-align: top; }"
+ "</style>"
+ "</head>"
+ "<body>"
+ '<div class="row">'
+ '<div class="table" style="overflow:auto; height: 650px;">'
+ '<table class="table-sm table-striped"'
+ 'id="ranking" valign="top">';
return s;
};
/* from http://hubrik.com/2015/11/16/sort-by-last-name-with-javascript/ */
CSRankings.compareNames = function (a, b) {
//split the names as strings into arrays
var aName = a.split(" ");
var bName = b.split(" ");
// get the last names by selecting
// the last element in the name arrays
// using array.length - 1 since full names
// may also have a middle name or initial
var aLastName = aName[aName.length - 1];
var bLastName = bName[bName.length - 1];
// compare the names and return either
// a negative number, positive number
// or zero.
if (aLastName < bLastName)
return -1;
if (aLastName > bLastName)
return 1;
return 0;
};
/* Create a pie chart */
CSRankings.makeChart = function (name) {
console.assert(CSRankings.color.length >= CSRankings.areas.length, "Houston, we have a problem.");
var data = [];
var datadict = {};
var keys = CSRankings.areas;
var uname = unescape(name);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = CSRankings.authorAreas[uname][key];
// Use adjusted count if this is for a department.
/*
DISABLED so department charts are invariant.
if (uname in CSRankings.stats) {
value = CSRankings.areaDeptAdjustedCount[key+uname] + 1;
if (value == 1) {
value = 0;
}
}
*/
// Round it to the nearest 0.1.
value = Math.round(value * 10) / 10;
if (value > 0) {
// if (key in CSRankings.parentMap) {
// key = CSRankings.parentMap[key];
// }
if (!(key in datadict)) {
datadict[key] = 0;
}
datadict[key] += value;
}
}
for (var key in datadict) {
data.push({ "label": CSRankings.areaDict[key],
"value": Math.round(datadict[key] * 10) / 10,
"color": CSRankings.color[CSRankings.areaPosition[key]] });
}
new d3pie(name + "-chart", {
"header": {
"title": {
"text": uname,
"fontSize": 24,
"font": "open sans"
},
"subtitle": {
"text": "Publication Profile",
"color": "#999999",
"fontSize": 14,
"font": "open sans"
},
"titleSubtitlePadding": 9
},
"size": {
"canvasHeight": 500,
"canvasWidth": 500,
"pieInnerRadius": "38%",
"pieOuterRadius": "83%"
},
"data": {
"content": data,
"smallSegmentGrouping": {
"enabled": true,
"value": 1
}
},
"labels": {
"outer": {
"pieDistance": 32
},
"inner": {
//"format": "percentage", // "value",
//"hideWhenLessThanPercentage": 0 // 2 // 100 // 2
"format": "value",
"hideWhenLessThanPercentage": 5 // 100 // 2
},
"mainLabel": {
"fontSize": 12
},
"percentage": {
"color": "#ffffff",
"decimalPlaces": 0
},
"value": {
"color": "#ffffff",
"fontSize": 10
},
"lines": {
"enabled": true
},
"truncation": {
"enabled": true
}
},
"effects": {
"load": {
"effect": "none"
},
"pullOutSegmentOnClick": {
"effect": "linear",
"speed": 400,
"size": 8
}
},
"misc": {
"gradient": {
"enabled": true,
"percentage": 100
}
}
});
};
CSRankings.loadScholarInfo = function (scholarInfo, cont) {
Papa.parse(CSRankings.scholarFile, {
header: true,
download: true,
complete: function (results) {
var data = results.data;
var d = data;
for (var _i = 0, d_1 = d; _i < d_1.length; _i++) {
var scholarPair = d_1[_i];
scholarInfo[scholarPair.name] = scholarPair.scholarid;
}
setTimeout(cont, 0);
}
});
};
CSRankings.loadAliases = function (aliases, cont) {
Papa.parse(CSRankings.aliasFile, {
header: true,
download: true,
complete: function (results) {
var data = results.data;
var d = data;
for (var _i = 0, d_2 = d; _i < d_2.length; _i++) {
var aliasPair = d_2[_i];
aliases[aliasPair.alias] = aliasPair.name;
}
setTimeout(cont, 0);
}
});
};
CSRankings.loadArticles = function (cont) {
jQuery.getJSON("articles.json", function (_) {
/* disabled for now
CSRankings.articles = data; */
setTimeout(cont, 0);
});
};
CSRankings.loadCountryInfo = function (countryInfo, cont) {
Papa.parse(CSRankings.countryinfoFile, {
header: true,
download: true,
complete: function (results) {
var data = results.data;
var ci = data;
for (var _i = 0, ci_1 = ci; _i < ci_1.length; _i++) {
var info = ci_1[_i];
countryInfo[info.institution] = info.region;
}
setTimeout(cont, 0);
}
});
};
CSRankings.loadAuthorInfo = function (cont) {
var _this = this;
Papa.parse(CSRankings.authorinfoFile, {
download: true,
header: true,
complete: function (results) {
var data = results.data;
_this.authors = data;
for (var i = 0; i < CSRankings.fields.length; i++) {
var str = 'input[name=' + CSRankings.fields[i] + ']';
jQuery(str).click(function () {
_this.rank();
});
}
setTimeout(cont, 0);
}
});
};
CSRankings.loadHomepages = function (homepages, cont) {
Papa.parse(CSRankings.homepagesFile, {
header: true,
download: true,
complete: function (results) {
var data = results.data;
var d = data;
for (var _i = 0, d_3 = d; _i < d_3.length; _i++) {
var namePage = d_3[_i];
if (typeof namePage.homepage === 'undefined') {
continue;
}
homepages[namePage.name.trim()] = namePage.homepage.trim();
}
setTimeout(cont, 0);
}
});
};
CSRankings.inRegion = function (dept, regions) {
switch (regions) {
case "world":
break;
case "USA":
if (dept in CSRankings.countryInfo) {
return false;
}
break;
case "europe":
if (!(dept in CSRankings.countryInfo)) {
return false;
}
if (CSRankings.countryInfo[dept] != "europe") {
return false;
}
break;
case "canada":
if (!(dept in CSRankings.countryInfo)) {
return false;
}
if (CSRankings.countryInfo[dept] != "canada") {
return false;
}
break;
case "northamerica":
if ((dept in CSRankings.countryInfo) && (CSRankings.countryInfo[dept] != "canada")) {
return false;
}
break;
case "australasia":
if (!(dept in CSRankings.countryInfo)) {
return false;
}
if (CSRankings.countryInfo[dept] != "australasia") {
return false;
}
break;
case "southamerica":
if (!(dept in CSRankings.countryInfo)) {
return false;
}
if (CSRankings.countryInfo[dept] != "southamerica") {
return false;
}
break;
case "asia":
if (!(dept in CSRankings.countryInfo)) {
return false;
}
if (CSRankings.countryInfo[dept] != "asia") {
return false;
}
break;
}
return true;
};
CSRankings.activateFields = function (value, fields) {
for (var i = 0; i < fields.length; i++) {
var str = "input[name=" + CSRankings.fields[fields[i]] + "]";
jQuery(str).prop('checked', value);
}
CSRankings.rank();
return false;
};
CSRankings.sortIndex = function (univagg) {
var keys = Object.keys(univagg);
keys.sort(function (a, b) {
if (univagg[a] > univagg[b]) {
return -1;
}
if (univagg[b] > univagg[a]) {
return 1;
}
if (a < b) {
return -1;
}
if (b < a) {
return 1;
}
return 0;
});
return keys;
};
CSRankings.countAuthorAreas = function (authors, startyear, endyear,
// weights : {[key:string] : number},
authorAreas) {
for (var r in authors) {
if (!authors.hasOwnProperty(r)) {
continue;
}
var auth = authors[r];
var year = auth.year;
if ((year < startyear) || (year > endyear)) {
continue;
}
var theArea = auth.area;
/*
DISABLING weight selection so all pie charts look the
same regardless of which areas are currently selected:
if (weights[theArea] === 0) {
continue;
}
*/
var theDept = auth.dept;
var theCount = parseFloat(auth.count);
// const theCount = parseFloat(auth.adjustedcount);
var name_1 = auth.name;
if (name_1 in CSRankings.aliases) {
name_1 = CSRankings.aliases[name_1];
}
if (!(name_1 in authorAreas)) {
authorAreas[name_1] = {};
for (var area in CSRankings.areaDict) {
if (CSRankings.areaDict.hasOwnProperty(area)) {
authorAreas[name_1][area] = 0;
}
}
}
if (!(theDept in authorAreas)) {
authorAreas[theDept] = {};
for (var area in CSRankings.areaDict) {
if (CSRankings.areaDict.hasOwnProperty(area)) {
authorAreas[theDept][area] = 0;
}
}
}
authorAreas[name_1][theArea] += theCount;
authorAreas[theDept][theArea] += theCount;
}
};
/* Build the dictionary of departments (and count) to be ranked. */
CSRankings.buildDepartments = function (authors, startyear, endyear, weights, regions, areaDeptAdjustedCount, deptCounts, deptNames, facultycount, facultyAdjustedCount) {
/* contains an author name if that author has been processed. */
var visited = {};
for (var r in authors) {
if (!authors.hasOwnProperty(r)) {
continue;
}
var _a = authors[r], name_2 = _a.name, year = _a.year, area = _a.area, dept = _a.dept;
if (name_2 in CSRankings.aliases) {
name_2 = CSRankings.aliases[name_2];
}
if (typeof dept === 'undefined') {
continue;
}
if ((weights[area] === 0) || (year < startyear) || (year > endyear)) {
continue;
}
if (!CSRankings.inRegion(dept, regions)) {
continue;
}
// If this area is a child area, accumulate totals for parent.
if (area in CSRankings.parentMap) {
area = CSRankings.parentMap[area];
}
var areaDept = area + dept;
var nameDept = name_2 + dept;
if (!(areaDept in areaDeptAdjustedCount)) {
areaDeptAdjustedCount[areaDept] = 0;
}
var count = parseInt(authors[r].count);
var adjustedCount = parseFloat(authors[r].adjustedcount);
areaDeptAdjustedCount[areaDept] += adjustedCount;
/* Is this the first time we have seen this person? */
if (!(name_2 in visited)) {
visited[name_2] = true;
facultycount[nameDept] = 0;
facultyAdjustedCount[nameDept] = 0;
if (!(dept in deptCounts)) {
deptCounts[dept] = 0;
deptNames[dept] = [];
}
deptNames[dept].push(name_2);
deptCounts[dept] += 1;
}
facultycount[nameDept] += count;
facultyAdjustedCount[nameDept] += adjustedCount;
}
};
/* Compute aggregate statistics. */
CSRankings.computeStats = function (deptNames, areaDeptAdjustedCount, areas, numAreas, displayPercentages, weights) {
CSRankings.stats = {};
var univagg = {};
for (var dept in deptNames) {
if (!deptNames.hasOwnProperty(dept)) {
continue;
}
if (displayPercentages) {
univagg[dept] = 1;
}
else {
univagg[dept] = 0;
}
for (var _i = 0, areas_1 = areas; _i < areas_1.length; _i++) {
var area = areas_1[_i];
// If the area is a child, ignore it.
if (area in CSRankings.parentMap) {
continue;
}
var areaDept = area + dept;
if (!(areaDept in areaDeptAdjustedCount)) {
areaDeptAdjustedCount[areaDept] = 0;
}
if (weights[area] != 0) {
if (displayPercentages) {
// Adjusted (smoothed) geometric mean.
univagg[dept] *= (areaDeptAdjustedCount[areaDept] + 1.0);
}
else {
univagg[dept] += areaDeptAdjustedCount[areaDept];
}
}
}
if (displayPercentages) {
// finally compute geometric mean.
univagg[dept] = Math.pow(univagg[dept], 1 / numAreas);
}
}
return univagg;
};
/* Updates the 'weights' of each area from the checkboxes. */
/* Returns the number of areas selected (checked). */
CSRankings.updateWeights = function (weights) {
var numAreas = 0;
for (var ind = 0; ind < CSRankings.areas.length; ind++) {
var area = CSRankings.areas[ind];
weights[area] = jQuery('input[name=' + CSRankings.fields[ind] + ']').prop('checked') ? 1 : 0;
if (weights[area] === 1) {
/* One more area checked. */
numAreas++;
}
}
return numAreas;
};
CSRankings.canonicalizeNames = function (deptNames, facultycount, facultyAdjustedCount) {
for (var dept in deptNames) {
if (!deptNames.hasOwnProperty(dept)) {
continue;
}
for (var ind = 0; ind < deptNames[dept].length; ind++) {
var name_3 = deptNames[dept][ind];
if (name_3 in CSRankings.aliases) {
deptNames[dept][ind] = CSRankings.aliases[name_3];
if (!(CSRankings.aliases[name_3] + dept in facultycount)) {
facultycount[CSRankings.aliases[name_3] + dept] = facultycount[name_3 + dept];
facultyAdjustedCount[CSRankings.aliases[name_3] + dept] = facultyAdjustedCount[name_3 + dept];
}
else {
facultycount[CSRankings.aliases[name_3] + dept] += facultycount[name_3 + dept];
facultyAdjustedCount[CSRankings.aliases[name_3] + dept] += facultyAdjustedCount[name_3 + dept];
}
}
}
}
};
/* Build drop down for faculty names and paper counts. */
CSRankings.buildDropDown = function (deptNames, facultycount, facultyAdjustedCount) {
var univtext = {};
var _loop_1 = function (dept) {
if (!deptNames.hasOwnProperty(dept)) {
return "continue";
}
var p = '<div class="row"><div class="table"><table class="table-striped" width="100%"><thead><th></th><td><small><em><abbr title="Click on an author\'s name to go to their home page.">Faculty</abbr></em></small></td><td align="right"><small><em> <abbr title="Total number of publications (click for DBLP entry).">Raw \# Pubs</abbr></em></small></td><td align="right"><small><em><abbr title="Count divided by number of co-authors">Adjusted \#</abbr></em></small></td></thead><tbody>';
/* Build a dict of just faculty from this department for sorting purposes. */
var fc = {};
for (var _i = 0, _a = deptNames[dept]; _i < _a.length; _i++) {
var name_4 = _a[_i];
fc[name_4] = facultycount[name_4 + dept];
}
var keys = Object.keys(fc);
keys.sort(function (a, b) {
if (fc[b] === fc[a]) {
var fb = Math.round(10.0 * facultyAdjustedCount[b + dept]) / 10.0;
var fa = Math.round(10.0 * facultyAdjustedCount[a + dept]) / 10.0;
if (fb === fa) {
return CSRankings.compareNames(a, b);
}
return fb - fa;
}
else {
return fc[b] - fc[a];
}
});
for (var _b = 0, keys_1 = keys; _b < keys_1.length; _b++) {
var name_5 = keys_1[_b];
var homePage = encodeURI(CSRankings.homepages[name_5]);
var dblpName = CSRankings.translateNameToDBLP(name_5);
p += "<tr><td> </td><td><small>"
+ '<a title="Click for author\'s home page." target="_blank" href="'
+ homePage
+ '" '
+ 'onclick="trackOutboundLink(\''
+ homePage
+ '\', true); return false;"'
+ '>'
+ name_5
+ '</a> ';
if (CSRankings.scholarInfo.hasOwnProperty(name_5)) {
var url = 'https://scholar.google.com/citations?user='
+ CSRankings.scholarInfo[name_5]
+ '&hl=en&oi=ao';
p += '<a target="_blank" href="' + url + '" '
+ 'onclick="trackOutboundLink(\''
+ url
+ '\', true); return false;"'
+ '>'
+ '<img src="https://scholar.google.com/favicon.ico" height="10" width="10">'
+ '</a> ';
}
p += "<span onclick=\"CSRankings.toggleChart('"
+ escape(name_5)
+ "')\" class=\"hovertip\" ><font color=\"blue\">" + CSRankings.PieChart + "</font></span>"
+ '</small>'
+ '</td><td align="right"><small>'
+ '<a title="Click for author\'s DBLP entry." target="_blank" href="'
+ dblpName
+ '" '
+ 'onclick="trackOutboundLink(\''
+ dblpName
+ '\', true); return false;"'
+ '>'
+ fc[name_5]
+ '</a>'
+ "</small></td>"
+ '<td align="right"><small>'
+ (Math.round(10.0 * facultyAdjustedCount[name_5 + dept]) / 10.0).toFixed(1)
+ "</small></td></tr>"
+ "<tr><td colspan=\"4\">"
+ '<div style="display:none;" id="' + escape(name_5) + "-chart" + '">'
+ '</div>'
+ "</td></tr>";
}
p += "</tbody></table></div></div>";
univtext[dept] = p;
};
for (var dept in deptNames) {
_loop_1(dept);
}
return univtext;
};
CSRankings.buildOutputString = function (displayPercentages, numAreas, univagg, deptCounts, univtext) {
var s = CSRankings.makePrologue();
/* Show the top N (with more if tied at the end) */
var minToRank = parseInt(jQuery("#minToRank").find(":selected").val());
if (displayPercentages) {
s = s + '<thead><tr><th align="left">Rank </th><th align="right">Institution </th><th align="right"><abbr title="Geometric mean count of papers published across all areas.">Avg. Count</abbr></th><th align="right"> <abbr title="Number of faculty who have published in these areas.">Faculty</abbr></th></th></tr></thead>';
}
else {
s = s + '<thead><tr><th align="left">Rank </th><th align="right">Institution </th><th align="right">Adjusted Pub Count</th><th align="right"> Faculty</th></tr></thead>';
}
s = s + "<tbody>";
/* As long as there is at least one thing selected, compute and display a ranking. */
if (numAreas > 0) {
var ties = 1; /* number of tied entries so far (1 = no tie yet); used to implement "competition rankings" */
var rank = 0; /* index */
var oldv = 9999999.999; /* old number - to track ties */
/* Sort the university aggregate count from largest to smallest. */
var keys2 = CSRankings.sortIndex(univagg);
/* Display rankings until we have shown `minToRank` items or
while there is a tie (those all get the same rank). */
for (var ind = 0; ind < keys2.length; ind++) {
var dept = keys2[ind];
var v = Math.round(10.0 * univagg[dept]) / 10.0;
if ((ind >= minToRank) && (v != oldv)) {
break;
}
if (v === 0.0) {
break;
}
if (oldv != v) {
if (CSRankings.useDenseRankings) {
rank = rank + 1;
}
else {
rank = rank + ties;
ties = 0;
}
}
var esc = escape(dept);
s += "\n<tr><td>" + rank + "</td>";
s += "<td>"
+ "<span onclick=\"CSRankings.toggleFaculty('" + dept + "')\" class=\"hovertip\" id=\"" + dept + "-widget\">" + "<font color=\"blue\">" + CSRankings.RightTriangle + "</font></span> "
+ "<span onclick=\"CSRankings.toggleFaculty('" + dept + "')\" class=\"hovertip\">" + dept + "</span>";
s += " <font color=\"blue\">" + "<span onclick=\"CSRankings.toggleChart('"
+ esc
+ "')\" class=\"hovertip\" id=\""
+ esc
+ "-widget\">" + CSRankings.PieChart + "</span></font>";
// s += '<div style="display:none;" style="width: 100%; height: 350px;" id="' + esc + '">' + '</div>';
s += "</td>";
s += '<td align="right">' + (Math.round(10.0 * v) / 10.0).toFixed(1) + "</td>";
s += '<td align="right">' + deptCounts[dept] + "<br />"; /* number of faculty */
s += "</td>";
s += "</tr>\n";
s += '<tr><td colspan="4"><div style="display:none;" style="width: 100%; height: 350px;" id="'
+ esc
+ '-chart">' + '</div></td></tr>';
s += '<tr><td colspan="4"><div style="display:none;" id="' + dept + '-faculty">' + univtext[dept] + '</div></td></tr>';
ties++;
oldv = v;
}
s += "</tbody>" + "</table>" + "<br />";
if (CSRankings.allowRankingChange) {
/* Disable option to change ranking approach for now. */
if (CSRankings.useDenseRankings) {
s += '<em><a class="only_these_areas" onClick="deactivateDenseRankings(); return false;"><font color="blue"><b>Using dense rankings. Click to use competition rankings.</b></font></a><em>';
}
else {
s += '<em><a class="only_these_areas" onClick="activateDenseRankings(); return false;"><font color="blue"><b>Using competition rankings. Click to use dense rankings.</b></font></a></em>';
}
}
s += "</div>" + "</div>" + "\n";
s += "<br>" + "</body>" + "</html>";
}
else {
/* Nothing selected. */
s = "<h4>Please select at least one area.</h4>";
}
return s;
};
/* Set all checkboxes to true. */
CSRankings.setAllCheckboxes = function () {
CSRankings.activateAll();
};
/* PUBLIC METHODS */
CSRankings.rank = function () {
var deptNames = {}; /* names of departments. */
var deptCounts = {}; /* number of faculty in each department. */
var facultycount = {}; /* name + dept -> raw count of pubs per name / department */
var facultyAdjustedCount = {}; /* name + dept -> adjusted count of pubs per name / department */
var currentWeights = {}; /* array to hold 1 or 0, depending on if the area is checked or not. */
CSRankings.areaDeptAdjustedCount = {};
var startyear = parseInt(jQuery("#startyear").find(":selected").text());
var endyear = parseInt(jQuery("#endyear").find(":selected").text());
var displayPercentages = true; // Boolean(parseInt(jQuery("#displayPercent").find(":selected").val()));
var whichRegions = jQuery("#regions").find(":selected").val();
var numAreas = CSRankings.updateWeights(currentWeights);
CSRankings.authorAreas = {};
CSRankings.countAuthorAreas(CSRankings.authors, startyear, endyear,
// currentWeights,
CSRankings.authorAreas);
CSRankings.buildDepartments(CSRankings.authors, startyear, endyear, currentWeights, whichRegions, CSRankings.areaDeptAdjustedCount, deptCounts, deptNames, facultycount, facultyAdjustedCount);
/* (university, total or average number of papers) */
CSRankings.stats = CSRankings.computeStats(deptNames, CSRankings.areaDeptAdjustedCount, CSRankings.areas, numAreas, displayPercentages, currentWeights);
/* Canonicalize names. */
CSRankings.canonicalizeNames(deptNames, facultycount, facultyAdjustedCount);
var univtext = CSRankings.buildDropDown(deptNames, facultycount, facultyAdjustedCount);
/* Start building up the string to output. */
var s = CSRankings.buildOutputString(displayPercentages, numAreas, CSRankings.stats, deptCounts, univtext);
/* Finally done. Redraw! */
setTimeout(function () { jQuery("#success").html(s); CSRankings.urlUpdate(); }, 0);
return false;
};
/* Turn the chart display on or off. */
CSRankings.toggleChart = function (name) {
var chart = document.getElementById(name + "-chart");
if (chart.style.display === 'block') {
chart.style.display = 'none';
chart.innerHTML = '';
}
else {
chart.style.display = 'block';
CSRankings.makeChart(name);
}
};
/* Expand or collape the view of conferences in a given area. */
CSRankings.toggleConferences = function (area) {
var e = document.getElementById(area + "-conferences");
var widget = document.getElementById(area + "-widget");
if (e.style.display === 'block') {
e.style.display = 'none';
widget.innerHTML = "<font color=\"blue\">" + CSRankings.RightTriangle + "</font>";
}
else {
e.style.display = 'block';
widget.innerHTML = "<font color=\"blue\">" + CSRankings.DownTriangle + "</font>";
}
var boxes = document.getElementById(area + "-conferences-checkboxes");
if (boxes.style.display === 'block') {
boxes.style.display = 'none';
}
else {
boxes.style.display = 'block';
}
};
/* Expand or collape the view of all faculty in a department. */
CSRankings.toggleFaculty = function (dept) {
var e = document.getElementById(dept + "-faculty");
var widget = document.getElementById(dept + "-widget");
if (e.style.display === 'block') {
e.style.display = 'none';
widget.innerHTML = "<font color=\"blue\">" + CSRankings.RightTriangle + "</font>";
}
else {
e.style.display = 'block';
widget.innerHTML = "<font color=\"blue\">" + CSRankings.DownTriangle + "</font>";
}
};
CSRankings.activateAll = function (value) {
if (value === void 0) { value = true; }
for (var i = 0; i < CSRankings.areas.length; i++) {
var str = "input[name=" + CSRankings.fields[i] + "]";
jQuery(str).prop('checked', value);
if (CSRankings.fields[i] in CSRankings.childMap) {
var parent_1 = CSRankings.fields[i];
for (var _i = 0, _a = CSRankings.childMap[parent_1]; _i < _a.length; _i++) {
var kid = _a[_i];
jQuery("input[name=" + kid + "]").prop('checked', value);
}
}
}
CSRankings.rank();
return false;
};
CSRankings.activateNone = function () {
return CSRankings.activateAll(false);
};
CSRankings.activateSystems = function (value) {
if (value === void 0) { value = true; }
return CSRankings.activateFields(value, CSRankings.systemsFields);
};
CSRankings.activateAI = function (value) {
if (value === void 0) { value = true; }
return CSRankings.activateFields(value, CSRankings.aiFields);
};
CSRankings.activateTheory = function (value) {
if (value === void 0) { value = true; }
return CSRankings.activateFields(value, CSRankings.theoryFields);
};
CSRankings.activateOthers = function (value) {
if (value === void 0) { value = true; }
return CSRankings.activateFields(value, CSRankings.otherFields);
};
CSRankings.deactivateSystems = function () {
return CSRankings.activateSystems(false);
};
CSRankings.deactivateAI = function () {
return CSRankings.activateAI(false);
};
CSRankings.deactivateTheory = function () {
return CSRankings.activateTheory(false);
};
CSRankings.deactivateOthers = function () {
return CSRankings.activateOthers(false);
};
// Update the URL according to the selected checkboxes.
CSRankings.urlUpdate = function () {
var s = '';
var count = 0;
for (var i = 0; i < CSRankings.fields.length; i++) {
var str = 'input[name=' + CSRankings.fields[i] + ']';
if (jQuery(str).prop('checked')) {
s += CSRankings.fields[i] + '&';
// console.log(CSRankings.fields[i]);
count += 1;
}
}
if (count > 0) {
// Trim off the trailing '&'.
s = s.slice(0, -1);
}
if (count == CSRankings.fields.length) {
s = ''; // Distinguished special URL - default = all selected.
}
else if (count == 0) {
s = '/index?none'; // Distinguished special URL - none selected.
}
else {
s = '/index?' + s;
}
CSRankings.navigoRouter.navigate(s);
};
CSRankings.geoCheck = function () {
// Figure out which country clients are coming from and set
// the default regions accordingly.
jQuery.getJSON('http://freegeoip.net/json/', function (result) {
switch (result.country_code) {
case "US":
case "CN":
case "IN":
case "KR":
case "JP":
case "TW":
case "SG":
// jQuery("#regions").val("USA");
// This is currently the default.
break;
default:
jQuery("#regions").val("world");
break;
}
});
};
return CSRankings;
}());
CSRankings.authorinfoFile = "/generated-author-info.csv";
CSRankings.countryinfoFile = "/country-info.csv";
CSRankings.aliasFile = "/dblp-aliases.csv";
CSRankings.homepagesFile = "/homepages.csv";
CSRankings.scholarFile = "/scholar.csv";
CSRankings.allowRankingChange = false; /* Can we change the kind of rankings being used? */
CSRankings.parentMap = { 'aaai': 'ai',
'ijcai': 'ai',
'cvpr': 'vision',
'eccv': 'vision',
'iccv': 'vision'
};
CSRankings.childMap = { 'ai': ['aaai', 'ijcai'],
'vision': ['cvpr', 'eccv', 'iccv'] };
CSRankings.areaMap = [{ area: "ai", title: "AI" },
// { area : "aaai", title : "AI" },
// { area : "ijcai", title : "AI" },
{ area: "vision", title: "Vision" },
// { area : "cvpr", title : "Vision" },
// { area : "eccv", title : "Vision" },
// { area : "iccv", title : "Vision" },
{ area: "mlmining", title: "ML" },
{ area: "nlp", title: "NLP" },
{ area: "ir", title: "Web & IR" },
{ area: "arch", title: "Arch" },
{ area: "comm", title: "Networks" },
{ area: "sec", title: "Security" },
{ area: "mod", title: "DB" },
{ area: "hpc", title: "HPC" },
{ area: "mobile", title: "Mobile" },
{ area: "metrics", title: "Metrics" },
{ area: "ops", title: "OS" },
{ area: "plan", title: "PL" },
{ area: "soft", title: "SE" },
{ area: "act", title: "Theory" },
{ area: "crypt", title: "Crypto" },
{ area: "log", title: "Logic" },
{ area: "graph", title: "Graphics" },
{ area: "chi", title: "HCI" },
{ area: "robotics", title: "Robotics" },
{ area: "bio", title: "Comp. Biology" },
{ area: "da", title: "EDA" },
{ area: "bed", title: "Embedded" },
{ area: "vis", title: "Visualization" },
{ area: "ecom", title: "ECom" }
//,{ area : "cse", title : "CSEd" }
];
CSRankings.aiAreas = ["ai", "vision", "mlmining", "nlp", "ir"];
CSRankings.systemsAreas = ["arch", "comm", "sec", "mod", "hpc", "mobile", "metrics", "ops", "plan", "soft", "da", "bed"];
CSRankings.theoryAreas = ["act", "crypt", "log"];