-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a component structure for QuickMenuInsert. Create a linked lis…
…t and circular linked list to allow move the focus easily. Improve the folder structire.
- Loading branch information
1 parent
1a939ea
commit 83f957c
Showing
25 changed files
with
986 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"Triggable" | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import JNode from './JNode'; | ||
|
||
class JCircularLinkedList { | ||
|
||
constructor() { | ||
this.head = null; | ||
this.tail = null; | ||
this.length = 0; | ||
} | ||
|
||
/** | ||
* Append a new node with the given value to the end of the list. | ||
* @param {JNode} node - The node to append. | ||
*/ | ||
append(node) { | ||
if (!(node instanceof JNode)) { | ||
throw new TypeError("Expected an instance of JNode."); | ||
} | ||
|
||
if (this.length === 0) { | ||
this.head = node; | ||
this.tail = node; | ||
|
||
this.head.setNext(this.tail); | ||
this.head.setPrevious(this.tail); | ||
} else { | ||
node.setPrevious(this.tail); | ||
node.setNext(this.head); | ||
|
||
this.tail.setNext(node); | ||
this.head.setPrevious(node); | ||
|
||
this.tail = node; | ||
} | ||
this.length++; | ||
} | ||
|
||
/** | ||
* Get the first node (head) of the list. | ||
* @returns {JNode} The first node. | ||
*/ | ||
getFirst() { | ||
return this.head; | ||
} | ||
|
||
/** | ||
* Get the last node (tail) of the list. | ||
* @returns {JNode} The last node. | ||
*/ | ||
getLast() { | ||
return this.tail; | ||
} | ||
} | ||
|
||
export default JCircularLinkedList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import JNode from './JNode'; | ||
|
||
class JLinkedList { | ||
|
||
constructor() { | ||
this.head = null; | ||
this.tail = null; | ||
this.length = 0; | ||
} | ||
|
||
/** | ||
* Append a new node with the given value to the end of the list. | ||
* @param {*} HTMLElement - The value to store in the new node. | ||
*/ | ||
append(node) { | ||
|
||
if (!(node instanceof JNode)) { | ||
throw new TypeError("Expected an instance of JNode."); | ||
} | ||
|
||
if (this.length === 0) { | ||
this.head = node; | ||
this.tail = node; | ||
} else { | ||
|
||
this.tail.setNext(node); | ||
node.setPrevious(this.tail); | ||
|
||
this.tail = node; | ||
} | ||
|
||
this.length++; | ||
|
||
|
||
/** | ||
* Get the node in the head. | ||
* @returns {JNode} node. | ||
*/ | ||
this.getFirst = () => { | ||
return this.head; | ||
} | ||
|
||
/** | ||
* Get the node in the tail. | ||
* @returns {JNode} node. | ||
*/ | ||
this.getLast = () => { | ||
return this.tail; | ||
} | ||
} | ||
} | ||
|
||
export default JLinkedList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* JNode is custom generic Johannes node | ||
*/ | ||
class JNode { | ||
|
||
constructor(htmlElement) { | ||
this.previousNode; | ||
this.nextNode; | ||
|
||
/** | ||
* The HTML element of the component in the DOM. | ||
* @type {HTMLElement} | ||
*/ | ||
this.htmlElement = htmlElement; | ||
|
||
|
||
/** | ||
* Sets the next node. | ||
* If the input is not a JNode, an error is thrown. | ||
* | ||
* @param {JNode} node - The node to be set as the next item. | ||
* @throws {TypeError} Throws an error if the provided node is not an instance of JNode. | ||
*/ | ||
this.setNext = (node) => { | ||
if (!(node instanceof JNode)) { | ||
throw new TypeError("Expected an instance of JNode."); | ||
} | ||
|
||
this.nextNode = node; | ||
} | ||
|
||
/** | ||
* Sets the previous node. | ||
* If the input is not a JNode, an error is thrown. | ||
* | ||
* @param {JNode} node - The node to be set as the previous item. | ||
* @throws {TypeError} Throws an error if the provided node is not an instance of JNode. | ||
*/ | ||
this.setPrevious = (node) => { | ||
if (!(node instanceof JNode)) { | ||
throw new TypeError("Expected an instance of JNode."); | ||
} | ||
|
||
this.previousNode = node; | ||
} | ||
} | ||
} | ||
|
||
export default JNode; |
Oops, something went wrong.