Last active
November 25, 2015 22:52
-
-
Save in8finity/db1682de3741fd35b34f to your computer and use it in GitHub Desktop.
Script to list all active links and active form elements on page and highlight em with borders (highlights first occurrence of link with red color, others - with yellow).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var links_hash = {}; | |
function store_in_links_hash(href, item, container) | |
{ | |
if(links_hash[href] == undefined) | |
{ | |
links_hash[href] = item; | |
//item.css("background-color", "red"); | |
//$(container).css("border", "2px solid red"); | |
console.log(href); | |
} | |
else | |
{ | |
//item.css("background-color", "yellow"); | |
//$(item).parent().css("border", "1px solid yellow"); | |
} | |
} | |
var source_links = $("a"); | |
source_links.each(function(item_index, item){ | |
var href = $(item).attr("href"); | |
if(!href) | |
return ""; | |
var href = href.replace(/\d+?/gi, "/\\d+?/"); | |
var container = $(item).parent(); | |
store_in_links_hash(href, item, container) | |
}); | |
var source_controls = $("button,input,select"); | |
source_controls.each(function(item_index, item){ | |
var href = $(item).closest("form").attr("action"); | |
if(!href) | |
return ""; | |
var href = href.replace(/\d+?/gi, "/\\d+?/"); | |
var container = $(item); | |
store_in_links_hash(href, item, container) | |
}); | |
var items_count = keys(links_hash).length; | |
console.log("There are: "+ items_count); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment