Mobile Web App Development

FIND A SOLUTION AT Academic Writers Bay

Mobile Web App Development,
Element 1: Portfolio
Gabor Vajai
Lsst ID: H1801079
Uwl ID: 2137692
Contents
Introduction of IT in the Valley ……………………………………………………………………………………………. 3
Requirement Gathering, and Analysis…………………………………………………………………………………… 4
Use Case Diagram……………………………………………………………………………………………………………… 5
Design (Prototype) ……………………………………………………………………………………………………………. 6
Coding…………………………………………………………………………………………………………………………….. 7
HTML:………………………………………………………………………………………………………………………….. 7
JavaScript codes ……………………………………………………………………………………………………………. 8
Model (Data) …………………………………………………………………………………………………………….. 9
VIEW Component …………………………………………………………………………………………………….. 12
Controller ……………………………………………………………………………………………………………….. 16
Style (CSS code) …………………………………………………………………………………………………………… 17
Implementation: …………………………………………………………………………………………………………….. 20
Conclusion:…………………………………………………………………………………………………………………….. 24
References ………………………………………………………………………………. Error! Bookmark not defined.
Introduction of IT in the Valley
IT in the Valley is an organization which carries out business transaction with
photographers, journalists, and advertisers. It issues papers at the end of each month, it
buys photographs from photographers, selling advertising space to advertisers, and
contracts journalists to write articles for them. As of present, the organization has been
doing its business transactions, and all the related activities, such as documentation,
reports, and financial transactions manually. The organization has decided to computerize
their transactions on a fully, to improve on transaction times, and achieve more revenue.
We will be designing and implementing a simple system, to record names of those the
business would be doing transactions with.
Requirement Gathering, and Analysis
First, we will need to gather business requirements, to find out what our program will be needed to
be able to have as a feature.
Requirements are as follows:
Entity Name What are they doing?
System
1. Collect adverts, stories, and photographs.
2. Pay Journalist and photographers
3. Record who is to pay for advertisement, when
it should appear, how large are size of the ad.
4. Create reports.
5. Store Data
Marketing Department
1. Receive Advertising details from advertiser.
2. Record the details.
3. Pass advertisements to Editor.
4. Advertise company
Editor
1. Checks and edits adverts.
2. Send adverts to processing centre.
3. Match one or more photographs with stories.
4. Choose stories and adverts and photos to
form a magazine.
5. Send magazines to advertisers.
6. Receive invoice
Processing centre
1. Store Adverts in text or graphics formats
2. Receive adverts
Advertisers
1. Place several different adverts in same
magazine issue.
2. Advertise Magazine
3. Begin legal proceedings.
4. Receive proceedings settlement payments.
5. Submit adverts
Journalist
1. Submit stories to Editor.
2. Get paid
Photographer
1. Submit photographs to Editor.
2. Get paid
Accounts Department
1. Send out payments to Journalists and
Photographers.
2. Invoice Advertisers for published adverts
3. Receive legal proceedings.
4. Settle proceedings and pay
Use Case Diagram
The table explained in the previous section can be visualized as below representing each department
of the business and its related function associated to it.
Use Case Diagram
Design (Prototype)
The design prototype is based on our system specification, and the diagram below was created to
showcase entity relations. There may be entities within the business that communicate or reliant on
each other, so to the entities connected with black lines are communicating with each other.
Coding
The coding is divided into five parts, apart from the MVC (Model, View and Controller) coding we will
explain html, and the CSS style code. First is the html code which is the frame for the content.
(Comments are grey)
HTML:
<!–File type is HTML–>
<!DOCTYPE html>
<!–English language is set–>
<html lang=”en”>
<head>
<!–Unicode Standard UTF8 characterset are being used–>
<meta charset=”utf-8″>
<!–Instructions how to scale the content–>
<!–
width: content will scale to device dimensions, initial scale: page load with
zoom 1X–>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<meta http-equiv=”X-UA-Compatible” content=”ie=edge”>
<!–Title name–>
<title>Todo App</title>
<!–referencing the stylesheet file–>
<link rel=”stylesheet” href=”style.css”>
</head>
<!–Body tags with the root div and referenced javascript file–>
<body>
<div id=”root”></div>http://script.min.js
</body>
</html>
The above HTML code calls JavaScript and CSS code, to implement the Complete MVC. (Model View
Controller
JavaScript codes
Constructors, prior to creating the model.
“use strict”;
/**
*
*Predefining the functions using cunstructors
*/
function _defineProperty(obj, key, value) if (key in obj) Object.definePro
perty(obj, key, value: value, enumerable: true, configurable: true, writable
: true ); else obj[key] = value; return obj;
function _instanceof(left, right) if (right != null && typeof Symbol !== “un
defined” && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](le
ft); else return left instanceof right;
function _classCallCheck(instance, Constructor) if (!_instanceof(instance, C
onstructor)) throw new TypeError(“Cannot call a class as a function”);
function _defineProperties(target, props) for (var i = 0; i < props.length;
i++) var descriptor = props[i]; descriptor.enumerable = descriptor.enumerabl
e
function _createClass(Constructor, protoProps, staticProps) if (protoProps)
_defineProperties(Constructor.prototype, protoProps); if (staticProps) _define
Properties(Constructor, staticProps); return Constructor;
Model (Data)
/**
* @class Model
* *
Data management within the application,
* answering any request from the controller and return string as data
*/
var Model =
/*#__PURE__*/
function ()
function Model()
_classCallCheck(this, Model);
/**
* string received from the local storage are being parsed to be a javascript
object
*/
this.todos = JSON.parse(localStorage.getItem(‘todos’))
/**
* Creating the class “Model”, using the function “_createclass”
*/
_createClass(Model, [
key: “bindTodoListChanged”,
value: function bindTodoListChanged(callback)
this.onTodoListChanged = callback;/**Adds
* Adds data to local storage,
* but it is being parsed back to a string
* before it can be passed onto the storage
*/
,
key: “_commit”,
value: function _commit(todos)
this.onTodoListChanged(todos);
localStorage.setItem(‘todos’, JSON.stringify(todos));,
/**
* if entry field is empty, no data will be passed onto local storage
*/
key: “addTodo”,
value: function addTodo(todoText)
var todo =
id: this.todos.length > 0 ? this.todos[this.todos.length – 1].id + 1 :
1,
text: todoText,
complete: false
;
this.todos.push(todo);
this._commit(this.todos);,
/**
* Update textfield according to userinput,
* and update localstorage aswell
*/
key: “editTodo”,
value: function editTodo(id, updatedText)
this.todos = this.todos.map(function (todo)
return todo.id === id ?
id: todo.id,
text: updatedText,
complete: todo.complete
: todo;
);
this._commit(this.todos);,
/**
* Deletes record from local storage.
*/
key: “deleteTodo”,
value: function deleteTodo(id)
this.todos = this.todos.filter(function (todo)
return todo.id !== id;
);
this._commit(this.todos);,
key: “toggleTodo”,
value: function toggleTodo(id)
this.todos = this.todos.map(function (todo)
return todo.id === id ?
id: todo.id,
text: todo.text,
complete: !todo.complete
: todo;
);
this._commit(this.todos);]);
return Model;
();
VIEW Component
/**
* @class View
* *
Visual representation of the model.
*/
var View =
/*#__PURE__*/
function ()
function View()
_classCallCheck(this, View);
/**
* Creating form for user input
*/
this.app = this.getElement(‘#root’);
this.form = this.createElement(‘form’);
this.input = this.createElement(‘input’);
this.input.type = ‘text’;
this.input.placeholder = ‘Add todo’;
this.input.name = ‘todo’;
this.submitButton = this.createElement(‘button’);
this.submitButton.textContent = ‘Submit’;
this.form.append(this.input, this.submitButton);
this.title = this.createElement(‘h1’);
this.title.textContent = ‘Todos’;
this.todoList = this.createElement(‘ul’, ‘todo-list’);
this.app.append(this.title, this.form, this.todoList);
this._temporaryTodoText = ”;
this._initLocalListeners();_createClass(View, [
key: “_resetInput”,
value: function _resetInput()
this.input.value = ”;,
key: “createElement”,
value: function createElement(tag, className)
var element = document.createElement(tag);
if (className) element.classList.add(className);
return element;,
key: “getElement”,
value: function getElement(selector)
var element = document.querySelector(selector);
return element;,
key: “displayTodos”,
value: function displayTodos(todos)
var _this = this;
// Delete all nodes
while (this.todoList.firstChild)
this.todoList.removeChild(this.todoList.firstChild);/**
* Showing default message
* if no data is being stored in local storage
*/
if (todos.length === 0)
var p = this.createElement(‘p’);
p.textContent = ‘Nothing to do! Add a task?’;
this.todoList.append(p);
else
// Creating nodes
todos.forEach(function (todo)
var li = _this.createElement(‘li’);
li.id = todo.id;
var checkbox = _this.createElement(‘input’);
checkbox.type = ‘checkbox’;
checkbox.checked = todo.complete;
var span = _this.createElement(‘span’);
span.contentEditable = true;
span.classList.add(‘editable’);
if (todo.complete)
var strike = _this.createElement(‘s’);
strike.textContent = todo.text;
span.append(strike);
else
span.textContent = todo.text;var deleteButton = _this.createElement(‘button’, ‘delete’);
deleteButton.textContent = ‘Delete’;
li.append(checkbox, span, deleteButton); // Append nodes
_this.todoList.append(li);
);// Debugging
console.log(todos);,
key: “_initLocalListeners”,
value: function _initLocalListeners()
var _this2 = this;
this.todoList.addEventListener(‘input’, function (event)
if (event.target.className === ‘editable’)
_this2._temporaryTodoText = event.target.innerText;);,
key: “bindAddTodo”,
value: function bindAddTodo(handler)
var _this3 = this;
this.form.addEventListener(‘submit’, function (event)
event.preventDefault();
if (_this3._todoText)
handler(_this3._todoText);
_this3._resetInput(););,
key: “bindDeleteTodo”,
value: function bindDeleteTodo(handler)
this.todoList.addEventListener(‘click’, function (event)
if (event.target.className === ‘delete’)
var id = parseInt(event.target.parentElement.id);
handler(id););,
key: “bindEditTodo”,
value: function bindEditTodo(handler)
var _this4 = this;
this.todoList.addEventListener(‘focusout’, function (event)
if (_this4._temporaryTodoText)
var id = parseInt(event.target.parentElement.id);
handler(id, _this4._temporaryTodoText);
_this4._temporaryTodoText = ”;);,
key: “bindToggleTodo”,
value: function bindToggleTodo(handler)
this.todoList.addEventListener(‘change’, function (event)
if (event.target.type === ‘checkbox’)
var id = parseInt(event.target.parentElement.id);
handler(id););,
key: “_todoText”,
get: function get()
return this.input.value;]);
return View;
();
Controller
/**
* @class Controller
* *
Links the user input and the view output.
* *
@param model
* @param view
*/
var Controller = function Controller(model, view)
var _this5 = this;
_classCallCheck(this, Controller);
_defineProperty(this, “onTodoListChanged”, function (todos)
_this5.view.displayTodos(todos);
);
_defineProperty(this, “handleAddTodo”, function (todoText)
_this5.model.addTodo(todoText);
);
_defineProperty(this, “handleEditTodo”, function (id, todoText)
_this5.model.editTodo(id, todoText);
);
_defineProperty(this, “handleDeleteTodo”, function (id)
_this5.model.deleteTodo(id);
);
_defineProperty(this, “handleToggleTodo”, function (id)
_this5.model.toggleTodo(id);
);
// Explicit this binding
this.model = model;
this.view = view;
this.model.bindTodoListChanged(this.onTodoListChanged);
this.view.bindAddTodo(this.handleAddTodo);
this.view.bindEditTodo(this.handleEditTodo);
this.view.bindDeleteTodo(this.handleDeleteTodo);
this.view.bindToggleTodo(this.handleToggleTodo);
// Display initial todos
this.onTodoListChanged(this.model.todos);
;
var app = new Controller(new Model(), new View());
Style (CSS code)
*,
*::before,
/* After each element, border-box property are set.
This means that, all container will be the same size with padding included in
the dimensions */
*::after
box-sizing: border-box/* HTML basic styling, setting the font family, font size and color */
html
font-family: sans-serif;
font-size: 1rem;
color: #444;/* styling the div “root”. this is part of the body.
setting the dimensions like width, margin and padding */
#root
max-width: 450px;
margin: 2rem auto;
padding: 0 1rem;/* styling the form part of the site. flex: all items are displayed the same s
ize,
regardless its content. Also setting the bottom padding */
form
display: flex;
margin-bottom: 2rem;/* properties of the buttons. Displaying as block element,
and setting the padding, font, and border. */
[type=”text”],
button
display: inline-block;
-webkit-appearance: none;
padding: .5rem 1rem;
font-size: 1rem;
border: 2px solid #ccc;
border-radius: 4px;/* further style for the button, cursor type, background color,
text color, and border */
button
cursor: pointer;
background: #007bff;
color: white;
border: 2px solid #007bff;
margin: 0 .5rem;/* text width equal to its container width */
[type=”text”]
width: 100%;/* setting text properties if active */
[type=”text”]:active,
[type=”text”]:focus
outline: 0;
border: 2px solid #007bff;/* checkbox propertes, like right margin and font size */
[type=”checkbox”]
margin-right: 1rem;
font-size: 2rem;/* header 1 properties, setting the color */
h1
color: #222;/* unordered list properties, no padding */
ul
padding: 0;/* properties of the list items, alignment is center,
and setting the border properties, background color, and border radius */
li
display: flex;
align-items: center;
padding: 1rem;
margin-bottom: 1rem;
background: #f4f4f4;
border-radius: 4px;/* styling the part if the list element, such as displaying as block,
and setting the padding, width and border properties */
li span
display: inline-block;
padding: .5rem;
width: 250px;
border-radius: 4px;
border: 2px solid transparent;/* list element properties when hovered over. change in its background color *
/
li span:hover
background: rgba(179, 215, 255, 0.52);/* list element properties when focused on.
Border color change, and background color change */
li span:focus
outline: 0;
border: 2px solid #007bff;
background: rgba(179, 207, 255, 0.52)Implementation:
Below is the implementation of the running web application, with the functionality explained.
To show that these Names are stored in the local storage, the one with the box ticked will
deleted using the delete button besides.
Conclusion
Model view controller is a very useful way to create functional website. From the design
above it is a design pattern that makes it very easy to create and work on web applications
due to the standard framework patterns. Most of the web applications are being created
using MVC pattern, and it has all types of JavaScript functions as well as server-side
programming, making MVC design pattern a very good choice when it comes to web
application development. Understanding MVC pattern and the different programming
languages connecting to JavaScript such as AJAX would give a very powerful skill to any
want- to-be web app developer.
References
Dalling, T. (n.d.). tomdalling.com. Retrieved from Model View Controller Explained:
https://www.tomdalling.com/blog/software-design/model-view-controller-explained/
(Accesed 01.2021)
Deacon, J. (n.d.). Model-View-Controller(MVC) Architecture.
(Accesed 01.2021)
Eygi, C. (n.d.). freeCodeCamp. Retrieved from JavaScript Callback Functions – What are
Callbacks in JS and How to Use Them: https://www.freecodecamp.org/news/javascriptcallback-functions-what-are-callbacks-in-js-and-how-to-use-them/
(Accesed 01.2021)
w3schools. (n.d.). w3schools. Retrieved from Example – Parsing JSON:
https://www.w3schools.com/js/js_json_parse.asp
(Accesed 01.2021)
w3SChools. (n.d.). W3Schools. Retrieved from JavaScript Object Constructors:
https://www.w3schools.com/js/js_object_constructors.asp
(Accesed 01.2021)

YOU MAY ALSO READ ...  Finding Freedom In Forgiveness
Order from Academic Writers Bay
Best Custom Essay Writing Services

QUALITY: 100% ORIGINAL PAPERNO PLAGIARISM – CUSTOM PAPER