UNPKG

domainr-search-box

Version:
60 lines (54 loc) 2.33 kB
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Simple Domainr Search Demo</title> <meta name="HandheldFriendly" content="True"> <meta name="MobileOptimized" content="320"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="/dist/domainr-search-box.css" /> <style> body { text-align: center; } body, input { font-family: "helvetica neue", helvetica, sans-serif; font-size: 18px; } #example { position: relative; width: 320px; margin: 40px auto; text-align: left; } #example input { box-sizing: border-box; width: 100%; border: 1px solid #ccc; border-radius: 2px; padding: 3px 10px; appearance: none; } #example input:focus { outline: none; } #results { position: relative; width: 100%; } #note { display: none; font-size: 14px; color: #f00; } </style> </head> <body> <div id="example"> <h1>Simple Domainr Search Demo</h1> <input type="text" id="search" name="search" placeholder="search all domains" autofocus="autofocus" autocomplete="off"> <div id="results"></div> <p id="note">To make this demo work, make a config.js with your <tt>clientId</tt> or <tt>mashapeKey</tt> and put it in the same directory. See config-sample.js for an example.</p> </div> <script src="/dist/domainr-search-box.min.js"></script> <script src="config.js"></script> <script> 'use strict'; /* global console, config */ if (!window.config) { console.error('You need a config.js.'); document.getElementById('note').style.display = 'block'; } if (!config.clientId && !config.mashapeKey) { console.error('Your config needs to specify either a clientId or a mashapeKey.'); } if (config.clientId && config.mashapeKey) { console.error('Please provide only a clientId or a mashapeKey; not both.'); } new domainr.SearchBox({ clientId: config.clientId, mashapeKey: config.mashapeKey, observe: document.getElementById('search'), renderTo: document.getElementById('results'), limit: 10, onSelect: function(result) { window.open('https://domainr.com/' + result.domain); } }); </script> </body> </html>