website/learnmore/catalog/index.html (119 lines of code) (raw):

--- title: Catalog page_mask: usermanual-pdf-exclude page_mask: started-pdf-exclude --- <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <head> {% include head.html %} <script type="text/javascript" src="{{site.path.style | relative_url}}/js/catalog/items.js"></script> <link rel="stylesheet" href="{{site.path.style | relative_url}}/css/catalog_items.css" type="text/css" media="screen"/> </head> <body> {% include header.html %} <div id="container"> <ul class="nav nav-tabs"> <li class="active"><a href="#entities" data-toggle="tab">Entities</a></li> <li><a href="#policies" data-toggle="tab">Policies</a></li> <li><a href="#locations" data-toggle="tab">Locations</a></li> </ul> <div class="tab-content"> <div class="tab-pane active" id="entities"> <input class="filter form-control" type="text" placeholder="Filter by type, e.g. webapp or nosql"> </div> <div class="tab-pane" id="policies"> <input class="filter form-control" type="text" placeholder="Filter by type, e.g. ha"> </div> <div class="tab-pane" id="enrichers"> <!-- TODO, and above --> <input class="filter form-control" type="text" placeholder="Filter by type, e.g. http"> </div> <div class="tab-pane" id="locations"> <input class="filter form-control" type="text" placeholder="Filter by type, e.g. http"> </div> <div class="tab-pane" id="locationResolvers"></div> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script> <script src="{{site.path.style | relative_url}}/js/underscore-min.js" type="text/javascript"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <script src="{{site.path.style | relative_url}}/js/catalog/bloodhound.js" type="text/javascript"></script> <script src="{{site.path.style | relative_url}}/js/catalog/common.js" type="text/javascript"></script> <script type="text/javascript"> var filter = function (element, items) { var ESCAPE_KEY = 27; var $element = $(element), $tab = $element.parent(), kind = $tab.attr("id"), collection = items[kind]; if (!collection) { console.warn("Unable to determine type for input", element); return; } // Number.MAX_VALUE configures Bloodhound to return all matches. var bloodhound = new Bloodhound({ name: kind, local: collection, limit: Number.MAX_VALUE, datumTokenizer: function (d) { return Bloodhound.tokenizers.nonword(d.type); }, queryTokenizer: Bloodhound.tokenizers.nonword }); bloodhound.initialize(); // Filter items as input changes var allAnchors = $tab.find("a").map(function (index, a) { return $(a); }); var hideAnchorsNotMatchingQuery = function () { var query = $element.val(); query = query.trim(); if (!query) { $tab.find("a").removeClass("hide"); } else { var matchedTypes = {}; bloodhound.get(query, function (suggestions) { _.each(suggestions, function (s) { // approximate a set! matchedTypes[s.type] = true; }); }); _.each(allAnchors, function (a) { if (_.has(matchedTypes, a.data("type"))) { a.removeClass("hide"); } else { a.addClass("hide"); } }); } }; $element.on("input", hideAnchorsNotMatchingQuery); // In case page is loaded with text in input, e.g. from back button. hideAnchorsNotMatchingQuery(); $element.on("keydown", function (e) { if (e.keyCode == ESCAPE_KEY) { $element.val(""); hideAnchorsNotMatchingQuery(); } }); }; $(document).ready(function () { updateItems(items); function updateItems(items) { if (!String.prototype.trim) { String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ''); }; } var card = function (collection, cardFunction, target) { var cards = _.map(collection, cardFunction); $(target).append(cards.join("")); }; card(items.entities, brooklyn.entityCard, "#entities"); card(items.policies, brooklyn.policyCard, "#policies"); //card(items.enrichers, brooklyn.enricherCard, "#enrichers"); card(items.locations, brooklyn.locationCard, "#locations"); //transformItemAndAddToElement(items.locations, brooklyn.locationCard, "#locations"); //items.locationResolvers.forEach(function (element) { $("#locationResolvers").append("<tr><td>" + element + "</td></tr>"); }); $("input.filter").each(function (index, element) { filter(element, items); }); } }); </script>