Giter Site home page Giter Site logo

spark's Introduction

Spark.js

Disclaimer

This is not actively developed, and there are better tools out there to use. I made this mostly as a learning exercise.

What is Spark.js?

A JavaScript framework that lets you write HTML from JavaScript.

Why use Spark.js?

Spark.js is very clean, in that the code is self descriptive, and doesn't require unnecessary characters. For example, in jQuery you do this to make a button with JavaScript:

<!doctype html>
<html>
<body id="body">

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
function test(){
  alert("Hi")
}
$(document).ready(function() {
$("#body").html("<button type=\"submit\" onclick=\"test()\">Test</button>")
})
</script>
</body>
</html>

Not bad right? You could even put the JavaScript in a seperate file, and load that file, so you could then write almost all of your HTML in JavaScript. That might look like this:

<!doctype html>
<html>
<body id="body">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
function test(){
  alert("Hi")
}
$(document).ready(function() {
$("#body").html("<form method=\"POST\"><input type=\"text\" /><button type=\"submit\">Submit</button>")
})
</script>
</body>
</html>

But at that point, even if the JavaScript is in a seperate file, it's even more complex than just writing the HTML, because everything is on one line, you have to put a backslash before quotes, etc. In Spark however, making a button looks like this:

<!doctype html>
<html>
<body id="body">
<script src="/spark.js"></script>
<script>
function test() {
alert("Hi")
}
Spark.create('button', {'type': 'submit', 'onclick': 'test()'}, 'Test')
</script>
</body>
</html>

If you were to put the JavaScript in a seperate file, you can see how much that is like writing a desktop application.

Spark works in Chrome and Firefox, and IE.

How can I help!

It's on GitHub! Just fork the repo, and send pull requests once you have added features or fixed bugs.

Where can I learn more?

The tutorial is here. The rest is on the wiki.

Complete Feature List

  • Dynamic creation of HTML with Spark.start(), Spark.end(), and Spark.create()
  • Cross browser ajax with Spark.ajax(), Spark.superAjax(), and Spark.get()
  • Spark.pack() for creating widgets and the Spark.widget object for accessing them (Docs on widgets here)
  • DOM selection tool Spark.sel() function for manipulating the DOM

spark's People

Contributors

jaeschrich avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

spark's Issues

Must use Single quotes in JSON args list

This works

Spark.create("a", {"onclick": "window.location(\'http://www.google.com\')}, "Test")

But not this:

Spark.create("a", {"onclick": "window.location(\"http://www.google.com\")"}, "Test")

IE Ajax

Ajax requests all fail in Internet Explorer.

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.