https://github.com/thinkphp/router
Standalone JS Routing
https://github.com/thinkphp/router
Last synced: 3 months ago
JSON representation
Standalone JS Routing
- Host: GitHub
- URL: https://github.com/thinkphp/router
- Owner: thinkphp
- Created: 2012-05-27T18:00:11.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-05-28T13:14:09.000Z (over 13 years ago)
- Last Synced: 2024-04-14T14:54:28.837Z (almost 2 years ago)
- Language: JavaScript
- Homepage: http://thinkphp.ro/apps/js-hacks/router/
- Size: 102 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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()