Version 1.2.0

Исправил ошибки заполнения некоторых ответов

Добавил options меню (такое же как и popup)

Версия более менее стабильная
This commit is contained in:
FutureX 2018-04-25 14:27:37 +03:00
parent 44b58955ba
commit 5850cf5c42
4 changed files with 78 additions and 18 deletions

View File

@ -50,8 +50,8 @@ function auto_mode() {
answers = document.getElementsByClassName('categories')[1];
if(test&&answers) fill_pronunciation(test,answers);
//text input
test = document.getElementsByTagName('input');
answers = document.getElementsByTagName('b');
test = document.getElementsByClassName('inputBox');
answers = document.getElementsByClassName('correctAnsDiv');
if(test&&answers) fill_input(test,answers);
//editDiv
test = document.getElementsByClassName('editableDiv');
@ -77,11 +77,14 @@ function fill_selectbox(test,answers) {
function fill_input(test,answers) {
var test_arr = Array.prototype.slice.call(test);
var answers_arr = Array.prototype.slice.call(answers);
var txt_answers_arr = [];
if(answers_arr&&test_arr)answers_arr.forEach(function(item, i) {
if(test_arr[i])
if(test_arr[i].getAttribute("type")!=="radio"){
test_arr[i].setAttribute("class","inputBox ng-scope ng-valid ng-dirty");
test_arr[i].value = item.innerHTML + "-";
txt_answers_arr = push_answer_b(item.getElementsByClassName("showAnswersentenseClass")[0],txt_answers_arr);
});
if(answers_arr&&test_arr)test_arr.forEach(function(item, i) {
if(item.getAttribute("type")!=="radio"&&item.getAttribute("class")!=="inputBox ng-scope ng-valid ng-dirty"){
item.setAttribute("class","inputBox ng-scope ng-valid ng-dirty");
item.value = txt_answers_arr[i]+"-";//.innerHTML + "-";
if(init===0)alert("Не забудьте убрать знак '-' в каждом задании");
init = 1;
}
@ -96,8 +99,8 @@ function fill_radio(test,answers) {
var text_answers_arr = Array.prototype.slice.call(answers_arr[i].getElementsByTagName('b'));
var answer = "";
if(text_answers_arr) text_answers_arr.forEach(function(item1) {
if(item1.innerHTML.search(/[a-zA-Z]/)===-1)answer=answer.substring(0,answer.length-1);
answer+=item1.innerHTML.replace(/(^\s*)|(\s*)$/g, '');
if(!item1.innerHTML.search(/[a-zA-Z]/)===-1)answer=answer.substring(0,answer.length-1)
if(item1.innerHTML!=='-')answer+=' ';
});
answer=answer.replace(/(^\s*)|(\s*)$/g, '');
@ -153,20 +156,31 @@ function fill_phrases(test,answers) {
var test_arr = Array.prototype.slice.call(test);
var answers_arr = Array.prototype.slice.call(answers);
if(answers_arr&&test_arr)answers_arr.forEach(function(item, i) {
var lil = 0;
var text_answers_arr = Array.prototype.slice.call(answers_arr[i].getElementsByTagName('b'));
var a = "";
if(text_answers_arr) text_answers_arr.forEach(function(item1) {a+=item1.innerHTML});
if(text_answers_arr) text_answers_arr.forEach(function(item1) {
if(item1.innerHTML.search(/[a-zA-Z]/)===-1)a=a.substring(0,a.length-1);
a+=item1.innerHTML.replace(/(^\s*)|(\s*)$/g, '');
if(item1.innerHTML!=='-')a+=' ';
});
a=a.replace(/(^\s*)|(\s*)$/g, '');
if(text_test_choises) text_test_choises.forEach(function(item,j) {
if(item.innerHTML === a&&test_choises[j].getAttribute("class")!=="dragger draggable ng-scope ui-draggable cloneDropped opacityDiv") {
test_choises[j].setAttribute("class","dragger draggable ng-scope ui-draggable cloneDropped opacityDiv");
var b = test_choises[j].cloneNode(true);
test_arr[i].append(b);
test_arr[i].setAttribute("style",b.getAttribute("style"));
test_arr[i].setAttribute("class","drop-dest droppable-Item all-items-drop dropped-items ui-droppable droppableWhiteBG droppableTransparentBG");
b.setAttribute("class","dragger draggable ng-scope ui-draggable cloneDropped clone");
b.setAttribute("style",b.getAttribute("style")+"position: relative; left: 0px; top: 0px;");
if(item.innerHTML.includes(a)) {
var b = item.innerHTML.replace(a, '');
if( b.search(/[a-zA-Z]/) === -1 )
if(lil===0&&test_choises[j].getAttribute("class")!=="dragger draggable ng-scope ui-draggable cloneDropped opacityDiv") {
test_choises[j].setAttribute("class","dragger draggable ng-scope ui-draggable cloneDropped opacityDiv");
var b = test_choises[j].cloneNode(true);
test_arr[i].append(b);
test_arr[i].setAttribute("style",b.getAttribute("style"));
test_arr[i].setAttribute("class","drop-dest droppable-Item all-items-drop dropped-items ui-droppable droppableWhiteBG droppableTransparentBG");
b.setAttribute("class","dragger draggable ng-scope ui-draggable cloneDropped clone");
b.setAttribute("style",b.getAttribute("style")+"position: relative; left: 0px; top: 0px;");
lil=1;
}
}
});
});
}
@ -187,4 +201,46 @@ function fill_editable(test,answers) {
if(!answers_arr[i].innerHTML.includes("No change"))
item.innerHTML=answers_arr[i].innerHTML.replace(/<[^>]+>/g,'');
});
}
//Найти ответы в строке(для inputBox)
function push_answer_b(answers,answers_arr){
if(answers){
var txt = answers.innerHTML+" ";
var answer = "";
var mode = 0;
var i = 0;
for(var i=0; i<txt.length;i++) {
var a = txt[i];
switch(mode){
case 0:
if(a === "<"){
var b = txt.substring(i,txt.length);
if(b.startsWith("<b>")){
mode = 2;
}
}
break;
case 1:
if(a === "<"){
var b = txt.substring(i,txt.length);
if(b.startsWith("</b>")){
mode = 0;
if(!b.startsWith("</b><")){
answer=answer.replace(/(^\s*)|(\s*)$/g, '');
answers_arr.push(answer);
answer = "";
}
}
}
else answer += a;
break;
case 2:
if(a === ">"){
mode = 1;
}
break;
}
}
}
return answers_arr;
}

View File

@ -14,6 +14,10 @@
"default_icon": "icons/icon.png",
"default_popup": "popup/popup.html"
},
"options_ui": {
"page": "popup/popup.html",
"open_in_tab": false
},
"background": {
"scripts": ["js/background.js", "js/true_mode.js" ]
},

View File

@ -18,7 +18,7 @@
<div class="button-add style style_1">
<input id="auto_mode" type="checkbox">
<label for="auto_mode" data-text="Автоматический режим"></label>
<label for="auto_mode" data-text="Автоматический режим(β)"></label>
<div class="button-add__icon"></div>
</div>

View File

@ -97,7 +97,7 @@ body {
.style_1 label:before, .style_1 label:after {
content: attr(data-text);
position: absolute;
right: 0.9rem; }
right: 0.4rem; }
.style_2 label:before, .style_2 label:after {
content: attr(data-text);
position: absolute;