Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kpole authored Jun 18, 2020
1 parent c43e194 commit 6d13670
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
9 changes: 3 additions & 6 deletions scripts/drawstatediagram.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
total = 0;
// 将项目内容添加到divNode中
function addItemContentToItemNode(divNode, index){
let preNode = document.createElement('pre');
preNode.className = "item-node";
Expand Down Expand Up @@ -26,7 +27,7 @@ function addItemContentToItemNode(divNode, index){
divNode.style.width = (MaxLength + 6) * 30 + "px";
divNode.style.height = (set.size) * 24 + 5 + "px";
}

// 创建div
function drawStateDiagram(){
let container = document.getElementById("parse-state-container");
container.innerHTML = "";
Expand All @@ -37,10 +38,6 @@ function drawStateDiagram(){
let depth = temp[0]; // 每个点的depth
let list = temp[1]; // 拓扑序排序之后
let colNum = new Array(itemCounts);
// console.log(edges);
// console.log(depth);
// console.log(items);
// console.log(list);

for(let i = 0; i < itemCounts; i++)colNum[i] = 0;
for(let i = 0; i < itemCounts; i ++){
Expand All @@ -60,7 +57,7 @@ function drawStateDiagram(){
container.style.height = Math.max(...colNum) * 350 + "px";
drawStateLine();
}

// 绘制边
function drawStateLine(){
let itemCounts = items.length;
jsPlumb.ready(function () {
Expand Down
10 changes: 4 additions & 6 deletions scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function showAllParseStep(){
// if(value == '') return;
// parse_step = analysis(value);
if(parse_step == undefined || parse_step == '') parseTextChange();
if(parse_step == undefined) return;
if(parse_step == undefined || parse_step == '') return;
let table = document.createElement("table");
table.id = "parse-steps";
let tr = document.createElement("tr");
Expand Down Expand Up @@ -317,13 +317,9 @@ function getLastNumber(str){


function changeStateDiagram(){
// console.log(curIndex);
// console.log(parse_step[curIndex]);
let curStateIndex = getLastNumber(parse_step[curIndex][0]);
// console.log("cur" + curStateIndex);
if(curIndex > 0) {
let pastStateIndex = getLastNumber(parse_step[curIndex-1][0]);
// console.log("past" + pastStateIndex);
document.getElementById("item_" + total+ pastStateIndex).classList.remove("item-current");
}
document.getElementById("item_" + total+ curStateIndex).classList.add("item-current");
Expand Down Expand Up @@ -358,7 +354,7 @@ function showOneStepOfParse(){
// 点击页面“单步演示”按钮触发该函数
function parseTextOneStep(){
if(parse_step == undefined || parse_step == '') parseTextChange();
if(parse_step == undefined) return;
if(parse_step == undefined || parse_step == '') return;
if(curIndex == 0){
let table = document.createElement("table");
table.id = "parse-steps";
Expand All @@ -381,6 +377,8 @@ function parseTextOneStep(){
function clearParseText(){
document.getElementById("parse-steps-container").innerHTML = '';
document.getElementById("parse-text").value = '';
let pastStateIndex = getLastNumber(parse_step[curIndex][0]);
document.getElementById("item_" + total+ pastStateIndex).classList.remove("item-current");
parse_step = "";
curIndex = 0;
}
Expand Down

0 comments on commit 6d13670

Please sign in to comment.