The goal here is to make a DOM manipulation library like unto jQuery for practice and to learn javascript more fully and completely
- By tag
- By class
- By Id
degrees = angle * (180/Math.PI); | |
slope = tangent(degrees); | |
length = Math.sqrt(1*1,m*m); | |
vector = [1/length,m/length]; | |
next_point = function(distance,start,magnatude){ | |
var end = [] | |
magnatude[0] = magnatude[0]*distance; | |
magnatude[1] = magnatude[1]*distance; | |
end[0] = start[0] + magnatude[0]; | |
end[1] = start[1] + magnatude[1]; |
(function(){ | |
var canvas = document.createElement("canvas"), | |
ctx = canvas.getContext("2d"), | |
ship = { | |
x: 250, | |
y: 250, | |
speed: 10, | |
angle: 0, | |
vx: 0, | |
vy: 0, |
<html> | |
<head> | |
<title>Clay Murray's Web Adventures</title> | |
<link rel="stylesheet" type="text/css" href="http://current.bootstrapcdn.com/bootstrap-v204/css/bootstrap.min.css"> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="navbar "> | |
<div class="navbar-inner"> | |
<div class="container"> |
setTimeout(function(){ | |
//timeout code goes here | |
//will run this code after 1000 miliseconds | |
//1000 miliseconds = 1 second | |
}, 1000); |
//Just proving it is async | |
setTimeout(function(){ | |
console.log("hello world"); | |
},1000); | |
for(var i=0; i<10; i++){ | |
console.log(i); | |
} | |
//Will print |
setInterval(function(){ | |
console.log("hello world"); | |
}, 1000) | |
//Will print | |
//hello world | |
//*1000 MS later* | |
//hello world | |
//Will run until stopped |
var interval = setInterval(function(){ | |
console.log("hello world") | |
}, 1000); | |
clearInterval(interval); |
function foo(){ | |
var num = 20; | |
return function(){ | |
console.log(num); | |
} | |
} | |
foobar = foo(); | |
foobar(); |
var rooms = {}; | |
io.sockets.on("connection", function(socket){ | |
socket.on("create room", function(roomName){ | |
if(!rooms[roomName]){ | |
rooms[roomName] = []; | |
} | |
rooms[roomName].push(socket); | |
}); | |
socket.on("message", function(data){ | |
rooms[data.roomName].forEach(function(s){ |