From 9accd9bff7958059430ca7b726585ad02e78895a Mon Sep 17 00:00:00 2001 From: Emery Berger Date: Fri, 1 Jan 2021 15:48:57 -0500 Subject: [PATCH] Added use of geolocation API. --- Makefile | 6 +- continents.js | 44 +++++++++++ continents.ts | 50 ++++++++++++ csrankings.js | 23 +++++- csrankings.min.js | 152 +++++++++++++++++++------------------ csrankings.ts | 25 +++++- index.html | 1 + tsconfig.json | 3 +- typescript/continents.d.ts | 8 ++ 9 files changed, 234 insertions(+), 78 deletions(-) create mode 100644 continents.js create mode 100644 continents.ts create mode 100644 typescript/continents.d.ts diff --git a/Makefile b/Makefile index f5e86ac697..4f273681d4 100644 --- a/Makefile +++ b/Makefile @@ -17,12 +17,12 @@ all: generated-author-info.csv csrankings.js csrankings.min.js # fix-affiliation clean: rm $(TARGETS) -csrankings.js: csrankings.ts +csrankings.js: csrankings.ts continents.ts @echo "Rebuilding JavaScript code." tsc --project tsconfig.json -csrankings.min.js: csrankings.js - closure-compiler --js csrankings.js > csrankings.min.js +csrankings.min.js: csrankings.js csrankings.ts + google-closure-compiler --js csrankings.js > csrankings.min.js update-dblp: $(MAKE) download-dblp diff --git a/continents.js b/continents.js new file mode 100644 index 0000000000..b02907c27e --- /dev/null +++ b/continents.js @@ -0,0 +1,44 @@ +function whichContinent(latitude, longitude) { + const point = [longitude, latitude]; + for (const cont in continents) { + if (inPolygon(point, pathToList(continents[cont]))) { + return cont; + } + } + return "unknown"; +} +// Adapted from https://stackoverflow.com/questions/13905646/get-the-continent-given-the-latitude-and-longitude +// Rough shape of continents. +const continents = { + "northamerica": { latitude: [90, 90, 78.13, 57.5, 15, 15, 1.25, 1.25, 51, 60, 60, 51, 51, 60], longitude: [-168.75, -10, -10, -37.5, -30, -75, -82.5, -105, -180, -180, -168.75, 166.6, 180, 180] }, + "asia": { latitude: [90, 42.5, 42.5, 40.79, 41, 40.55, 40.4, 40.05, 39.17, 35.46, 33, 31.74, 29.54, 27.78, 11.3, 12.5, -60, -60, -31.88, -11.88, -10.27, 33.13, 51, 60, 90, 90, 90, 60, 60], longitude: [77.5, 48.8, 30, 28.81, 29, 27.31, 26.75, 26.36, 25.19, 27.91, 27.5, 34.58, 34.92, 34.46, 44.3, 52, 75, 110, 110, 110, 140, 140, 166.6, 180, 180, -180, -168.75, -168.75, -180] }, + "europe": { latitude: [90, 90, 42.5, 42.5, 40.79, 41, 40.55, 40.40, 40.05, 39.17, 35.46, 33, 38, 35.42, 28.25, 15, 57.5, 78.13], longitude: [-10, 77.5, 48.8, 30, 28.81, 29, 27.31, 26.75, 26.36, 25.19, 27.91, 27.5, 10, -10, -13, -30, -37.5, -10] }, + "australia": { latitude: [-11.88, -10.27, -10, -30, -52.5, -31.88], longitude: [110, 140, 145, 161.25, 142.5, 110] }, + "southamerica": { latitude: [1.25, 1.25, 15, 15, -60, -60], longitude: [-105, -82.5, -75, -30, -30, -105] }, + "africa": { latitude: [15, 28.25, 35.42, 38, 33, 31.74, 29.54, 27.78, 11.3, 12.5, -60, -60], longitude: [-30, -13, -10, 10, 27.5, 34.58, 34.92, 34.46, 44.3, 52, 75, -30] }, + // "asia2" : { latitude: [90, 90, 60, 60], longitude: [-180, -168.75, -168.75, -180] }, + // "northAmerica2" : { latitude: [51, 51, 60], longitude: [166.6, 180, 180] }, + "antarctica": { latitude: [-60, -60, -90, -90], longitude: [-180, 180, 180, -180] } +}; +function inPolygon(point, vs) { + // ray-casting algorithm based on + // https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html/pnpoly.html + let x = point[0], y = point[1]; + let inside = false; + for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) { + let xi = vs[i][0], yi = vs[i][1]; + let xj = vs[j][0], yj = vs[j][1]; + let intersect = ((yi > y) != (yj > y)) + && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); + if (intersect) + inside = !inside; + } + return inside; +} +function pathToList(path) { + let l = []; + for (let i = 0; i < path["longitude"].length; i++) { + l.push([path["longitude"][i], path["latitude"][i]]); + } + return l; +} diff --git a/continents.ts b/continents.ts new file mode 100644 index 0000000000..4687964aa7 --- /dev/null +++ b/continents.ts @@ -0,0 +1,50 @@ +function whichContinent(latitude: number, longitude: number) : string { + const point = [longitude, latitude]; + for (const cont in continents) { + if (inPolygon(point, pathToList(continents[cont]))) { + return cont; + } + } + return "unknown"; +} + +// Adapted from https://stackoverflow.com/questions/13905646/get-the-continent-given-the-latitude-and-longitude +// Rough shape of continents. +const continents : any = { + "northamerica" : { latitude: [90, 90, 78.13, 57.5, 15, 15, 1.25, 1.25, 51, 60, 60, 51, 51, 60], longitude: [-168.75, -10, -10, -37.5, -30, -75, -82.5, -105, -180, -180, -168.75, 166.6, 180, 180] }, + "asia" : { latitude: [90, 42.5, 42.5, 40.79, 41, 40.55, 40.4, 40.05, 39.17, 35.46, 33, 31.74, 29.54, 27.78, 11.3, 12.5, -60, -60, -31.88, -11.88, -10.27, 33.13, 51, 60, 90, 90, 90, 60, 60], longitude: [77.5, 48.8, 30, 28.81, 29, 27.31, 26.75, 26.36, 25.19, 27.91, 27.5, 34.58, 34.92, 34.46, 44.3, 52, 75, 110, 110, 110, 140, 140, 166.6, 180, 180, -180, -168.75, -168.75, -180] }, + "europe" : { latitude: [90, 90, 42.5, 42.5, 40.79, 41, 40.55, 40.40, 40.05, 39.17, 35.46, 33, 38, 35.42, 28.25, 15, 57.5, 78.13],longitude: [-10, 77.5, 48.8, 30, 28.81, 29, 27.31, 26.75, 26.36, 25.19, 27.91, 27.5, 10, -10, -13, -30, -37.5, -10] }, + "australia" : { latitude: [-11.88, -10.27, -10, -30, -52.5, -31.88], longitude: [110, 140, 145, 161.25, 142.5, 110] }, + "southamerica" : { latitude: [1.25, 1.25, 15, 15, -60, -60], longitude: [-105, -82.5, -75, -30, -30, -105] }, + "africa" : { latitude: [15, 28.25, 35.42, 38, 33, 31.74, 29.54, 27.78, 11.3, 12.5, -60, -60], longitude: [-30, -13, -10, 10, 27.5, 34.58, 34.92, 34.46, 44.3, 52, 75, -30] }, + // "asia2" : { latitude: [90, 90, 60, 60], longitude: [-180, -168.75, -168.75, -180] }, + // "northAmerica2" : { latitude: [51, 51, 60], longitude: [166.6, 180, 180] }, + "antarctica" : { latitude: [-60, -60, -90, -90],longitude: [-180, 180, 180, -180] } +}; + +function inPolygon(point : Array, vs : Array>) { + // ray-casting algorithm based on + // https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html/pnpoly.html + let x = point[0], y = point[1]; + + let inside = false; + for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) { + let xi = vs[i][0], yi = vs[i][1]; + let xj = vs[j][0], yj = vs[j][1]; + + let intersect = ((yi > y) != (yj > y)) + && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); + if (intersect) inside = !inside; + } + + return inside; +} + +function pathToList(path : any) { + let l = []; + for (let i = 0; i < path["longitude"].length; i++) { + l.push([path["longitude"][i], path["latitude"][i]]); + } + return l; +} + diff --git a/csrankings.js b/csrankings.js index c10c51d995..8bcce7a71b 100644 --- a/csrankings.js +++ b/csrankings.js @@ -19,6 +19,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge /// /// /// +/// ; ; ; @@ -250,7 +251,7 @@ class CSRankings { this.countAuthorAreas(); yield this.loadCountryInfo(this.countryInfo); this.addListeners(); - /* CSRankings.geoCheck(); */ + CSRankings.geoCheck(); this.rank(); }))(); } @@ -1311,6 +1312,26 @@ class CSRankings { } return start; } + static geoCheck() { + navigator.geolocation.getCurrentPosition((position) => { + const continent = whichContinent(position.coords.latitude, position.coords.longitude); + let regions = document.getElementById("regions"); + switch (continent) { + case "northamerica": + return; + case "europe": + case "asia": + case "southamerica": + case "africa": + regions.value = continent; + break; + default: + regions.value = "world"; + break; + } + CSRankings.getInstance().rank(); + }); + } /* public static geoCheck(): void { // Figure out which country clients are coming from and set diff --git a/csrankings.min.js b/csrankings.min.js index 1aea60a715..715680ca81 100644 --- a/csrankings.min.js +++ b/csrankings.min.js @@ -1,34 +1,40 @@ -var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,d){a!=Array.prototype&&a!=Object.prototype&&(a[b]=d.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_"; -$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var a=0;return function(b){return $jscomp.SYMBOL_PREFIX+(b||"")+a++}}(); -$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var b=0;return $jscomp.iteratorPrototype(function(){return ba||1342177279>>=1)b+=b;return c}},"es6","es3");$jscomp.polyfill("Math.log10",function(a){return a?a:function(a){return Math.log(a)/Math.LN10}},"es6","es3"); -var __awaiter=this&&this.__awaiter||function(a,b,d,c){function e(a){return a instanceof d?a:new d(function(b){b(a)})}return new (d||(d=Promise))(function(d,g){function f(a){try{h(c.next(a))}catch(n){g(n)}}function l(a){try{h(c["throw"](a))}catch(n){g(n)}}function h(a){a.done?d(a.value):e(a.value).then(f,l)}h((c=c.apply(a,b||[])).next())})},CSRankings=function(){var a=this;this.note={};this.authorFile="./csrankings.csv";this.authorinfoFile="./generated-author-info.csv";this.countryinfoFile="./country-info.csv"; +$jscomp.generator.Generator_=function(a){this.next=function(b){return a.next_(b)};this.throw=function(b){return a.throw_(b)};this.return=function(b){return a.return_(b)};this[Symbol.iterator]=function(){return this}};$jscomp.generator.createGenerator=function(a,b){b=new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(b));$jscomp.setPrototypeOf&&a.prototype&&$jscomp.setPrototypeOf(b,a.prototype);return b};$jscomp.initSymbol=function(){}; +$jscomp.polyfill("Symbol",function(a){if(a)return a;var b=function(d,h){this.$jscomp$symbol$id_=d;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:h})};b.prototype.toString=function(){return this.$jscomp$symbol$id_};var c=0,e=function(d){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new b("jscomp_symbol_"+(d||"")+"_"+c++,d)};return e},"es6","es3"); +$jscomp.polyfill("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;cb||1342177279>>=1)c+=c;return e}},"es6","es3");$jscomp.polyfill("Math.log10",function(a){return a?a:function(b){return Math.log(b)/Math.LN10}},"es6","es3"); +var __awaiter=this&&this.__awaiter||function(a,b,c,e){function d(h){return h instanceof c?h:new c(function(f){f(h)})}return new (c||(c=Promise))(function(h,f){function g(m){try{l(e.next(m))}catch(p){f(p)}}function k(m){try{l(e["throw"](m))}catch(p){f(p)}}function l(m){m.done?h(m.value):d(m.value).then(g,k)}l((e=e.apply(a,b||[])).next())})},CSRankings=function(){var a=this;this.note={};this.authorFile="./csrankings.csv";this.authorinfoFile="./generated-author-info.csv";this.countryinfoFile="./country-info.csv"; this.turingFile="./turing.csv";this.turingImage="./png/acm-turing-award.png";this.acmfellowFile="./acm-fellows.csv";this.acmfellowImage="./png/acm.png";this.homepageImage="./house-logo.png";this.allowRankingChange=!1;this.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:"icml",title:"ML"},{area:"kdd",title:"ML"}, {area:"nips",title:"ML"},{area:"nlp",title:"NLP"},{area:"acl",title:"NLP"},{area:"emnlp",title:"NLP"},{area:"naacl",title:"NLP"},{area:"ir",title:"Web+IR"},{area:"sigir",title:"Web+IR"},{area:"www",title:"Web+IR"},{area:"arch",title:"Arch"},{area:"asplos",title:"Arch"},{area:"isca",title:"Arch"},{area:"micro",title:"Arch"},{area:"hpca",title:"Arch"},{area:"comm",title:"Networks"},{area:"sigcomm",title:"Networks"},{area:"nsdi",title:"Networks"},{area:"sec",title:"Security"},{area:"ccs",title:"Security"}, {area:"oakland",title:"Security"},{area:"usenixsec",title:"Security"},{area:"ndss",title:"Security"},{area:"pets",title:"Security"},{area:"mod",title:"DB"},{area:"sigmod",title:"DB"},{area:"vldb",title:"DB"},{area:"icde",title:"DB"},{area:"pods",title:"DB"},{area:"hpc",title:"HPC"},{area:"sc",title:"HPC"},{area:"hpdc",title:"HPC"},{area:"ics",title:"HPC"},{area:"mobile",title:"Mobile"},{area:"mobicom",title:"Mobile"},{area:"mobisys",title:"Mobile"},{area:"sensys",title:"Mobile"},{area:"metrics",title:"Metrics"}, @@ -37,60 +43,62 @@ this.turingFile="./turing.csv";this.turingImage="./png/acm-turing-award.png";thi {area:"icra",title:"Robotics"},{area:"iros",title:"Robotics"},{area:"rss",title:"Robotics"},{area:"bio",title:"Comp. Bio"},{area:"ismb",title:"Comp. Bio"},{area:"recomb",title:"Comp. Bio"},{area:"da",title:"EDA"},{area:"dac",title:"EDA"},{area:"iccad",title:"EDA"},{area:"bed",title:"Embedded"},{area:"emsoft",title:"Embedded"},{area:"rtas",title:"Embedded"},{area:"rtss",title:"Embedded"},{area:"visualization",title:"Visualization"},{area:"vis",title:"Visualization"},{area:"vr",title:"Visualization"}, {area:"ecom",title:"ECom"},{area:"ec",title:"ECom"},{area:"wine",title:"ECom"}];this.aiAreas=["ai","vision","mlmining","nlp","ir"];this.systemsAreas="arch comm sec mod hpc mobile metrics ops plan soft da bed".split(" ");this.theoryAreas=["act","crypt","log"];this.interdisciplinaryAreas="graph chi robotics bio visualization ecom".split(" ");this.areaNames=[];this.fields=[];this.aiFields=[];this.systemsFields=[];this.theoryFields=[];this.otherFields=[];this.areaDict={};this.areaPosition={};this.scholarInfo= {};this.aliases={};this.turing={};this.acmfellow={};this.countryInfo={};this.homepages={};this.useDenseRankings=!1;this.authors=[];this.dblpAuthors={};this.authorAreas={};this.stats={};this.areaDeptAdjustedCount={};this.areaStringMap={};this.color="#f30000 #0600f3 #00b109 #14e4b4 #0fe7fb #67f200 #ff7e00 #8fe4fa #ff5300 #640000 #3854d1 #d00ed8 #7890ff #01664d #04231b #e9f117 #f3228e #7ce8ca #ff5300 #ff5300 #7eff30 #9a8cf6 #79aff9 #bfbfbf #56b510 #00e2f6 #ff4141 #61ff41".split(" ");this.RightTriangle= -"►";this.DownTriangle="▼";this.PieChart="closed piechart";this.OpenPieChart="opened piechart";CSRankings.theInstance=this;this.navigoRouter=new Navigo(null,!0);for(var b=0;b=CSRankings.minToRank?(a=a.scrollTop,CSRankings.minToRank=5E3,CSRankings.getInstance().rank(),a):0}; -CSRankings.getInstance=function(){return CSRankings.theInstance};CSRankings.promise=function(a){"undefined"!==typeof Promise?Promise.resolve().then(a):setTimeout(a,0)}; +"►";this.DownTriangle="▼";this.PieChart="closed piechart";this.OpenPieChart="opened piechart";CSRankings.theInstance=this;this.navigoRouter=new Navigo(null,!0);for(var b=0;b=CSRankings.minToRank?(a=a.scrollTop,CSRankings.minToRank=5E3,CSRankings.getInstance().rank(),a):0};CSRankings.getInstance=function(){return CSRankings.theInstance};CSRankings.promise=function(a){"undefined"!==typeof Promise?Promise.resolve().then(a):setTimeout(a,0)}; CSRankings.prototype.translateNameToDBLP=function(a){a=a.replace(/ Jr\./g,"_Jr.");a=a.replace(/ II/g,"_II");a=a.replace(/ III/g,"_III");a=a.replace(/'|\-|\./g,"=");a=a.replace(/\u00c1/g,"=Aacute=");a=a.replace(/\u00e1/g,"=aacute=");a=a.replace(/\u00e8/g,"=egrave=");a=a.replace(/\u00e9/g,"=eacute=");a=a.replace(/\u00ed/g,"=iacute=");a=a.replace(/\u00ef/g,"=iuml=");a=a.replace(/\u00f3/g,"=oacute=");a=a.replace(/\u00c7/g,"=Ccedil=");a=a.replace(/\u00e7/g,"=ccedil=");a=a.replace(/\u00e4/g,"=auml=");a= -a.replace(/\u00f6/g,"=ouml=");a=a.replace(/\u00f8/g,"=oslash=");a=a.replace(/\u00d6/g,"=Ouml=");a=a.replace(/\u00dc/g,"=Uuml=");a=a.replace(/\u00fc/g,"=uuml=");a=a.replace(/\u00df/g,"=szlig=");a=a.split(" ");var b=a[a.length-1];0'}; -CSRankings.sum=function(a){for(var b=0,d=0;dc?b[e]:c);e=[];for(var f in b)e.push(b[f]);f=CSRankings.sum(e);d=0;1=c-d&&.2<=1*b[g]/f&&1b?1:0}; -CSRankings.prototype.makeChart=function(a){var b=[],d={},c=CSRankings.topTierAreas,e=unescape(a),f;for(f in c){if(!(e in this.authorAreas))return;c=this.authorAreas[e][f];c=Math.round(10*c)/10;0
'}; +CSRankings.sum=function(a){for(var b=0,c=0;ce?b[d]:e);d=[];for(var h in b)d.push(b[h]);h=CSRankings.sum(d);c=0;1=e-c&&.2<=1*b[f]/h&&1b?1:0}; +CSRankings.prototype.makeChart=function(a){var b=[],c={},e=CSRankings.topTierAreas,d=unescape(a),h;for(h in e){if(!(d in this.authorAreas))return;e=this.authorAreas[d][h];e=Math.round(10*e)/10;0"+c+""):b+(""+c+"");b+="
";d+=1});document.querySelector("#progress").innerHTML=b}; -CSRankings.prototype.loadTuring=function(a){return __awaiter(this,void 0,void 0,function d(){var c=this,e,f,g,k,l,h;return $jscomp.generator.createGenerator(d,function(d){if(1==d.nextAddress)return e=c,d.yield(new Promise(function(a){Papa.parse(e.turingFile,{header:!0,download:!0,complete:function(c){a(c.data)}})}),2);g=f=d.yieldResult;k=$jscomp.makeIterator(g);for(l=k.next();!l.done;l=k.next())h=l.value,a[h.name]=h.year;d.jumpToEnd()})})}; -CSRankings.prototype.loadACMFellow=function(a){return __awaiter(this,void 0,void 0,function d(){var c=this,e,f,g,k,l,h;return $jscomp.generator.createGenerator(d,function(d){if(1==d.nextAddress)return e=c,d.yield(new Promise(function(a){Papa.parse(e.acmfellowFile,{header:!0,download:!0,complete:function(c){a(c.data)}})}),2);g=f=d.yieldResult;k=$jscomp.makeIterator(g);for(l=k.next();!l.done;l=k.next())h=l.value,a[h.name]=h.year;d.jumpToEnd()})})}; -CSRankings.prototype.loadCountryInfo=function(a){return __awaiter(this,void 0,void 0,function d(){var c=this,e,f,g,k,l,h;return $jscomp.generator.createGenerator(d,function(d){if(1==d.nextAddress)return e=c,d.yield(new Promise(function(a){Papa.parse(e.countryinfoFile,{header:!0,download:!0,complete:function(c){a(c.data)}})}),2);g=f=d.yieldResult;k=$jscomp.makeIterator(g);for(l=k.next();!l.done;l=k.next())h=l.value,a[h.institution]=h.region;d.jumpToEnd()})})}; -CSRankings.prototype.loadAuthorInfo=function(){return __awaiter(this,void 0,void 0,function b(){var d=this,c,e,f,g,k,l,h;return $jscomp.generator.createGenerator(b,function(b){if(1==b.nextAddress)return c=d,b.yield(new Promise(function(b){Papa.parse(c.authorFile,{download:!0,header:!0,complete:function(c){b(c.data)}})}),2);f=e=b.yieldResult;for(g=0;g"+e+""):b+(""+e+"");b+="
";c+=1});document.querySelector("#progress").innerHTML=b}; +CSRankings.prototype.loadTuring=function(a){return __awaiter(this,void 0,void 0,function c(){var e=this,d,h,f,g,k,l;return $jscomp.generator.createGenerator(c,function(m){if(1==m.nextAddress)return d=e,m.yield(new Promise(function(p){Papa.parse(d.turingFile,{header:!0,download:!0,complete:function(n){p(n.data)}})}),2);f=h=m.yieldResult;g=$jscomp.makeIterator(f);for(k=g.next();!k.done;k=g.next())l=k.value,a[l.name]=l.year;m.jumpToEnd()})})}; +CSRankings.prototype.loadACMFellow=function(a){return __awaiter(this,void 0,void 0,function c(){var e=this,d,h,f,g,k,l;return $jscomp.generator.createGenerator(c,function(m){if(1==m.nextAddress)return d=e,m.yield(new Promise(function(p){Papa.parse(d.acmfellowFile,{header:!0,download:!0,complete:function(n){p(n.data)}})}),2);f=h=m.yieldResult;g=$jscomp.makeIterator(f);for(k=g.next();!k.done;k=g.next())l=k.value,a[l.name]=l.year;m.jumpToEnd()})})}; +CSRankings.prototype.loadCountryInfo=function(a){return __awaiter(this,void 0,void 0,function c(){var e=this,d,h,f,g,k,l;return $jscomp.generator.createGenerator(c,function(m){if(1==m.nextAddress)return d=e,m.yield(new Promise(function(p){Papa.parse(d.countryinfoFile,{header:!0,download:!0,complete:function(n){p(n.data)}})}),2);f=h=m.yieldResult;g=$jscomp.makeIterator(f);for(k=g.next();!k.done;k=g.next())l=k.value,a[l.institution]=l.region;m.jumpToEnd()})})}; +CSRankings.prototype.loadAuthorInfo=function(){return __awaiter(this,void 0,void 0,function b(){var c=this,e,d,h,f,g,k,l;return $jscomp.generator.createGenerator(b,function(m){if(1==m.nextAddress)return e=c,m.yield(new Promise(function(p){Papa.parse(e.authorFile,{download:!0,header:!0,complete:function(n){p(n.data)}})}),2);h=d=m.yieldResult;for(f=0;fb)){var f=this.authors[d];e=f.name;var g=f.dept;f=parseFloat(f.count);if(!(e in this.authorAreas)){this.authorAreas[e]={};for(var k in this.areaDict)this.areaDict.hasOwnProperty(k)&&(this.authorAreas[e][k]= -0)}if(!(g in this.authorAreas)){this.authorAreas[g]={};for(var l in this.areaDict)this.areaDict.hasOwnProperty(l)&&(this.authorAreas[g][l]=0)}this.authorAreas[e][c]+=f;this.authorAreas[g][c]+=f}}}}; -CSRankings.prototype.buildDepartments=function(a,b,d,c,e,f,g,k){var l={},h;for(h in this.authors)if(this.authors.hasOwnProperty(h)){var m=this.authors[h],n=m.dept;if(this.inRegion(n,c)){var p=m.area;if(0!==d[p]){var q=m.year;if(!(qb)&&"undefined"!==typeof n){m=m.name;p in CSRankings.parentMap&&(p=CSRankings.parentMap[p]);p+=n;p in this.areaDeptAdjustedCount||(this.areaDeptAdjustedCount[p]=0);q=parseInt(this.authors[h].count);var r=parseFloat(this.authors[h].adjustedcount);this.areaDeptAdjustedCount[p]+= -r;m in l||(l[m]=!0,g[m]=0,k[m]=0,n in e||(e[n]=0,f[n]=[]),f[n].push(m),e[n]+=1);g[m]+=q;k[m]+=r}}}}};CSRankings.prototype.computeStats=function(a,b,d){this.stats={};for(var c in a)if(a.hasOwnProperty(c)){this.stats[c]=1;for(var e in CSRankings.topLevelAreas){var f=e+c;f in this.areaDeptAdjustedCount||(this.areaDeptAdjustedCount[f]=0);0!=d[e]&&(this.stats[c]*=this.areaDeptAdjustedCount[f]+1)}this.stats[c]=Math.pow(this.stats[c],1/b)}}; -CSRankings.prototype.updateWeights=function(a){for(var b=0,d=0;dFaculty
';f.fc= -{};for(var l=$jscomp.makeIterator(a[g]),h=l.next();!h.done;h=l.next())h=h.value,f.fc[h]=b[h];l=Object.keys(f.fc);l.sort(function(a){return function(b,d){return a.fc[d]===a.fc[b]?c.compareNames(b,d):a.fc[d]-a.fc[b]}}(f));l=$jscomp.makeIterator(l);for(h=l.next();!h.done;h=l.next()){h=h.value;var m=encodeURI(this.homepages[h]),n=this.dblpAuthors[h];k+=''}k+="
  # Pubs Adj. #
    "+h+" ";this.note.hasOwnProperty(h)&&(k+='['+('')+this.note[h]+"] ");this.acmfellow.hasOwnProperty(h)&&(k+='ACM Fellow ');this.turing.hasOwnProperty(h)&&(k+='Turing Award ');k+=''+this.areaString(h).toLowerCase()+ -" ";k+='Home page ';this.scholarInfo.hasOwnProperty(h)&&"NOSCHOLARPAGE"!=this.scholarInfo[h]&&(m="https://scholar.google.com/citations?user="+this.scholarInfo[h]+"&hl=en&oi=ao",k+='Google Scholar '); -k+='";k+='DBLP';k+="';k+=""+this.PieChart+'"+f.fc[h]+''+(Math.round(10*d[h])/10).toFixed(1)+'
";e[g]=k}f={fc:f.fc}}return e}; -CSRankings.prototype.buildOutputString=function(a,b,d,c){var e=this.makePrologue();e=e+'#Institution'+" ".repeat(20)+'Count Faculty'; -e+="";if(0=c&&m!=g)break;if(0===m)break;g!=m&&(this.useDenseRankings?f+=1:(f+=a,a=0));g=escape(h);e+="\n"+f;e+=" ".repeat(4-Math.ceil(Math.log10(f)));e+="";e+=''+this.RightTriangle+"";e+=" "+ -h+' '+this.PieChart+"";e+="";e+=''+(Math.round(10*m)/10).toFixed(1)+"";e+=''+b[h];e+="";e+="\n";e+='
';e+='";a++;g=m}e+="
\n
"}else e= -"

Please select at least one area by clicking one or more checkboxes.

";return e};CSRankings.prototype.setAllOn=function(a){a=void 0===a?!0:a;for(var b=0;bthis.scrollHeight-50){var a=CSRankings.updateMinimum(this);a&&$("div").scrollTop(a)}});a?this.navigoRouter.resume():this.navigoRouter.pause();a=this.updatedURL();this.navigoRouter.navigate(a);m=performance.now();console.log("Rank took "+(m-b)+" milliseconds.");return!1}; -CSRankings.prototype.toggleChart=function(a){var b=document.getElementById(a+"-chart"),d=document.getElementById(a+"-chartwidget");"block"===b.style.display?(b.style.display="none",b.innerHTML="",d.innerHTML=this.PieChart):(b.style.display="block",this.makeChart(a),d.innerHTML=this.OpenPieChart)}; +CSRankings.prototype.activateFields=function(a,b){for(var c=0;cb)){var h=this.authors[c];d=h.name;var f=h.dept;h=parseFloat(h.count);if(!(d in this.authorAreas)){this.authorAreas[d]={};for(var g in this.areaDict)this.areaDict.hasOwnProperty(g)&&(this.authorAreas[d][g]= +0)}if(!(f in this.authorAreas)){this.authorAreas[f]={};for(var k in this.areaDict)this.areaDict.hasOwnProperty(k)&&(this.authorAreas[f][k]=0)}this.authorAreas[d][e]+=h;this.authorAreas[f][e]+=h}}}}; +CSRankings.prototype.buildDepartments=function(a,b,c,e,d,h,f,g){var k={},l;for(l in this.authors)if(this.authors.hasOwnProperty(l)){var m=this.authors[l],p=m.dept;if(this.inRegion(p,e)){var n=m.area;if(0!==c[n]){var q=m.year;if(!(qb)&&"undefined"!==typeof p){m=m.name;n in CSRankings.parentMap&&(n=CSRankings.parentMap[n]);n+=p;n in this.areaDeptAdjustedCount||(this.areaDeptAdjustedCount[n]=0);q=parseInt(this.authors[l].count);var r=parseFloat(this.authors[l].adjustedcount);this.areaDeptAdjustedCount[n]+= +r;m in k||(k[m]=!0,f[m]=0,g[m]=0,p in d||(d[p]=0,h[p]=[]),h[p].push(m),d[p]+=1);f[m]+=q;g[m]+=r}}}}};CSRankings.prototype.computeStats=function(a,b,c){this.stats={};for(var e in a)if(a.hasOwnProperty(e)){this.stats[e]=1;for(var d in CSRankings.topLevelAreas){var h=d+e;h in this.areaDeptAdjustedCount||(this.areaDeptAdjustedCount[h]=0);0!=c[d]&&(this.stats[e]*=this.areaDeptAdjustedCount[h]+1)}this.stats[e]=Math.pow(this.stats[e],1/b)}}; +CSRankings.prototype.updateWeights=function(a){for(var b=0,c=0;cFaculty  # Pubs Adj. #';h.$jscomp$loop$prop$fc$28= +{};for(var k=$jscomp.makeIterator(a[f]),l=k.next();!l.done;l=k.next())l=l.value,h.$jscomp$loop$prop$fc$28[l]=b[l];k=Object.keys(h.$jscomp$loop$prop$fc$28);k.sort(function(n){return function(q,r){return n.$jscomp$loop$prop$fc$28[r]===n.$jscomp$loop$prop$fc$28[q]?e.compareNames(q,r):n.$jscomp$loop$prop$fc$28[r]-n.$jscomp$loop$prop$fc$28[q]}}(h));k=$jscomp.makeIterator(k);for(l=k.next();!l.done;l=k.next()){l=l.value;var m=encodeURI(this.homepages[l]),p=this.dblpAuthors[l];g+='    "+l+" ";this.note.hasOwnProperty(l)&&(g+='[')+this.note[l]+"] ");this.acmfellow.hasOwnProperty(l)&&(g+='ACM Fellow ');this.turing.hasOwnProperty(l)&&(g+='Turing Award ');g+=''+ +this.areaString(l).toLowerCase()+" ";g+='Home page ';this.scholarInfo.hasOwnProperty(l)&&"NOSCHOLARPAGE"!=this.scholarInfo[l]&&(m="https://scholar.google.com/citations?user="+this.scholarInfo[l]+"&hl=en&oi=ao",g+='Google Scholar ');g+='";g+='DBLP';g+="');g+=""+this.PieChart+'"+h.$jscomp$loop$prop$fc$28[l]+''+(Math.round(10*c[l])/10).toFixed(1)+'
'}g+="";d[f]=g}h={$jscomp$loop$prop$fc$28:h.$jscomp$loop$prop$fc$28}}return d}; +CSRankings.prototype.buildOutputString=function(a,b,c,e){var d=this.makePrologue();d=d+'#Institution'+" ".repeat(20)+'Count Faculty'; +d+="";if(0=e&&m!=f)break;if(0===m)break;f!=m&&(this.useDenseRankings?h+=1:(h+=a,a=0));f=escape(l);d+="\n"+h;d+=" ".repeat(4-Math.ceil(Math.log10(h)));d+="";d+=''+this.RightTriangle+"";d+=" "+ +l+' '+this.PieChart+"";d+="";d+=''+(Math.round(10*m)/10).toFixed(1)+"";d+=''+b[l];d+="";d+="\n";d+='
';d+='";a++;f=m}d+="
\n
"}else d= +"

Please select at least one area by clicking one or more checkboxes.

";return d};CSRankings.prototype.setAllOn=function(a){a=void 0===a?!0:a;for(var b=0;bthis.scrollHeight-50){var p=CSRankings.updateMinimum(this);p&&$("div").scrollTop(p)}});a?this.navigoRouter.resume():this.navigoRouter.pause();a=this.updatedURL();this.navigoRouter.navigate(a);m=performance.now();console.log("Rank took "+(m-b)+" milliseconds.");return!1}; +CSRankings.prototype.toggleChart=function(a){var b=document.getElementById(a+"-chart"),c=document.getElementById(a+"-chartwidget");"block"===b.style.display?(b.style.display="none",b.innerHTML="",c.innerHTML=this.PieChart):(b.style.display="block",this.makeChart(a),c.innerHTML=this.OpenPieChart)}; CSRankings.prototype.toggleConferences=function(a){var b=document.getElementById(a+"-conferences");a=document.getElementById(a+"-widget");"block"===b.style.display?(b.style.display="none",a.innerHTML=this.RightTriangle):(b.style.display="block",a.innerHTML=this.DownTriangle)}; CSRankings.prototype.toggleFaculty=function(a){var b=document.getElementById(a+"-faculty");a=document.getElementById(a+"-widget");"block"===b.style.display?(b.style.display="none",a.innerHTML=this.RightTriangle):(b.style.display="block",a.innerHTML=this.DownTriangle)};CSRankings.prototype.activateAll=function(a){this.setAllOn(void 0===a?!0:a);this.rank();return!1};CSRankings.prototype.activateNone=function(){return this.activateAll(!1)}; CSRankings.prototype.activateSystems=function(a){return this.activateFields(void 0===a?!0:a,this.systemsFields)};CSRankings.prototype.activateAI=function(a){return this.activateFields(void 0===a?!0:a,this.aiFields)};CSRankings.prototype.activateTheory=function(a){return this.activateFields(void 0===a?!0:a,this.theoryFields)};CSRankings.prototype.activateOthers=function(a){return this.activateFields(void 0===a?!0:a,this.otherFields)};CSRankings.prototype.deactivateSystems=function(){return this.activateSystems(!1)}; CSRankings.prototype.deactivateAI=function(){return this.activateAI(!1)};CSRankings.prototype.deactivateTheory=function(){return this.activateTheory(!1)};CSRankings.prototype.deactivateOthers=function(){return this.activateOthers(!1)}; -CSRankings.prototype.updatedURL=function(){for(var a="",b=0,d=0,c={},e=0;e /// /// +/// declare function escape(s: string): string; declare function unescape(s: string): string; @@ -181,7 +182,7 @@ class CSRankings { this.countAuthorAreas(); await this.loadCountryInfo(this.countryInfo); this.addListeners(); - /* CSRankings.geoCheck(); */ + CSRankings.geoCheck(); this.rank(); })(); } @@ -1593,6 +1594,27 @@ class CSRankings { return start; } + public static geoCheck(): void { + navigator.geolocation.getCurrentPosition((position) => { + const continent = whichContinent(position.coords.latitude, position.coords.longitude); + let regions = ( document.getElementById("regions")); + switch (continent) { + case "northamerica": + return; + case "europe": + case "asia": + case "southamerica": + case "africa": + regions!.value = continent; + break; + default: + regions!.value = "world"; + break; + } + CSRankings.getInstance().rank(); + }); + } + /* public static geoCheck(): void { // Figure out which country clients are coming from and set @@ -1856,3 +1878,4 @@ class CSRankings { } var csr: CSRankings = new CSRankings(); + \ No newline at end of file diff --git a/index.html b/index.html index f4f79e862c..bca43828c0 100644 --- a/index.html +++ b/index.html @@ -203,6 +203,7 @@ + diff --git a/tsconfig.json b/tsconfig.json index f8b904bbd9..9ab84e31ae 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,5 +11,6 @@ "strictNullChecks": true, "pretty": true }, - "files": [ "csrankings.ts" ] + "files": [ "csrankings.ts", "continents.ts" ], + "moduleResolution": "node" } diff --git a/typescript/continents.d.ts b/typescript/continents.d.ts new file mode 100644 index 0000000000..4a435fdb87 --- /dev/null +++ b/typescript/continents.d.ts @@ -0,0 +1,8 @@ +export function whichContinent (latitude : number, longitude : number): string; + +// whichContinent = continents.whichContinent; + +declare module 'continents' { + export = whichContinent; +} +