").concat(t.max,"
");var h=document.createElement("div");h.classList.add("task-description"),h.innerHTML="".concat(t.text,"
"),h.innerHTML+="Добавить отзыв";var p=document.createElement("div");p.classList.add("overlay"),p.onclick=function(){var t=document.querySelector('[data-active="true"]');E(t,s),t.scrollIntoView({behavior:"smooth"})},r.appendChild(c),r.appendChild(h),r.appendChild(u),r.appendChild(p)}m.push(r)}function E(t,n){var e=t.querySelector("textarea");if(e){e.focus();var r=e.parentElement.querySelector(".askFeedback");r&&r.remove();var i=document.createElement("DIV");i.classList.add("askFeedback"),i.innerHTML=n,t.querySelector(".feedback-buttons").appendChild(i)}}function _(t){h.innerHTML="";var n=document.createElement("div");n.classList.add("header");var e=document.createElement("div");e.classList.add("content");var u=document.createElement("p");if(u.classList.add("close"),u.innerHTML="×",u.addEventListener("click",(function(){h.classList.toggle("visible"),i=!1})),n.appendChild(u),t.some((function(t){return t&&t.needFeedback&&!t.feedback}))){var a=document.querySelector('.checkbox-container[data-active="true"]');a.querySelector("textarea")&&(a.scrollIntoView({behavior:"smooth"}),E(a,s)),e.innerHTML='Ваша оценка - ".concat(g>=0?g:0," ").concat(l," \r\n
Отзыв по пунктам ТЗ:\r\n
");var p={0:"Не выполненные/не засчитанные пункты:",1:"Частично выполненные пункты:",2:"Выполненные пункты:",penalty:"Штрафы:"};Object.keys(p).forEach((function(t){f.some((function(n){return n.type==t&&0!=n.status||"penalty"!=n.type&&n.status==t}))&&(e.innerHTML+="".concat(p[t],"\r\n
"),f.filter((function(n){return n.type==t&&0!=n.status||"penalty"!=n.type&&n.status==t})).map((function(t,n){e.innerHTML+="".concat(n+1,") ").concat(t.text," \r\n").concat(t.feedback?'
Отзыв: '+t.feedback+"
":"","\r\n")})))})),o=e.innerText}h.appendChild(n),h.appendChild(e),h.classList.add("visible"),i=!0}function k(t){t?c=0:c++,v.innerText=c}function O(t){if(!y[t].needFeedback||!y[t].feedback||((e=y[t]).feedback=e.feedback.replace(/(\s+)/g," ").trim(),e.feedback.length<8)){if(y[t].needFeedback){var n=y[t].activeRadio.closest(".checkbox-container");return n.querySelector("a").click(),E(n,"Фидбек не может быть пустым! Минимальная длина 8 символов"),void setTimeout((function(){return E(n,s)}),3e3)}}else document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="true"}));var e}function L(t){var n;y[t].needFeedback&&(c--,v.innerText=c,y[t].activeRadio.checked=!1,n=y[t].max,g-=+(n/2).toFixed(1),p.innerHTML=g<0?0:g,delete y[t].needFeedback,delete y[t].activeRadio,delete y[t].status,document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="true"})),g||S.classList.add("hidden"))}function F(t,n,e,r){y[t].feedback=n.value,n.value?(e.classList.add("feedback-add"),e.innerHTML="Изменить отзыв"):(delete y[t].feedback,e.classList.remove("feedback-add"),e.innerHTML="Добавить отзыв"),r.remove()}S.addEventListener("click",(function(t){g=0,i=!1,y.map((function(t){t&&delete t.status,t&&delete t.feedback})),document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="true",t.querySelectorAll("input").forEach((function(t){return t.checked=!1}));var n=t.querySelector("form");n&&n.remove(),t.querySelector(".add-feedback").innerHTML="Добавить отзыв"})),k("reset"),p.innerHTML=0,S.classList.add("hidden"),h.classList.remove("visible")})),S.click(),b.addEventListener("click",(function(t){var n=t.target.parentElement,e=t.target.dataset.id,r=y[e];if("INPUT"===t.target.tagName){var o=t.target,c=o.dataset.score;if(u&&"true"==n.dataset.active)return n.dataset.active="false",void t.preventDefault();if(u&&"false"==n.dataset.active)return n.dataset.active="true",void t.preventDefault();if(!u&&"false"!=n.dataset.active){void 0===r.status&&k();var a=[0,+(r.max/2).toFixed(1),r.max];if(r.status>=0&&(g-="penalty"!==r.type?a[r.status]:2*a[r.status]),g+="penalty"!==r.type?a[c]:2*a[c],r.status=c,p.innerHTML=g<0?0:g,1==+c&&"subtask"==r.type){r.needFeedback=!0,r.activeRadio=o;var f=o.closest(".checkbox-container");f.querySelector("textarea")||f.querySelector("a").click(),f.scrollIntoView({behavior:"smooth"}),E(f,s),document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="false",t===f&&(t.dataset.active="true")}))}else if(r.needFeedback&&"subtask"==r.type){r.needFeedback=!1;var l=o.closest(".checkbox-container").querySelector("form");l&&l.remove(),document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="true"}))}if(void 0!==r.activeRadio&&r.activeRadio.dataset.score!==c&&r.feedback){r.activeRadio=o;var h=o.closest(".checkbox-container");h.querySelector("a").click(),E(h,"Вы изменили оценку. Возможно стоит изменить отзыв?")}i&&_(y)}y.some((function(t){return t&&void 0!==t.status}))?S.classList.remove("hidden"):S.classList.add("hidden"),r.activeRadio=o}})),window.addFeedback=function(t){t.preventDefault(),document.querySelectorAll(".add-form").forEach((function(t){return t.remove()}));var n=t.target,e=n.closest(".checkbox-container").querySelector("input").dataset.id,r=document.createElement("form");r.classList.add("add-form");var i=document.createElement("textarea");i.setAttribute("placeholder","Use Ctrl + Enter to save this feedback or ESC to cancel"),y[e].feedback&&(i.value=y[e].feedback),r.appendChild(i);var o=document.createElement("a");o.innerText="Отмена",o.onclick=function(){r.remove(),L(e)};var c=o.cloneNode();c.innerText="Сохранить",c.onclick=function(){F(e,i,n,r),O(e)};var a=document.createElement("DIV");a.classList.add("feedback-buttons"),a.appendChild(o),a.appendChild(c),r.appendChild(a),n.parentElement.appendChild(r),i.focus(),i.select(),r.addEventListener("keyup",(function(t){13==t.keyCode&&u?(F(e,i,n,r),O(e)):27==t.keyCode&&(L(e),r.remove())}))},window.copyToClipboard=function(t){t.preventDefault(),t.target.classList.add("not-link"),t.target.innerText="Скопировано!",setTimeout((function(){t.target.classList.remove("not-link"),t.target.innerText="Скопировать в буфер"}),1e3);var n=document.createElement("textarea");n.value=o,n.setAttribute("readonly",""),n.style.position="absolute",n.style.left="-9999px",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}}function i(t,n,e,r,i,o,u){try{var c=t[o](u),a=c.value}catch(t){return void e(t)}c.done?n(a):Promise.resolve(a).then(r,i)}function o(t){return function(){var n=this,e=arguments;return new Promise((function(r,o){var u=t.apply(n,e);function c(t){i(u,r,o,c,a,"next",t)}function a(t){i(u,r,o,c,a,"throw",t)}c(void 0)}))}}function u(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}e.r(n);var c=document.querySelector(".start");c&&c.addEventListener("click",(function(t){t.stopPropagation(),"SECTION"==t.target.parentElement.tagName&&(t.target.parentElement.style.display="none")}));var a=document.querySelector("header"),f=a.offsetTop;window.onscroll=function(){window.pageYOffset>f+100?a.classList.add("sticky"):a.classList.remove("sticky")},new function t(n){var e=this;!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),u(this,"getTask",function(){var t=o(regeneratorRuntime.mark((function t(n){var i,o,u,c,a,f,s,l;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.match(/http/),t.next=3,fetch(n);case 3:if((i=t.sent).ok){t.next=8;break}return e.fetchFails.push(n),e.renderErrors(),t.abrupt("return");case 8:return t.next=11,i.json();case 11:o=t.sent,e.tasks.push(o),(u=document.createElement("DIV")).classList.add("taskContainer"),u.dataset.name=o.taskName,(c=document.createElement("DIV")).classList.add("taskLink"),(a=document.createElement("a")).setAttribute("href",o.github),a.setAttribute("target","_blank"),(f=document.createElement("img")).classList.add("icon"),f.src="./images/gh.svg",f.alt="GitHub link",a.appendChild(f),a.setAttribute("title","Original repo README"),(s=document.createElement("a")).setAttribute("href",o.externalLink||n),s.innerText=o.taskName,o.externalLink||(s.onclick=function(t){t.preventDefault(),e.tasksList.remove(),document.querySelector(".back").classList.remove("hidden"),r(o.criteria,o.taskName,o.information)}),c.appendChild(s),(l=c.cloneNode()).innerHTML="",l.appendChild(a),u.appendChild(l),u.appendChild(c),e.tasksList&&e.tasksList.appendChild(u),e.loader.classList.remove("visible");case 39:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}()),u(this,"initTasks",o(regeneratorRuntime.mark((function t(){var n,r,i,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.loader=document.querySelector(".loader"),e.tasksList=document.querySelector(".tasks-list"),e.errorsContainer=document.querySelector(".fetch-errors"),t.next=5,fetch(e.url);case 5:if((n=t.sent).ok){t.next=10;break}return e.fetchFails.push(e.url.match(/.*\/(?!\/)(.*)$/)[1]),e.renderErrors(),t.abrupt("return");case 10:return t.next=13,n.json();case 13:r=t.sent,i=Object.values(r),o=0;case 16:if(!(o3?'class="wide-digit"':"",">").concat(t.max,"
");var f=document.createElement("div");f.classList.add("task-description"),f.innerHTML="".concat(t.text.split("`").map((function(t,n,e){return n
".concat(l["your-mark"]).concat(E>=0?E:0," ").concat(s," \r\n
").concat(l["review-by-points"],"\r\n
");var h={0:l["result-descriptions"][0],1:l["result-descriptions"][1],2:l["result-descriptions"][2],penalty:l.penalties};Object.keys(h).forEach((function(t){a.some((function(n){return n.type==t&&0!=n.status||"penalty"!=n.type&&n.status==t}))&&(e.innerHTML+="".concat(h[t],"\r\n
"),a.filter((function(n){return n.type==t&&0!=n.status||"penalty"!=n.type&&n.status==t})).map((function(t,n){e.innerHTML+="".concat(n+1,") ").concat(t.text," \r\n").concat(t.feedback?'
'.concat(l.review,"")+t.feedback+"
":"","\r\n")})))})),u=e.innerText}g.appendChild(n),g.appendChild(e),g.classList.add("visible"),c=!0}function j(t){t?f=0:f++,b.innerText=f}function T(t){if(!w[t].needFeedback||!w[t].feedback||((e=w[t]).feedback=e.feedback.replace(/(\s+)/g," ").trim(),e.feedback.length<8)){if(w[t].needFeedback){var n=w[t].activeRadio.closest(".checkbox-container");return n.querySelector("a").click(),P(n,l["not-empty-feedback"]),void setTimeout((function(){return P(n,v)}),3e3)}}else document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="true"}));var e}function I(t){var n;w[t].needFeedback&&(f--,b.innerText=f,w[t].activeRadio.checked=!1,n=w[t].max,S-=+(n/2).toFixed(1),m.innerHTML=S<0?0:S,delete w[t].needFeedback,delete w[t].activeRadio,delete w[t].status,document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="true"})),S||F.classList.add("hidden"))}function N(t,n,e,r){w[t].feedback=n.value,n.value?(e.classList.add("feedback-add"),e.innerHTML=l["change-review"]):(delete w[t].feedback,e.classList.remove("feedback-add"),e.innerHTML=l["add-review"]),r.remove()}F.addEventListener("click",(function(t){S=0,E=0,Object.keys(k).forEach((function(t){return delete k[t]})),c=!1,w.map((function(t){t&&delete t.status,t&&delete t.feedback})),document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="true",t.querySelectorAll("input").forEach((function(t){return t.checked=!1}));var n=t.querySelector("form");n&&n.remove(),t.querySelector(".add-feedback").innerHTML=l["add-review"]})),j("reset"),m.innerHTML=0,F.classList.add("hidden"),g.classList.remove("visible")})),F.click(),L.addEventListener("click",(function(t){var n=t.target.parentElement,e=t.target.dataset.id,r=w[e];if("INPUT"===t.target.tagName){var o=t.target,i=o.dataset.score;if(s&&"true"==n.dataset.active)return n.dataset.active="false",void t.preventDefault();if(s&&"false"==n.dataset.active)return n.dataset.active="true",void t.preventDefault();if(!s&&"false"!=n.dataset.active){void 0===r.status&&j();var u="%"===r.max[r.max.length-1],a=[0,+(r.max/2).toFixed(1),r.max];r.status>=0&&!u&&(S-="penalty"!==r.type?a[r.status]:2*a[r.status]),u?1==i?k[r.text]=r.max.slice(0,-1):delete k[r.text]:S+="penalty"!==r.type?a[i]:2*a[i];var f=Object.keys(k).reduce((function(t,n){return t-k[n]}),0);if(E=(S-S*(.01*f)).toFixed(1),r.status=i,m.innerHTML=E<0?0:E,1==+i&&"subtask"==r.type){r.needFeedback=!0,r.activeRadio=o;var l=o.closest(".checkbox-container");l.querySelector("textarea")||l.querySelector("a").click(),l.scrollIntoView({behavior:"smooth"}),P(l,v),document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="false",t===l&&(t.dataset.active="true")}))}else if(r.needFeedback&&"subtask"==r.type){r.needFeedback=!1;var h=o.closest(".checkbox-container").querySelector("form");h&&h.remove(),document.querySelectorAll(".checkbox-container").forEach((function(t){t.dataset.active="true"}))}if(void 0!==r.activeRadio&&r.activeRadio.dataset.score!==i&&r.feedback){r.activeRadio=o;var p=o.closest(".checkbox-container");p.querySelector("a").click(),P(p,d)}c&&A(w)}w.some((function(t){return t&&void 0!==t.status}))?F.classList.remove("hidden"):F.classList.add("hidden"),r.activeRadio=o}})),window.addFeedback=function(t){t.preventDefault(),document.querySelectorAll(".add-form").forEach((function(t){return t.remove()}));var n=t.target,e=n.closest(".checkbox-container").querySelector("input").dataset.id,r=document.createElement("form");r.classList.add("add-form");var o=document.createElement("textarea");o.setAttribute("placeholder",l["use-ctrl-enter"]),w[e].feedback&&(o.value=w[e].feedback),r.appendChild(o);var i=document.createElement("a");i.innerText=l.cancel,i.onclick=function(){r.remove(),I(e)};var c=i.cloneNode();c.innerText=l.save,c.onclick=function(){N(e,o,n,r),T(e)};var u=document.createElement("DIV");u.classList.add("feedback-buttons"),u.appendChild(i),u.appendChild(c),r.appendChild(u),n.parentElement.appendChild(r),o.focus(),o.select(),r.addEventListener("keyup",(function(t){13==t.keyCode&&s?(N(e,o,n,r),T(e)):27==t.keyCode&&(I(e),r.remove())}))},window.copyToClipboard=function(t){t.preventDefault(),t.target.classList.add("not-link"),t.target.innerText=l.copied,setTimeout((function(){t.target.classList.remove("not-link"),t.target.innerText=l["copy-to-clipboard"]}),1e3);var n=document.createElement("textarea");n.value=u,n.setAttribute("readonly",""),n.style.position="absolute",n.style.left="-9999px",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}}var u="rs-checklist-lang";function a(){var t=localStorage.getItem(u);return t||"ru"}function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function f(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */f=function(){return t};var t={},n=Object.prototype,e=n.hasOwnProperty,r=Object.defineProperty||function(t,n,e){t[n]=e.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function a(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{a({},"")}catch(t){a=function(t,n,e){return t[n]=e}}function l(t,n,e,o){var i=n&&n.prototype instanceof v?n:v,c=Object.create(i.prototype),u=new O(o||[]);return r(c,"_invoke",{value:E(t,e,u)}),c}function h(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var p={};function v(){}function d(){}function y(){}var g={};a(g,i,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(F([])));b&&b!==n&&e.call(b,i)&&(g=b);var x=y.prototype=v.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(n){a(t,n,(function(t){return this._invoke(n,t)}))}))}function S(t,n){var o;r(this,"_invoke",{value:function(r,i){function c(){return new n((function(o,c){!function r(o,i,c,u){var a=h(t[o],t,i);if("throw"!==a.type){var f=a.arg,l=f.value;return l&&"object"==s(l)&&e.call(l,"__await")?n.resolve(l.__await).then((function(t){r("next",t,c,u)}),(function(t){r("throw",t,c,u)})):n.resolve(l).then((function(t){f.value=t,c(f)}),(function(t){return r("throw",t,c,u)}))}u(a.arg)}(r,i,o,c)}))}return o=o?o.then(c,c):c()}})}function E(t,n,e){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return M()}for(e.method=o,e.arg=i;;){var c=e.delegate;if(c){var u=k(c,e);if(u){if(u===p)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===r)throw r="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);r="executing";var a=h(t,n,e);if("normal"===a.type){if(r=e.done?"completed":"suspendedYield",a.arg===p)continue;return{value:a.arg,done:e.done}}"throw"===a.type&&(r="completed",e.method="throw",e.arg=a.arg)}}}function k(t,n){var e=n.method,r=t.iterator[e];if(void 0===r)return n.delegate=null,"throw"===e&&t.iterator.return&&(n.method="return",n.arg=void 0,k(t,n),"throw"===n.method)||"return"!==e&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+e+"' method")),p;var o=h(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,p;var i=o.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,p):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,p)}function _(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function L(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function F(t){if(t){var n=t[i];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function n(){for(;++r${el.max}
`; + el.type == 'penalty' + ? langData['penalty'] + : langData['score']; + taskMaxScore.innerHTML = `${scoreDesc}3) ? 'class="wide-digit"' : ''}>${el.max}
`; const taskDesc = document.createElement('div'); taskDesc.classList.add('task-description'); - taskDesc.innerHTML = `${el.text}
`; + taskDesc.innerHTML = `${getFormatedText(el.text)}
`; taskDesc.innerHTML += - "Добавить отзыв"; + `${langData['add-review']}`; const overlay = document.createElement('div'); overlay.classList.add('overlay'); @@ -285,28 +304,30 @@ export function render(criteria, taskName, information) { }); askLeaveFeedback(parent, askFeedback); } - content.innerHTML = `Ваша оценка - ${ - total >= 0 ? total : 0 - } ${points} \r\n
Отзыв по пунктам ТЗ:\r\n
`; + let points = totalWithPercent % 10 > 1 && totalWithPercent % 10 <= 4 + ? langData['point'] + : langData['points']; + content.innerHTML += `${langData['your-mark']}${ + totalWithPercent >= 0 ? totalWithPercent : 0 + } ${points} \r\n
${langData['review-by-points']}\r\n
`; const resultDescriptions = { - 0: 'Не выполненные/не засчитанные пункты:', - 1: 'Частично выполненные пункты:', - 2: 'Выполненные пункты:', - penalty: 'Штрафы:', + 0: langData['result-descriptions'][0], + 1: langData['result-descriptions'][1], + 2: langData['result-descriptions'][2], + penalty: langData['penalties'], }; Object.keys(resultDescriptions).forEach((desc) => { let partialResult = []; @@ -326,7 +347,7 @@ export function render(criteria, taskName, information) { partialResult.map((item, i) => { content.innerHTML += `${i + 1}) ${item.text} \r\n${ item.feedback - ? '
Отзыв: ' + + ? `
${langData['review']}` + item.feedback + '
' : '' @@ -364,7 +385,7 @@ export function render(criteria, taskName, information) { const textarea = document.createElement('textarea'); textarea.setAttribute( 'placeholder', - 'Use Ctrl + Enter to save this feedback or ESC to cancel' + langData['use-ctrl-enter'] ); if (filteredCriteria[id].feedback) { textarea.value = filteredCriteria[id].feedback; @@ -372,13 +393,13 @@ export function render(criteria, taskName, information) { box.appendChild(textarea); const closeText = document.createElement('a'); - closeText.innerText = 'Отмена'; + closeText.innerText = langData['cancel']; closeText.onclick = () => { box.remove(); resetRadioState(id); }; const saveText = closeText.cloneNode(); - saveText.innerText = 'Сохранить'; + saveText.innerText = langData['save']; saveText.onclick = () => { handleAreaEvent(id, textarea, link, box); checkFeedback(id); @@ -419,7 +440,7 @@ export function render(criteria, taskName, information) { parent.querySelector('a').click(); askLeaveFeedback( parent, - 'Фидбек не может быть пустым! Минимальная длина 8 символов' + langData['not-empty-feedback'] ); setTimeout(() => askLeaveFeedback(parent, askFeedback), 3000); return; @@ -457,11 +478,11 @@ export function render(criteria, taskName, information) { filteredCriteria[id].feedback = textarea.value; if (textarea.value) { link.classList.add('feedback-add'); - link.innerHTML = 'Изменить отзыв'; + link.innerHTML = langData['change-review']; } else { delete filteredCriteria[id].feedback; link.classList.remove('feedback-add'); - link.innerHTML = 'Добавить отзыв'; + link.innerHTML = langData['add-review']; } box.remove(); } @@ -469,10 +490,10 @@ export function render(criteria, taskName, information) { window.copyToClipboard = (e) => { e.preventDefault(); e.target.classList.add('not-link'); - e.target.innerText = 'Скопировано!'; + e.target.innerText = langData['copied']; setTimeout(() => { e.target.classList.remove('not-link'); - e.target.innerText = 'Скопировать в буфер'; + e.target.innerText = langData['copy-to-clipboard']; }, 1000); const el = document.createElement('textarea'); el.value = toClipBoard; @@ -485,3 +506,24 @@ export function render(criteria, taskName, information) { document.body.removeChild(el); }; } + +//chande `some code` tosome code
+function getFormatedText(text) {
+ return text
+ .split('`')
+ .map((text, i, arr) =>
+ (i < (arr.length - 1))
+ ? [text, ((i % 2) === 0 ? '' : '
')]
+ : text
+ )
+ .flat()
+ .join('')
+}
+
+export const LANG = 'rs-checklist-lang'
+const DEFAULT_LANG = 'ru'
+
+export function getLang () {
+ const langRes = localStorage.getItem(LANG);
+ return langRes ? langRes : DEFAULT_LANG;
+}
\ No newline at end of file
diff --git a/js/script.js b/js/script.js
index 331e567..c7df155 100644
--- a/js/script.js
+++ b/js/script.js
@@ -1,4 +1,6 @@
-import { RenderTasks } from "../js/RenderTasks.js"
+import lang from '../lang/lang.json'
+import { RenderTasks } from "./RenderTasks.js"
+import { getLang, LANG } from './RenderView.js';
const start = document.querySelector('.start');
start && start.addEventListener("click", function(e) {
@@ -9,6 +11,16 @@ const header = document.querySelector('header');
const offsetTop = header.offsetTop;
window.onscroll = () => stickyHeader();
+const langSelectorNode = document.querySelector('.lang-selector')
+langSelectorNode.addEventListener(
+ 'click',
+ langSelector
+)
+for (let node of langSelectorNode.children){
+ if (node.textContent.trim() == getLang()) {
+ node.classList.add('disabled-link')
+ }
+};
function stickyHeader() {
if (window.pageYOffset > offsetTop + 100) {
@@ -18,6 +30,28 @@ function stickyHeader() {
}
}
+function langSelector(e) {
+ const tagName = e.target.tagName.toString();
+ const langText = e.target.textContent;
+ const disabled = e.target.parentElement.classList.contains('disabled-link')
+
+ if(tagName.toUpperCase() !== 'A' || disabled) return;
+ localStorage.setItem(LANG, langText);
+ window.location.reload();
+}
+
const renderTasks = new RenderTasks('tasks-to-render.json');
renderTasks.initTasks();
+const setTextWithLang = () => {
+ const curLang = lang[ getLang() ];
+ document.querySelector('.feedback button').textContent =
+ curLang['show-review'];
+ document.querySelector('.reset').textContent =
+ curLang['reset'];
+ document.querySelector('.total-points').innerHTML =
+ curLang['total-points'];
+ document.querySelector('.progress').innerHTML =
+ `${curLang['checked']} 0${curLang['out-of']}`;
+}
+setTextWithLang();
diff --git a/lang/lang.json b/lang/lang.json
new file mode 100644
index 0000000..56f35b3
--- /dev/null
+++ b/lang/lang.json
@@ -0,0 +1,84 @@
+{
+ "ru": {
+ "reset": "Сбросить",
+ "total-points": "Общий балл: ",
+ "show-review": "Показать отзыв",
+ "score": "Балл за выполнение",
+ "penalty": "Штрафные баллы",
+ "checked": "Проверено",
+ "add-review": "Добавить отзыв",
+ "change-review": "Изменить отзыв",
+ "cancel": "Отмена",
+ "save": "Сохранить",
+ "copied": "Скопировано!",
+ "copy-to-clipboard": "Скопировать в буфер",
+ "not-empty-feedback": "Фидбек не может быть пустым! Минимальная длина 8 символов",
+ "use-ctrl-enter": "Use Ctrl + Enter to save this feedback or ESC to cancel",
+ "review": "Отзыв: ",
+ "penalties": "Штрафы:",
+ "your-mark": "Ваша оценка - ",
+ "review-by-points": "Отзыв по пунктам ТЗ:",
+ "not-all-items": "Вы проверили не все пункты задания",
+ "remaining": "Осталось ",
+ "out-of": " из ",
+ "remaining-end": "",
+ "obligatory-feedback": "Вам необходимо оставить обязательный фидбек ко всем пунктам, где отмечено - ",
+ "partially-completed": "Выполнено частично",
+ "changed-assessment": "Вы изменили оценку. Возможно стоит изменить отзыв?",
+ "partially-completed-checked": "Вы отметили: выполнено частично. Обязательно оставьте фидбек!",
+ "result-descriptions": [
+ "Не выполненные/не засчитанные пункты:",
+ "Частично выполненные пункты:",
+ "Выполненные пункты:"
+ ],
+ "check-marks": [
+ "не выполнено",
+ "выполнено частично",
+ "выполнено полностью"
+ ],
+ "penalty-marks": ["нет", "да"],
+ "point": "балла",
+ "points": "баллов"
+ },
+ "en": {
+ "reset": "Reset",
+ "total-points": "Total points: ",
+ "show-review": "Show Review",
+ "score": "Completion score",
+ "penalty": "Penalty points",
+ "checked": "Checked",
+ "add-review": "Add a review",
+ "change-review": "Edit a Review",
+ "cancel": "Cancel",
+ "save": "Save",
+ "copied": "Copied!",
+ "copy-to-clipboard": "Copy to clipboard",
+ "not-empty-feedback": "Feedback cannot be empty! Minimum length 8 characters",
+ "use-ctrl-enter": "Use Ctrl + Enter to save this feedback or ESC to cancel",
+ "review": "Review: ",
+ "penalties": "Penalties:",
+ "your-mark": "Your rating - ",
+ "review-by-points": "Feedback on the points of the Terms of Reference:",
+ "not-all-items": "You have not checked all the items of the task",
+ "remaining": "",
+ "out-of": " of ",
+ "remaining-end": " left",
+ "obligatory-feedback": "You need to leave a mandatory feedback to all the points where it is marked - ",
+ "partially-completed": "Partially done",
+ "changed-assessment": "You have changed the rating. Perhaps you should change your review?",
+ "partially-completed-checked": "You noted: partially completed. Be sure to leave a feedback!",
+ "result-descriptions": [
+ "Items not completed / not counted:",
+ "Partially completed items:",
+ "Completed items:"
+ ],
+ "check-marks": [
+ "not completed",
+ "partially completed",
+ "completed"
+ ],
+ "penalty-marks": ["no", "yes"],
+ "point": "points",
+ "points": "points"
+ }
+}
\ No newline at end of file
diff --git a/public/script.js b/public/script.js
new file mode 100644
index 0000000..a87f690
--- /dev/null
+++ b/public/script.js
@@ -0,0 +1,22 @@
+"use strict";
+
+var _RenderTasks = require("../js/RenderTasks.js");
+var start = document.querySelector('.start');
+start && start.addEventListener("click", function (e) {
+ e.stopPropagation();
+ if (e.target.parentElement.tagName == "SECTION") e.target.parentElement.style.display = "none";
+});
+var header = document.querySelector('header');
+var offsetTop = header.offsetTop;
+window.onscroll = function () {
+ return stickyHeader();
+};
+function stickyHeader() {
+ if (window.pageYOffset > offsetTop + 100) {
+ header.classList.add("sticky");
+ } else {
+ header.classList.remove("sticky");
+ }
+}
+var renderTasks = new _RenderTasks.RenderTasks('tasks-to-render.json');
+renderTasks.initTasks();
\ No newline at end of file
diff --git a/tasks-to-render.json b/tasks-to-render.json
index 112ad29..c9dbce8 100644
--- a/tasks-to-render.json
+++ b/tasks-to-render.json
@@ -1 +1 @@
-{"0":"active-tasks/Angular-YouTube-client.json","1":"active-tasks/HTML&CSS.json","2":"active-tasks/Nodejs_basic-task1-caesar.json","3":"active-tasks/art-quiz.json","4":"active-tasks/async-race.json","5":"active-tasks/audio-player.json","6":"active-tasks/calculator.json","7":"active-tasks/clean-code-s1e1.json","8":"active-tasks/codejam-2022q3.json","9":"active-tasks/codejam-the-gem-puzzle.json","10":"active-tasks/covid-dashboard.json","11":"active-tasks/custom-video.json","12":"active-tasks/cv-stage1.json","13":"active-tasks/cv.json","14":"active-tasks/eco-sounds.json","15":"active-tasks/english-for-kids.json","16":"active-tasks/english-puzzle.json","17":"active-tasks/fancy-weather.json","18":"active-tasks/image-galery.json","19":"active-tasks/js30.json","20":"active-tasks/memory-game.json","21":"active-tasks/momentum-stage1.json","22":"active-tasks/momentum.json","23":"active-tasks/movie-app.json","24":"active-tasks/movie-search.json","25":"active-tasks/museum-adaptive.json","26":"active-tasks/museum-dom.json","27":"active-tasks/museum-stage0.json","28":"active-tasks/museum.json","29":"active-tasks/photo-filter.json","30":"active-tasks/portfolio.json","31":"active-tasks/random-game.json","32":"active-tasks/random-jokes.json","33":"active-tasks/react-schedule.json","34":"active-tasks/react-xcheck.json","35":"active-tasks/rs-clone-presentation.json","36":"active-tasks/rs-clone.json","37":"active-tasks/rs-ds-2-linear-regression.json","38":"active-tasks/rs-ds-7-clustering-dimensionality-reduction.json","39":"active-tasks/rs-lang.json","40":"active-tasks/rs-scc.json","41":"active-tasks/rslang.json","42":"active-tasks/rss-english-for-kids.json","43":"active-tasks/rss-fancy-weather.json","44":"active-tasks/rss-movie-search.json","45":"active-tasks/rss-singolo-dom-and-responsive.json","46":"active-tasks/rss-singolo.json","47":"active-tasks/rss-virtual-keyboard.json","48":"active-tasks/schedule.json","49":"active-tasks/song-bird.json","50":"active-tasks/songbird.json","51":"active-tasks/speakit.json","52":"active-tasks/tic-tac-toe.json","53":"active-tasks/travel-part1.json","54":"active-tasks/travel-part2.json","55":"active-tasks/travel-part3.json","56":"active-tasks/virtual-keyboard.json","57":"active-tasks/virtual-piano.json","58":"active-tasks/wildlife.json"}
\ No newline at end of file
+{"0":"active-tasks/Angular-YouTube-client.json","1":"active-tasks/HTML&CSS.json","2":"active-tasks/Nodejs_basic-task1-caesar.json","3":"active-tasks/art-quiz.json","4":"active-tasks/async-race.json","5":"active-tasks/audio-player.json","6":"active-tasks/calculator.json","7":"active-tasks/clean-code-s1e1.json","8":"active-tasks/codejam-2022q3.json","9":"active-tasks/codejam-the-gem-puzzle.json","10":"active-tasks/covid-dashboard.json","11":"active-tasks/custom-video.json","12":"active-tasks/cv-stage1.json","13":"active-tasks/cv.json","14":"active-tasks/eco-sounds.json","15":"active-tasks/english-for-kids.json","16":"active-tasks/english-puzzle.json","17":"active-tasks/fancy-weather.json","18":"active-tasks/image-galery.json","19":"active-tasks/js30.json","20":"active-tasks/memory-game.json","21":"active-tasks/momentum-stage1.json","22":"active-tasks/momentum.json","23":"active-tasks/movie-app.json","24":"active-tasks/movie-search.json","25":"active-tasks/museum-adaptive.json","26":"active-tasks/museum-dom.json","27":"active-tasks/museum-stage0.json","28":"active-tasks/museum.json","29":"active-tasks/node-nodejs-basics.json","30":"active-tasks/photo-filter.json","31":"active-tasks/portfolio.json","32":"active-tasks/random-game.json","33":"active-tasks/random-jokes.json","34":"active-tasks/react-schedule.json","35":"active-tasks/react-xcheck.json","36":"active-tasks/rs-clone-presentation.json","37":"active-tasks/rs-clone.json","38":"active-tasks/rs-ds-2-linear-regression.json","39":"active-tasks/rs-ds-7-clustering-dimensionality-reduction.json","40":"active-tasks/rs-lang.json","41":"active-tasks/rs-scc.json","42":"active-tasks/rslang.json","43":"active-tasks/rss-english-for-kids.json","44":"active-tasks/rss-fancy-weather.json","45":"active-tasks/rss-movie-search.json","46":"active-tasks/rss-singolo-dom-and-responsive.json","47":"active-tasks/rss-singolo.json","48":"active-tasks/rss-virtual-keyboard.json","49":"active-tasks/schedule.json","50":"active-tasks/song-bird.json","51":"active-tasks/songbird.json","52":"active-tasks/speakit.json","53":"active-tasks/tic-tac-toe.json","54":"active-tasks/travel-part1.json","55":"active-tasks/travel-part2.json","56":"active-tasks/travel-part3.json","57":"active-tasks/virtual-keyboard.json","58":"active-tasks/virtual-piano.json","59":"active-tasks/wildlife.json"}
\ No newline at end of file