diff --git a/client/react/README.md b/client/react/README.md deleted file mode 100644 index 4496fae..0000000 --- a/client/react/README.md +++ /dev/null @@ -1,34 +0,0 @@ -## ChattyPantz Client Demo - React.js - -This folder contains a simple demonstration of a client connection to the server using javascript and html. - -### Dependencies - -* You must be connected to the internet to load CDN react.js, semnatic-ui.js, and jquery.js. -* The server should be running on localhost:6660 - -### Instructions - -Assumption: server is up and running on localhost:6660. - -If needed, you can change the API host and port endpoint in scripts/services/api.js: -``` -var server = "ws://127.0.0.1:6660/v1.0/chat"; -``` -1. Load app/index.html in your browser. -2. Enter a nickname. -3. Connect to the server. - -You will be placed into room "Demo". A list of user nicknames from the room will also be displayed. -NOTE: If your nickname already exists when logging into the room, you will be warned and disconnected. - -4. Now, send your messages. -5. When you are done, disconnect from the server. - -### Enhancements - -The application doesn't demonstrate multi-room management, nor does it demonstrate the following request types: -* GET_NICKNAME: 102 -* LIST_ROOMS: 103 -* HIDE: 106 -* UNHIDE: 107 diff --git a/client/react/app/index.html b/client/react/app/index.html deleted file mode 100644 index d6b433e..0000000 --- a/client/react/app/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - Chattypantz Client Demo - - - - - - - - -
-
-

ChattyPantz Client Demo

-
-
-
- - - - - - - - - diff --git a/client/react/app/js/actions/ChattypantzActions.js b/client/react/app/js/actions/ChattypantzActions.js deleted file mode 100644 index 5d465df..0000000 --- a/client/react/app/js/actions/ChattypantzActions.js +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * TodoActions - */ - -var AppDispatcher = require('../dispatcher/AppDispatcher'); -var TodoConstants = require('../constants/ChattypantzConstants'); - -var TodoActions = { - - /** - * @param {string} text - */ - create: function(text) { - AppDispatcher.dispatch({ - actionType: TodoConstants.TODO_CREATE, - text: text - }); - }, - - /** - * @param {string} id The ID of the ToDo item - * @param {string} text - */ - updateText: function(id, text) { - AppDispatcher.dispatch({ - actionType: TodoConstants.TODO_UPDATE_TEXT, - id: id, - text: text - }); - }, - - /** - * Toggle whether a single ToDo is complete - * @param {object} todo - */ - toggleComplete: function(todo) { - var id = todo.id; - var actionType = todo.complete ? - TodoConstants.TODO_UNDO_COMPLETE : - TodoConstants.TODO_COMPLETE; - - AppDispatcher.dispatch({ - actionType: actionType, - id: id - }); - }, - - /** - * Mark all ToDos as complete - */ - toggleCompleteAll: function() { - AppDispatcher.dispatch({ - actionType: TodoConstants.TODO_TOGGLE_COMPLETE_ALL - }); - }, - - /** - * @param {string} id - */ - destroy: function(id) { - AppDispatcher.dispatch({ - actionType: TodoConstants.TODO_DESTROY, - id: id - }); - }, - - /** - * Delete all the completed ToDos - */ - destroyCompleted: function() { - AppDispatcher.dispatch({ - actionType: TodoConstants.TODO_DESTROY_COMPLETED - }); - } - -}; - -module.exports = TodoActions; diff --git a/client/react/app/js/app.js b/client/react/app/js/app.js deleted file mode 100644 index bed0852..0000000 --- a/client/react/app/js/app.js +++ /dev/null @@ -1,8 +0,0 @@ -var React = require('react'); - -var TodoApp = require('./components/ChattypantzApp.react'); - -React.render( - , - document.getElementById('chattypantzapp') -); diff --git a/client/react/app/js/constants/ChattypantzConstants.js b/client/react/app/js/constants/ChattypantzConstants.js deleted file mode 100644 index 506fd64..0000000 --- a/client/react/app/js/constants/ChattypantzConstants.js +++ /dev/null @@ -1,13 +0,0 @@ -var requestType = require('requestType'); - -module.exports = requestType({ - SET_NICKNAME: 101, - GET_NICKNAME: 102, - LIST_ROOMS: 103, - JOIN: 104, - LIST_NAMES: 105, - HIDE: 106, - UNHIDE: 107, - MSG: 108, - LEAVE: 109 - }); diff --git a/client/react/app/js/dispatcher/AppDispatcher.js b/client/react/app/js/dispatcher/AppDispatcher.js deleted file mode 100644 index 5231a4e..0000000 --- a/client/react/app/js/dispatcher/AppDispatcher.js +++ /dev/null @@ -1,3 +0,0 @@ -var Dispatcher = require('flux').Dispatcher; - -module.exports = new Dispatcher(); diff --git a/client/react/app/js/stores/ChattypantzStore.js b/client/react/app/js/stores/ChattypantzStore.js deleted file mode 100644 index 5a63072..0000000 --- a/client/react/app/js/stores/ChattypantzStore.js +++ /dev/null @@ -1,165 +0,0 @@ -var AppDispatcher = require('../dispatcher/AppDispatcher'); -var EventEmitter = require('events').EventEmitter; -var ChattypantzConstants = require('../constants/ChattypantzConstants'); -var assign = require('object-assign'); - -var CHANGE_EVENT = 'change'; - -var _todos = {}; - -/** - * Create a TODO item. - * @param {string} text The content of the TODO - */ -function create(text) { - // Hand waving here -- not showing how this interacts with XHR or persistent - // server-side storage. - // Using the current timestamp + random number in place of a real id. - var id = (+new Date() + Math.floor(Math.random() * 999999)).toString(36); - _todos[id] = { - id: id, - complete: false, - text: text - }; -} - -/** - * Update a TODO item. - * @param {string} id - * @param {object} updates An object literal containing only the data to be - * updated. - */ -function update(id, updates) { - _todos[id] = assign({}, _todos[id], updates); -} - -/** - * Update all of the TODO items with the same object. - * the data to be updated. Used to mark all TODOs as completed. - * @param {object} updates An object literal containing only the data to be - * updated. - - */ -function updateAll(updates) { - for (var id in _todos) { - update(id, updates); - } -} - -/** - * Delete a TODO item. - * @param {string} id - */ -function destroy(id) { - delete _todos[id]; -} - -/** - * Delete all the completed TODO items. - */ -function destroyCompleted() { - for (var id in _todos) { - if (_todos[id].complete) { - destroy(id); - } - } -} - -var TodoStore = assign({}, EventEmitter.prototype, { - - /** - * Tests whether all the remaining TODO items are marked as completed. - * @return {boolean} - */ - areAllComplete: function() { - for (var id in _todos) { - if (!_todos[id].complete) { - return false; - } - } - return true; - }, - - /** - * Get the entire collection of TODOs. - * @return {object} - */ - getAll: function() { - return _todos; - }, - - emitChange: function() { - this.emit(CHANGE_EVENT); - }, - - /** - * @param {function} callback - */ - addChangeListener: function(callback) { - this.on(CHANGE_EVENT, callback); - }, - - /** - * @param {function} callback - */ - removeChangeListener: function(callback) { - this.removeListener(CHANGE_EVENT, callback); - } -}); - -// Register callback to handle all updates -AppDispatcher.register(function(action) { - var text; - - switch(action.actionType) { - case TodoConstants.TODO_CREATE: - text = action.text.trim(); - if (text !== '') { - create(text); - TodoStore.emitChange(); - } - break; - - case TodoConstants.TODO_TOGGLE_COMPLETE_ALL: - if (TodoStore.areAllComplete()) { - updateAll({complete: false}); - } else { - updateAll({complete: true}); - } - TodoStore.emitChange(); - break; - - case TodoConstants.TODO_UNDO_COMPLETE: - update(action.id, {complete: false}); - TodoStore.emitChange(); - break; - - case TodoConstants.TODO_COMPLETE: - update(action.id, {complete: true}); - TodoStore.emitChange(); - break; - - case TodoConstants.TODO_UPDATE_TEXT: - text = action.text.trim(); - if (text !== '') { - update(action.id, {text: text}); - TodoStore.emitChange(); - } - break; - - case TodoConstants.TODO_DESTROY: - destroy(action.id); - TodoStore.emitChange(); - break; - - case TodoConstants.TODO_DESTROY_COMPLETED: - destroyCompleted(); - TodoStore.emitChange(); - break; - - default: - // no op - } -}); - -module.exports = ChattypantzStore;