{"id":28614139,"url":"https://github.com/karlisup/spotlight","last_synced_at":"2025-07-24T12:02:10.827Z","repository":{"id":28046894,"uuid":"115622144","full_name":"karlisup/spotlight","owner":"karlisup","description":"🔍Search widget for your web API","archived":false,"fork":false,"pushed_at":"2022-12-01T22:03:47.000Z","size":4607,"stargazers_count":53,"open_issues_count":11,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-12T01:13:04.805Z","etag":null,"topics":["api","searchbar","spotlight"],"latest_commit_sha":null,"homepage":"https://karlisup.github.io/spotlight/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karlisup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-28T12:39:36.000Z","updated_at":"2025-05-05T12:26:49.000Z","dependencies_parsed_at":"2023-01-14T08:01:03.573Z","dependency_job_id":null,"html_url":"https://github.com/karlisup/spotlight","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/karlisup/spotlight","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlisup%2Fspotlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlisup%2Fspotlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlisup%2Fspotlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlisup%2Fspotlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karlisup","download_url":"https://codeload.github.com/karlisup/spotlight/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlisup%2Fspotlight/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266839172,"owners_count":23993053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","searchbar","spotlight"],"created_at":"2025-06-12T01:13:01.716Z","updated_at":"2025-07-24T12:02:10.783Z","avatar_url":"https://github.com/karlisup.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://karlisup.github.com/spotlight\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/karlisup/spotlight/master/spotlight.gif\"\u003e\n  \u003c/a\u003e    \n\u003c/p\u003e\n\n# Spotlight\nSearch widget for your web API · [Demo](https://karlisup.github.com/spotlight)\n\n## Features\n- **Simple \u0026 Fast** - Have your search results without moving your hands from keyboard where you want them.\n- **Your API** - Connect your API and handle it as you want - in front end or back end. Front end example.\n- **Keybindings** - Do whatever you imagine with your results. Copy, open link in a new page, execute ```JavaScript``` script.\n- **Autocomplete** - Find faster thing you have been looking for. One letter may be enough.\n- **Theamable** - Change the look of the search input or the results to your liking.\n- **Open Source** - Use it in any project you desire. Let your imagination be the only limit.\n\n## Getting Started\nThese instructions will get you a copy of spotlight search feature with demo weather API up and running on your local machine.\n\n### Prerequisites\nFor now spotlight requires jQuery. Include this code before closing `\u003cbody\u003e` tag.\n```html\n\u003cscript src=\"/assets/js/jquery-3.2.1.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"/assets/js/spotlight.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"/assets/js/spotlight-modules.js\"\u003e\u003c/script\u003e\n```\nFor style put this in `\u003chead\u003e` section\n```html\n\u003clink rel=\"stylesheet\" href=\"/assets/css/spotlight.css\"\u003e\n```\nPut this spotlight container between `\u003cbody\u003e` tags.\n```html\n\u003cnav class=\"spotlight\"\u003e\n    \u003cdiv class=\"spotlight__search\"\u003e\n        \u003cdiv class=\"spotlight__inputbg\" data-autocomplete=\"\"\u003e\u003c/div\u003e\n        \u003cinput class=\"spotlight__input\" type=\"text\" autofocus\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"spotlight__results spotlight__results--empty\"\u003e\n        \u003cul class=\"spotlight__list\"\u003e\u003c/ul\u003e\n        \u003cdiv class=\"spotlight__indicator\"\u003e\n            \u003cdiv class=\"spotlight__thumb\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n\u003c/nav\u003e\n```\n\n### Configuration in `spotlight-modules.js`\nControl when you want to do call to the API e.g:\n* when string starts with `wf ` call `getForecast`\n* when string is longer then 3 chars\n* when string is not empty\n```javascript\ninput.on('input', function () {\n    var searchString = input.val();\n    if (searchString.length \u003e 0) {\n        // get Forecast\n        getForecast(searchString)\n    }\n})\n```\nConfigure actions. In **example** what to do when `Ctrl`/`Cmd`+`C` has been hit.\n```javascript\ninput.on('keydown', function (e) {\n    var keyCode = e.keyCode || e.which;\n    // configure what to copy when Ctrl/Cmd+C is triggered\n    if ((e.ctrlKey || e.metaKey) \u0026\u0026 keyCode == 67) {\n        var title = $('.spotlight__title', '.spotlight__item--active').html()\n        var subtitle = $('.spotlight__subtitle', '.spotlight__item--active').html()\n        copyToClipboard(subtitle + ' ' + title)\n    }\n    // after actions gain focus back on input\n    $('.spotlight__input').focus();\n});\n```\n\nGetting forecast **example**.\n```javascript\nfunction getForecast(location) {\n        var locationQuery = escape(\"select item from weather.forecast where woeid in (select woeid from geo.places(1) where text='\" + location + \"') and u='c'\"),\n            locationUrl = \"https://query.yahooapis.com/v1/public/yql?q=\" + locationQuery + \"\u0026format=json\";\n        $.ajax({\n            url: locationUrl,\n            method: 'GET'\n        }).then(function (data) {\n            if (data.query.results !== null) {\n                var ajaxResults = data.query.results.channel.item;\n                var title = ajaxResults.title.substring(15) // remove text \"Conditions for \"\n                returnWeatherForecast(ajaxResults.forecast)\n                spotlight.setAutocomplete(title)\n            } else {\n                spotlight.clearTitle();\n                spotlight.returnResults('');\n            }\n        });\n    }\n```\nReturning processed forecast data to Spotlight **example**.\n```javascript\nfunction returnWeatherForecast(forecast) {\n    var populatedResults = ''\n    var forecast = forecast.concat(forecast)\n    $(forecast).each(function() {\n        var image = {}\n        image.alt = this.text\n        switch (this.text) {\n            case \"Blowing Snow\":\n            case \"Snow Showers\":\n            case \"Rain And Snow\":\n            case \"Scattered Snow Showers\":\n                image.src = \"006-snowing-2.svg\"\n                break;\n            case \"Wintry Mix\":\n            case \"Snow\":\n                image.src = \"007-snowing.svg\"\n                break;\n            case \"Partly Cloudy\":\n            case \"Mostly Cloudy\":\n            case \"Mostly Sunny\":\n                image.src = \"003-cloudy-day.svg\"\n                break;\n            case \"Rain\":\n            case \"Showers\":\n            case \"Scattered Showers\":\n                image.src = \"009-rain.svg\"\n                break;\n            case \"Cloudy\":\n                image.src = \"008-cloudy.svg\"\n                break;\n            case \"Scattered Thundershowers\":\n            case \"Isolated Thunderstorms\":\n            case \"Thunderstorms\":\n            case \"Scattered Thunderstorms\":\n                image.src = \"002-storm.svg\"\n                break;\n            case \"Sunny\":\n            case \"Clear\":\n            case \"Mostly Clear\":\n                image.src = \"005-sun.svg\"\n                break;\n            case \"Windy\":\n            case \"Breezy\":\n                image.src = \"001-wind.svg\"\n                break;\n            default:\n                image.src = null;\n        }\n        if (image.src === null) {\n            image = null\n        } else {\n            image.src = 'assets/images/weather/' + image.src\n        }\n\n        populatedResults += spotlight.formatSingleSearchResult(\n            image,\n            'from ' + this.low + '° to ' + this.high + '°C' ,\n            this.date + ' (' + this.day + ')'\n        )\n    })\n    spotlight.returnResults(populatedResults)\n}\n```\n\n## Keybindings\n- ```Ctrl``` ```Ctrl``` - Show search bar\n- ```Esc``` - Exit search\n- ```Tab``` - Autocomplete\n- ```Up``` - Navigate up\n- ```Down``` - Navigate down\n- ```Cmd/Ctrl + C``` - Copy string\n\n## Contributing\nAs this is my free time fun project any suggestions, contributions are most welcome. Feel free to open issues, or contact me.\nHave ☀️ Day!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarlisup%2Fspotlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarlisup%2Fspotlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarlisup%2Fspotlight/lists"}