Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 74 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
c64eefe
Setting up GitHub Classroom Feedback
drteresavasquez Sep 8, 2020
739b77c
Initial commit
ryanmcnair Sep 8, 2020
ae373b8
Update README.md
drteresavasquez Sep 8, 2020
b7bf596
Update README.md
drteresavasquez Sep 9, 2020
c7110f2
uploading webpack template files and folder structure
ryanmcnair Sep 9, 2020
63845cd
updated template files
ryanmcnair Sep 9, 2020
a86cefc
updating template files
ryanmcnair Sep 9, 2020
fe18691
Merge pull request #21 from nss-evening-cohort-13/setup
ryanmcnair Sep 9, 2020
e7948be
adding folder structure and update to package.json
ryanmcnair Sep 9, 2020
3a0666f
adding main.js to components folder
ryanmcnair Sep 9, 2020
3ecb377
Merge pull request #22 from nss-evening-cohort-13/setup
ryanmcnair Sep 9, 2020
e1414db
adding PR and issue ticket templates
ryanmcnair Sep 9, 2020
71e2983
Merge pull request #23 from nss-evening-cohort-13/setup
ryanmcnair Sep 9, 2020
93036ed
added seed data for 5 messages
bandstrar Sep 9, 2020
8971c8e
add navbar
michaelpfohl Sep 9, 2020
bfcbbb3
change button color
michaelpfohl Sep 9, 2020
81da7f5
Merge branch 'development' into seed-data
bandstrar Sep 9, 2020
abea990
Merge pull request #24 from nss-evening-cohort-13/seed-data
bandstrar Sep 9, 2020
abfe184
Merge pull request #25 from nss-evening-cohort-13/navbar
michaelpfohl Sep 9, 2020
99b3c49
all seed data messages are displayed
Sep 9, 2020
72cc3e2
Merge pull request #27 from nss-evening-cohort-13/display
ryanmcnair Sep 10, 2020
3c5cf68
Added functionality to the clear button and added buttonActions.js page
ryanmcnair Sep 10, 2020
35e4d42
added delete buttons to the messages
bandstrar Sep 10, 2020
b97f75e
Merge pull request #28 from nss-evening-cohort-13/clear
ryanmcnair Sep 10, 2020
a343931
add ability to add messages
michaelpfohl Sep 10, 2020
69fca16
Merge branch 'development' into add-message
michaelpfohl Sep 10, 2020
912bf53
Merge pull request #29 from nss-evening-cohort-13/delete-message
bandstrar Sep 10, 2020
3057de8
refactor add message and add ability to press enter
michaelpfohl Sep 10, 2020
7b627d7
Merge branch 'add-message' of https://github.com/nss-evening-cohort-1…
michaelpfohl Sep 10, 2020
e992a25
Merge pull request #30 from nss-evening-cohort-13/add-message
michaelpfohl Sep 10, 2020
00defbe
fix issue where clear did not clear data
michaelpfohl Sep 10, 2020
2ffff3d
Merge pull request #31 from nss-evening-cohort-13/clear-fix
michaelpfohl Sep 10, 2020
b2ab7fd
added splice to remove button
bandstrar Sep 11, 2020
8bdce9f
removed duplicate scss file
bandstrar Sep 11, 2020
2dcba3b
Merge pull request #32 from nss-evening-cohort-13/splice
bandstrar Sep 11, 2020
a613adb
added functional dark mode checkbox
bandstrar Sep 11, 2020
5744a5a
Merge pull request #33 from nss-evening-cohort-13/development
michaelpfohl Sep 11, 2020
e850b77
message limit complete and most recent messages show first
Sep 11, 2020
2d30b67
added user data and created radio buttons on the DOM
ryanmcnair Sep 12, 2020
730e6bf
add clean timestamp to messages
michaelpfohl Sep 12, 2020
70fc25a
dryed up dark mode function
bandstrar Sep 12, 2020
8d03f60
made some form input changes
ryanmcnair Sep 12, 2020
2482b72
Merge pull request #34 from nss-evening-cohort-13/timestamp
michaelpfohl Sep 12, 2020
91ac8a6
message limit working with no errors
Sep 12, 2020
3046864
Merge pull request #35 from nss-evening-cohort-13/message-limit
kaitvan Sep 12, 2020
d035912
reordered data according to dates
michaelpfohl Sep 12, 2020
e1ffc9e
Merge pull request #36 from nss-evening-cohort-13/data-order
michaelpfohl Sep 12, 2020
165cb27
added multiple users and images
ryanmcnair Sep 12, 2020
73574df
Merge branch 'development' into multiple-users
michaelpfohl Sep 12, 2020
297568f
Merge pull request #37 from nss-evening-cohort-13/multiple-users
ryanmcnair Sep 12, 2020
8120d8a
fixing error within the messageData.js page
ryanmcnair Sep 12, 2020
c0129d3
Merge pull request #38 from nss-evening-cohort-13/bugfix
ryanmcnair Sep 12, 2020
1d7676e
merged development changes to dark mode branch
bandstrar Sep 12, 2020
b73c9b0
updated styling
bandstrar Sep 12, 2020
542143f
Merge pull request #39 from nss-evening-cohort-13/development
ryanmcnair Sep 12, 2020
df33e78
add ability to use emojis
michaelpfohl Sep 12, 2020
b50661f
Merge pull request #40 from nss-evening-cohort-13/dark-mode
bandstrar Sep 12, 2020
99b78a9
Merge pull request #41 from nss-evening-cohort-13/emoji
michaelpfohl Sep 12, 2020
39456c4
large text checkbox toggles between large font on the page and regula…
Sep 12, 2020
6651b19
Merge pull request #42 from nss-evening-cohort-13/large-text
kaitvan Sep 12, 2020
f4c6272
edit button displays message in input field
Sep 12, 2020
895931b
editing works
Sep 12, 2020
3a1d4b3
Merge pull request #44 from nss-evening-cohort-13/editing
kaitvan Sep 12, 2020
aa2deb9
added styling
ryanmcnair Sep 12, 2020
440ffe3
Merge pull request #45 from nss-evening-cohort-13/styling
ryanmcnair Sep 12, 2020
cbbe4a6
added three chat bot user personas
ryanmcnair Sep 12, 2020
c8eeb3b
Merge pull request #46 from nss-evening-cohort-13/chatbot
ryanmcnair Sep 12, 2020
8c0d854
Merge pull request #43 from nss-evening-cohort-13/development
michaelpfohl Sep 12, 2020
2ee0021
added a new flying ace picture and updated bot message input to lower…
ryanmcnair Sep 13, 2020
ea842b9
fix bug where IDs were not dynamic when multiple bots called
michaelpfohl Sep 13, 2020
acc9105
Merge pull request #47 from nss-evening-cohort-13/bugfix
ryanmcnair Sep 13, 2020
484693b
fixed bug that would prevent editing and deleting bot replies
bandstrar Sep 14, 2020
62164e8
Merge pull request #48 from nss-evening-cohort-13/new-bugs
bandstrar Sep 14, 2020
2f7d1ad
Merge pull request #49 from nss-evening-cohort-13/development
michaelpfohl Sep 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"@babel/preset-env"
]
}
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
webpack.config.js
node_modules
build
22 changes: 22 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module"
},
"extends": "airbnb-base",
"globals": {
"document": true,
"window": true,
"$": true,
"XMLHttpRequest": true,
"allowTemplateLiterals": true
},
"rules": {
"no-console": [1, { "allow": ["error", "warn"] }],
"comma-dangle": ["error", "only-multiline"],
"no-debugger": 1,
"class-methods-use-this": 0,
"linebreak-style": 0,
"max-len": [1,200,2]
}
}
Empty file removed .github/.keep
Empty file.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vscode/
.DS_Store
package-lock.json
node_modules/
dist/
build/
.firebase/
22 changes: 22 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--- Provide a general summary of the issue in the Title above -->
<!--- DELETE ALL COMMENTS BEFORE CREATING ISSUE -->

# User Story
<!-- Write a description of what the user should see and experience based on THIS ticket -->

# Acceptance Criteria
<!-- The Acceptance Criteria of a User Story consists of a set of Test Scenarios that are to be met to confirm that the software is working as expected. The Acceptance Criteria illustrates the scope of the individual ticket and expectations from the team and client. -->

<!-- The Acceptance Criteria is applicable to specific User Story. Acceptance Criteria of each User Story will be different based on the requirements of that User Story. -->

<!-- EXAMPLE -->
<!-- WHEN the user visits any page -->
<!-- THEN I should see a Bootstrap NavBar -->
<!-- AND there should be links to the other pages -->
<!-- AND the current page should be In Bold -->

# Dependecies
<!-- List out all of the dev work that needs to be completed for this ticket and what other tickets are impacted or blocking this ticket's start/finish -->

# Dev Notes
<!-- List out all of the dev work that needs to be completed for this ticket and what other tickets are impacted or blocking this ticket's start/finish -->
25 changes: 25 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--- Provide a general summary of your changes in the Title above -->
<!--- DELETE ALL COMMENTS BEFORE CREATING PULL REQUEST -->

## Description
<!--- Describe your changes in detail -->

## Related Issue
<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->

## How Can This Be Tested?
<!--- Please describe in detail how teammates can test your changes. -->

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cd [repo name]
1. If the user unchecks the box, the background color should change back to white with black text for messages.

### Messages
1. When the page is first loaded, you must load 5 messages from a local JSON file and pre-fill a message area `<div>` below the input field that will also hold all new messages as they get created.
1. When the page is first loaded, you must load 5 messages from a module file and pre-fill a message area `<div>` below the input field that will also hold all new messages as they get created.
1. When the user presses the return key in the message field, the new message should be inserted into the message area.
1. The message should have a button displayed after it with the text "Delete" inside of it.
1. When the delete button next to a message is clicked, only that message should be removed from the DOM.
Expand All @@ -44,8 +44,8 @@ cd [repo name]
Create multiple modules, following the Single Responsibility Principle, that perform the following functions.

1. One module should load the seed data file and returns the array of objects.
1. One module should contain a function that accepts an element `id`, and the user message, and then add the user's message - along with the delete button - to the specified parent element. Each message should be stored in a private array in this IIFE. This IIFE should also expose a function to read all messages, and delete a single message.
1. One module should accept a message element `id` and then remove the correct element from the DOM. This module should also remove the corresponding message from the private array that was created in the previous IIFE.
1. One module should contain a function that accepts an element `id`, and the user message, and then add the user's message - along with the delete button - to the specified parent element. Each message should be stored in a private array in this module. This module should also expose a function to read all messages, and delete a single message.
1. One module should accept a message element `id` and then remove the correct element from the DOM. This module should also remove the corresponding message from the private array that was created in the previous module.

## Helpful hints

Expand Down Expand Up @@ -140,4 +140,4 @@ const users = [
1. Again, this will change the structure of your data file.

### Need inspiration?
[Dr. T's Cohort 21 Chatty Group Project](https://drteresavasquez.github.io/d21-group-chatty-justice_league/#)
[Dr. T's Cohort 21 Chatty Group Project](https://drteresavasquez.github.io/d21-group-chatty-justice_league/#)
Binary file added documentation/createproject 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/createproject 3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/createproject.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/lit-screen 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/lit-screen 3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/lit-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/notacceptable 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/notacceptable 3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/notacceptable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/usetemplate 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/usetemplate 3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/usetemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "chatty",
"version": "1.0.0",
"description": "Creating a messaging application.",
"main": "src/javascripts/main.js",
"scripts": {
"start": "webpack-dev-server --mode development --open",
"build": "webpack --mode production --module-bind js=babel-loader"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "7.11.4",
"@babel/preset-env": "7.11.0",
"babel-loader": "8.1.0",
"css-loader": "4.2.2",
"eslint": "7.7.0",
"eslint-config-airbnb-base": "14.2.0",
"eslint-loader": "4.0.2",
"eslint-plugin-import": "2.22.0",
"file-loader": "6.0.0",
"html-loader": "1.3.0",
"html-webpack-plugin": "4.3.0",
"mini-css-extract-plugin": "0.10.0",
"node-sass": "4.14.1",
"sass-loader": "10.0.1",
"webpack": "4.44.1",
"webpack-cli": "3.3.12",
"webpack-dev-server": "3.11.0"
},
"dependencies": {
"@fortawesome/fontawesome-free": "5.14.0",
"axios": "0.20.0",
"bootstrap": "4.5.2",
"emojis": "^1.0.10",
"jquery": "3.5.1",
"moment": "^2.27.0",
"popper.js": "1.16.1"
}
}
Binary file added src/assets/images/Charlie Brown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/Chuck.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/Franklin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/Linus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/Lucy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/Marcie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/Peppermint Patty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/Schroeder.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/Teacher.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/flyingace.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/pigpen.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/pumpkin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/snoopy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/woodstock.gif
40 changes: 40 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chatty</title>
</head>
<body>
<div id="navbar" class="d-block">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<a class="navbar-brand ml-2 mr-5 my-2" href="#">SnoopyChat</a>
<form class="form-inline" id="message-form">
<input class="form-control-lg mr-sm-2 message--input" id="message-input" type="text" placeholder="Message">
</form>
<button class="btn btn-outline-success btn-lg mx-4 my-2 my-sm-0" type="submit" id="send">Send</button>
<button class="btn btn-outline-danger btn-lg mx-3 my-2 my-sm-0" type="submit" id="clear-button">Clear</button>
</nav>
</div>
<div class="container text-center">
<div class="error" id="error"></div>
</div>
<div class="container">
<div class="row">
<div id="settings-container">
<h4>Post as:</h4>
<div id="user-options"></div>
<div class="container row">
<input type="checkbox" class="m-2" id="darkMode">
<h3 class="ml-1">Dark Mode</h3>
<input type="checkbox" class="m-2" id="largeText">
<h3 class="ml-1">Large Text</h3>
</div>
</div>
<div id="messages-container" class="col-9">
<ul class="list-unstyled" id="messages-list"></ul>
</div>
</div>
</div>
</body>
</html>
83 changes: 83 additions & 0 deletions src/javascripts/components/addMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import moment from 'moment';
import emojis from 'emojis';
import Message from '../helpers/data/messageData';
import Print from './displayMessages';
import Bot from '../helpers/data/botData';

const messageAction = () => {
const lastIndex = Message.getMessages().length - 1;
let idNumber = Message.getMessages().length === 0 ? 1 : Number(Message.getMessages()[lastIndex].id) + 1;
const messageValue = $('#message-input').val();
if (messageValue === '') {
$('#error').html('<p>Please enter a message</p>');
} else {
if (!Message.editing) {
const radioSelection = document.querySelector(
'input[name=character]:checked'
).value;
const imageSelection = document.querySelector(
'input[name=character]:checked'
).id;
const newMessage = {
id: idNumber.toString(),
user: `${radioSelection}`,
image: `${imageSelection}`,
message: emojis.unicode(messageValue),
timestamp: moment().format('MMMM Do YYYY, h:mm a'),
};
Message.getMessages().push(newMessage);
} else {
Message.holding.message = emojis.unicode(messageValue);
Message.getMessages().forEach((obj) => {
let oldMessage = obj.message;
if (obj.id === Message.holding.id) {
oldMessage = Message.holding.message;
}
return oldMessage;
});
Message.editing = false;
}
for (let i = 0; i < Bot.bots.length; i += 1) {
const lowerCaseMessageValue = messageValue.toLowerCase();
if (
lowerCaseMessageValue.includes(
Bot.bots[i].respondTo.find((word) => lowerCaseMessageValue.includes(word))
)
) {
const botMessage = {
id: (idNumber + 1).toString(),
user: `${Bot.bots[i].user}`,
image: `${Bot.bots[i].image}`,
message: `${
Bot.bots[i].message[
Math.floor(Math.random() * Bot.bots[i].message.length)
]
}`,
timestamp: moment().format('MMMM Do YYYY, h:mm a'),
};
idNumber += 1;
setTimeout(() => {
Message.getMessages().push(botMessage);
Print.printMessages();
}, Math.floor(Math.random() * 10000) + 1000);
}
}
$('#message-input').val('');
$('#error').html('');
Print.printMessages();
}
};

const addMessage = () => {
$('#send').on('click', () => {
messageAction();
});
$('#message-input').on('keypress', (e) => {
if (e.which === 13) {
e.preventDefault();
messageAction();
}
});
};

export default { addMessage };
10 changes: 10 additions & 0 deletions src/javascripts/components/buttonActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Data from '../helpers/data/messageData';

const clearButton = () => {
$('#clear-button').on('click', () => {
$('#messages-list').empty();
Data.getMessages().length = 0;
});
};

export default { clearButton };
38 changes: 38 additions & 0 deletions src/javascripts/components/displayMessages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Data from '../helpers/data/messageData';
import Delete from './removeMessage';
import Edit from './editMessage';

const displayMessage = (obj) => {
const domString = `
<li class="media mb-3 message-content" id="${obj.id}">
<img class="mr-3 rounded-circle" src="${obj.image}" alt="${obj.user}">
<div class="media-body">
<h5 class="mt-0 mb-1">${obj.user}</h5>
<p class="message--content">${obj.message}</p>
<div class="d-flex justify-content-between">
<p class="timestamp">${obj.timestamp}</p>
<div class="d-flex justify-content-end">
<button type="button" class="edit" id="edit${obj.id}"><i class="far fa-edit"></i></button>
<button type="button" class="close" id="delete${obj.id}"><span>&times;</span></button>
</div>
</div>
</div>
</li>`;
$('#messages-list').append(domString);
$(`#delete${obj.id}`).on('click', Delete.removeMessage);
$(`#edit${obj.id}`).on('click', Edit.editMessage);
};

const clearDom = () => {
$('#messages-list').html('');
};

const printMessages = () => {
clearDom();
for (let i = Data.getMessages().length - 1; i > Data.getMessages().length - 21; i -= 1) {
if (typeof Data.getMessages()[i] === 'undefined') break;
displayMessage(Data.getMessages()[i]);
}
};

export default { printMessages };
17 changes: 17 additions & 0 deletions src/javascripts/components/editMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Message from '../helpers/data/messageData';

const editMessage = (e) => {
Message.editing = true;
const messageId = e.target.closest('li').id;
Message.getMessages().forEach((obj) => {
const findId = Message.getMessages().indexOf(obj);
const messageToBeEdited = Message.getMessages()[findId];
const selectedMessage = messageToBeEdited.message;
if (messageId === obj.id) {
$('#message-input').val(selectedMessage);
Message.holding = messageToBeEdited;
}
});
};

export default { editMessage };
13 changes: 13 additions & 0 deletions src/javascripts/components/modes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const darkMode = () => {
$('#darkMode').on('click', () => {
document.body.classList.toggle('dark-mode');
});
};

const largeText = () => {
$('#largeText').on('click', () => {
document.body.classList.toggle('large-text');
});
};

export default { darkMode, largeText };
16 changes: 16 additions & 0 deletions src/javascripts/components/multipleUsers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Users from '../helpers/data/userData';

const userSelection = () => {
Users.selectUsers().forEach((item) => {
$('#user-options').append(`
<div class="form-check" name ="radioselector">
<input class="form-check-input" type="radio" name="character" id="${item.image}" value="${item.user}" checked>
<img class="mr-3 rounded-circle" id="image" src="${item.image}"/></br>
<label class="form-check-label" for="exampleRadios1">
<b>${item.user}</b>
</label>
`);
});
};

export default { userSelection };
Loading