forked from nus-cs2103-AY1718S2/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from ncaminh/master
Fix issues, add Portfolio...
- Loading branch information
Showing
39 changed files
with
1,722 additions
and
159 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# ncaminh-reusedgit | ||
###### \resources\games\Snake.html | ||
``` html | ||
<canvas id="gc" width="400" height="400"></canvas> | ||
<script> | ||
gc.style.left = "300px"; | ||
gc.style.top = "20px"; | ||
gc.style.position = "absolute"; | ||
window.onload=function() { | ||
canv=document.getElementById("gc"); | ||
ctx=canv.getContext("2d"); | ||
document.addEventListener("keydown",keyPush); | ||
setInterval(game,1000/15); | ||
} | ||
px=py=10; | ||
gs=tc=20; | ||
ax=ay=15; | ||
xv=yv=0; | ||
trail=[]; | ||
tail = 5; | ||
function game() { | ||
px+=xv; | ||
py+=yv; | ||
if(px<0) { | ||
px= tc-1; | ||
} | ||
if(px>tc-1) { | ||
px= 0; | ||
} | ||
if(py<0) { | ||
py= tc-1; | ||
} | ||
if(py>tc-1) { | ||
py= 0; | ||
} | ||
ctx.fillStyle="black"; | ||
ctx.fillRect(0,0,canv.width,canv.height); | ||
ctx.fillStyle="lime"; | ||
for(var i=0;i<trail.length;i++) { | ||
ctx.fillRect(trail[i].x*gs,trail[i].y*gs,gs-2,gs-2); | ||
if(trail[i].x==px && trail[i].y==py) { | ||
tail = 5; | ||
} | ||
} | ||
trail.push({x:px,y:py}); | ||
while(trail.length>tail) { | ||
trail.shift(); | ||
} | ||
if(ax==px && ay==py) { | ||
tail++; | ||
ax=Math.floor(Math.random()*tc); | ||
ay=Math.floor(Math.random()*tc); | ||
} | ||
ctx.fillStyle="red"; | ||
ctx.fillRect(ax*gs,ay*gs,gs-2,gs-2); | ||
} | ||
function keyPush(evt) { | ||
switch(evt.keyCode) { | ||
case 37: | ||
xv=-1;yv=0; | ||
break; | ||
case 38: | ||
xv=0;yv=-1; | ||
break; | ||
case 39: | ||
xv=1;yv=0; | ||
break; | ||
case 40: | ||
xv=0;yv=1; | ||
break; | ||
} | ||
} | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# ncaminh-unused-reused | ||
###### \resources\view\testMap.html | ||
``` html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"> | ||
<meta charset="utf-8"> | ||
<title>Displaying text directions with <code>setPanel()</code></title> | ||
<style> | ||
/* Always set the map height explicitly to define the size of the div | ||
* element that contains the map. */ | ||
#map { | ||
height: 100%; | ||
} | ||
/* Optional: Makes the sample page fill the window. */ | ||
html, body { | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
#floating-panel { | ||
position: absolute; | ||
top: 10px; | ||
left: 25%; | ||
z-index: 5; | ||
background-color: #fff; | ||
padding: 5px; | ||
border: 1px solid #999; | ||
text-align: center; | ||
font-family: 'Roboto','sans-serif'; | ||
line-height: 30px; | ||
padding-left: 10px; | ||
} | ||
#right-panel { | ||
font-family: 'Roboto','sans-serif'; | ||
line-height: 30px; | ||
padding-left: 10px; | ||
} | ||
#right-panel select, #right-panel input { | ||
font-size: 15px; | ||
} | ||
#right-panel select { | ||
width: 100%; | ||
} | ||
#right-panel i { | ||
font-size: 12px; | ||
} | ||
#right-panel { | ||
height: 100%; | ||
float: right; | ||
width: 390px; | ||
overflow: auto; | ||
} | ||
#map { | ||
margin-right: 400px; | ||
} | ||
#floating-panel { | ||
background: #fff; | ||
padding: 5px; | ||
font-size: 14px; | ||
font-family: Arial; | ||
border: 1px solid #ccc; | ||
box-shadow: 0 2px 2px rgba(33, 33, 33, 0.4); | ||
display: none; | ||
} | ||
@media print { | ||
#map { | ||
height: 500px; | ||
margin: 0; | ||
} | ||
#right-panel { | ||
float: none; | ||
width: auto; | ||
} | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="floating-panel"> | ||
<strong>Start:</strong> | ||
<select id="start"> | ||
<option value="Singapore+118177">Kent Ridge MRT</option> | ||
<option value="Singapore+139349">Buona Vista MRT</option> | ||
</select> | ||
<br> | ||
<strong>End:</strong> | ||
<select id="end"> | ||
<option value="Singapore+118177">Kent Ridge MRT</option> | ||
<option value="Singapore+139349">Buona Vista MRT</option> | ||
</select> | ||
</div> | ||
<div id="right-panel"></div> | ||
<div id="map"></div> | ||
<script> | ||
function initMap() { | ||
var directionsDisplay = new google.maps.DirectionsRenderer; | ||
var directionsService = new google.maps.DirectionsService; | ||
var map = new google.maps.Map(document.getElementById('map'), { | ||
zoom: 15, | ||
center: {lat: 1.2925, lng: 103.7849} | ||
}); | ||
directionsDisplay.setMap(map); | ||
directionsDisplay.setPanel(document.getElementById('right-panel')); | ||
var control = document.getElementById('floating-panel'); | ||
control.style.display = 'block'; | ||
map.controls[google.maps.ControlPosition.TOP_CENTER].push(control); | ||
var onChangeHandler = function() { | ||
calculateAndDisplayRoute(directionsService, directionsDisplay); | ||
}; | ||
document.getElementById('start').addEventListener('change', onChangeHandler); | ||
document.getElementById('end').addEventListener('change', onChangeHandler); | ||
} | ||
function calculateAndDisplayRoute(directionsService, directionsDisplay) { | ||
var start = document.getElementById('start').value; | ||
var end = document.getElementById('end').value; | ||
directionsService.route({ | ||
origin: start, | ||
destination: end, | ||
travelMode: 'DRIVING' | ||
}, function(response, status) { | ||
if (status === 'OK') { | ||
directionsDisplay.setDirections(response); | ||
} else { | ||
window.alert('Directions request failed due to ' + status); | ||
} | ||
}); | ||
} | ||
</script> | ||
<script async defer | ||
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBWyCJkCym1dSouzHX_FxLk6Tj11C7F0Ao&callback=initMap"> | ||
</script> | ||
</body> | ||
</html> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# ncaminh-unused | ||
###### \resources\games\Snake.html | ||
``` html | ||
<canvas id="gc" width="400" height="400"></canvas> | ||
<script> | ||
gc.style.left = "300px"; | ||
gc.style.top = "20px"; | ||
gc.style.position = "absolute"; | ||
window.onload=function() { | ||
canv=document.getElementById("gc"); | ||
ctx=canv.getContext("2d"); | ||
document.addEventListener("keydown",keyPush); | ||
setInterval(game,1000/15); | ||
} | ||
px=py=10; | ||
gs=tc=20; | ||
ax=ay=15; | ||
xv=yv=0; | ||
trail=[]; | ||
tail = 5; | ||
function game() { | ||
px+=xv; | ||
py+=yv; | ||
if(px<0) { | ||
px= tc-1; | ||
} | ||
if(px>tc-1) { | ||
px= 0; | ||
} | ||
if(py<0) { | ||
py= tc-1; | ||
} | ||
if(py>tc-1) { | ||
py= 0; | ||
} | ||
ctx.fillStyle="black"; | ||
ctx.fillRect(0,0,canv.width,canv.height); | ||
ctx.fillStyle="lime"; | ||
for(var i=0;i<trail.length;i++) { | ||
ctx.fillRect(trail[i].x*gs,trail[i].y*gs,gs-2,gs-2); | ||
if(trail[i].x==px && trail[i].y==py) { | ||
tail = 5; | ||
} | ||
} | ||
trail.push({x:px,y:py}); | ||
while(trail.length>tail) { | ||
trail.shift(); | ||
} | ||
if(ax==px && ay==py) { | ||
tail++; | ||
ax=Math.floor(Math.random()*tc); | ||
ay=Math.floor(Math.random()*tc); | ||
} | ||
ctx.fillStyle="red"; | ||
ctx.fillRect(ax*gs,ay*gs,gs-2,gs-2); | ||
} | ||
function keyPush(evt) { | ||
switch(evt.keyCode) { | ||
case 37: | ||
xv=-1;yv=0; | ||
break; | ||
case 38: | ||
xv=0;yv=-1; | ||
break; | ||
case 39: | ||
xv=1;yv=0; | ||
break; | ||
case 40: | ||
xv=0;yv=1; | ||
break; | ||
} | ||
} | ||
</script> | ||
``` |
Oops, something went wrong.