41 lines
1.6 KiB
TypeScript

class Util {
public static HandleLink(e: Event) {
Search($(e.target).text());
Settings.SaveResults();
}
public static HandleHiddenLink(e: Event) {
Search($(e.target).find(".searchvalue").text());
Settings.SaveResults();
}
public static RemoveResult(e: Event) {
let ref = $(e.target).parent().parent().children(".resultbody").children("h2").children("a").text();
delete CurrentReferences[ref.trim().toLowerCase()];
$(e.target).parent().parent().remove();
Settings.SaveResults();
}
public static HandleError(e) {
let self = this;
// for now we're going to put the error in the main result div.
let t = $("<div class='strongsdef result'><a href='javascript:void(0)' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><span class='resultbody'>" + e + "</span><br clear='all' /></div>");
$("#result").prepend(t);
t.find(".removeresult").click(function (e) {
self.RemoveResult(e);
});
return false;
}
public static GetUrlVars() {
// Read a page's GET URL variables and return them as an associative array.
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
};