@@ -117,7 +117,7 @@ export class RecRecRecommenderView extends LitElement {
117
117
paperCitingAuthorCountMap : Map < string , Map < string , number > > ;
118
118
paperCitingAuthorCountSumMap : Map < string , number > ;
119
119
120
- authorPaperCiteTimesMap : Map < string , Map < string , number > > ;
120
+ authorPaperCiteTimesMap : Map < string , Map < string , [ string , number ] > > ;
121
121
authorPaperCiteTimesSumMap : Map < string , number > ;
122
122
123
123
myCollaborators : Set < string > ;
@@ -189,7 +189,7 @@ export class RecRecRecommenderView extends LitElement {
189
189
descriptionOverlayElement : HTMLElement | undefined ;
190
190
191
191
@state ( )
192
- overlayPaperCounts : [ string , number ] [ ] ;
192
+ overlayPaperCounts : [ string , number , string ] [ ] ;
193
193
194
194
@state ( )
195
195
overlayPaperCountsType : 'citeTimes' | 'paperCount' = 'citeTimes' ;
@@ -216,7 +216,10 @@ export class RecRecRecommenderView extends LitElement {
216
216
this . paperCitingAuthorCountMap = new Map < string , Map < string , number > > ( ) ;
217
217
this . paperCitingAuthorCountSumMap = new Map < string , number > ( ) ;
218
218
219
- this . authorPaperCiteTimesMap = new Map < string , Map < string , number > > ( ) ;
219
+ this . authorPaperCiteTimesMap = new Map <
220
+ string ,
221
+ Map < string , [ string , number ] >
222
+ > ( ) ;
220
223
this . authorPaperCiteTimesSumMap = new Map < string , number > ( ) ;
221
224
222
225
this . myCollaborators = new Set < string > ( ) ;
@@ -232,7 +235,12 @@ export class RecRecRecommenderView extends LitElement {
232
235
/**
233
236
* This method is called when the DOM is added for the first time
234
237
*/
235
- firstUpdated ( ) { }
238
+ firstUpdated ( ) {
239
+ // Cancel the overlay when user clicks any external area
240
+ document . addEventListener ( 'click' , ( ) => {
241
+ this . citeTimeBlurred ( ) ;
242
+ } ) ;
243
+ }
236
244
237
245
/**
238
246
* This method is called before new DOM is updated and rendered
@@ -248,7 +256,10 @@ export class RecRecRecommenderView extends LitElement {
248
256
this . allAuthors = new Map < string , Recommender > ( ) ;
249
257
this . paperCitingAuthorCountSumMap = new Map < string , number > ( ) ;
250
258
this . paperCitingAuthorCountMap = new Map < string , Map < string , number > > ( ) ;
251
- this . authorPaperCiteTimesMap = new Map < string , Map < string , number > > ( ) ;
259
+ this . authorPaperCiteTimesMap = new Map <
260
+ string ,
261
+ Map < string , [ string , number ] >
262
+ > ( ) ;
252
263
this . authorPaperCiteTimesSumMap = new Map < string , number > ( ) ;
253
264
this . myCollaborators = new Set < string > ( ) ;
254
265
@@ -373,7 +384,10 @@ export class RecRecRecommenderView extends LitElement {
373
384
const paperCitingAuthorCountSumMap = new Map < string , number > ( ) ;
374
385
375
386
// Map author id => Map <paper (author's paper), number of times that paper cites my work>
376
- const authorPaperCiteTimesMap = new Map < string , Map < string , number > > ( ) ;
387
+ const authorPaperCiteTimesMap = new Map <
388
+ string ,
389
+ Map < string , [ string , number ] >
390
+ > ( ) ;
377
391
const paperCiteTimesMap = new Map < string , number > ( ) ;
378
392
const authorPaperMap = new Map < string , Set < string > > ( ) ;
379
393
const paperIDMap = new Map < string , string > ( ) ;
@@ -458,10 +472,13 @@ export class RecRecRecommenderView extends LitElement {
458
472
// Resolve the author => <author's paper title, citing times> map
459
473
for ( const author of authorPaperMap . keys ( ) ) {
460
474
const papers = authorPaperMap . get ( author ) ! ;
461
- const curPaperCiteTimesMap = new Map < string , number > ( ) ;
475
+ const curPaperCiteTimesMap = new Map < string , [ string , number ] > ( ) ;
462
476
for ( const paper of papers ) {
463
477
const paperTitle = paperIDMap . get ( paper ) ! ;
464
- curPaperCiteTimesMap . set ( paperTitle , paperCiteTimesMap . get ( paper ) ! ) ;
478
+ curPaperCiteTimesMap . set ( paperTitle , [
479
+ paper ,
480
+ paperCiteTimesMap . get ( paper ) !
481
+ ] ) ;
465
482
}
466
483
authorPaperCiteTimesMap . set ( author , curPaperCiteTimesMap ) ;
467
484
@@ -776,6 +793,8 @@ export class RecRecRecommenderView extends LitElement {
776
793
e . stopPropagation ( ) ;
777
794
e . preventDefault ( ) ;
778
795
796
+ this . citeTimeBlurred ( ) ;
797
+
779
798
if ( ! this . paperOverlayElement ) {
780
799
console . error ( 'paperOverlayElement are not initialized yet.' ) ;
781
800
return ;
@@ -919,12 +938,12 @@ export class RecRecRecommenderView extends LitElement {
919
938
// Private Helpers ||
920
939
//==========================================================================||
921
940
getPaperCiteCounts ( authorID : string ) {
922
- const paperCounts : [ string , number ] [ ] = [ ] ;
941
+ const paperCounts : [ string , number , string ] [ ] = [ ] ;
923
942
924
943
for ( const paper of this . papers ) {
925
944
const countMap = this . paperCitingAuthorCountMap . get ( paper . paperId ) ;
926
945
if ( countMap !== undefined && countMap . has ( authorID ) ) {
927
- paperCounts . push ( [ paper . title , countMap . get ( authorID ) ! ] ) ;
946
+ paperCounts . push ( [ paper . title , countMap . get ( authorID ) ! , paper . paperId ] ) ;
928
947
}
929
948
}
930
949
@@ -935,16 +954,16 @@ export class RecRecRecommenderView extends LitElement {
935
954
}
936
955
937
956
getPaperCounts ( authorID : string ) {
938
- const paperCounts : [ string , number ] [ ] = [ ] ;
957
+ const paperCounts : [ string , number , string ] [ ] = [ ] ;
939
958
940
959
const paperMap = this . authorPaperCiteTimesMap . get ( authorID ) ;
941
960
if ( paperMap === undefined ) {
942
961
console . error ( `Can't find author ${ authorID } ` ) ;
943
962
throw Error ( `Can't find author ${ authorID } ` ) ;
944
963
}
945
964
946
- for ( const [ paper , count ] of paperMap . entries ( ) ) {
947
- paperCounts . push ( [ paper , count ] ) ;
965
+ for ( const [ paper , info ] of paperMap . entries ( ) ) {
966
+ paperCounts . push ( [ paper , info [ 1 ] , info [ 0 ] ] ) ;
948
967
}
949
968
950
969
// Sort the papers by the cite times
@@ -998,7 +1017,6 @@ export class RecRecRecommenderView extends LitElement {
998
1017
@touchstart = ${ ( e : TouchEvent ) => {
999
1018
e . stopPropagation ( ) ;
1000
1019
} }
1001
- @blur = ${ ( ) => this . citeTimeBlurred ( ) }
1002
1020
>
1003
1021
<span class= "svg-icon" > ${ unsafeHTML ( iconFile ) } </ span>
1004
1022
${ recommender . paperCount }
@@ -1017,7 +1035,6 @@ export class RecRecRecommenderView extends LitElement {
1017
1035
@touchstart = ${ ( e : TouchEvent ) => {
1018
1036
e . stopPropagation ( ) ;
1019
1037
} }
1020
- @blur = ${ ( ) => this . citeTimeBlurred ( ) }
1021
1038
>
1022
1039
<span class= "svg-icon" > ${ unsafeHTML ( iconCiteTimes ) } </ span>
1023
1040
${ recommender . citeTimes }
@@ -1074,9 +1091,14 @@ export class RecRecRecommenderView extends LitElement {
1074
1091
1075
1092
// Compile the paper overlay
1076
1093
let paperOverlayContent = html `` ;
1077
- for ( const [ paper , count ] of this . overlayPaperCounts ) {
1094
+ for ( const [ paper , count , paperID ] of this . overlayPaperCounts ) {
1078
1095
paperOverlayContent = html `${ paperOverlayContent }
1079
- <div class= "cell-paper" > ${ paper } </ div>
1096
+ <a
1097
+ class= "cell-paper"
1098
+ target = "_blank"
1099
+ href= ${ `https://www.semanticscholar.org/paper/${ paperID } ` }
1100
+ > ${ paper } </ a
1101
+ >
1080
1102
<div class= "cell-count" > ${ count } x </ div> ` ;
1081
1103
}
1082
1104
@@ -1246,7 +1268,14 @@ export class RecRecRecommenderView extends LitElement {
1246
1268
</ div>
1247
1269
</ div>
1248
1270
1249
- <div id= "paper-overlay" class = "popper- to oltip hidden" role= "to oltip">
1271
+ <div
1272
+ id= "paper-overlay"
1273
+ class = "popper- to oltip hidden"
1274
+ role= "to oltip"
1275
+ @click = ${ ( e : MouseEvent ) => {
1276
+ e . stopPropagation ( ) ;
1277
+ } }
1278
+ >
1250
1279
<div class= "popper-content" >
1251
1280
<div class= "table-title" >
1252
1281
<span
0 commit comments