Skip to content

Commit dea5a05

Browse files
committed
add problem parse
1 parent bd25041 commit dea5a05

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

src/index.html

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,14 @@
440440
flex-grow: 1;
441441
}
442442

443+
problem-set problem-editor > div {
444+
display: none;
445+
}
446+
447+
problem-set problem-editor > div.active {
448+
display: block;
449+
}
450+
443451
.d-none {
444452
display: none;
445453
}
@@ -597,16 +605,7 @@
597605
<!-- <div data-id="0" onclick="editProb(this)" class="active">A+B Problem</div> -->
598606
</problem-list>
599607
<problem-editor>
600-
<div class="form-group">
601-
<label for="general_standard">Title</label>
602-
<input type="text" class="form-control" id="problem_title_">
603-
<span class="bmd-help">The title of this problem, should be brief.</span>
604-
</div>
605-
<div class="form-group">
606-
<label for="general_standard">Type</label>
607-
<input type="text" class="form-control" id="problem_type_">
608-
<span class="bmd-help">Type, could be OnlineJudge or VirtualJudge.</span>
609-
</div>
608+
610609
</problem-editor>
611610
</problem-set>
612611
</div>
@@ -660,9 +659,27 @@
660659
focusTab("problem-editor");
661660
var i=0;
662661
message.problems.forEach((ele)=>{
663-
$('problem-list').append(`<div data-id="${i}" onclick="editProb(this)" ${i==0?'class="active"':''}>${ele.title}</div>`);
662+
$('problem-list').append(`<div data-id="${i}" onclick="editProb(this)">${ele.title}</div>`);
663+
$('problem-editor').append(`
664+
<div data-id="${i}">
665+
<div class="form-group">
666+
<label for="problem_title_${i}">Title</label>
667+
<input type="text" class="form-control" id="problem_title_${i}">
668+
<span class="bmd-help">The title of this problem, should be brief.</span>
669+
</div>
670+
<div class="form-group">
671+
<label for="problem_type_${i}">Type</label>
672+
<input type="text" class="form-control" id="problem_type_${i}">
673+
<span class="bmd-help">Type, could be OnlineJudge or VirtualJudge.</span>
674+
</div>
675+
</div>
676+
`);
677+
$(`#problem_title_${i}`).val(ele.title);
678+
$(`#problem_type_${i}`).val(ele.type);
679+
$(`problem-editor > div[data-id="${i}"]`).bootstrapMaterialDesign();
664680
});
665681
$('problem-list').append(`<div data-id="-1" onclick="newProb()"><i class="MDI plus-circle"></i> Add New Problem</div>`);
682+
if($('problem-list')[0]) editProb($('problem-list > div')[0]);
666683
});
667684

668685
function focusTab(tabName){
@@ -673,7 +690,9 @@
673690
function editProb(ele){
674691
$('problem-list > div').removeClass('active');
675692
$(ele).addClass('active');
676-
console.log($(ele).attr("data-id"));
693+
let id=$(ele).attr("data-id");
694+
$('problem-editor > div').removeClass("active");
695+
$(`problem-editor > div[data-id="${id}"]`).addClass("active");
677696
}
678697

679698
ipcRenderer.on("windowStatusChange", (event, message) => {

0 commit comments

Comments
 (0)