| @@ -0,0 +1,92 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <title>Lat/Lng Object Literal</title> | ||
| <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> | ||
| <meta charset="utf-8"> | ||
| <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; | ||
| } | ||
| </style> | ||
| <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC23tLDaC-xc7rCmcKlJSvPXXqTcMAsQ9Y"></script> | ||
| <script> | ||
| // In this example, we center the map, and add a marker, using a LatLng object | ||
| // literal instead of a google.maps.LatLng object. LatLng object literals are | ||
| // a convenient way to add a LatLng coordinate and, in most cases, can be used | ||
| // in place of a google.maps.LatLng object. | ||
| // attempts to store lat and long into a format that can be used | ||
| /* Stores lat and lon as global variables so that we can manipulate them | ||
| */ | ||
| var lat = 0; | ||
| var lon = 0; | ||
|
|
||
| positionFunc(); | ||
| //setInterval(function () { }, 3000); | ||
|
|
||
| // Function retrives lat + lon and calls printLat. getCurrentPosition has 2 calls. 1st is on success.2nd is on failure. | ||
| function positionFunc() { | ||
| navigator.geolocation.watchPosition(success, failure); | ||
| } | ||
| function failure() { | ||
| $('#lat').html("<p>Unable to get location! R u connected to the net? Orusing a bad browser?</p>"); | ||
| } | ||
| // changes global variable lat and lon | ||
| function success(position) { | ||
| lat = position.coords.latitude; | ||
| lon = position.coords.longitude; | ||
| //Google - API - ready lat long string// | ||
| } | ||
| var coords = new google.maps.LatLng(lat, lon); | ||
| var map; | ||
| function initialize() { | ||
| var mapOptions = { | ||
| zoom: 16, | ||
| center: coords | ||
| }; | ||
| map = new google.maps.Map(document.getElementById('map'), | ||
| mapOptions); | ||
|
|
||
| var marker = new google.maps.Marker({ | ||
| // The below line is equivalent to writing: | ||
| // position: new google.maps.LatLng(-34.397, 150.644) | ||
| position: coords, | ||
| map: map | ||
| }); | ||
|
|
||
| // You can use a LatLng literal in place of a google.maps.LatLng object when | ||
| // creating the Marker object. Once the Marker object is instantiated, its | ||
| // position will be available as a google.maps.LatLng object. In this case, | ||
| // we retrieve the marker's position using the | ||
| // google.maps.LatLng.getPosition() method. | ||
| var infowindow = new google.maps.InfoWindow({ | ||
| content: '<p>Marker Location:' + marker.getPosition() + '</p>' | ||
| }); | ||
|
|
||
| google.maps.event.addListener(marker, 'click', function () { | ||
| infowindow.open(map, marker); | ||
| }); | ||
| } | ||
|
|
||
| google.maps.event.addDomListener(window, 'load', initialize); | ||
| </script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id="map"></div> | ||
| </body> | ||
|
|
||
| </html> |
| @@ -0,0 +1,20 @@ | ||
| // attempts to store lat and long into a format that can be used | ||
| /* Stores lat and lon as global variables so that we can manipulate them | ||
| */ | ||
| var lat = 0; | ||
| var lon = 0; | ||
|
|
||
| // Function retrives lat + lon and calls printLat. getCurrentPosition has 2 calls. 1st is on success.2nd is on failure. | ||
| function positionFunc() { | ||
| navigator.geolocation.getCurrentPosition(success, failure); | ||
| } | ||
| function failure() { | ||
| $('#lat').html("<p>Unable to get location! R u connected to the net? Orusing a bad browser?</p>"); | ||
| } | ||
| // changes global variable lat and lon | ||
| function success(position) { | ||
| lat = position.coords.latitude; | ||
| lon = position.coords.longitude; | ||
| $('#lat').html(lat + "is the Latitude"); | ||
| $('#lon').html(lon + "is the Longitude"); | ||
| } |
| @@ -0,0 +1,26 @@ | ||
| <!DOCTYPE html> | ||
| <!swap all 'getCurrentPosition' with 'watchPosition'> | ||
|
|
||
|
|
||
| <html> | ||
| <title> | ||
| TESTingL n Lon | ||
| </title> | ||
|
|
||
| <script src="jquery.js"></script> | ||
|
|
||
| <body> | ||
| <p>Click the button to get your lat + lon.</p> | ||
|
|
||
| <button onclick="positionFunc()">FindLat</button> | ||
|
|
||
|
|
||
| <!--This returns latitude(lat) and longitude(lon). And prints it--> | ||
| <script src='Latitude_n_Longitude.js'></script> | ||
|
|
||
| </script> | ||
| <div id="lat"></div> | ||
| <div id="lon"></div> | ||
| </body> | ||
|
|
||
| </html> |
| @@ -0,0 +1,53 @@ | ||
| <!DOCTYPE html> | ||
| <!swap all 'getCurrentPosition' with 'watchPosition'> | ||
|
|
||
|
|
||
| <html> | ||
| <title> | ||
| BIG HTML | ||
| </title> | ||
|
|
||
|
|
||
|
|
||
| <body> | ||
|
|
||
| <p>Click the button to get your lat + lon.</p> | ||
|
|
||
| <button onclick="positionFunc()">FindLat</button> | ||
|
|
||
| <p id="lat+lon"></p> | ||
|
|
||
| <script> | ||
| // attempts to store lat and long into a format that can be used | ||
| var y = document.getElementById("lat+lon"); | ||
| /* Stores lat and lon as global variables so that we can manipulate them | ||
| */ | ||
| var lat = 0; | ||
| var lon = 0; | ||
| // Function retrives lat + lon and calls printLat | ||
|
|
||
| function positionFunc() { | ||
| if (navigator.geolocation) { | ||
| navigator.geolocation.getCurrentPosition(success); | ||
| } else { | ||
| y.innerHTML = "you suck"; | ||
| } | ||
| } | ||
|
|
||
| function success(position) { | ||
| lat = position.coords.latitude; | ||
| lon = position.coords.longitude; | ||
| printLat(lat, lon); | ||
| } | ||
|
|
||
| // Prints lat + lon | ||
| function printLat(lat, lon) { | ||
| y.innerHTML = "latitude ==" + lat + "<br> longitude ==" + lon; | ||
| } | ||
|
|
||
| </script> | ||
|
|
||
| </script> | ||
| </body> | ||
|
|
||
| </html> |
| @@ -0,0 +1,44 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <style> | ||
| #map { | ||
| height: 400px; | ||
| width: 100%; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <h3>My Google Maps Demo</h3> | ||
| <div id="map"></div> | ||
| <script> | ||
| function initMap() { | ||
| if (navigator.geolocation) { | ||
| navigator.geolocation.getCurrentPosition(success, failure); | ||
|
|
||
| var coords = new google.maps.LatLng(lat, lng); | ||
| var map = new google.maps.Map(document.getElementById('map'), { | ||
| zoom: 16, | ||
| center: coords | ||
| }); | ||
| var marker = new google.maps.Marker({ | ||
| position: coords, | ||
| map: map | ||
| }); | ||
| } | ||
| } | ||
| function success(position) { | ||
| lat = position.coords.latitude; | ||
| lng = position.coords.longitude; | ||
| } | ||
| function failure() { | ||
| $('#map').html("Error 404 lol"); | ||
| } | ||
| </script> | ||
| <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC23tLDaC-xc7rCmcKlJSvPXXqTcMAsQ9Y&callback=initMap"> | ||
| </script> | ||
| </body> | ||
|
|
||
| </html> |
| @@ -0,0 +1,30 @@ | ||
| // attempts to store lat and long into a format that can be used | ||
| /* Stores lat and lon as global variables so that we can manipulate them | ||
| */ | ||
| var lat = 0; | ||
| var lon = 0; | ||
|
|
||
| // Function retrives lat + lon and calls printLat. getCurrentPosition has 2 calls. 1st is on success.2nd is on failure. | ||
| function positionFunc() { | ||
| navigator.geolocation.getCurrentPosition(success, failure); | ||
| } | ||
| function failure() { | ||
| $('#lat').html("<p>Unable to get location! R u connected to the net? Orusing a bad browser?</p>"); | ||
| } | ||
| // changes global variable lat and lon | ||
| function success(position) { | ||
| lat = position.coords.latitude; | ||
| lon = position.coords.longitude; | ||
| $('#lat').html(lat + "is the Latitude"); | ||
| $('#lon').html(lon + "is the Longitude"); | ||
| //Google - API - ready lat long string// | ||
| var coords = new google.maps.LatLng(lat, lon); | ||
| var mapOptions = { | ||
| zoom: 16, | ||
| centre: coords, | ||
| mapTypeId: google.maps.MapTypeId.ROADMAP | ||
| }; | ||
| var map = new google.maps.Map(document.getElementById("map"), mapOptions); | ||
| var marker = new google.maps.Marker({ map: map, position: coords }); | ||
|
|
||
| } |
| @@ -0,0 +1,92 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <title>Lat/Lng Object Literal</title> | ||
| <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> | ||
| <meta charset="utf-8"> | ||
| <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; | ||
| } | ||
| </style> | ||
| <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC23tLDaC-xc7rCmcKlJSvPXXqTcMAsQ9Y"></script> | ||
| <script> | ||
| // In this example, we center the map, and add a marker, using a LatLng object | ||
| // literal instead of a google.maps.LatLng object. LatLng object literals are | ||
| // a convenient way to add a LatLng coordinate and, in most cases, can be used | ||
| // in place of a google.maps.LatLng object. | ||
| // attempts to store lat and long into a format that can be used | ||
| /* Stores lat and lon as global variables so that we can manipulate them | ||
| */ | ||
| var lat = 0; | ||
| var lon = 0; | ||
|
|
||
| positionFunc(); | ||
| //setInterval(function () { }, 3000); | ||
|
|
||
| // Function retrives lat + lon and calls printLat. getCurrentPosition has 2 calls. 1st is on success.2nd is on failure. | ||
| function positionFunc() { | ||
| navigator.geolocation.watchPosition(success, failure); | ||
| } | ||
| function failure() { | ||
| $('#lat').html("<p>Unable to get location! R u connected to the net? Orusing a bad browser?</p>"); | ||
| } | ||
| // changes global variable lat and lon | ||
| function success(position) { | ||
| lat = position.coords.latitude; | ||
| lon = position.coords.longitude; | ||
| //Google - API - ready lat long string// | ||
| } | ||
| var coords = new google.maps.LatLng(lat, lon); | ||
| var map; | ||
| function initialize() { | ||
| var mapOptions = { | ||
| zoom: 16, | ||
| center: coords | ||
| }; | ||
| map = new google.maps.Map(document.getElementById('map'), | ||
| mapOptions); | ||
|
|
||
| var marker = new google.maps.Marker({ | ||
| // The below line is equivalent to writing: | ||
| // position: new google.maps.LatLng(-34.397, 150.644) | ||
| position: coords, | ||
| map: map | ||
| }); | ||
|
|
||
| // You can use a LatLng literal in place of a google.maps.LatLng object when | ||
| // creating the Marker object. Once the Marker object is instantiated, its | ||
| // position will be available as a google.maps.LatLng object. In this case, | ||
| // we retrieve the marker's position using the | ||
| // google.maps.LatLng.getPosition() method. | ||
| var infowindow = new google.maps.InfoWindow({ | ||
| content: '<p>Marker Location:' + marker.getPosition() + '</p>' | ||
| }); | ||
|
|
||
| google.maps.event.addListener(marker, 'click', function () { | ||
| infowindow.open(map, marker); | ||
| }); | ||
| } | ||
|
|
||
| google.maps.event.addDomListener(window, 'load', initialize); | ||
| </script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id="map"></div> | ||
| </body> | ||
|
|
||
| </html> |
| @@ -0,0 +1,34 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <title> | ||
| THIS IS TAKEN FROM W3SCHOOL | ||
| </title> | ||
|
|
||
| <body> | ||
|
|
||
| <p>Click the button to get your coordinates.</p> | ||
|
|
||
| <button onclick="getLocation()">Try It</button> | ||
|
|
||
| <p id="demo"></p> | ||
|
|
||
| <script> | ||
| var x = document.getElementById("demo"); | ||
|
|
||
| function getLocation() { | ||
| if (navigator.geolocation) { | ||
| navigator.geolocation.getCurrentPosition(showPosition); | ||
| } else { | ||
| x.innerHTML = "Geolocation is not supported by this browser."; | ||
| } | ||
| } | ||
|
|
||
| function showPosition(position) { | ||
| x.innerHTML = "Latitude: " + position.coords.latitude + | ||
| "<br>Longitude: " + position.coords.longitude; | ||
| } | ||
| </script> | ||
|
|
||
| </body> | ||
|
|
||
| </html> |
| @@ -0,0 +1,9 @@ | ||
| var a = 4; | ||
| var b = 5; | ||
| addition(); | ||
| function addition() { | ||
| a = a + 2; | ||
| b = b + 2; | ||
|
|
||
| } | ||
| alert(a + " " + b) |
| @@ -0,0 +1,17 @@ | ||
| <!DOCTYPE: HTML> | ||
| <html> | ||
| <title> | ||
| THIS IS THE TITLE. HELLO. | ||
| </title> | ||
|
|
||
| <body> | ||
|
|
||
| <script src="server.js"></script> | ||
|
|
||
|
|
||
|
|
||
| </body> | ||
|
|
||
|
|
||
|
|
||
| </html> |
| @@ -0,0 +1,11 @@ | ||
| var http = require('http'); | ||
|
|
||
| function onRequest(request, response) { | ||
| console.log('A user made a request' + request.url); | ||
| response.writeHead(200, { "Context-Type": "text/plain" }); | ||
| response.write("Here is some data"); | ||
| response.end(); | ||
| } | ||
|
|
||
| http.createServer(onRequest).listen(8080); | ||
| console.log("Server is now running..."); |
| @@ -0,0 +1,77 @@ | ||
| //Assuming all players are in | ||
| -----Server Data----- | ||
| Players (string name, bool isCopper) | ||
| -bool GameRunning | ||
| -int NumOfCoppers (set by creator) | ||
| -int LongestDistance (set by creator) | ||
| -int Timer (how much time left in seconds) | ||
| Robbers (string name, float longitude, float latitude) | ||
| --------------------- | ||
|
|
||
| -----Client Data----- | ||
| -string name | ||
| -float longitude | ||
| -float latitude | ||
| -bool isCaught (whether or not they are caught) | ||
| -float howWarm (0-1 cold-hot) | ||
| --------------------- | ||
|
|
||
| -----Client----- | ||
| Game loop: | ||
| Draw map | ||
| If !isCopper: | ||
| Server::sendLocation(name,longitude,latitude) | ||
| Draw Caught button | ||
| If Caught button is pressed: | ||
| inGame=false | ||
| Server::gotCaught(Name) | ||
| Go to idle page | ||
|
|
||
| If isCopper: | ||
| ??? = Server::getRobberNames() | ||
| Draw list of robbers (get robber data from server) | ||
| //Get player label | ||
| ??? = Server::getRobberLocations() | ||
| Calculate distance between client and robbers (get robbers data) | ||
| howWarm = Min(robbers distance)/MaximumDistance | ||
|
|
||
| Idle Page Loop: | ||
| If !GameRunning: | ||
| Go to end game page | ||
|
|
||
| End game: | ||
| If (isCopper and Timer>0): | ||
| Draw "Game over. Coppers win" | ||
| Else: | ||
| Draw "Game over. Robbers win" | ||
|
|
||
| -----Server----- | ||
| Loop: | ||
| If Timer==0 or #Robbers==0: | ||
| GameRunning=false | ||
| Else: | ||
| Timer-=1 | ||
| Handle incoming requests | ||
| Sleep a second | ||
|
|
||
| Void StartGame() | ||
| GameRunning=true | ||
| Randomly assign isCopper=true to different players | ||
| Bool GetIsCopper(string name) | ||
| Look up name in Players | ||
| Return isCopper | ||
| Void gotCaught(string name) | ||
| Look up name in Robbers | ||
| Remove player from Robbers | ||
| Void sendLocation(string name) | ||
| Look up name in Robbers | ||
| Overwrite longitude/latitude | ||
|
|
||
| String[] getRobberNames() | ||
| Return array of Robbers names | ||
|
|
||
| Float[][] getRobberLocations() | ||
| Return array of Robber locations | ||
|
|
||
| ---------------- | ||
|
|
| @@ -0,0 +1 @@ | ||
| alert('Hello World!'); |