Giter VIP home page Giter VIP logo

aem-example's Introduction

AEM JavaScript Example

Build Status

Running the Example

Production Version

http://jayproulx.github.com/aem-example/

Running the Node.js HTTP Server

There are instructions on starting up the HTTP server over on the Untethered repo:

https://github.com/jayproulx/generator-untethered#developing-an-untethered-ui

Download the zip

The zip file is available here.

Drop the contents of that zip into the root folder of your local web server.

If you have node installed, I've added a quick express server that you can use to launch it instead.

# node server.js

Requirements

A JavaScript application simulating house automation: pressing a button on a control panel would visually turn on a light, change the temperature or close the curtains. Some constraints:

  • the application must use jQuery
  • the components must have HTTP based "server" interaction (use a static file for simplicity, data persistence is not required). For example, the heating component retrieves the current temperature from the server and also sends the desired one back to the server.
  • the solution has to be extensible and documented, so that we can develop our own components that react to events

The application will be executed on a plain HTTP server with no possibility to run code server side and is being viewed in 2 major browsers of your choice.

Meeting the Requirements

The application must use jQuery

jQuery is used to consume the events dispatched by the Automation API, render all updates, and provide a simple form for updating the data. Click the "API Consumer" menu item at the top of the screen to see a pure jQuery UI that dispatches and responds to events.

The components must have HTTP based server interaction

The Automation API sends mock requests to the server to store and update data. In some cases, we don't use the response because of the static nature of the mock data. For the purposes of this example, the jQuery API consumer posts logging data to a fictitious logging service.

The solution has to be extensible and documented

There are annotations in all relevant source code directories src/main/www/**, and comments in the code. The code comments are not meant to be exhaustively or extensively documented, and assumes the reader has knowledge of the language and frameworks used. Code that is not immediately clear or highly formulaic will be commented for the reader to quickly understand the intentions.

To demonstrate extensibility, a jQuery API consumer has been provided as an example, along with a UI to manipulate the available data.

The API is fully documented here

Self-prescribed Requirements

Provide common continuous integration functionality

It's 2014, we expect more from our code, performance and quality than is available out of the box. Code should be optimized, minified and unit tested.

Provide both AngularJS and jQuery examples

The assignment requirements include a jQuery requirement, however there has been quite a bit of talk with the hiring manager and team about AngularJS as a primary context. I've included AngularJS to demonstrate some of that skill set, and to "prove" the provided Automation API, I've built a jQuery API consumer that does some basic dom manipulation and an AJAX request.

Notes on Inclusions and Exclusions

This sample is meant to be just that, a sample. There are plenty of opportunities to add more validation and error reporting everywhere. I've added basic validation where necessary or risky, but I haven't validated and reported every possible error to keep application structure, business logic, and rendering code clean and clear.

createDocumentFragment() is more efficient than direct DOM manipulation with jQuery in most cases, accessing certain element properties or calling certain methods can cause extra paints, and some combinations of CSS classes cause excessive rendering time. This sample has taken some steps towards rendering performance, but there are always more steps that can be taken to improve it further.

Basically, this is a sample, it's not an exhaustive list of best practices and solutions.

Running the Node.js HTTP Server

There are instructions on starting up the HTTP server over on the Untethered repo:

https://github.com/jayproulx/generator-untethered#developing-an-untethered-ui

Tested On

  • OSX Firefox Latest
  • OSX Chrome Latest
  • OSX Safari Latest

I expect this should work on most modern browsers. Animations run more smoothly on Chrome, Safari and iOS than Firefox.

Attribution

White House SVG

http://commons.wikimedia.org/wiki/File:White_House_FloorPlan2.svg

aem-example's People

Contributors

jayproulx avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.