Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

18
LINES

< > BotCompany Repo | #1031444 // hjs_handleOwnedClicks [dev.]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3346L/20K).

// needs JQuery
sS hjs_handleOwnedClicks(S code default "") {
  ret hjs(replaceDollarVars([[
    function handleOwnedClick(e) {
      var link = $(e.target).closest("a[href], a[onclick]").get();
      if (link == null) return;
      console.log("link: " + link);
      var owner = $(link).closest("[data-owner]").get();
      if (owner == null) return;
      console.log("owner: " + owner);
      owner = $(owner).attr("data-owner");
      console.log("You clicked on link " + link + " owned by " + owner);
      $code
    }
     
    document.addEventListener("click", handleOwnedClick);
  ]], code := unnull(code));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031444
Snippet name: hjs_handleOwnedClicks [dev.]
Eternal ID of this version: #1031444/5
Text MD5: 1e32ee2b93e697c7a866ec5601795b20
Transpilation MD5: 7b5804442660a3845525cc84b8e866af
Author: stefan
Category: javax / javascript
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-14 02:51:12
Source code size: 636 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 144 / 236
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)