You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
export function registerPortHandlers(termName, instance) {
var self = this;
// Attach block actions
var actions = document.querySelectorAll('[data-term*="' + termName + '"]');
# This will iterate through all links
for (var n = 0; n < actions.length; ++n) {
var anchor = actions[n];
var port = anchor.getAttribute("data-port");
var protocol = anchor.getAttribute("data-protocol") || "http:";
var link;
if (port) {
link =
protocol +
"//" +
instance.proxy_host +
"-" +
port +
".direct." +
self.opts.baseUrl.split("/")[2] +
anchor.getAttribute("href");
}
var openFn = function (link) {
return function (evt) {
evt.preventDefault();
if (link) {
window.open(link, "_blank");
}
};
};
anchor.addEventListener("click", function () {
openFn(link);
});
// anchor.onauxclick = openFn(link);
anchor.addEventListener("contextmenu", function () {
# since this is an anonymous function, "link" will not be evaluated yet, but instead it will be called with the value of "link" as it was left in memory after processing the last a-tag in the above loop
if (link) {
this.setAttribute("href", link);
}
});
}
}
I would build this mechanism by taking the function to build the links from the attributes and attach them to the listeners, so they are run every time a click or right click is done. This will ensure the function will only operate on the link's attributes it is attached to. The main function then would only attach the listeners, but do not yet evaluate the links. What do you think?
The text was updated successfully, but these errors were encountered:
In
sdk/src/utils.ts
Line 93 in 1739da9
I would build this mechanism by taking the function to build the links from the attributes and attach them to the listeners, so they are run every time a click or right click is done. This will ensure the function will only operate on the link's attributes it is attached to. The main function then would only attach the listeners, but do not yet evaluate the links. What do you think?
The text was updated successfully, but these errors were encountered: