I need to have the HTML separated from the Javascript. Also, I am visually-impaired, so please
do not upload an image, because I can’t see it; and the screen reader won’t read it to me. Please
write simple code, so that I can try to follow it. In Javascript, using JSFiddle, we are going to
create a Doubly Linked List. The List will be made up of Nodes. Each node will have the
following properties; Node Properties id - A simple id for the node itself, content - A value
(String) next - A pointer to the next node in the List (null for the last node). last - A pointer to the
previous node in the List List Properties head - Pointer to the first node in the list length -
Number of nodes in the list Next - you will populate your list with 5 nodes with content A, B, C,
D, E. You will also create a print function for the list that will print the nodes in order. You will
need to create some functions to support this functionality. You will now need to write an
interface to allow the user to add nodes to the end of the list. There should be a single text box to
enter the Node content, and a button \"Add to List\". When the user adds a node to the list, then
you should add the node with the content to the end of the list and print the new list. I need to
have the HTML separated from the Javascript. Also, I am visually-impaired, so please do not
upload an image, because I can’t see it; and the screen reader won’t read it to me. Please write
simple code, so that I can try to follow it. In Javascript, using JSFiddle, we are going to create a
Doubly Linked List. The List will be made up of Nodes. Each node will have the following
properties; Node Properties id - A simple id for the node itself, content - A value (String) next -
A pointer to the next node in the List (null for the last node). last - A pointer to the previous node
in the List List Properties head - Pointer to the first node in the list length - Number of nodes in
the list Next - you will populate your list with 5 nodes with content A, B, C, D, E. You will also
create a print function for the list that will print the nodes in order. You will need to create some
functions to support this functionality. You will now need to write an interface to allow the user
to add nodes to the end of the list. There should be a single text box to enter the Node content,
and a button \"Add to List\". When the user adds a node to the list, then you should add the node
with the content to the end of the list and print the new list.
Solution
var list = null;
//a function for creating a list
function createList() {
var value = document.getElementById(\"LinkName\").value;
var length = document.getElementById(\"LinkName\").length;
list = new List(value,length);
document.getElementById(\"demo\").innerHTML = list.print();
}
//a function for adding a new node to list
function addNode() {
var id = document.getElementById(\"LinkName\").id;
var value = document.getElementById(\"LinkName\").value;
list.addNode(id,value);
do.
I need to have the HTML separated from the Javascript. Also, I am vi.pdf
1. I need to have the HTML separated from the Javascript. Also, I am visually-impaired, so please
do not upload an image, because I can’t see it; and the screen reader won’t read it to me. Please
write simple code, so that I can try to follow it. In Javascript, using JSFiddle, we are going to
create a Doubly Linked List. The List will be made up of Nodes. Each node will have the
following properties; Node Properties id - A simple id for the node itself, content - A value
(String) next - A pointer to the next node in the List (null for the last node). last - A pointer to the
previous node in the List List Properties head - Pointer to the first node in the list length -
Number of nodes in the list Next - you will populate your list with 5 nodes with content A, B, C,
D, E. You will also create a print function for the list that will print the nodes in order. You will
need to create some functions to support this functionality. You will now need to write an
interface to allow the user to add nodes to the end of the list. There should be a single text box to
enter the Node content, and a button "Add to List". When the user adds a node to the list, then
you should add the node with the content to the end of the list and print the new list. I need to
have the HTML separated from the Javascript. Also, I am visually-impaired, so please do not
upload an image, because I can’t see it; and the screen reader won’t read it to me. Please write
simple code, so that I can try to follow it. In Javascript, using JSFiddle, we are going to create a
Doubly Linked List. The List will be made up of Nodes. Each node will have the following
properties; Node Properties id - A simple id for the node itself, content - A value (String) next -
A pointer to the next node in the List (null for the last node). last - A pointer to the previous node
in the List List Properties head - Pointer to the first node in the list length - Number of nodes in
the list Next - you will populate your list with 5 nodes with content A, B, C, D, E. You will also
create a print function for the list that will print the nodes in order. You will need to create some
functions to support this functionality. You will now need to write an interface to allow the user
to add nodes to the end of the list. There should be a single text box to enter the Node content,
and a button "Add to List". When the user adds a node to the list, then you should add the node
with the content to the end of the list and print the new list.
Solution
var list = null;
//a function for creating a list
function createList() {
var value = document.getElementById("LinkName").value;
var length = document.getElementById("LinkName").length;
list = new List(value,length);
2. document.getElementById("demo").innerHTML = list.print();
}
//a function for adding a new node to list
function addNode() {
var id = document.getElementById("LinkName").id;
var value = document.getElementById("LinkName").value;
list.addNode(id,value);
document.getElementById("demo").innerHTML = list.print();
}
// Define the link object with following properties
function Node(_id,_value, _last) {
this.id=_id;// A simple id for the node itself
this.value = _value; // The value stored
this.last = _last; // A pointer to the previous link
this.next = null; // a pointer to the next link
return this; // returns the created node
}
Node.prototype.asString = function() {
return "Node Value:" + this.value + "
";
}
// Define the List object
function List(_value,_length) {
// We will define the list with the first link defined
this.length = _length;
this.head = new Node(_id,_value, null); // Pointer TO the head is null
this.last = this.head; // When created - head and last are the same.
}
List.prototype.addNode = function(_value) {
var node = new Node(_id,_value, _last);
if (this._length) {
this.last.next = node;
node.last = this.last;
this.last = node;
} else {
this.head = node;
3. this.last = node;
}
this._length++;
return node;
}
//print function
List.prototype.print = function()
{
var s = "";
var n = this.head;
while (n != null){
s += n.asString();
n = n.next;
}
return s;
}
//create data structure object
var _list= new createList();
//add nodes
var node = new Node(_id,_value, _last);
node.id = 1;
node.value = "A";
_list.addNode(node);
var node = new Node(_id,_value, _last);
node.id = 2;
node.value = "B";
_list.addNode(node);
var node = new Node(_id,_value, _last);
node.id = 3;
node.value = "C";
_list.addNode(node);
var node = new Node(_id,_value, _last);
node.id = 4;
node.value = "D";
_list.addNode(node);
var node = new Node(_id,_value, _last);