diff --git a/js/auto_mode.js b/js/auto_mode.js index 705fa2c..0df4c76 100644 --- a/js/auto_mode.js +++ b/js/auto_mode.js @@ -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")){ + mode = 2; + } + } + break; + case 1: + if(a === "<"){ + var b = txt.substring(i,txt.length); + if(b.startsWith("")){ + mode = 0; + if(!b.startsWith("<")){ + 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; } \ No newline at end of file diff --git a/manifest.json b/manifest.json index 15f1be8..1c8816a 100644 --- a/manifest.json +++ b/manifest.json @@ -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" ] }, diff --git a/popup/popup.html b/popup/popup.html index 2bea787..0800069 100644 --- a/popup/popup.html +++ b/popup/popup.html @@ -18,7 +18,7 @@
- +
diff --git a/popup/popup_style.css b/popup/popup_style.css index b1406ab..aec0a06 100644 --- a/popup/popup_style.css +++ b/popup/popup_style.css @@ -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;