Code Work

WORKING SHIT!
master
Paulo Vieira 2017-12-27 10:47:04 +00:00
parent 2376456fa9
commit 7528e0c730
67 changed files with 6253 additions and 2431 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers;
use App\Http\Resources\Department as DepartmentResource;
use Illuminate\Http\Request;
use App\Department;
class DepartmentControllerAPI extends Controller
{
//
public function index()
{
return DepartmentResource::collection(Department::all());
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Resources\Game as GameResource;
use App\Game;
class MemoryGameControllerAPI extends Controller
{
public function index()
{
return GameResource::collection(Game::all());
}
public function lobby()
{
return GameResource::collection(Game::where('status', 'pending')->get());
}
public function gamesStatus($status)
{
return GameResource::collection(Game::where('status', $status)->get());
}
public function getGame($id)
{
return new GameResource(Game::find($id));
}
public function store(Request $request)
{
$request->validate([
'player1' => 'required',
]);
$game = new Game();
$game->fill($request->all());
// No matter what status and winner was defined on the client.
// When creating a game it will always assume "pending" status
// and winner will be null
$game->status = 'pending';
$game->winner = null;
$game->save();
return response()->json(new GameResource($game), 201);
}
public function joinAndStart(Request $request, $id)
{
$player2 = $request->all()["player2"];
$game = Game::findOrFail($id);
if (!(is_null($game->player2) || ($game->player2 == ""))) {
return response()->json(array('code'=> 409, 'message' => 'Cannot join a game that already has a second player'), 409);
}
if (is_null($game->status) || ($game->status != "pending")) {
return response()->json(array('code'=> 409, 'message' => 'Cannot join a game whose status is not "pending"'), 409);
}
$game->player2 = $player2;
$game->status = 'active';
$game->save();
return new GameResource($game);
}
public function endgame($id, $winner)
{
$game = Game::findOrFail($id);
if (is_null($game->player1) || ($game->player1 == "")) {
return response()->json(array('code'=> 409, 'message' => 'Cannot end a game that has no first player'), 409);
}
if (is_null($game->player2) || ($game->player2 == "")) {
return response()->json(array('code'=> 409, 'message' => 'Cannot end a game that has no second player'), 409);
}
if (is_null($game->status) || ($game->status != "active")) {
return response()->json(array('code'=> 409, 'message' => 'Cannot end a game whose status is not "active"'), 409);
}
if (($winner != 0) && ($winner != 1) && ($winner != 2)) {
return response()->json(array('code'=> 409, 'message' => 'To end a game winner must be 0 (tie), 1 (player1) or 2 (player2)'), 409);
}
$game->winner = $winner;
$game->status = 'complete';
$game->save();
return new GameResource($game);
}
}

View File

@ -9,10 +9,4 @@ class VueController extends Controller
return view('vue.index');
}
public function userProfile()
{
return view('vue.user.profile');
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class Department extends Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
//return parent::toArray($request);
return [
'id' => $this->id,
'name' => $this->name,
'date' => $this->updated_at->toDateTimeString()
];
}
}

View File

@ -19,7 +19,8 @@ class User extends Resource
'name' => $this->name,
'email' => $this->email,
'age' => $this->age,
'nickname' => $this->nickname,
'department_id' => $this->department_id,
'department' => $this->department->name,
];
}
}

View File

@ -18,8 +18,7 @@ class User extends Authenticatable
'name',
'email',
'age',
'nickname',
'blocked'
'department_id',
];
/**
@ -28,8 +27,11 @@ class User extends Authenticatable
* @var array
*/
protected $hidden = [
'password', 'remember_token', 'admin'
'password', 'remember_token',
];
public function department()
{
return $this->belongsTo(Department::class);
}
}

View File

@ -13,16 +13,20 @@ class InitialMigrations extends Migration
*/
public function up()
{
Schema::create('departments', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->timestamps();
});
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('nickname');
$table->string('password');
$table->rememberToken();
$table->integer('age');
$table->integer('admin');
$table->integer('blocked');
$table->integer('department_id')->unsigned();
$table->foreign('department_id')->references('id')->on('departments');
$table->timestamps();
});
Schema::create('password_resets', function (Blueprint $table) {
@ -32,7 +36,7 @@ class InitialMigrations extends Migration
});
}
/**
* Reverse the migrations.
*
@ -40,6 +44,7 @@ class InitialMigrations extends Migration
*/
public function down()
{
Schema::dropIfExists('departments');
Schema::dropIfExists('password_resets');
Schema::dropIfExists('users');
}

View File

@ -11,6 +11,7 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
$this->call(DepartmentsTableSeeder::class);
$this->call(UsersTableSeeder::class);
}
}

View File

@ -13,12 +13,14 @@ class UsersTableSeeder extends Seeder
public function run()
{
$faker = Faker\Factory::create('pt_PT');
$departments = DB::table('departments')->pluck('id')->toArray();
for ($i = 0; $i < $this->numberOfUsers; ++$i) {
DB::table('users')->insert($this->fakeUser($faker));
DB::table('users')->insert($this->fakeUser($faker, $faker->randomElement($departments)));
}
}
private function fakeUser(Faker\Generator $faker)
private function fakeUser(Faker\Generator $faker, $departmentId)
{
static $password;
$createdAt = Carbon\Carbon::now()->subDays(30);
@ -26,12 +28,10 @@ class UsersTableSeeder extends Seeder
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'nickname' => $faker->unique()->name,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
'age' => $faker->numberBetween(18, 75),
'admin' => 0,
'blocked' => 0,
'department_id' => $departmentId,
'created_at' => $createdAt,
'updated_at' => $updatedAt,
];

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
"hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
},
"devDependencies": {
"axios": "^0.16.2",
"bootstrap-sass": "^3.3.7",

BIN
laravel/public/img/0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

BIN
laravel/public/img/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
laravel/public/img/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -60,17 +60,24 @@
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 53);
/******/ return __webpack_require__(__webpack_require__.s = 74);
/******/ })
/************************************************************************/
/******/ ({
/***/ 53:
/***/ 74:
/***/ (function(module, exports, __webpack_require__) {
(function webpackMissingModule() { throw new Error("Cannot find module \"/home/vagrant/memoryGame/resources/assets/js/tictactoe.js\""); }());
module.exports = __webpack_require__(75);
/***/ }),
/***/ 75:
/***/ (function(module, exports) {
throw new Error("Module build failed: Error: ENOENT: no such file or directory, open '/home/vagrant/projeto/resources/assets/js/tictactoe.js'\n at Error (native)");
/***/ })
/******/ });

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,3 @@
{
"/js/vueapp.js": "/js/vueapp.js",
"/js/tictactoe.js": "/js/tictactoe.js"
"/js/vueapp.js": "/js/vueapp.js"
}

View File

@ -0,0 +1,42 @@
<template>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr v-for="department in departments" :key="department.id">
<td>{{ department.name }}</td>
<td>{{ department.date }}</td>
</tr>
</tbody>
</table>
</template>
<script type="text/javascript">
// Component code (not registered)
module.exports={
data: function () {
return {
departments: []
}
},
mounted(){
if (this.$root.departments.length === 0) {
axios.get('api/departments')
.then(response=>{
this.$root.departments = response.data.data;
this.departments = this.$root.departments;
})
} else {
this.departments = this.$root.departments;
}
}
}
</script>
<style scoped>
/* Specific style applied only on the component*/
</style>

View File

@ -1,58 +1,131 @@
<template>
<div>
<div>
<h3 class="text-center">{{ title }}</h3>
</div> <!--<br>
<h2>Current Player : {{ currentPlayer }}</h2>
<br>
</div>
<div class="game-zone-content">
<div class="alert alert-success" v-if="showSuccess">
<button type="button" class="close-btn" v-on:click="showSuccess=false">&times;</button>
<strong>{{ successMessage }} &nbsp;&nbsp;&nbsp;&nbsp;<a v-show="gameEnded" v-on:click.prevent="restartGame">Restart</a></strong>
</div>
<div class="board">
<div v-for="(piece, key) of board" >
<img v-bind:src="pieceImageURL(piece)" v-on:click="clickPiece(key)">
<div class="gameseparator">
<div>
<h2 class="text-center">Game {{ game.gameID }}</h2>
<br>
</div>
<div class="game-zone-content">
<div class="alert" :class="alerttype">
<strong>{{ message }} &nbsp;&nbsp;&nbsp;&nbsp;<a v-show="game.gameEnded" v-on:click.prevent="closeGame">Close Game</a></strong>
</div>
<div>
<p><button class="btn btn-xs btn-success" v-on:click.prevent="startGame(game)">Start Game</button></p>
</div>
<div class="board">
<div class="board">
<div class="line" v-for="(line, x) in game.boardImages" >
<div v-for="(piece, y) in line" >
{{x}}{{y}}
<img v-bind:src="pieceImageURL(piece, x, y)" v-on:click="clickPiece(x,y)">
</div>
</div>
</div>
</div>
<hr>
</div> -->
</div>
</div>
</template>
</template type="text/javascript">
<script type="text/javascript">
export default {
props: ['game'],
data: function(){
return {
title: 'Memory Game',
showSuccess: false,
showFailure: false,
successMessage: '',
failMessage: '',
currentValue: 1,
gameEnded:false,
player1User: undefined,
player2User: undefined,
board: [0,0,0,0,0,0,0,0,0]
return {
}
},
computed: {
ownPlayerNumber(){
if (this.game.player1SocketID == this.$parent.socketId) {
return 1;
} else if (this.game.player2SocketID == this.$parent.socketId) {
return 2;
}
return 0;
},
ownPlayerName(){
var ownNumber = this.ownPlayerNumber;
if (ownNumber == 1)
return this.game.player1;
if (ownNumber == 2)
return this.game.player2;
return "Unknown";
},
adversaryPlayerName(){
var ownNumber = this.ownPlayerNumber;
if (ownNumber == 1)
return this.game.player2;
if (ownNumber == 2)
return this.game.player1;
return "Unknown";
},
message(){
if (!this.game.gameStarted) {
return "Game has not started yet";
} else if (this.game.gameEnded) {
if (this.game.winner == this.ownPlayerNumber) {
return "Game has ended. You Win.";
} else if (this.game.winner == 0) {
return "Game has ended. There was a tie.";
}
return "Game has ended and " + this.adversaryPlayerName + " has won. You lost.";
} else {
if (this.game.playerTurn == this.ownPlayerNumber) {
return "It's your turn";
} else {
return "It's " + this.adversaryPlayerName + " turn";
}
}
return "Game is inconsistent";
},
alerttype(){
if (!this.game.gameStarted) {
return "alert-warning";
} else if (this.game.gameEnded) {
if (this.game.winner == this.ownPlayerNumber) {
return "alert-success";
} else if (this.game.winner == 0) {
return "alert-info";
}
return "alert-danger";
}
if (this.game.playerTurn == this.ownPlayerNumber) {
return "alert-success";
} else {
return "alert-info";
}
}
},
methods: {
startGame(game){
this.$socket.emit('start_game', {gameID: game.gameID});
},
pieceImageURL (pieceNumber, x,y) {
var imgSrc = String(pieceNumber);
return 'img/' + imgSrc + '.png';
},
closeGame (){
this.$parent.close(this.game);
},
clickPiece(x,y){
if (!this.game.gameEnded) {
if (this.game.playerTurn != this.ownPlayerNumber) {
alert("It's not your turn to play");
} else {
if (this.game.board[index] == 0) {
this.$parent.play(this.game, index);
}
}
}
}
<script>
}
}
</script>
<style>
<style scoped>
.gameseparator{
border-style: solid;
border-width: 2px 0 0 0;
border-color: black;
}
</style>

View File

@ -1,81 +0,0 @@
<template>
<div>
<div class="jumbotron">
<h1>{{ title }}</h1>
</div>
<user-list :users="users" @edit-click="editUser" @delete-click="deleteUser" @message="childMessage" ref="usersListRef"></user-list>
<div class="alert alert-success" v-if="showSuccess">
<button type="button" class="close-btn" v-on:click="showSuccess=false">&times;</button>
<strong>{{ successMessage }}</strong>
</div>
<user-edit :user="currentUser" @user-saved="savedUser" @user-canceled="cancelEdit" v-if="currentUser"></user-edit>
</div>
</template>
<script type="text/javascript">
import UserList from './userList.vue';
import UserEdit from './userEdit.vue';
export default {
data: {
title: 'User Profile',
editingUser: false,
showSuccess: false,
showFailure: false,
successMessage: '',
failMessage: '',
currentUser: null,
user: null
},
methods: {
editUser: function(user){
this.currentUser = user;
this.editingUser = true;
this.showSuccess = false;
},
saveUser: function(){
this.editingUser = false; // desaparece na vista esta secção
axios.put('api/users/'+this.currentUser.username,this.currentUser)
.then(response=>{
this.showSuccess = true;
this.successMessage = 'Your details have been saved';
// Copies response.data.data properties to this.currentUser
// without changing this.currentUser reference
Object.assign(this.currentUser, response.data.data);
this.currentUser = null;
this.editingUser = false;
});
},
cancelEdit: function(){
this.showSuccess = false;
this.editingUser = false;
axios.get('api/users/'+this.currentUser.username)
.then(response=>{
console.dir (this.currentUser);
// Copies response.data.data properties to this.currentUser
// without changing this.currentUser reference
Object.assign(this.currentUser, response.data.data);
console.dir (this.currentUser);
this.currentUser = null;
});
},
getLoginUser: function() {
axios.get('api/login')
.then(response=>{this.user = response.data.data;});
}
},
mounted() {
}
}
</script>
<style scoped>
p {
font-size: 2em;
text-align: center;
}
</style>

View File

@ -0,0 +1,140 @@
<template>
<div>
<div>
<h3 class="text-center">{{ title }}</h3>
<br>
<h2>Current Player : {{ currentPlayer }}</h2>
<br>
</div>
<div class="game-zone-content">
<div class="alert alert-success" v-if="showSuccess">
<button type="button" class="close-btn" v-on:click="showSuccess=false">&times;</button>
<strong>{{ successMessage }} &nbsp;&nbsp;&nbsp;&nbsp;<a v-show="gameEnded" v-on:click.prevent="restartGame">Restart</a></strong>
</div>
<div class="board">
<div v-for="(piece, key) of board" >
<img v-bind:src="pieceImageURL(piece)" v-on:click="clickPiece(key)">
</div>
</div>
<hr>
</div>
</div>
</template>
<script type="text/javascript">
export default {
data: function(){
return {
title: 'Memory',
showSuccess: false,
showFailure: false,
successMessage: '',
failMessage: '',
currentValue: 1,
gameEnded:false,
player1User: undefined,
player2User: undefined,
board: [0,0,0,0,0,0,0,0,0]
}
},
methods: {
pieceImageURL: function (piece) {
var imgSrc = String(piece);
return 'img/' + imgSrc + '.png';
},
clickPiece: function(index) {
if(this.board[index] || this.gameEnded) return;
this.board[index] = this.currentValue;
this.successMessage = this.currentPlayer+' has Played';
this.showSuccess = true;
this.currentValue = (this.currentValue == 1)? 2 : 1;
this.checkGameEnded();
},
restartGame:function(){
console.log('restartGame');
this.board= [0,0,0,0,0,0,0,0,0];
this.showSuccess= false;
this.showFailure= false;
this.successMessage= '';
this.failMessage= '';
this.currentValue= 1;
this.gameEnded= false;
},
// ----------------------------------------------------------------------------------------
// GAME LOGIC - START
// ----------------------------------------------------------------------------------------
hasRow: function(value){
return ((this.board[0]==value) && (this.board[1]==value) && (this.board[2]==value)) ||
((this.board[3]==value) && (this.board[4]==value) && (this.board[5]==value)) ||
((this.board[6]==value) && (this.board[7]==value) && (this.board[8]==value)) ||
((this.board[0]==value) && (this.board[3]==value) && (this.board[6]==value)) ||
((this.board[1]==value) && (this.board[4]==value) && (this.board[7]==value)) ||
((this.board[2]==value) && (this.board[5]==value) && (this.board[8]==value)) ||
((this.board[0]==value) && (this.board[4]==value) && (this.board[8]==value)) ||
((this.board[2]==value) && (this.board[4]==value) && (this.board[6]==value));
},
checkGameEnded: function(){
if (this.hasRow(1)) {
this.successMessage = this.playerName(1) + ' won the Game';
this.showSuccess = true;
this.gameEnded = true;
}
if (this.hasRow(2)) {
this.successMessage = this.playerName(2) + ' won the Game';
this.showSuccess = true;
this.gameEnded = true;
}
if (this.isBoardComplete()) {
this.successMessage = 'The Game ended in a Tie';
this.showSuccess = true;
this.gameEnded = true;
}
return false;
},
isBoardComplete:function(){
var returnValue = true;
this.board.forEach(function(element) {
if (element === 0) {
returnValue = false;
return;
}
});
return returnValue;
},
// ----------------------------------------------------------------------------------------
// GAME LOGIC - END
// ----------------------------------------------------------------------------------------
playerName: function(playerNumber){
console.log(playerNumber);
console.log(this.player1User);
if(this.player1User != undefined && playerNumber == 1){
return this.player1User.name;
}
if(this.player2User != undefined && playerNumber == 2){
return this.player2User.name;
}
return 'Player '+playerNumber;
}
},
computed:{
currentPlayer: function(){
console.log(this.currentValue);
console.log(this.playerName(this.currentValue));
return this.playerName(this.currentValue);
}
},
mounted(){
if(this.$root.$data.player1){
this.player1User = this.$root.$data.player1;
}
if(this.$root.$data.player2 ){
this.player2User = this.$root.$data.player2;
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,91 @@
<template>
<div>
<div class="jumbotron">
<h1>{{ title }}</h1>
</div>
<user-list :users="users" @edit-click="editUser" @delete-click="deleteUser" @message="childMessage" ref="usersListRef"></user-list>
<div class="alert alert-success" v-if="showSuccess">
<button type="button" class="close-btn" v-on:click="showSuccess=false">&times;</button>
<strong>{{ successMessage }}</strong>
</div>
<user-edit :user="currentUser" :departments="departments" @user-saved="savedUser" @user-canceled="cancelEdit" v-if="currentUser"></user-edit>
</div>
</template>
<script type="text/javascript">
import UserList from './userList.vue';
import UserEdit from './userEdit.vue';
export default {
data: function(){
return {
title: 'List Users',
showSuccess: false,
successMessage: '',
currentUser: null,
users: [],
departments: []
}
},
methods: {
editUser: function(user){
this.currentUser = user;
this.showSuccess = false;
},
deleteUser: function(user){
axios.delete('api/users/'+user.id)
.then(response => {
this.showSuccess = true;
this.successMessage = 'User Deleted';
this.getUsers();
});
},
savedUser: function(){
this.currentUser = null;
this.$refs.usersListRef.editingUser = null;
this.showSuccess = true;
this.successMessage = 'User Saved';
},
cancelEdit: function(){
this.currentUser = null;
this.$refs.usersListRef.editingUser = null;
this.showSuccess = false;
},
getUsers: function(){
axios.get('api/users')
.then(response=>{this.users = response.data.data; });
},
childMessage: function(message){
this.showSuccess = true;
this.successMessage = message;
}
},
components: {
'user-list': UserList,
'user-edit': UserEdit
},
mounted() {
this.getUsers();
if (this.$root.departments.length === 0) {
axios.get('api/departments')
.then(response=>{
this.$root.departments = response.data.data;
this.departments = this.$root.departments;
})
} else {
this.departments = this.$root.departments;
}
}
}
</script>
<style scoped>
p {
font-size: 2em;
text-align: center;
}
</style>

View File

@ -0,0 +1,67 @@
<template>
<div class="jumbotron">
<h2>Edit User</h2>
<div class="form-group">
<label for="inputName">Name</label>
<input
type="text" class="form-control" v-model="user.name"
name="name" id="inputName"
placeholder="Fullname"/>
</div>
<div class="form-group">
<label for="inputEmail">Email</label>
<input
type="email" class="form-control" v-model="user.email"
name="email" id="inputEmail"
placeholder="Email address"/>
</div>
<div class="form-group">
<label for="inputAge">Age</label>
<input
type="number" class="form-control" v-model="user.age"
name="age" id="inputAge"
placeholder="Age"/>
</div>
<div class="form-group">
<label for="department_id">Department:</label>
<select class="form-control" id="department_id" name="department_id" v-model="user.department_id" >
<option v-for="department in departments" v-bind:value="department.id"> {{ department.name }} </option>
</select>
</div>
<div class="form-group">
<a class="btn btn-default" v-on:click.prevent="saveUser()">Save</a>
<a class="btn btn-default" v-on:click.prevent="cancelEdit()">Cancel</a>
</div>
</div>
</template>
<script type="text/javascript">
module.exports={
props: ['user', 'departments'],
methods: {
saveUser: function(){
axios.put('api/users/'+this.user.id, this.user)
.then(response=>{
// Copy object properties from response.data.data to this.user
// without creating a new reference
Object.assign(this.user, response.data.data);
this.$emit('user-saved', this.user)
});
},
cancelEdit: function(){
axios.get('api/users/'+this.user.id)
.then(response=>{
// Copy object properties from response.data.data to this.user
// without creating a new reference
Object.assign(this.user, response.data.data);
this.$emit('user-canceled', this.user);
});
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,61 @@
<template>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Age</th>
<th>Department</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id" :class="{activerow: editingUser === user}">
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>{{ user.age }}</td>
<td>{{ user.department }}</td>
<td>
<a class="btn btn-xs btn-success" v-on:click.prevent="definePlayer(user,1)">P1</a>
<a class="btn btn-xs btn-success" v-on:click.prevent="definePlayer(user,2)">P2</a>
<a class="btn btn-xs btn-primary" v-on:click.prevent="editUser(user)">Edit</a>
<a class="btn btn-xs btn-danger" v-on:click.prevent="deleteUser(user)">Delete</a>
</td>
</tr>
</tbody>
</table>
</template>
<script type="text/javascript">
// Component code (not registered)
module.exports={
props: ['users'],
data: function(){
return {
editingUser: null
}
},
methods: {
editUser: function(user){
this.editingUser = user;
this.$emit('edit-click', user);
},
deleteUser: function(user){
this.editingUser = null;
this.$emit('delete-click', user);
},
definePlayer: function(user,player){
this.$root.$data['player'+player] = user;
this.$emit('message', user.name+' selected as Player'+player);
}
},
}
</script>
<style scoped>
tr.activerow {
background: #123456 !important;
color: #fff !important;
}
</style>

View File

@ -1,10 +0,0 @@
/*jshint esversion: 6 */
require('./bootstrap');
window.Vue = require('vue');
const app = new Vue({
el: '#app',
});

View File

@ -10,157 +10,22 @@ require('./bootstrap');
window.Vue = require('vue');
// ------------------------- ------------------------- ------------------------- -------------------------
// CODE - EXERCISE 1
// ------------------------- ------------------------- ------------------------- -------------------------
// import UserList from './components/userList.vue';
// Vue.component('user-list', UserList);
// const app = new Vue({
// el: '#app',
// data: {
// title: 'List Users',
// showSuccess: false,
// showFailure: false,
// successMessage: '',
// failMessage: '',
// currentUser: null,
// users: [],
// departments: []
// },
// methods: {
// editUser: function(user){
// this.currentUser = user;
// this.showSuccess = false;
// },
// deleteUser: function(user){
// axios.delete('api/users/'+user.id)
// .then(response => {
// this.showSuccess = true;
// this.successMessage = 'User Deleted';
// this.getUsers();
// });
// },
// saveUser: function(){
// if (this.currentUser) {
// axios.put('api/users/'+this.currentUser.id,this.currentUser)
// .then(response=>{
// this.showSuccess = true;
// this.successMessage = 'User Saved';
// // Copies response.data.data properties to this.currentUser
// // without changing this.currentUser reference
// Object.assign(this.currentUser, response.data.data);
// this.currentUser = null;
// this.$refs.usersListRef.editingUser = null;
// });
// }
// },
// cancelEdit: function(){
// this.showSuccess = false;
// axios.get('api/users/'+this.currentUser.id)
// .then(response=>{
// // Copies response.data.data properties to this.currentUser
// // without changing this.currentUser reference
// Object.assign(this.currentUser, response.data.data);
// this.currentUser = null;
// this.$refs.usersListRef.editingUser = null;
// });
// },
// getUsers: function(){
// axios.get('api/users')
// .then(response=>{this.users = response.data.data;});
// }
// },
// mounted() {
// this.getUsers();
// axios.get('api/departments')
// .then(response=>{this.departments = response.data.data; });
// }
// });
// ------------------------- ------------------------- ------------------------- -------------------------
// CODE - EXERCISE 2
// ------------------------- ------------------------- ------------------------- -------------------------
// import UserList from './components/userList.vue';
// Vue.component('user-list', UserList);
// import UserEdit from './components/userEdit.vue';
// Vue.component('user-edit', UserEdit);
// const app = new Vue({
// el: '#app',
// data: {
// title: 'List Users',
// showSuccess: false,
// successMessage: '',
// currentUser: null,
// users: [],
// departments: []
// },
// methods: {
// editUser: function(user){
// this.currentUser = user;
// this.showSuccess = false;
// },
// deleteUser: function(user){
// axios.delete('api/users/'+user.id)
// .then(response => {
// this.showSuccess = true;
// this.successMessage = 'User Deleted';
// this.getUsers();
// });
// },
// savedUser: function(){
// this.currentUser = null;
// this.$refs.usersListRef.editingUser = null;
// this.showSuccess = true;
// this.successMessage = 'User Saved';
// },
// cancelEdit: function(){
// this.currentUser = null;
// this.$refs.usersListRef.editingUser = null;
// this.showSuccess = false;
// },
// getUsers: function(){
// axios.get('api/users')
// .then(response=>{this.users = response.data.data;});
// }
// },
// mounted() {
// this.getUsers();
// axios.get('api/departments')
// .then(response=>{this.departments = response.data.data; });
// }
// });
// ------------------------- ------------------------- ------------------------- -------------------------
// CODE - EXERCISE 3
// ------------------------- ------------------------- ------------------------- -------------------------
// import UserComponent from './components/user.vue';
// Vue.component('user', UserComponent);
// const app = new Vue({
// el: '#app'
// });
import VueRouter from 'vue-router';
Vue.use(VueRouter);
const memgame = Vue.component('memgame', require('./components/memoryGame.vue'));
const userProfile = Vue.component('userProfile', require('./components/profile.vue'));
const user = Vue.component('user', require('./components/user.vue'));
const department = Vue.component('department', require('./components/departmentList.vue'));
const singleplayerMode = Vue.component('singleplayerMode', require('./components/singleplayerMode.vue'));
const multiplayerMode = Vue.component('multiplayerMode', require('./components/multiplayerMode.vue'));
const routes = [
{ path: '/memorygame', component: memgame },
{ path: '/profile', component: userProfile},
{ path: '/', redirect: '/users' },
{ path: '/users', component: user },
{ path: '/departments', component: department },
{ path: '/singleplayerMode', component: singleplayerMode },
{ path: '/multiplayerMode', component: multiplayerMode }
];
@ -171,7 +36,8 @@ const router = new VueRouter({
const app = new Vue({
router,
data:{
player1: undefined,
player1:undefined,
player2: undefined,
departments: [],
}
}).$mount('#app');

View File

@ -4,18 +4,18 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
@yield('metatags')
@yield('metatags')
<title>@yield('title')</title>
@yield('extrastyles')
@yield('extrastyles')
<!-- Latest compiled and minified CSS & JS -->
<link rel="stylesheet" href="{{ URL::asset('css/app.css') }}">
</head>
</head>
<body>
<div class="container" id="app">
@yield('content')
</div>
@yield('pagescript')
@yield('pagescript')
</body>
</html>

View File

@ -1,22 +1,21 @@
@extends('master')
@section('title', 'Jogo Da Memória')
@section('title', 'Vue.js App')
@section('content')
<router-link to="/users">Users</router-link> -
<router-link to="/departments">Departments</router-link> -
<router-link to="/singleplayerMode">SinglePlayer Memory Game</router-link> -
<router-link to="/multiplayerMode">Multiplayer Memory Game</router-link>
<router-link to="/game">Game</router-link> -
<router-link to="/profile">Profile</router-link>
<router-view></router-view>
<router-view></router-view>
@endsection
@section('pagescript')
<script src="js/vueapp.js"></script>
{{-- <script src="/js/manifest.js"></script>
<!-- <script src="/js/manifest.js"></script>
<script src="/js/vendor.js"></script>
<script src="/js/vueapp.js"></script> --}}
@stop
<script src="/js/vueapp.js"></script>
-->
@stop

View File

@ -1,85 +0,0 @@
@extends('master')
@section('title', 'User Profile')
@section('content')
<div class="jumbotron">
<h1>@{{ title }}</h1>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Username</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id" :class="{active: currentUser === user}">
<td>@{{ user.name }}</td>
<td>@{{ user.email }}</td>
<td>@{{ user.username }}</td>
<td>
<a class="btn btn-xs btn-primary" v-on:click.prevent="editUser(user)">Edit</a>
<!-- <a class="btn btn-xs btn-danger" v-on:click.prevent="deleteUser(user)">Delete</button> -->
</td>
</tr>
</tbody>
</table>
<div class="alert alert-success" v-if="showSuccess">
<button type="button" class="close-btn" v-on:click="showSuccess=false">&times;</button>
<strong>@{{ successMessage }}</strong>
</div>
<div class="jumbotron" v-if="editingUser" >
<h2>Edit Your Details</h2>
<div class="form-group">
<label for="inputName">Name</label>
<input
type="text" class="form-control" v-model="currentUser.name"
name="name" id="inputName"
placeholder="Fullname" value="" />
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input
type="text" class="form-control" v-model="currentUser.password"
name="password" id="password"
placeholder="Password" value=""/>
</div>
<div class="form-group">
<label for="inputEmail">Email</label>
<input
type="email" class="form-control" v-model="currentUser.email"
name="email" id="inputEmail"
placeholder="Email address" value=""/>
</div>
<div class="form-group">
<a class="btn btn-default" v-on:click.prevent="saveUser()">Save</a>
<a class="btn btn-default" v-on:click.prevent="cancelEdit()">Cancel</a>
</div>
</div>
@endsection
@section('pagescript')
<script src="js/userapp.js"></script>
<!-- <script src="/js/manifest.js"></script>
<script src="/js/vendor.js"></script>
<script src="/js/vueapp.js"></script>
-->
@stop

View File

@ -25,4 +25,11 @@ Route::get('users/{id}', 'UserControllerAPI@getUser');
Route::post('users', 'UserControllerAPI@store');
Route::put('users/{id}', 'UserControllerAPI@update');
Route::delete('users/{id}', 'UserControllerAPI@delete');
Route::get('games', 'GameControllerAPI@index');
Route::get('games/lobby', 'GameControllerAPI@lobby');
Route::get('games/status/{status}', 'GameControllerAPI@gamesStatus');
Route::get('games/{id}', 'GameControllerAPI@getGame');
Route::post('games', 'GameControllerAPI@store');
Route::patch('games/{id}/join-start', 'GameControllerAPI@joinAndStart');
Route::patch('games/{id}/endgame/{winner}', 'GameControllerAPI@endgame');

View File

@ -12,6 +12,3 @@
*/
Route::get('/','VueController@index');
Route::get('/userProfile','VueController@userProfile');

View File

@ -14,6 +14,6 @@ let mix = require('laravel-mix');
mix.js('resources/assets/js/vueapp.js', 'public/js');
//mix.js('resources/assets/js/vueapp.js', 'public/js').extract(['vue', 'axios', 'jquery']);
mix.sass('resources/assets/sass/app.scss', 'public/css');
//mix.sass('resources/assets/sass/app.scss', 'public/css');
mix.js('resources/assets/js/tictactoe.js', 'public/js');
//mix.js('resources/assets/js/tictactoe.js', 'public/js');

View File

@ -1,68 +1,68 @@
1.2.1 / 2016-04-18
==================
* enable client side use
1.2.0 / 2014-02-12
==================
* prefix events with `$` to support object prototype method names
1.1.3 / 2014-06-20
==================
* republish for npm
* add LICENSE file
1.1.2 / 2014-02-10
==================
* package: rename to "component-emitter"
* package: update "main" and "component" fields
* Add license to Readme (same format as the other components)
* created .npmignore
* travis stuff
1.1.1 / 2013-12-01
==================
* fix .once adding .on to the listener
* docs: Emitter#off()
* component: add `.repo` prop
1.1.0 / 2013-10-20
==================
* add `.addEventListener()` and `.removeEventListener()` aliases
1.0.1 / 2013-06-27
==================
* add support for legacy ie
1.0.0 / 2013-02-26
==================
* add `.off()` support for removing all listeners
0.0.6 / 2012-10-08
==================
* add `this._callbacks` initialization to prevent funky gotcha
0.0.5 / 2012-09-07
==================
* fix `Emitter.call(this)` usage
0.0.3 / 2012-07-11
==================
* add `.listeners()`
* rename `.has()` to `.hasListeners()`
0.0.2 / 2012-06-28
==================
* fix `.off()` with `.once()`-registered callbacks
1.2.1 / 2016-04-18
==================
* enable client side use
1.2.0 / 2014-02-12
==================
* prefix events with `$` to support object prototype method names
1.1.3 / 2014-06-20
==================
* republish for npm
* add LICENSE file
1.1.2 / 2014-02-10
==================
* package: rename to "component-emitter"
* package: update "main" and "component" fields
* Add license to Readme (same format as the other components)
* created .npmignore
* travis stuff
1.1.1 / 2013-12-01
==================
* fix .once adding .on to the listener
* docs: Emitter#off()
* component: add `.repo` prop
1.1.0 / 2013-10-20
==================
* add `.addEventListener()` and `.removeEventListener()` aliases
1.0.1 / 2013-06-27
==================
* add support for legacy ie
1.0.0 / 2013-02-26
==================
* add `.off()` support for removing all listeners
0.0.6 / 2012-10-08
==================
* add `this._callbacks` initialization to prevent funky gotcha
0.0.5 / 2012-09-07
==================
* fix `Emitter.call(this)` usage
0.0.3 / 2012-07-11
==================
* add `.listeners()`
* rename `.has()` to `.hasListeners()`
0.0.2 / 2012-06-28
==================
* fix `.off()` with `.once()`-registered callbacks

View File

@ -1,24 +1,24 @@
(The MIT License)
Copyright (c) 2014 Component contributors <dev@component.io>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
(The MIT License)
Copyright (c) 2014 Component contributors <dev@component.io>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,74 +1,74 @@
# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter)
Event emitter component.
## Installation
```
$ component install component/emitter
```
## API
### Emitter(obj)
The `Emitter` may also be used as a mixin. For example
a "plain" object may become an emitter, or you may
extend an existing prototype.
As an `Emitter` instance:
```js
var Emitter = require('emitter');
var emitter = new Emitter;
emitter.emit('something');
```
As a mixin:
```js
var Emitter = require('emitter');
var user = { name: 'tobi' };
Emitter(user);
user.emit('im a user');
```
As a prototype mixin:
```js
var Emitter = require('emitter');
Emitter(User.prototype);
```
### Emitter#on(event, fn)
Register an `event` handler `fn`.
### Emitter#once(event, fn)
Register a single-shot `event` handler `fn`,
removed immediately after it is invoked the
first time.
### Emitter#off(event, fn)
* Pass `event` and `fn` to remove a listener.
* Pass `event` to remove all listeners on that event.
* Pass nothing to remove all listeners on all events.
### Emitter#emit(event, ...)
Emit an `event` with variable option args.
### Emitter#listeners(event)
Return an array of callbacks, or an empty array.
### Emitter#hasListeners(event)
Check if this emitter has `event` handlers.
## License
MIT
# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter)
Event emitter component.
## Installation
```
$ component install component/emitter
```
## API
### Emitter(obj)
The `Emitter` may also be used as a mixin. For example
a "plain" object may become an emitter, or you may
extend an existing prototype.
As an `Emitter` instance:
```js
var Emitter = require('emitter');
var emitter = new Emitter;
emitter.emit('something');
```
As a mixin:
```js
var Emitter = require('emitter');
var user = { name: 'tobi' };
Emitter(user);
user.emit('im a user');
```
As a prototype mixin:
```js
var Emitter = require('emitter');
Emitter(User.prototype);
```
### Emitter#on(event, fn)
Register an `event` handler `fn`.
### Emitter#once(event, fn)
Register a single-shot `event` handler `fn`,
removed immediately after it is invoked the
first time.
### Emitter#off(event, fn)
* Pass `event` and `fn` to remove a listener.
* Pass `event` to remove all listeners on that event.
* Pass nothing to remove all listeners on all events.
### Emitter#emit(event, ...)
Emit an `event` with variable option args.
### Emitter#listeners(event)
Return an array of callbacks, or an empty array.
### Emitter#hasListeners(event)
Check if this emitter has `event` handlers.
## License
MIT

View File

@ -1,163 +1,163 @@
/**
* Expose `Emitter`.
*/
if (typeof module !== 'undefined') {
module.exports = Emitter;
}
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
};
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
.push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function(event, fn){
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
// specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this;
// remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
}
// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)
, callbacks = this._callbacks['$' + event];
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};
/**
* Expose `Emitter`.
*/
if (typeof module !== 'undefined') {
module.exports = Emitter;
}
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
};
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
.push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function(event, fn){
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
// specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this;
// remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
}
// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)
, callbacks = this._callbacks['$' + event];
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};

View File

@ -2823,16 +2823,16 @@ return /******/ (function(modules) { // webpackBootstrap
/* 15 */
/***/ function(module, exports) {
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
module.children = [];
module.webpackPolyfill = 1;
}
return module;
}
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
module.children = [];
module.webpackPolyfill = 1;
}
return module;
}
/***/ },
@ -3015,212 +3015,212 @@ return /******/ (function(modules) { // webpackBootstrap
/* 18 */
/***/ function(module, exports, __webpack_require__) {
/**
* Expose `Emitter`.
*/
if (true) {
module.exports = Emitter;
}
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
};
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
.push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function(event, fn){
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
// specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this;
// remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
}
// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)
, callbacks = this._callbacks['$' + event];
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};
/**
* Expose `Emitter`.
*/
if (true) {
module.exports = Emitter;
}
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
};
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
.push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function(event, fn){
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
// specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this;
// remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
}
// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)
, callbacks = this._callbacks['$' + event];
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};
/***/ },
/* 19 */
/***/ function(module, exports) {
/**
* Compiles a querystring
* Returns string representation of the object
*
* @param {Object}
* @api private
*/
exports.encode = function (obj) {
var str = '';
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
if (str.length) str += '&';
str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
}
}
return str;
};
/**
* Parses a simple querystring into an object
*
* @param {String} qs
* @api private
*/
exports.decode = function(qs){
var qry = {};
var pairs = qs.split('&');
for (var i = 0, l = pairs.length; i < l; i++) {
var pair = pairs[i].split('=');
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
return qry;
};
/**
* Compiles a querystring
* Returns string representation of the object
*
* @param {Object}
* @api private
*/
exports.encode = function (obj) {
var str = '';
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
if (str.length) str += '&';
str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
}
}
return str;
};
/**
* Parses a simple querystring into an object
*
* @param {String} qs
* @api private
*/
exports.decode = function(qs){
var qry = {};
var pairs = qs.split('&');
for (var i = 0, l = pairs.length; i < l; i++) {
var pair = pairs[i].split('=');
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
return qry;
};
/***/ },
@ -4613,45 +4613,45 @@ return /******/ (function(modules) { // webpackBootstrap
/* 30 */
/***/ function(module, exports) {
/**
* Parses an URI
*
* @author Steven Levithan <stevenlevithan.com> (MIT license)
* @api private
*/
var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
var parts = [
'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
];
module.exports = function parseuri(str) {
var src = str,
b = str.indexOf('['),
e = str.indexOf(']');
if (b != -1 && e != -1) {
str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
}
var m = re.exec(str || ''),
uri = {},
i = 14;
while (i--) {
uri[parts[i]] = m[i] || '';
}
if (b != -1 && e != -1) {
uri.source = src;
uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
uri.ipv6uri = true;
}
return uri;
};
/**
* Parses an URI
*
* @author Steven Levithan <stevenlevithan.com> (MIT license)
* @api private
*/
var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
var parts = [
'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
];
module.exports = function parseuri(str) {
var src = str,
b = str.indexOf('['),
e = str.indexOf(']');
if (b != -1 && e != -1) {
str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
}
var m = re.exec(str || ''),
uri = {},
i = 14;
while (i--) {
uri[parts[i]] = m[i] || '';
}
if (b != -1 && e != -1) {
uri.source = src;
uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
uri.ipv6uri = true;
}
return uri;
};
/***/ }

0
node_server/node_modules/engine.io-client/lib/transports/index.js generated vendored Normal file → Executable file
View File

0
node_server/node_modules/engine.io-client/lib/transports/polling-xhr.js generated vendored Normal file → Executable file
View File

View File

@ -1,3 +1,3 @@
.DS_Store
node_modules
.DS_Store
node_modules
npm-debug.log

View File

@ -1,21 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Gal Koren
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
The MIT License (MIT)
Copyright (c) 2015 Gal Koren
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,3 +1,3 @@
test:
@./node_modules/.bin/mocha test.js
test:
@./node_modules/.bin/mocha test.js

View File

@ -1 +1 @@
Provides methods for converting an object into string representation, and vice versa.
Provides methods for converting an object into string representation, and vice versa.

View File

@ -1,37 +1,37 @@
/**
* Compiles a querystring
* Returns string representation of the object
*
* @param {Object}
* @api private
*/
exports.encode = function (obj) {
var str = '';
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
if (str.length) str += '&';
str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
}
}
return str;
};
/**
* Parses a simple querystring into an object
*
* @param {String} qs
* @api private
*/
exports.decode = function(qs){
var qry = {};
var pairs = qs.split('&');
for (var i = 0, l = pairs.length; i < l; i++) {
var pair = pairs[i].split('=');
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
return qry;
};
/**
* Compiles a querystring
* Returns string representation of the object
*
* @param {Object}
* @api private
*/
exports.encode = function (obj) {
var str = '';
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
if (str.length) str += '&';
str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
}
}
return str;
};
/**
* Parses a simple querystring into an object
*
* @param {String} qs
* @api private
*/
exports.decode = function(qs){
var qry = {};
var pairs = qs.split('&');
for (var i = 0, l = pairs.length; i < l; i++) {
var pair = pairs[i].split('=');
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
return qry;
};

View File

@ -1,27 +1,27 @@
var assert = require('better-assert');
var expect = require('expect.js');
var util = require('./index.js');
describe('querystring test suite', function(){
it('should parse a querystring and return an object', function () {
// Single assignment
var queryObj = util.decode("foo=bar");
expect(queryObj.foo).to.be("bar");
// Multiple assignments
queryObj = util.decode("france=paris&germany=berlin");
expect(queryObj.france).to.be("paris");
expect(queryObj.germany).to.be("berlin");
// Assignments containing non-alphanumeric characters
queryObj = util.decode("india=new%20delhi");
expect(queryObj.india).to.be("new delhi");
});
it('should construct a query string from an object', function () {
expect(util.encode({ a: 'b' })).to.be('a=b');
expect(util.encode({ a: 'b', c: 'd' })).to.be('a=b&c=d');
expect(util.encode({ a: 'b', c: 'tobi rocks' })).to.be('a=b&c=tobi%20rocks');
});
});
var assert = require('better-assert');
var expect = require('expect.js');
var util = require('./index.js');
describe('querystring test suite', function(){
it('should parse a querystring and return an object', function () {
// Single assignment
var queryObj = util.decode("foo=bar");
expect(queryObj.foo).to.be("bar");
// Multiple assignments
queryObj = util.decode("france=paris&germany=berlin");
expect(queryObj.france).to.be("paris");
expect(queryObj.germany).to.be("berlin");
// Assignments containing non-alphanumeric characters
queryObj = util.decode("india=new%20delhi");
expect(queryObj.india).to.be("new delhi");
});
it('should construct a query string from an object', function () {
expect(util.encode({ a: 'b' })).to.be('a=b');
expect(util.encode({ a: 'b', c: 'd' })).to.be('a=b&c=d');
expect(util.encode({ a: 'b', c: 'tobi rocks' })).to.be('a=b&c=tobi%20rocks');
});
});

View File

@ -1,2 +1,2 @@
.DS_Store
.DS_Store
.node_modules/*

View File

@ -1,5 +1,5 @@
n.n.n / 2014-02-09
==================
* parseuri first commit
n.n.n / 2014-02-09
==================
* parseuri first commit

View File

@ -1,21 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Gal Koren
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
The MIT License (MIT)
Copyright (c) 2014 Gal Koren
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,3 +1,3 @@
test:
@./node_modules/.bin/mocha test.js
test:
@./node_modules/.bin/mocha test.js

View File

@ -1,2 +1,2 @@
# parseuri
Module for parsing URI's in engine.io-client
# parseuri
Module for parsing URI's in engine.io-client

View File

@ -1,39 +1,39 @@
/**
* Parses an URI
*
* @author Steven Levithan <stevenlevithan.com> (MIT license)
* @api private
*/
var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
var parts = [
'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
];
module.exports = function parseuri(str) {
var src = str,
b = str.indexOf('['),
e = str.indexOf(']');
if (b != -1 && e != -1) {
str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
}
var m = re.exec(str || ''),
uri = {},
i = 14;
while (i--) {
uri[parts[i]] = m[i] || '';
}
if (b != -1 && e != -1) {
uri.source = src;
uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
uri.ipv6uri = true;
}
return uri;
};
/**
* Parses an URI
*
* @author Steven Levithan <stevenlevithan.com> (MIT license)
* @api private
*/
var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
var parts = [
'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
];
module.exports = function parseuri(str) {
var src = str,
b = str.indexOf('['),
e = str.indexOf(']');
if (b != -1 && e != -1) {
str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
}
var m = re.exec(str || ''),
uri = {},
i = 14;
while (i--) {
uri[parts[i]] = m[i] || '';
}
if (b != -1 && e != -1) {
uri.source = src;
uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
uri.ipv6uri = true;
}
return uri;
};

View File

@ -1,51 +1,51 @@
var assert = require('better-assert');
var expect = require('expect.js');
var parseuri = require('./index.js');
describe('my suite', function(){
it('should parse an uri', function () {
var http = parseuri('http://google.com')
, https = parseuri('https://www.google.com:80')
, query = parseuri('google.com:8080/foo/bar?foo=bar')
, localhost = parseuri('localhost:8080')
, ipv6 = parseuri('2001:0db8:85a3:0042:1000:8a2e:0370:7334')
, ipv6short = parseuri('2001:db8:85a3:42:1000:8a2e:370:7334')
, ipv6port = parseuri('2001:db8:85a3:42:1000:8a2e:370:7334:80')
, ipv6abbrev = parseuri('2001::7334:a:80')
, ipv6http = parseuri('http://[2001::7334:a]:80')
, ipv6query = parseuri('http://[2001::7334:a]:80/foo/bar?foo=bar')
expect(http.protocol).to.be('http');
expect(http.port).to.be('');
expect(http.host).to.be('google.com');
expect(https.protocol).to.be('https');
expect(https.port).to.be('80');
expect(https.host).to.be('www.google.com');
expect(query.port).to.be('8080');
expect(query.query).to.be('foo=bar');
expect(query.path).to.be('/foo/bar');
expect(query.relative).to.be('/foo/bar?foo=bar');
expect(localhost.protocol).to.be('');
expect(localhost.host).to.be('localhost');
expect(localhost.port).to.be('8080');
expect(ipv6.protocol).to.be('');
expect(ipv6.host).to.be('2001:0db8:85a3:0042:1000:8a2e:0370:7334');
expect(ipv6.port).to.be('');
expect(ipv6short.protocol).to.be('');
expect(ipv6short.host).to.be('2001:db8:85a3:42:1000:8a2e:370:7334');
expect(ipv6short.port).to.be('');
expect(ipv6port.protocol).to.be('');
expect(ipv6port.host).to.be('2001:db8:85a3:42:1000:8a2e:370:7334');
expect(ipv6port.port).to.be('80');
expect(ipv6abbrev.protocol).to.be('');
expect(ipv6abbrev.host).to.be('2001::7334:a:80');
expect(ipv6abbrev.port).to.be('');
expect(ipv6http.protocol).to.be('http');
expect(ipv6http.port).to.be('80');
expect(ipv6http.host).to.be('2001::7334:a');
expect(ipv6query.protocol).to.be('http');
expect(ipv6query.port).to.be('80');
expect(ipv6query.host).to.be('2001::7334:a');
expect(ipv6query.relative).to.be('/foo/bar?foo=bar');
});
});
var assert = require('better-assert');
var expect = require('expect.js');
var parseuri = require('./index.js');
describe('my suite', function(){
it('should parse an uri', function () {
var http = parseuri('http://google.com')
, https = parseuri('https://www.google.com:80')
, query = parseuri('google.com:8080/foo/bar?foo=bar')
, localhost = parseuri('localhost:8080')
, ipv6 = parseuri('2001:0db8:85a3:0042:1000:8a2e:0370:7334')
, ipv6short = parseuri('2001:db8:85a3:42:1000:8a2e:370:7334')
, ipv6port = parseuri('2001:db8:85a3:42:1000:8a2e:370:7334:80')
, ipv6abbrev = parseuri('2001::7334:a:80')
, ipv6http = parseuri('http://[2001::7334:a]:80')
, ipv6query = parseuri('http://[2001::7334:a]:80/foo/bar?foo=bar')
expect(http.protocol).to.be('http');
expect(http.port).to.be('');
expect(http.host).to.be('google.com');
expect(https.protocol).to.be('https');
expect(https.port).to.be('80');
expect(https.host).to.be('www.google.com');
expect(query.port).to.be('8080');
expect(query.query).to.be('foo=bar');
expect(query.path).to.be('/foo/bar');
expect(query.relative).to.be('/foo/bar?foo=bar');
expect(localhost.protocol).to.be('');
expect(localhost.host).to.be('localhost');
expect(localhost.port).to.be('8080');
expect(ipv6.protocol).to.be('');
expect(ipv6.host).to.be('2001:0db8:85a3:0042:1000:8a2e:0370:7334');
expect(ipv6.port).to.be('');
expect(ipv6short.protocol).to.be('');
expect(ipv6short.host).to.be('2001:db8:85a3:42:1000:8a2e:370:7334');
expect(ipv6short.port).to.be('');
expect(ipv6port.protocol).to.be('');
expect(ipv6port.host).to.be('2001:db8:85a3:42:1000:8a2e:370:7334');
expect(ipv6port.port).to.be('80');
expect(ipv6abbrev.protocol).to.be('');
expect(ipv6abbrev.host).to.be('2001::7334:a:80');
expect(ipv6abbrev.port).to.be('');
expect(ipv6http.protocol).to.be('http');
expect(ipv6http.port).to.be('80');
expect(ipv6http.host).to.be('2001::7334:a');
expect(ipv6query.protocol).to.be('http');
expect(ipv6query.port).to.be('80');
expect(ipv6query.host).to.be('2001::7334:a');
expect(ipv6query.relative).to.be('/foo/bar?foo=bar');
});
});

0
node_server/node_modules/uws/build/Release/obj.target/uws.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/build/Release/uws.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_darwin_46.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_darwin_47.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_darwin_48.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_darwin_51.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_linux_46.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_linux_47.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_linux_48.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_linux_51.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_win32_48.node generated vendored Normal file → Executable file
View File

0
node_server/node_modules/uws/uws_win32_51.node generated vendored Normal file → Executable file
View File