-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.js
More file actions
87 lines (57 loc) · 2.01 KB
/
Stack.js
File metadata and controls
87 lines (57 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
let Length = 3;
let boardExist = false;
// import * as base from 'baseDataStructure.js';
// function assign() {
// console.log('assign()');
// base.assign();
// }
// function clearAll() { base.clearAll(); }
// function removeInput() { base.removeInput(); }
// function stackTop() {
// let summonBoard = document.getElementById('board');
// }
function push() {
}
function pop() {
let summonBoard = document.getElementById('board');
}
function buildStack() {
let summonBoard = document.getElementById('board');
let stackContainer = document.createElement('table');
let getVal = document.getElementById('inputBoard');
Length = parseInt(getVal.value);
getVal.innerHTML = '';
let table = document.createElement('table');
}
// import { Length, boardExist } from "./Stack";
function clearAll() {
removeInput();
}
function removeInput() {
console.log('removeInput function is activated.');
let board = document.getElementById('input');
boardExist = false;
board.innerHTML = '';
board.setAttribute('background-color', 'transparent');
}
function assign() { //出現輸入列 然後交給build
console.log('assign()');
if (!boardExist) {
boardExist = true;
let inputBoard = document.createElement('input');
let inputBoardContainer = document.getElementById('input');
let submit = document.createElement('button');
let cancel = document.createElement('button');
inputBoardContainer.setAttribute('background-color', 'white');
inputBoardContainer.className = 'input';
inputBoard.type = Number;
inputBoard.id = 'inputBoard';
inputBoard.placeholder = '請輸入0~10之間的數字';
submit.value = 'submit';
submit.addEventListener('click', buildStack, false);
cancel.value = 'cancel';
cancel.addEventListener('click', removeInput, false);
inputBoardContainer.appendChild(inputBoard);
inputBoardContainer.appendChild(submit);
}
}