├── Single-Page-App-with-REST-API ├── frontend │ ├── Final │ │ ├── views │ │ │ ├── error.pug │ │ │ ├── index.pug │ │ │ └── layout.pug │ │ ├── package.json │ │ ├── routes │ │ │ ├── users.js │ │ │ └── index.js │ │ ├── bin │ │ │ └── www │ │ ├── public │ │ │ ├── stylesheets │ │ │ │ └── style.css │ │ │ └── javascripts │ │ │ │ └── scripts.js │ │ └── app.js │ ├── Start │ │ ├── layout.pug │ │ ├── index.js │ │ ├── style.css │ │ └── scripts.js │ └── README.md ├── backend │ ├── data │ │ ├── mockgen.js │ │ ├── game.js │ │ ├── guess.js │ │ └── new.js │ ├── .vscode │ │ └── launch.json │ ├── README.md │ ├── package.json │ ├── handlers │ │ ├── game.js │ │ ├── new.js │ │ └── guess.js │ ├── server.js │ ├── api.json │ └── config │ │ └── swagger.json └── README.md ├── BabylonJS-game-with-WebVR ├── after │ ├── textures │ │ ├── skybox_nx.jpg │ │ ├── skybox_ny.jpg │ │ ├── skybox_nz.jpg │ │ ├── skybox_px.jpg │ │ ├── skybox_py.jpg │ │ └── skybox_pz.jpg │ ├── index.html │ ├── css │ │ └── stylesheet.css │ └── js │ │ └── main.js ├── before │ ├── textures │ │ ├── skybox_nx.jpg │ │ ├── skybox_ny.jpg │ │ ├── skybox_nz.jpg │ │ ├── skybox_px.jpg │ │ ├── skybox_py.jpg │ │ └── skybox_pz.jpg │ ├── index.html │ ├── css │ │ └── stylesheet.css │ └── js │ │ └── main.js └── README.md ├── README.md ├── LICENSE ├── SECURITY.md ├── .gitignore └── ThirdPartyNotices.txt /Single-Page-App-with-REST-API/frontend/Final/views/error.pug: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h1= message 5 | h2= error.status 6 | pre #{error.stack} 7 | -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/after/textures/skybox_nx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/after/textures/skybox_nx.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/after/textures/skybox_ny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/after/textures/skybox_ny.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/after/textures/skybox_nz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/after/textures/skybox_nz.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/after/textures/skybox_px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/after/textures/skybox_px.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/after/textures/skybox_py.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/after/textures/skybox_py.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/after/textures/skybox_pz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/after/textures/skybox_pz.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/before/textures/skybox_nx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/before/textures/skybox_nx.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/before/textures/skybox_ny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/before/textures/skybox_ny.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/before/textures/skybox_nz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/before/textures/skybox_nz.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/before/textures/skybox_px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/before/textures/skybox_px.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/before/textures/skybox_py.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/before/textures/skybox_py.jpg -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/before/textures/skybox_pz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Windows-tutorials-web/HEAD/BabylonJS-game-with-WebVR/before/textures/skybox_pz.jpg -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/data/mockgen.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var Swagmock = require('swagmock'); 3 | var Path = require('path'); 4 | var apiPath = Path.resolve(__dirname, '../config/swagger.json'); 5 | var mockgen; 6 | 7 | module.exports = function () { 8 | /** 9 | * Cached mock generator 10 | */ 11 | mockgen = mockgen || Swagmock(apiPath); 12 | return mockgen; 13 | }; 14 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Final/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "memorygamesample", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./bin/www" 7 | }, 8 | "dependencies": { 9 | "body-parser": "~1.17.1", 10 | "cookie-parser": "~1.4.3", 11 | "debug": "~2.6.3", 12 | "express": "~4.15.2", 13 | "morgan": "~1.8.1", 14 | "pug": "~2.0.0-beta11", 15 | "serve-favicon": "~2.4.2" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Final/views/index.pug: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | 5 | .container-fluid 6 | form(method="GET") 7 | select(id="selectGameSize" class="form-control" onchange="newGame()") 8 | option(value="0") New Game 9 | option(value="2") 2 Matches 10 | option(value="4") 4 Matches 11 | option(value="6") 6 Matches 12 | option(value="8") 8 Matches 13 | #game-board.row-fluid 14 | script restoreGame(); -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible Node.js debug attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "program": "${workspaceRoot}/server.js" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Start/layout.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | title= title 5 | link(rel='stylesheet', href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' integrity='sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u' crossorigin='anonymous') 6 | script(type="text/javascript" src=" http://code.jquery.com/jquery-3.1.1.min.js") 7 | script(type='text/javascript' src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' integrity='sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa' crossorigin='anonymous') 8 | link(rel='stylesheet', href='/stylesheets/style.css') 9 | script(type='text/javascript' src='/javascripts/scripts.js') 10 | body 11 | block content 12 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Final/views/layout.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | title= title 5 | link(rel='stylesheet', href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' integrity='sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u' crossorigin='anonymous') 6 | script(type="text/javascript" src=" http://code.jquery.com/jquery-3.1.1.min.js") 7 | script(type='text/javascript' src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' integrity='sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa' crossorigin='anonymous') 8 | link(rel='stylesheet', href='/stylesheets/style.css') 9 | script(type='text/javascript' src='/javascripts/scripts.js') 10 | body 11 | block content 12 | -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_type: sample 3 | languages: 4 | - javascript 5 | products: 6 | - windows 7 | statusNotificationTargets: 8 | - codefirst@microsoft.com 9 | urlFragment: get-started-webvr-babylon 10 | description: "This is the complete sample code for the getting started tutorial on WebVR and Babylon.js." 11 | --- 12 | 13 | # Get Started Tutorial: Adding WebVR support to a 3D Babylon.js game 14 | 15 | This is the complete sample code for the [Get Started Tutorial: Adding WebVR support to a 3D Babylon.js game](https://docs.microsoft.com/windows/uwp/get-started/adding-webvr-to-a-babylonjs-game) on [Windows Dev Center](https://developer.microsoft.com/windows). 16 | 17 | This sample takes a Babylon.js game (located in the **before** folder) and adds WebVR support to it so that the game can be viewed with a VR headset. 18 | The final game is located within the **after** folder. 19 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/README.md: -------------------------------------------------------------------------------- 1 | # REST API sample (Memory Game API) 2 | 3 | This is the complete code for Part I of [Get Started Tutorial: A single-page web app + REST API](https://docs.microsoft.com/en-us/windows/uwp/get-started/get-started-tutorial-fullstack-web-app). This code demonstrates the game logic for a simple game of *Memory* (also known as [Concentration](https://en.wikipedia.org/wiki/Concentration_(game))) using a cloud-hostable REST API service. 4 | 5 | ## Requirements: 6 | 7 | - [Node.js](https://nodejs.org/en/download/) - Be sure to select the option to add Node to your PATH. 8 | 9 | ## To run the sample: 10 | 11 | 1. Copy down this folder and open your favorite shell to it. 12 | 13 | 2. Run `npm install` to install the dependencies. 14 | 15 | 3. Run `npm start` to start the Node server. 16 | 17 | 4. Navigate to [http://localhost:8000/](http://localhost:8000/), which provides a [Swagger UI](http://swagger.io/swagger-ui/) that documents the operations provided by the Memory Game API and provides a manual testing interface. 18 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_type: sample 3 | languages: 4 | - javascript 5 | products: 6 | - windows 7 | statusNotificationTargets: 8 | - codefirst@microsoft.com 9 | urlFragment: get-started-single-page-app 10 | description: "This is the complete sample code for the tutorial on getting started with single page web apps and REST API." 11 | --- 12 | 13 | # Get Started Tutorial: A single-page web app + REST API - Sample Code 14 | 15 | This is the complete sample code for the [Get Started Tutorial: A single-page web app + REST API](https://docs.microsoft.com/windows/uwp/get-started/get-started-tutorial-fullstack-web-app) on [Windows Dev Center](https://developer.microsoft.com/windows). 16 | 17 | This 2-part sample uses popular fullstack web technologies to run a simple *Memory* game that both works in the browser and as a Hosted Web App for the Microsoft Store. 18 | 19 | The [backend](backend/README.md) folder demonstrates a simple REST API service for the cloud-hostable game logic, such that game state is preserved when playing across different devices. 20 | 21 | The [frontend](frontend/README.md) folder demonstrates a single-page web application with responsive layout for the game itself. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Windows Tutorials for Web Technologies - Sample Code 2 | 3 | This is the code sample repository for web-related tutorials on [Windows Dev Center](https://developer.microsoft.com/en-us/windows), including: 4 | 5 | - [Get Started Tutorial: Adding WebVR support to a 3D Babylon.js game](https://docs.microsoft.com/windows/uwp/get-started/adding-webvr-to-a-babylonjs-game) 6 | - [Get Started Tutorial: Single-page web app + REST API backend](https://docs.microsoft.com/windows/uwp/get-started/get-started-tutorial-fullstack-web-app) 7 | 8 | Refer to the README file in each sample's folder for requirements and instructions on running. 9 | 10 | ## Contributing 11 | 12 | We welcome your input on issues and suggestions for new samples! Please file them as issues on this GitHub repo. At this time we are not accepting new samples from the public, but please check back as we evolve our contribution model. 13 | 14 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "memorygameapisample", 3 | "description": "", 4 | "version": "1.0.0", 5 | "author": "Microsoft Corporation", 6 | "contributors": [], 7 | "repository": { 8 | "type": "git", 9 | "url": "git://github.com/Microsoft/Windows-tutorials-web/" 10 | }, 11 | "bugs": "http://github.com/Microsoft/Windows-tutorials-web/issues", 12 | "publishConfig": { 13 | "registry": "https://registry.npmjs.org" 14 | }, 15 | "dependencies": { 16 | "body-parser": "^1.15.0", 17 | "express": "^4.0.0", 18 | "swaggerize-express": "^4.0.0", 19 | "swaggerize-ui": "^1.0.1", 20 | "swagmock": "~0.0.2" 21 | }, 22 | "devDependencies": { 23 | "eslint": "^2", 24 | "istanbul": "~0.4.3", 25 | "is-my-json-valid": "^2.13.1", 26 | "js-yaml": "^3.2.6", 27 | "supertest": "^1.2.0", 28 | "swagger-parser": "^3.4.1", 29 | "tape": "^4" 30 | }, 31 | "scripts": { 32 | "test": "tape 'tests/**/*.js'", 33 | "cover": "istanbul cover tape -- 'tests/**/*.js'", 34 | "lint": "eslint .", 35 | "regenerate": "yo swaggerize:test --framework express --apiPath './config/swagger.json'" 36 | }, 37 | "generator-swaggerize": { 38 | "version": "3.1.0" 39 | }, 40 | "main": "./server" 41 | } 42 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/README.md: -------------------------------------------------------------------------------- 1 | # Single-page web app sample (Memory Game app) 2 | 3 | This folder contains the initial and completed front-end code for Part II of [Get Started Tutorial: A single-page web app + REST API](https://docs.microsoft.com/en-us/windows/uwp/get-started/get-started-tutorial-fullstack-web-app). This code demonstrates the UI for simple game of *Memory* (also known as [Concentration](https://en.wikipedia.org/wiki/Concentration_(game))) as a single-page web app that works across devices. 4 | 5 | ## Requirements: 6 | 7 | - [Node.js](https://nodejs.org/en/download/) - Be sure to select the option to add Node to your PATH. 8 | 9 | - [Express generator](http://expressjs.com/en/starter/generator.html)- After you install Node, install Express by running `npm install express-generator -g` 10 | 11 | ## To run the sample: 12 | 13 | 1. Copy down the parent folder *Single-Page-App-with-REST-API* for both the backend and frontend samples. 14 | 15 | 2. Follow the README directions in the [.\backend](..\backend\README.md) folder to start running the REST API service (on [http://localhost:8000/](http://localhost:8000/)). 16 | 17 | 3. Open your favorite shell to the *.\frontend\Final* subfolder. 18 | 19 | 4. Run `npm install` to install the dependencies. 20 | 21 | 5. Run `npm start` to start the Node server. 22 | 23 | 6. Navigate to [http://localhost:3000/](http://localhost:3000/). Select a new game from the dropdown menu, and start clicking on cards to reveal their values and find matches. 24 | -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/after/index.html: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/before/index.html: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Start/index.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | module.exports = function (app) { 25 | 26 | app.get('/', function (req, res, next) { 27 | 28 | res.render('index', { title: 'Memory Game Sample' }); 29 | 30 | }); 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Final/routes/users.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | var express = require('express'); 25 | var router = express.Router(); 26 | 27 | /* GET users listing. */ 28 | router.get('/', function(req, res, next) { 29 | res.send('respond with a resource'); 30 | }); 31 | 32 | module.exports = router; 33 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Final/routes/index.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | var express = require('express'); 25 | var router = express.Router(); 26 | 27 | /* GET home page. */ 28 | router.get('/', function(req, res, next) { 29 | res.render('index', { title: 'Memory Game Sample' }); 30 | }); 31 | 32 | module.exports = router; 33 | -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/after/css/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* 2 | // --------------------------------------------------------------------------------- 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // The MIT License (MIT) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // --------------------------------------------------------------------------------- 25 | */ 26 | 27 | html, body { 28 | overflow: hidden; 29 | width : 100%; 30 | height : 100%; 31 | margin : 0; 32 | padding : 0; 33 | } 34 | 35 | #renderCanvas { 36 | width : 100%; 37 | height : 100%; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /BabylonJS-game-with-WebVR/before/css/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* 2 | // --------------------------------------------------------------------------------- 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // The MIT License (MIT) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // --------------------------------------------------------------------------------- 25 | */ 26 | 27 | html, body { 28 | overflow: hidden; 29 | width : 100%; 30 | height : 100%; 31 | margin : 0; 32 | padding : 0; 33 | } 34 | 35 | #renderCanvas { 36 | width : 100%; 37 | height : 100%; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Final/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | var app = require('../app'); 8 | var debug = require('debug')('memory:server'); 9 | var http = require('http'); 10 | 11 | /** 12 | * Get port from environment and store in Express. 13 | */ 14 | 15 | var port = normalizePort(process.env.PORT || '3000'); 16 | app.set('port', port); 17 | 18 | /** 19 | * Create HTTP server. 20 | */ 21 | 22 | var server = http.createServer(app); 23 | 24 | /** 25 | * Listen on provided port, on all network interfaces. 26 | */ 27 | 28 | server.listen(port); 29 | server.on('error', onError); 30 | server.on('listening', onListening); 31 | 32 | /** 33 | * Normalize a port into a number, string, or false. 34 | */ 35 | 36 | function normalizePort(val) { 37 | var port = parseInt(val, 10); 38 | 39 | if (isNaN(port)) { 40 | // named pipe 41 | return val; 42 | } 43 | 44 | if (port >= 0) { 45 | // port number 46 | return port; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | /** 53 | * Event listener for HTTP server "error" event. 54 | */ 55 | 56 | function onError(error) { 57 | if (error.syscall !== 'listen') { 58 | throw error; 59 | } 60 | 61 | var bind = typeof port === 'string' 62 | ? 'Pipe ' + port 63 | : 'Port ' + port; 64 | 65 | // handle specific listen errors with friendly messages 66 | switch (error.code) { 67 | case 'EACCES': 68 | console.error(bind + ' requires elevated privileges'); 69 | process.exit(1); 70 | break; 71 | case 'EADDRINUSE': 72 | console.error(bind + ' is already in use'); 73 | process.exit(1); 74 | break; 75 | default: 76 | throw error; 77 | } 78 | } 79 | 80 | /** 81 | * Event listener for HTTP server "listening" event. 82 | */ 83 | 84 | function onListening() { 85 | var addr = server.address(); 86 | var bind = typeof addr === 'string' 87 | ? 'pipe ' + addr 88 | : 'port ' + addr.port; 89 | debug('Listening on ' + bind); 90 | } 91 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/handlers/game.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | 'use strict'; 25 | var dataProvider = require('../data/game.js'); 26 | /** 27 | * Operations on /game 28 | */ 29 | module.exports = { 30 | /** 31 | * summary: Retrieves the current state of the memory game board. 32 | * parameters: (none) 33 | * produces: application/json, text/json 34 | * responses: 200, 400 35 | */ 36 | get: function game_get(req, res, next) { 37 | var status; 38 | var message; 39 | 40 | // If there's a game in progress, retrieve its current state 41 | if (global.board){ 42 | status = 200; 43 | var provider = dataProvider['get']['200']; 44 | var board = provider(req, res, function (err, data) { 45 | if (err) { 46 | next(err); 47 | return; 48 | } 49 | }); 50 | res.json(board); 51 | } 52 | else { // No game in progress: set bad request error 53 | status = 400; 54 | message = "Please start a new game (POST '/new?size={# of matches}')." 55 | } 56 | res.status(status).send(message); 57 | } 58 | }; 59 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/data/game.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | 'use strict'; 25 | var Mockgen = require('./mockgen.js'); 26 | /** 27 | * Operations on /game 28 | */ 29 | module.exports = { 30 | /** 31 | * summary: Retrieves the current state of the game 32 | * description: Returns an array of card objects, where position in 33 | * the array indicates card ID and the "cleared" property indicates 34 | * if its match has already been found. The value of cleared cards is also 35 | * reported. 36 | * 37 | * parameters: (none) 38 | * produces: application/json, text/json 39 | * responses: 200 40 | * operationId: game_get 41 | */ 42 | get: { 43 | 200: function (req, res, callback) { 44 | // Only reveal cleared card values 45 | var currentBoardState = []; 46 | var board = global.board; 47 | 48 | for (var i=0; i < board.length; i++){ 49 | var card = {}; 50 | card.cleared = board[i].cleared; 51 | if ("true" == card.cleared) { // To debug the board, comment this line 52 | card.value = board[i].value; 53 | } // And this line 54 | currentBoardState.push(card); 55 | } 56 | return currentBoardState; 57 | } 58 | } 59 | }; 60 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/data/guess.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | 'use strict'; 25 | var Mockgen = require('./mockgen.js'); 26 | var card1 = null; 27 | /** 28 | * Operations on /guess 29 | */ 30 | module.exports = { 31 | /** 32 | * summary: Reveals the specified card and checks for match to the previous. 33 | * description: Each guess consists of 2 specified cards. 34 | * parameters: card 35 | * produces: application/json, text/json 36 | * responses: 200 37 | * operationId: game_guess 38 | */ 39 | put: { 40 | 200: function (req, res, callback) { 41 | // Obtain the card values 42 | var response = {}; 43 | var card = req.query.card; 44 | 45 | response.id = card; 46 | response.value = global.board[card].value; 47 | 48 | // If 1st card has been specified, check if this 2nd card matches 49 | if (card1 !== null){ 50 | if (global.board[card1].value === global.board[card].value){ 51 | global.board[card1].cleared = 52 | global.board[card].cleared = "true"; 53 | } 54 | card1 = null; 55 | } else { // This is the 1st card of the guess 56 | card1 = card; 57 | } 58 | 59 | return Array(response); 60 | } 61 | } 62 | }; 63 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Start/style.css: -------------------------------------------------------------------------------- 1 | /********************************************************* 2 | // 3 | // Copyright (c) Microsoft. All rights reserved. 4 | // This code is licensed under the MIT License (MIT). 5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF 6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY 7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR 8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. 9 | // 10 | //********************************************************* 11 | /* general styles */ 12 | 13 | body { 14 | background: #000000; 15 | color: #000000; 16 | } 17 | 18 | html, body, .container-fluid, .row-fluid { 19 | height: 96%; 20 | } 21 | 22 | /* Boostrap overrides */ 23 | 24 | .form-control { 25 | width: 15%; 26 | min-width: 150px; 27 | float: right; 28 | margin-top: 10px; 29 | margin-right: 5px; 30 | } 31 | 32 | .btn { 33 | margin: 5px; 34 | } 35 | 36 | .col-xs-3 { 37 | padding: 0; 38 | } 39 | 40 | .container-fluid { 41 | min-width: 305px; 42 | min-height: 305px; 43 | } 44 | 45 | 46 | /* game setup */ 47 | 48 | #game-board { 49 | margin: 0 auto; 50 | position: relative; 51 | clear: both; 52 | } 53 | 54 | #playAgain { 55 | text-align: center; 56 | } 57 | 58 | 59 | #playAgain p { 60 | margin: 0 auto; 61 | color: #5fe883; 62 | font-size: 2em; 63 | } 64 | 65 | /* cards */ 66 | 67 | .flipContainer { 68 | position: relative; 69 | border: 1vh solid transparent; 70 | min-height: 50px; 71 | min-width: 50px; 72 | /* add code from Part 5.1 here */ 73 | } 74 | 75 | .cards { 76 | position: absolute; 77 | width: 100%; 78 | height: 100%; 79 | border: solid 3px #000000; 80 | /* add code from Part 5.2 here */ 81 | } 82 | 83 | .cards div { 84 | margin: 0; 85 | width: 100%; 86 | height: 100%; 87 | display: block; 88 | position: absolute; 89 | backface-visibility: hidden; 90 | } 91 | 92 | .cards .front { 93 | background-color: #ffffff; 94 | text-align: center; 95 | display: table; 96 | } 97 | 98 | .cards .back { 99 | transform: rotateY(180deg); 100 | background-color: #D3D3D3; 101 | text-align: center; 102 | display: table; 103 | } 104 | 105 | .cards.matched .back { 106 | background-color: #5fe883; 107 | } 108 | 109 | .cards .back .glyphicon { 110 | display: table-cell; 111 | vertical-align: middle; 112 | font-size: 8vh; 113 | } 114 | 115 | .cards .front .glyphicon { 116 | display: table-cell; 117 | vertical-align: middle; 118 | font-size: 8vh; 119 | } 120 | 121 | .cards.flip { 122 | /* add code from Part 5.3 here */ 123 | } 124 | 125 | .rows1 { 126 | height: 100%; 127 | } 128 | 129 | .rows2 { 130 | height: 50%; 131 | } 132 | 133 | .rows3 { 134 | height: 33%; 135 | } 136 | 137 | .rows4 { 138 | height: 25%; 139 | } 140 | 141 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Final/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | /********************************************************* 2 | // 3 | // Copyright (c) Microsoft. All rights reserved. 4 | // This code is licensed under the MIT License (MIT). 5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF 6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY 7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR 8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. 9 | // 10 | //********************************************************* 11 | /* general styles */ 12 | 13 | body { 14 | background: #000000; 15 | color: #000000; 16 | } 17 | 18 | html, body, .container-fluid, .row-fluid { 19 | height: 96%; 20 | } 21 | 22 | /* Boostrap overrides */ 23 | 24 | .form-control { 25 | width: 15%; 26 | min-width: 150px; 27 | float: right; 28 | margin-top: 10px; 29 | margin-right: 5px; 30 | } 31 | 32 | .btn { 33 | margin: 5px; 34 | } 35 | 36 | .col-xs-3 { 37 | padding: 0; 38 | } 39 | 40 | .container-fluid { 41 | min-width: 305px; 42 | min-height: 305px; 43 | } 44 | 45 | 46 | /* game setup */ 47 | 48 | #game-board { 49 | margin: 0 auto; 50 | position: relative; 51 | clear: both; 52 | } 53 | 54 | #playAgain { 55 | text-align: center; 56 | } 57 | 58 | 59 | #playAgain p { 60 | margin: 0 auto; 61 | color: #5fe883; 62 | font-size: 2em; 63 | } 64 | 65 | /* cards */ 66 | 67 | .flipContainer { 68 | position: relative; 69 | border: 1vh solid transparent; 70 | min-height: 50px; 71 | min-width: 50px; 72 | perspective: 1000px; 73 | } 74 | 75 | .cards { 76 | position: absolute; 77 | width: 100%; 78 | height: 100%; 79 | border: solid 3px #000000; 80 | transform-style: preserve-3d; 81 | transition-duration: 1s; 82 | } 83 | 84 | .cards div { 85 | margin: 0; 86 | width: 100%; 87 | height: 100%; 88 | display: block; 89 | position: absolute; 90 | backface-visibility: hidden; 91 | } 92 | 93 | .cards .front { 94 | background-color: #ffffff; 95 | text-align: center; 96 | display: table; 97 | } 98 | 99 | .cards .back { 100 | transform: rotateY(180deg); 101 | background-color: #D3D3D3; 102 | text-align: center; 103 | display: table; 104 | } 105 | 106 | .cards.matched .back { 107 | background-color: #5fe883; 108 | } 109 | 110 | .cards .back .glyphicon { 111 | display: table-cell; 112 | vertical-align: middle; 113 | font-size: 8vh; 114 | } 115 | 116 | .cards .front .glyphicon { 117 | display: table-cell; 118 | vertical-align: middle; 119 | font-size: 8vh; 120 | } 121 | 122 | .cards.flip { 123 | transform: rotateY(180deg); 124 | } 125 | 126 | .rows1 { 127 | height: 100%; 128 | } 129 | 130 | .rows2 { 131 | height: 50%; 132 | } 133 | 134 | .rows3 { 135 | height: 33%; 136 | } 137 | 138 | .rows4 { 139 | height: 25%; 140 | } 141 | 142 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/frontend/Final/app.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | var express = require('express'); 25 | var path = require('path'); 26 | var favicon = require('serve-favicon'); 27 | var logger = require('morgan'); 28 | var cookieParser = require('cookie-parser'); 29 | var bodyParser = require('body-parser'); 30 | 31 | var index = require('./routes/index'); 32 | var users = require('./routes/users'); 33 | 34 | var app = express(); 35 | 36 | // view engine setup 37 | app.set('views', path.join(__dirname, 'views')); 38 | app.set('view engine', 'pug'); 39 | 40 | // uncomment after placing your favicon in /public 41 | //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); 42 | app.use(logger('dev')); 43 | app.use(bodyParser.json()); 44 | app.use(bodyParser.urlencoded({ extended: false })); 45 | app.use(cookieParser()); 46 | app.use(express.static(path.join(__dirname, 'public'))); 47 | 48 | app.use('/', index); 49 | app.use('/users', users); 50 | 51 | // catch 404 and forward to error handler 52 | app.use(function(req, res, next) { 53 | var err = new Error('Not Found'); 54 | err.status = 404; 55 | next(err); 56 | }); 57 | 58 | // error handler 59 | app.use(function(err, req, res, next) { 60 | // set locals, only providing error in development 61 | res.locals.message = err.message; 62 | res.locals.error = req.app.get('env') === 'development' ? err : {}; 63 | 64 | // render the error page 65 | res.status(err.status || 500); 66 | res.render('error'); 67 | }); 68 | 69 | module.exports = app; 70 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/handlers/new.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | 'use strict'; 25 | var dataProvider = require('../data/new.js'); 26 | var MAX_MATCHES = 20; 27 | /** 28 | * Operations on /new 29 | */ 30 | module.exports = { 31 | /** 32 | * summary: Initializes a new game board of the specified size (# of matches) 33 | * parameters: size 34 | * produces: application/json, text/json 35 | * responses: 200, 400 36 | */ 37 | post: function game_new(req, res, next) { 38 | var status; 39 | var message; 40 | global.board = null; // Null out the current game 41 | 42 | // This is a valid game size: initialize new game board 43 | if ((req.query.size > 0)&&(req.query.size <= MAX_MATCHES)){ 44 | status = 200; 45 | var provider = dataProvider['post']['200']; 46 | 47 | // Call the data layer to shuffle up a new game 48 | var board = provider(req, res, function (err, data) { 49 | if (err) { 50 | next(err); 51 | return; 52 | } 53 | }); 54 | message = "Ready to play! Matches to find = " + 55 | req.query.size; 56 | } else { // Invalid # of matches specified: set bad request error 57 | status = 400; 58 | message = "Size of game (# of matches) must be between 1 and " + 59 | MAX_MATCHES + ". Specified size = " + req.query.size; 60 | } 61 | res.status(status).send(message); 62 | } 63 | }; 64 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/server.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | 'use strict'; 25 | 26 | var port = process.env.PORT || 8000; // Better flexibility than hardcoding the port 27 | 28 | var Http = require('http'); 29 | var Express = require('express'); 30 | var BodyParser = require('body-parser'); 31 | var Swaggerize = require('swaggerize-express'); 32 | var SwaggerUi = require('swaggerize-ui'); // Provides UI for testing our API 33 | var Path = require('path'); 34 | 35 | var App = Express(); 36 | var Server = Http.createServer(App); 37 | 38 | App.use(function(req, res, next) { // Enable cross origin resource sharing (for app frontend) 39 | res.header('Access-Control-Allow-Origin', '*'); 40 | res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,OPTIONS'); 41 | res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With'); 42 | 43 | // Prevents CORS preflight request (for PUT game_guess) from redirecting 44 | if ('OPTIONS' == req.method) { 45 | res.send(200); 46 | } 47 | else { 48 | next(); // Passes control to next (Swagger) handler 49 | } 50 | }); 51 | 52 | App.use(BodyParser.json()); 53 | App.use(BodyParser.urlencoded({ 54 | extended: true 55 | })); 56 | 57 | App.use(Swaggerize({ 58 | api: Path.resolve('./config/swagger.json'), 59 | handlers: Path.resolve('./handlers'), 60 | docspath: '/swagger' // Hooks up the testing UI 61 | })); 62 | 63 | App.use('/', SwaggerUi({ // Serves the testing UI from our base URL 64 | docs: '/swagger' // 65 | })); 66 | 67 | Server.listen(port, function () { // Starts server with our modfied port settings 68 | }); 69 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/handlers/guess.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | 'use strict'; 25 | var dataProvider = require('../data/guess.js'); 26 | /** 27 | * Operations on /guess 28 | */ 29 | module.exports = { 30 | /** 31 | * summary: Specifies a card (ID) to reveal 32 | * parameters: card 33 | * produces: application/json, text/json 34 | * responses: 200, 400 35 | */ 36 | put: function game_guess(req, res, next) { 37 | var status, message; 38 | var validGuess = true; 39 | var board = global.board; 40 | var guess = req.query.card; 41 | 42 | // Ensure there's a game running 43 | if (!board){ 44 | validGuess = false; 45 | message = "Please start a new game (POST '/new?size={# of matches}')." 46 | } 47 | // Ensure card isn't out of range 48 | else if ((guess < 0)||(guess > board.length)){ 49 | validGuess = false; 50 | message = "Please specify card ids within the range of 0 to " + 51 | String(board.length-1) + "."; 52 | } 53 | // Check that card hasn't been cleared 54 | else if ("true" == board[guess].cleared) { 55 | validGuess = false; 56 | message = "Please specify a card which hasn't been cleared." 57 | } 58 | 59 | // This is a valid guess: reveal the card 60 | if (validGuess){ 61 | status = 200; 62 | var provider = dataProvider['put']['200']; 63 | var card = provider(req, res, function (err, data) { 64 | if (err) { 65 | next(err); 66 | return; 67 | } 68 | }); 69 | res.json(card); 70 | } else { // This is not a valid guess: set bad request error 71 | status = 400; 72 | } 73 | 74 | res.status(status).send(message); 75 | } 76 | }; 77 | -------------------------------------------------------------------------------- /Single-Page-App-with-REST-API/backend/data/new.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // --------------------------------------------------------------------------------- 24 | 'use strict'; 25 | var Mockgen = require('./mockgen.js'); 26 | 27 | // Knuth shuffle courtesy of https://www.kirupa.com/html5/shuffling_array_js.htm 28 | Array.prototype.shuffle = function() { 29 | var input = this; 30 | for (var i=input.length-1; i >=0; i--){ 31 | var randomIndex = Math.floor(Math.random()*(i+1)); 32 | var itemAtIndex = input[randomIndex]; 33 | input[randomIndex] = input[i]; 34 | input[i] = itemAtIndex; 35 | } 36 | return input; 37 | }; 38 | /** 39 | * Operations on /new 40 | */ 41 | module.exports = { 42 | /** 43 | * summary: Sets up a new game board with specified # of matches 44 | * description: The game board is a global array of "card" objects, where 45 | * their position in the array indicates their ID, and their "value" and 46 | * "cleared" properties represent their value and game status. For example, 47 | * a new board of size=1 (1 matches) would be generated as: 48 | * [ 49 | * { "cleared":"false", 50 | * "value":"0", 51 | * }, 52 | * { "cleared":"false", 53 | * "value":"0", 54 | * } 55 | * ] 56 | * parameters: size 57 | * produces: application/json, text/json 58 | * responses: 200 59 | * operationId: game_new 60 | */ 61 | post: { 62 | 200: function (req, res, callback) { 63 | // Generate random [0...size] value pairs and shuffle them 64 | var values = Array.from(Array(req.query.size).keys()); 65 | var deck = values.concat(values.slice()); 66 | deck.shuffle(); 67 | 68 | // Create corresponding card objects 69 | var board = []; 70 | for (var i=0; iYou Win!