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

ajmax

v0.0.14

Published

micro MVC framework for single-page AJAX/html5 apps

Downloads

7

Readme

AJMAX.js

AJMax.js is a micro-framework, which makes easy and straightforward to development one-page Ajax applications.

It has a light-weight HTML-template engine, which performs data-binding on the client side very efficiently.

It enforces strict MVC model, where Model is JSON-based REST API, View is HTML templates, and Controller is written in JavaScript or JSON, running either on the client side or the server side.

It allows developers to describe data-binding instructions (and controll behaviors) in JSON (instead of JavaScript), which simplifies the development process, and also makes it possible to describe it on the server side and send it to the client.

Data-binding Instructions (DBI)

For example, the following code fetches the JSON data that describes 'me' using Facebook Graph API, and binds it with the HTML template named 'hello', and inserts the generated HTML at the location specified by the JQuery selector '#message'.

FB.api('/me', { fields:'name' }, function(data) {
  ctx.exec({ cmd:'html', params:{ data:result, template:'hello', selector:'#message' }});
});

If the 'data' is { name:"John Smith" } and the template 'hello' is "<p>Hello, $(.name)!</p>", this instruction will generate

"\<p\>Hello, John Smith!\</p\>"

and set as the innerHTML of the DOM element specified by '#message'>. It effectively performs

$('#message').html("<p>Hello, John Smith!</p>");

Since this instruction is written in JSON (not in JavaScript), it allows the server to send it to the client and modify the DOM appropriately.

It is possible describe various controll behaviors in DBI instructions. For example,

FB.api('/me/friends', function(result) {
  ctx.exec([
    { cmd:'html', params:{ template:'friends', selector:'#contents' }}, // (1)
    { cmd:'html', params:{ data:result.data, template:'friend', selector:'#friends', // (2)
      bindings:[
        { selector:'.friend', event:'click', actions:[ // (3)
          { cmd:'hide', params: { selector:'#contents' } }, // (4)
          { cmd:'emit', params: { event:'friend_selected', type:'client' } } // (5)
        ]}
      ]}
    }
  ]);
});

will fetch the list of Facebook friends, then perform following actions.

  1. insert the HTML template named 'friends' at the DOM element specified by the selector '#contents' (no data binding)
  2. bind the list of frneds (result.data) with the HTML template named 'friend', and insert it at the DOM element specified by the selector '#friends'
  3. then, find all the DOM element specified by the selector '.friends', and bind the 'click' event with (4) and (5)
  4. hide the DOM element specified by the selector '#contents'
  5. emit the event 'friend_selected' to the client-side of JavaScript

Flexibility

Because of this symetry (the data binding instruction are portable across server and client) allows maximum flexibility to the developer. It essentially allows three possible architectures.

  1. Server is a pure REST API server (Model), and all controlloing logics (Controller) are written on the client side.
  2. Along with the Model, all controlling logics (Controller) are written on the server side, and the client simply interprets the instructions from the server side, and route appropriate events (such as 'click' events) to the server.
  3. Controlling logics that involves data access are written on the server side, but the rest of controlling logics (mostly UI behaviors) are written on the client side.