An open API service indexing awesome lists of open source software.

https://github.com/thinkphp/router

Standalone JS Routing
https://github.com/thinkphp/router

Last synced: 3 months ago
JSON representation

Standalone JS Routing

Awesome Lists containing this project

README

          

Router
------

A basic routes framework for JS using hashchange event.

Synopsis
========

var app = new Router()

app.get('/pages/:n', function( data ){

//do something with data
console.log( data.n )
})

app.run()

How to use
==========

var app = new Router()

app.get('/bubble', function() {

var arr = [9,8,7,6,5,4,3,2,1,0],
n = arr.length,
swap = function(i,j) {var aux = arr[i]; arr[i] = arr[j]; arr[j] = aux;}

console.log(arr);

for(var i=0;iarr[j]) {
swap(i,j)
}
}
}

console.log( 'bubble sort' )
console.log(arr);
})

app.get('/insert', function() {

var arr = [9,8,7,6,5,4,3,2,1,0],
n = arr.length

console.log( arr )

for(var i=1;i=0 && temp < arr[j]) {
arr[j+1] = arr[j]
j--
}
arr[j+1] = temp
}

console.log( 'insert sort' )
console.log( arr )

})

app.get('/subsets/:n', function( data ) {

var n = parseInt( data.n ),
arr = [],
out = ""

for(var i=0;i=0;j--) {

if(arr[j] > 1) {
arr[j] -= 2
arr[j-1] += 1
}
}

for(var j=0;j= 0; k--) {
s = s + parseInt(arr[k])
}

}while(s < n)

console.log( out )
})

app.get('/services/:denumire', function( data ){

console.log(data.denumire)
})

app.run()