npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

geonames-server-jquery-plugin

v0.2.2

Published

[![Build Status](https://travis-ci.org/alchemy-fr/GeonamesServer-jQuery-Plugin.png?branch=master)](https://travis-ci.org/alchemy-fr/GeonamesServer-jQuery-Plugin)

Downloads

457

Readme

Geonames Server jQuery Plugin

Build Status

This jQuery plugin allows auto-completion for locations in an <input> HTML tag.

It requires an acces to a working Geonames Server.

Dependencies

This plugins depends on the jQuery Autocomplete widget which requires :

  • [UI core] (http://api.jqueryui.com/category/ui-core/)
  • [Widget Factory] (http://api.jqueryui.com/jQuery.widget/)
  • [Position] (http://api.jqueryui.com/position/)
  • Menu

note : This widget requires some functional CSS, otherwise it would not work. If you build a custom theme, use the widget's specific CSS file as a starting point.

Usage

<input id="geoname-id" value="" />

<script type="text/javascript">
    $("#geoname-id").geocompleter({
        "server": "http://geonames-server.tld/",
        "limit" : 30,
        "sort" : "population"
    });
</script>

Options

  • sort (optional, string, default value : population) available values :

    • population : The results will be sorted by population.
    • closeness : The results will be sorted by closeness to the place the request was sent from.
  • name (optional, string) : Filters city whose begins with a given name.

  • country (optional, string) : Only cities located in countries whose name begins with this parameter will be returned.

  • limit (optional, string) : The number of results.

  • client-ip (optional, string) : This parameter is used within the closeness sort parameter to provide a custom remote IP. /city?sort=closeness&client-ip=80.12.81.19

  • init-input (optional, boolean) : option to initialize the autocompleter with a geoname-id

  • onInit (optional, function) : callback triggered after plugin initialization, it takes original input and autocomplete input as arguments

Advanced usage

<input id="geoname-id" value="" />

<script type="text/javascript">
    var geocompleter = $("#geoname-id").geocompleter({
        "server": "http://geonames-server.tld/",
    });

    // You can override any option of the jquery ui autocomplete widget
    // see available options http://api.jqueryui.com/autocomplete/

    // setter
    geocompleter.geocompleter("autocompleter", "option", "disabled", true);
    //getter
    geocompleter.geocompleter("autocompleter", "option", "disabled");

    // You can bind your own callback to the jquery ui autocomplete events
    geotocompleter("autocompleter", "on", "autocompletechange", function(event, ui) {});

    // This plugin defines a custom event when ajax request to the geonames server fails
    geocompleter.geocompleter("autocompleter", "on", "geotocompleter.request.error", function(jqXhr, status, error) {});
</script>

Run tests

This plugin is testable. You need PhantomJS to run the test suite. Install developer dependencies before running the test suite.

npm install
make test

License

This project is licensed under the MIT license.