From 9303d515b89e60cabe91d6bcc26a4131f305b6a0 Mon Sep 17 00:00:00 2001 From: fraklo Date: Mon, 31 Oct 2016 15:35:01 -0700 Subject: [PATCH] Append user email in mailto link --- js/stalk.js | 349 ++++++++++++++++++++++++++-------------------------- 1 file changed, 175 insertions(+), 174 deletions(-) diff --git a/js/stalk.js b/js/stalk.js index 5b3a75e..3a60a5d 100644 --- a/js/stalk.js +++ b/js/stalk.js @@ -7,237 +7,238 @@ var showInactive = false; var store = []; var descriptions = { - "year" : function(yr) { - if(yr != 0) { - return "class of " + (yr.length == 2 ? "20" + yr : yr); - } else { - return ""; - } - }, - "major" : "studies ", - "phone" : "phone: ", - "room" : function(rm) { - return (rm.match("^[N|C|M|K|A|B|C|D]{2}-[0-9]{3}$") ? "lives in " : "room: ") + rm - }, - "country" : "from " + "year" : function(yr) { + if(yr != 0) { + return "class of " + (yr.length == 2 ? "20" + yr : yr); + } else { + return ""; + } + }, + "major" : "studies ", + "phone" : "phone: ", + "room" : function(rm) { + return (rm.match("^[N|C|M|K|A|B|C|D]{2}-[0-9]{3}$") ? "lives in " : "room: ") + rm + }, + "country" : "from " } function loggedIn() { - if(c.user && c.user != "") { - $("#overlay").hide('slow'); - $('#search').focus(); - } + if(c.user && c.user != "") { + $("#overlay").hide('slow'); + $('#search').focus(); + } } function updateResults() { - console.log("Updating results..."); + console.log("Updating results..."); - timeout = null; - var spinId = setTimeout(blankOut, 500); - var query = $("#search").val(); + timeout = null; + var spinId = setTimeout(blankOut, 500); + var query = $("#search").val(); - try{ - window.history.pushState( {} , window.title, '/?q='+escape(query) ); - } catch(e){} + try{ + window.history.pushState( {} , window.title, '/?q='+escape(query) ); + } catch(e){} - if(!showInactive) { - query += " active: true"; - } + if(!showInactive) { + query += " active: true"; + } - c.search(query, [], 7000, 0, function(error, data) { - clearTimeout(spinId); - hideSpinner(); - $("#frame").empty(); + c.search(query, [], 7000, 0, function(error, data) { + clearTimeout(spinId); + hideSpinner(); + $("#frame").empty(); - if(!error) { - store = data.data; + if(!error) { + store = data.data; - store.map(function(e, idx) { - $("#frame") - .append($("") - .attr("src", e.picture) - .attr("id", e.username) + store.map(function(e, idx) { + $("#frame") + .append($("") + .attr("src", e.picture) + .attr("id", e.username) .on("error", function(){ $(this).attr("src", "/imgs/duck.jpg").off("error"); }) - ); - }); - - $("div#frame img").hover( - function() { // Hover in - makeHighlight(this.id); - } - ); - } - }); + ); + }); + + $("div#frame img").hover( + function() { // Hover in + makeHighlight(this.id); + } + ); + } + }); } function getUserData(uid) { - for (var i = store.length - 1; i >= 0; i--) { - if(store[i].username == uid) - return store[i]; - }; + for (var i = store.length - 1; i >= 0; i--) { + if(store[i].username == uid) + return store[i]; + }; } function makeHighlight(uid) { - // Kill the others - $("div.highlight").remove(); + // Kill the others + $("div.highlight").remove(); - var anchor = $(("img#" + uid)); + var anchor = $(("img#" + uid)); - var usr = getUserData(uid); + var usr = getUserData(uid); - var highlight = $("
") - .addClass("highlight") - .attr("data-uid", uid); + var highlight = $("
") + .addClass("highlight") + .attr("data-uid", uid); - switch(usr.college) { - case "Nordmetall": - highlight.addClass("c-n"); - break; + switch(usr.college) { + case "Nordmetall": + highlight.addClass("c-n"); + break; - case "C3": - highlight.addClass("c-3"); - break; + case "C3": + highlight.addClass("c-3"); + break; - case "Mercator": - highlight.addClass("c-m"); - break; + case "Mercator": + highlight.addClass("c-m"); + break; - case "Krupp": - highlight.addClass("c-k"); - break; + case "Krupp": + highlight.addClass("c-k"); + break; - default: - highlight.addClass("c-none"); - } + default: + highlight.addClass("c-none"); + } - var img = $("") - .attr("src", usr.picture) - .attr("data-uid", uid) + var img = $("") + .attr("src", usr.picture) + .attr("data-uid", uid) .on("error", function(){ $(this).attr("src", "/imgs/duck.jpg").off("error"); }); - highlight - .append(img) - .append($("").attr("src", usr.flag).attr("class", "flag").on("error", function(){ - $(this).attr("src", "/imgs/NoCountry.png").off("error"); + highlight + .append(img) + .append($("").attr("src", usr.flag).attr("class", "flag").on("error", function(){ + $(this).attr("src", "/imgs/NoCountry.png").off("error"); })) - .append(getHighlightDetails(usr)) - .css(getHighlightPosition(anchor)); + .append(getHighlightDetails(usr)) + .css(getHighlightPosition(anchor)); - highlight.hover( - function() {}, - function() { - this.remove(); - } - ); + highlight.hover( + function() {}, + function() { + this.remove(); + } + ); - anchor.before(highlight); + anchor.before(highlight); } function getHighlightDetails(usr) { - var dtls = $("
") - .addClass("hl-ctn"); - dtls.append($("").attr("href", "mailto:" + usr.email) - .append($("

").html(usr.fullName))); - - var lst = $("