A Pen by Rob
How do I make an a pen by rob?
What is a a pen by rob? How do you make a a pen by rob? This script and codes were developed by Rob on 18 August 2022, Thursday.
A Pen by Rob - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>A Pen by Rob</title> <link rel='stylesheet prefetch' href='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <select name="CAT_Category" id="CAT_Category" class="cat_listbox" rows="4" multiple="multiple"> <option value="-1">-- All Categories --</option> <option value="78482">Categories</option> <option value="79654">---Craft</option> <option value="143758">---Eat &</option> <option value="79647">----Eat & Drink</option> <option value="143756">------Health &</option> <option value="79508">---Health & Beauty</option> <option value="143760">---Home &</option> <option value="79655">---Home & Living</option> <option value="143065">---Luxuries</option> <option value="79622">---EMedia</option> <option value="79626">------Books</option> <option value="79626">------Nonfiction</option> <option value="79632">---Games</option> <option value="79633">------Magazines</option> <option value="79627">------Movies</option> <option value="79628">---Music</option> <option value="142866">---Mens Style</option> <option value="142867">------Clothes</option> <option value="142870">------Eyewear</option> <option value="142869">---Gear</option> <option value="143064">------Grooming</option> <option value="143762">------Jewellery &</option> <option value="142871">------Jewellery & Watches</option> <option value="142868">------Shoes</option> <option value="79653">---Outdoors</option> <option value="79619">---Play</option> <option value="79648">------Collectables</option> <option value="79652">------Gaming</option> <option value="79650">------Hobbies</option> <option value="84694">------Musical Instruments</option> <option value="79649">------Sports</option> <option value="79651">------Toys</option> <option value="79618">---Tech</option> <option value="79684">------Audio Visual</option> <option value="79636">------Computers</option> <option value="79634">------Mobile Phones</option> <option value="84693">------Photography</option> <option value="78487">---Transport</option> <option value="79641">------Aircraft</option> <option value="84691">------Bicycles</option> <option value="79637">------Boats</option> <option value="79640">------Cars</option> <option value="84695">------Electric</option> <option value="79638">------Motorcycles</option> <option value="78498">---Travel</option> <option value="79617">---Womens Style</option> <option value="79629">------Accessories</option> <option value="79631">------Bags</option> <option value="79630">------Clothes</option> <option value="142865">------Eyewear</option> <option value="143754">------Jewellery &</option> <option value="79643">------Jewellery & Watches</option> <option value="142864">------Shoes</option> <option value="79646">---Work</option> </select>
<div id="checklist">
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
A Pen by Rob - Script Codes CSS Codes
ul {
}
.root {
}
.categoryList { margin-left: 0; list-style: none;
}
A Pen by Rob - Script Codes JS Codes
var categories = { parseCategories: function(){ // create an array containing all categories var catOptions = $('select#CAT_Category').children(); // the target element where we will append the list var target = $('#checklist'); // the list stack initialized with a ul element var listStack = [$('<ul class="categoryList">')]; // take the first item off the option list because it's useless Array.prototype.shift.call(catOptions); Array.prototype.shift.call(catOptions); // use the recursive method to append all items to the result var result = this.parseSubCategories(listStack, catOptions, 1); // append the result to the target element target.append(result); }, /* listStack - the stack of lists, for each level in the tree you need to push a new list onto the stack when you get to an element that is lower level than the current, pop the list off and append it to that list options is the list of option items taken from the CMS currentLevel is how deep you currently are in the tree */ parseSubCategories: function(listStack, options, currentLevel) { if(options.length == 0) { return listStack; } var itemLevel = 0; // remove and keep the first element of the option list var listItem = Array.prototype.shift.call(options); var itemName = listItem.innerHTML.replace(/^-{3,}\1*/g, function(sequence){ itemLevel = Math.floor(sequence.length/3); return ""; // return value minus the --- prefixes }); //console.log(itemName + "found at: " + itemLevel + " currentLevel: " + currentLevel); // get the current list from the stack var currentList = listStack[listStack.length-1]; //console.log('appending ' + itemName + " to " + currentList.attr('class')); if(itemLevel > currentLevel) { // item is a child of the parent so create a new list and append the item to it // then append the list to the parent list and use the new list to append items var childList = this.makeCategoryList(itemLevel); var listItem = this.makeListItem(listItem.value, itemName); childList.append(listItem); currentList.append(childList); listStack.push(childList); this.parseSubCategories(listStack, options, ++currentLevel); } else if (itemLevel == currentLevel) { // item is a sibling of the parent, so add it to the current list currentList.append(this.makeListItem(listItem.value, itemName)); this.parseSubCategories(listStack, options, currentLevel); } else { // start a new branch by popping the last list off the stack and // append the current item to the list under it var prevList = listStack.pop(); currentList = listStack[listStack.length - 1]; //console.log('new branch ' + itemName + ' - setting current level: ' + itemLevel); currentList.append(this.makeListItem(listItem.value, itemName)); this.parseSubCategories(listStack, options, itemLevel); } return listStack; }, makeListItem: function(value, itemName) { return $('<li>').html('<label class="checkbox"' + 'for="' + value + '"><input type="checkbox"' + 'name="' + value + '" id="' + value + '" value="' + value + '">' + itemName + '</input></label>'); }, makeCategoryList: function(depth) { var leftMargin = depth * 10; return $('<ul class="categoryList" style="margin-left:' + leftMargin + 'px"' + '>'); }
};
categories.parseCategories();
Developer | Rob |
Username | rowinf |
Uploaded | August 18, 2022 |
Rating | 3 |
Size | 3,452 Kb |
Views | 40,480 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Bootstrap test | 1,906 Kb |
A Pen by Rob | 1,972 Kb |
Responsive Calendar | 2,460 Kb |
Foundation Off-Canvas menu test | 2,424 Kb |
Table filters | 1,727 Kb |
Flash Cards | 3,086 Kb |
Nav Menu with Chevron | 1,966 Kb |
Html5 form validation | 2,090 Kb |
Get combo box item value | 1,981 Kb |
JQuery Animations | 3,190 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
SCSS Social Icons Flat | Mattsince87 | 3,482 Kb |
Experiment | Toddmoy | 2,849 Kb |
APortfolio | Skybutterfly | 5,174 Kb |
Kudos Please | TimPietrusky | 6,624 Kb |
Animate a paper plane along an SVG path, looking ahead | PotatoDie | 3,734 Kb |
Login-ng-modal | Heedoo | 3,566 Kb |
CSS Variables | Jdsteinbach | 4,759 Kb |
Slider | Mohammed-fawzy | 2,634 Kb |
CSS Grid Overlay | Cliffpyles | 3,090 Kb |
Off Canvas | Mariamarica | 1,870 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!