diff --git a/src/adonisjs/public/translator/translator.js b/src/adonisjs/public/translator/translator.js index a671eb90..68082499 100644 --- a/src/adonisjs/public/translator/translator.js +++ b/src/adonisjs/public/translator/translator.js @@ -319,14 +319,11 @@ class Translator { matchStart = -1 let selected = '' for (const mk in Translator.element) { - // if (!((mk == "annotation" || mk == "select") && - // this.authoringRender)) { const pos = mdfocus.search(Translator.element[mk].mark) if (pos > -1 && (matchStart == -1 || pos < matchStart)) { selected = mk matchStart = pos } - // } } if (matchStart > -1) { @@ -338,11 +335,22 @@ class Translator { } // translate the expression to an object - const matchSize = mdfocus.match(Translator.element[selected].mark)[0].length + let matchSize = + mdfocus.match(Translator.element[selected].mark)[0].length + + if (selected == 'literal') { + const litClose = mdfocus.substr(matchStart + matchSize) + .search(Translator.literalClose) + matchSize = (litClose > -1) + ? litClose - matchStart + matchSize + 3 + : mdfocus.length - matchStart + matchSize + 1 + } + const toTranslate = mdfocus.substr(matchStart, matchSize) const transObj = this._initializeObject( this._mdToObj(selected, - Translator.element[selected].mark.exec(toTranslate)), toTranslate) + Translator.element[selected].mark.exec(toTranslate), toTranslate), + toTranslate) // attach to a knot array (if it is a knot) or an array inside a knot if (selected == 'knot') { @@ -746,17 +754,21 @@ class Translator { // eighth cycle - aggregates options let optionGroup = null let subtype = null + let prevsubor = null for (let c = 1; c < compiled.length; c++) { const pr = (c > 1 && compiled[c - 1].type == 'linefeed') ? c - 2 : c - 1 if (compiled[c].type == 'option') { let stype = compiled[c].subtype + let suborop = (compiled[c].subordinate) ? true : false if (compiled[pr].type == 'input' && compiled[pr].subtype && compiled[pr].subtype == 'choice' && compiled[pr].options == null) { subtype = stype + prevsubor = suborop optionGroup = compiled[pr] optionGroup.options = {} } else if (compiled[pr].type == 'option' && - compiled[c].subtype == subtype) { + compiled[c].subtype == subtype && + suborop == prevsubor) { optionGroup = this._initializeObject( { type: 'input', @@ -770,7 +782,8 @@ class Translator { this._transferOption(optionGroup.options, compiled[pr]) compiled[pr] = optionGroup } - if (optionGroup != null && compiled[c].subtype == subtype) { + if (optionGroup != null && compiled[c].subtype == subtype && + suborop == prevsubor) { this._transferOption(optionGroup.options, compiled[c]) optionGroup._source += '\n' + compiled[c]._source if (compiled[c].target && !optionGroup.reveal) @@ -781,6 +794,7 @@ class Translator { } else optionGroup = null subtype = stype + prevsubor = suborop } else if (compiled[c].type != 'linefeed' || compiled[c].content.length > 1) optionGroup = null @@ -886,7 +900,6 @@ class Translator { {type: 'condition-close', seq: pos+1, _source: ''}) - c++ inCondition = false } if (compiled[c].type == 'condition') { @@ -1106,10 +1119,11 @@ class Translator { } } - _mdToObj (mdType, match) { + _mdToObj (mdType, match, toTranslate) { let obj switch (mdType) { case 'knot' : obj = this._knotMdToObj(match); break + case 'literal': obj = this._literalMdToObj(match, toTranslate); break case 'blockquote': obj = this._blockquoteMdToObj(match); break case 'image': obj = this._imageMdToObj(match); break case 'media': obj = this._mediaMdToObj(match); break @@ -1246,8 +1260,8 @@ class Translator { console.log('Error in finding seq: ' + seq) } else { html = html.substring(0, next) + - this.objToHTML(content[current], ss) + - html.substring(end + 2) + this.objToHTML(content[current], ss) + + html.substring(end + 2) } next = html.indexOf('@@') } @@ -1281,6 +1295,7 @@ class Translator { if ((obj.render !== undefined && !obj.render) || (obj.inherited && this.authoringRender)) { html = '' } else { switch (obj.type) { + case 'literal': html = this._literalObjToHTML(obj); break case 'blockquote': html = this._blockquoteObjToHTML(obj); break case 'text' : html = this._textObjToHTML(obj, superseq); break case 'text-block': html = this._textBlockObjToHTML(obj, superseq) @@ -1442,19 +1457,6 @@ class Translator { case 'formal-close': element._source = this._formalCloseObjToMd(element) break } - - // linefeed of the merged block (if block), otherwise linefeed of the content - /* - element._source += (((element.mergeLine === undefined && - Translator.isLine.includes(element.type)) || - (element.mergeLine !== undefined && - element.mergeLine)) - ? "\n" : ""); - console.log("=== element"); - console.log(element); - */ - - // element._source += "\n\n"; } /* @@ -1533,6 +1535,32 @@ class Translator { ? ': ' + obj.inheritance : '') } + /* + * Text Raw to Obj + */ + _literalMdToObj (matchArray, toTranslate) { + return { + type: 'literal', + subtype: matchArray[2], + delimiter: matchArray[1], + content: toTranslate.substring(matchArray[0].length, + toTranslate.length - 3) + } + } + + /* + * Text Obj to HTML + */ + _literalObjToHTML (obj) { + let result = obj.content + if (this.authoringRender) + result = Translator.htmlTemplatesEditable.text + .replace('[seq]', obj.seq) + .replace('[author]', this._authorAttrSub(obj.seq)) + .replace('[content]', obj.content) + return result + } + /* * Blockquote Md to Obj */ @@ -2527,6 +2555,7 @@ class Translator { _computeMdToObj (matchArray) { const compute = { type: 'compute', + subordinate: /^\t|^ [\t ]/.test(matchArray[0]), expression: matchArray[1].trim() } @@ -2724,7 +2753,7 @@ class Translator { } (function () { - Translator.marksLayerTitle = /^[ \t]*\_{2,}((?:.(?!\_{2,}))*.)(?:\_{2,})?[ \t]*$/igm + Translator.marksLayerTitle = /^[ \t]*\_{3,}((?:.(?!\_{3,}))*.)\_{3,}[ \t]*$/igm Translator.marksKnotTitle = /((?:^[ \t]*(?:#+)[ \t]*(?:[^\( \t\n\r\f][^\(\n\r\f]*)(?:\((?:\w[\w \t,]*)\))?(?:\:[ \t]*[^\(\n\r\f][^\(\n\r\f\t]*)?[ \t]*#*[ \t]*$)|(?:^[ \t]*(?:[^\( \t\n\r\f][^\(\n\r\f]*)(?:\((?:\w[\w \t,]*)\))?(?:\:[ \t]*[^\(\n\r\f][^\(\n\r\f\t]*)?[ \t]*[\f\n\r][\n\r]?(?:==+|--+)$))/igm Translator.fragment = { @@ -2735,6 +2764,9 @@ class Translator { Translator.fragment.compute = '~[ \\t]*' + Translator.fragment.expression Translator.element = { + literal: { + mark: /(~~~|```)[ \t]*([^\n]*)$/im + }, knot: { mark: /(?:^[ \t]*(#+)[ \t]*([^\( \t\n\r\f\:#][^\(\n\r\f\:#]*)(?:\((\w[\w \t,]*)\))?[ \t]*(?:\:[ \t]*([^\(\n\r\f#][^\(\n\r\f\t#]*))?[ \t]*(#+)?[ \t]*$)|^(?:(==+|--+)[\f\n\r][\n\r]?)?(?:[ \t]*([^\( \t\n\r\f\:][^\(\n\r\f\:]*)(?:\((\w[\w \t,]*)\))?[ \t]*(?:\:[ \t]*([^\(\n\r\f][^\(\n\r\f\t]*))?[ \t]*[\f\n\r][\n\r]?(==+|--+)$)/im, subfield: true, @@ -2796,7 +2828,7 @@ class Translator { mark: new RegExp('\\$[ \\t]*\\(' + Translator.fragment.expression + '\\)[ \\t]*', 'im') }, compute: { - mark: new RegExp(Translator.fragment.compute + '$', 'im') + mark: new RegExp('[ \\t]*' + Translator.fragment.compute + '$', 'im') }, 'context-open': { mark: /\{\{(?:([^\:\n\r\f]+)\:)?([\w \t\+\-\*\."=%]+)?(?:@(\w+))?(?:\/((?:\w+\:)?\w+)(?:[ \t]+((?:\w+\:)?\w+))?\/)?$/im @@ -2825,6 +2857,8 @@ class Translator { */ } + Translator.literalClose = /(~~~|```)/im + Translator.marksAnnotation = { 'context-open': Translator.element['context-open'].mark, 'context-close': Translator.element['context-close'].mark, diff --git a/src/adonisjs/public/user/js/user-signup.js b/src/adonisjs/public/user/js/user-signup.js index f7404696..3b5ca0fc 100644 --- a/src/adonisjs/public/user/js/user-signup.js +++ b/src/adonisjs/public/user/js/user-signup.js @@ -1,90 +1,130 @@ class UserSignup { start () { - this._showTerm = this._showTerm.bind(this) - MessageBus.i.subscribe('/user/term', this._showTerm) + this._expandTerm = this._expandTerm.bind(this) + MessageBus.i.subscribe('/user/term/expand', this._expandTerm) + this._retractTerm = this._retractTerm.bind(this) + MessageBus.i.subscribe('/user/term/retract', this._retractTerm) this._signup = this._signup.bind(this) MessageBus.i.subscribe('/user/signup', this._signup) - } + this.update = this.update.bind(this) - _showTerm () { - console.log('=== show term') - document.querySelector('#name_participant').value = document.querySelector('#username').value const now = new Date() - document.querySelector('#date_agree').value = now.getDate() + '/' + (now.getMonth()+1) + '/' + now.getFullYear() - document.querySelector('#term-form').style.display = 'initial' + const sdate = now.getDate() + '/' + (now.getMonth()+1) + '/' + now.getFullYear() + document.querySelector('#date_agree_1').value = sdate + document.querySelector('#date_agree_2').innerHTML = sdate + } + + update () { + document.querySelector('#name_participant').innerHTML = document.querySelector('#username').value + document.querySelector('#name_responsible').innerHTML = document.querySelector('#respname').value + document.querySelector('#email_responsible').innerHTML = document.querySelector('#email').value + document.querySelector('#answer_agree').innerHTML = + (document.querySelector('#agree_radio').checked) + ? 'Concordo em participar da pesquisa' + : (document.querySelector('#not_agree_radio').checked) + ? 'Não desejo participar da pesquisa' + : '' + } + + _expandTerm () { + this.update() + document.querySelector('#term-part').style.display = 'initial' + document.querySelector('#button-expand').style.display = 'none' + } + + _retractTerm () { + document.querySelector('#term-part').style.display = 'none' + document.querySelector('#button-expand').style.display = 'initial' + } + + _showFeedback (message, color) { + const feed1 = document.querySelector('#feedback-message-1') + const feed2 = document.querySelector('#feedback-message-2') + if (color != null) { + feed1.style.color = 'blue' + feed2.style.color = 'blue' + } + feed1.innerHTML = message + feed2.innerHTML = message } async _signup (topic, message) { const parameters = (message && message.value) ? message.value : null console.log('===== user parameters') console.log(parameters) - const feed = document.querySelector('#feedback-message') - feed.innerHTML = '' + + this._showFeedback('') if (parameters == null) - feed.innerHTML = 'Erro de processamento, entre novamente na página a partir do link' - else if (parameters.username.length == 0) - feed.innerHTML = 'Nome do usuário é obrigatório.' + this._showFeedback('Erro de processamento, entre novamente na página a partir do link') + else if (parameters.login.length == 0) + this._showFeedback('Login do usuário é obrigatório.') + else if (parameters.username.trim().length == 0) + this._showFeedback('Nome do usuário é obrigatório.') + else if (parameters.respname.length == 0) + this._showFeedback('Nome do responsável é obrigatório.') else if (parameters.email.length == 0) - feed.innerHTML = 'O e-mail do usuário ou do responsável do usuário é obrigatório.' + this._showFeedback('O e-mail do responsável do usuário é obrigatório.') else if (parameters.password.length == 0) - feed.innerHTML = 'A senha é obrigatória.' + this._showFeedback('A senha é obrigatória.') else { + /* if (parameters.agree && parameters.agree.length > 0 && parameters.agree == 'agree') { if (parameters.name_responsible.length == 0) - feed.innerHTML = 'Como você concordou com o termo, precisa informar o nome do responsável no termo.' + this._showFeedback('Como você concordou com o termo, precisa informar o nome do responsável no termo.') else if (parameters.name_participant == 0) - feed.innerHTML = 'Como você concordou com o termo, precisa repetir o nome do participante no termo.' + this._showFeedback('Como você concordou com o termo, precisa repetir o nome do participante no termo.') else if (parameters.date_agree == 0) - feed.innerHTML = 'Como você concordou com o termo, precisa informar a data.' + this._showFeedback('Como você concordou com o termo, precisa informar a data.') else if (parameters.email_responsible == 0) - feed.innerHTML = 'Como você concordou com o termo, precisa informar/repetir o email do responsável.' + this._showFeedback('Como você concordou com o termo, precisa informar/repetir o email do responsável.') } - if (feed.innerHTML.length == 0) { - console.log('========== creating user ==========') - const userJson = { - username: parameters.username, - email: parameters.email, - password: parameters.password, - login: parameters.email.replace('@', '_').replace('.', '_'), - institution: parameters.institution, - grade: parameters.grade, - eventId: new URL(document.location).searchParams.get('event') - } - let user = await MessageBus.i.request('user/create/post', userJson) + */ + // if (feed.innerHTML.length == 0) { + console.log('========== creating user ==========') + const login = parameters.login.replace(/ /g, '_') + const userJson = { + username: parameters.username, + email: login + '@museu.unicamp.br', + password: parameters.password, + login: login, + institution: parameters.institution, + grade: parameters.grade, + eventId: new URL(document.location).searchParams.get('event') + } + let user = await MessageBus.i.request('user/create/post', userJson) + console.log(user.message) + if (user.message.error) { + console.log('--- error') console.log(user.message) - if (user.message.error) { - console.log('--- error') - console.log(user.message) - if (user.message.error.includes('409')) - feed.innerHTML = - 'O nome ou e-mail no seu cadastro já foi cadastrado anteriormente. ' + - 'Por enquanto, o sistema não aceita dois cadastros com o mesmo nome ou email. ' + - 'Se você é responsável por mais de uma criança e está usando o seu e-mail, ' + - 'coloque um (2) logo após o e-mail. A mesma estratégia pode ser usada no nome.' - else - feed.innerHTML ='Houve algum erro no cadastro.' - } else if (parameters.agree && parameters.agree.length > 0 && parameters.agree == 'agree') { - feed.style.color = 'blue' - feed.innerHTML = 'Usuário cadastrado com sucesso. Ainda há uma etapa extra a ser cumprida. Você receberá um e-mail para confirmar que é o responsável. Em seguida, o participante também receberá um link para confirmar a sua concordância com a pesquisa.' - const termJson = { - userId: user.message.id, - termId: parameters.term, - nameResponsible: parameters.name_responsible, - emailResponsible: parameters.email_responsible, - nameParticipant: parameters.name_participant, - date: parameters.date_agree, - role: parameters.role, - agree: '1' - } - console.log('=== term json') - console.log(termJson) - let term = await MessageBus.i.request('user/term/post', termJson) - console.log('=== term add') - console.log(term) - } else { - feed.style.color = 'blue' - feed.innerHTML = 'Usuário cadastrado com sucesso.' + if (user.message.error.includes('409')) + this._showFeedback('Já existe um usuário com este login. Por favor, escolha outro login.') + else + this._showFeedback('Houve algum erro no cadastro.') + } else { + const agree = (parameters.agree && parameters.agree.length > 0 && parameters.agree == 'agree') + const termJson = { + userId: user.message.id, + termId: parameters.term, + nameResponsible: parameters.respname, + emailResponsible: parameters.email, + nameParticipant: parameters.username, + date: parameters.date_agree_1, + role: parameters.role, + agree: (agree) ? '1' : '0' } + console.log('=== term json') + console.log(termJson) + let term = await MessageBus.i.request('user/term/post', termJson) + console.log('=== term add') + console.log(term) + document.querySelector('#complete-form').style.display = 'none' + if (agree) + this._showFeedback( + 'Usuário cadastrado com sucesso.
' + + 'Importante: Ainda há duas etapas extras a serem cumpridas. Você receberá um e-mail para confirmar que é o responsável. Em seguida, o participante também receberá um link para confirmar a sua concordância com a pesquisa.', 'blue') + else + this._showFeedback('Usuário cadastrado com sucesso.', 'blue') + // } } /* else { diff --git a/src/adonisjs/public/user/signup/index.html b/src/adonisjs/public/user/signup/index.html index 56990430..127f1f6a 100644 --- a/src/adonisjs/public/user/signup/index.html +++ b/src/adonisjs/public/user/signup/index.html @@ -66,61 +66,89 @@
- - - -
-

Cadastro de Usuário

+

Cadastro de Usuário na Plataforma (para participação na oficina)

-
+
+
+
+ +
+
-
+

Este cadastro deve obrigatoriamente ser preenchido pelo responsável da criança ou adolescente que participará da oficina.

+
- - + + + + Digite o nome da criança ou adolescente que participará da oficina. +
-
- - +
+ + + + Escolha um login para o participante (sem espaços em branco). Ele usará para fazer login na plataforma no início da oficina. +
-
+
- + + + Escolha uma senha para o participante. + +
+
+ + + + Digite o nome do responsável pelo participante da oficina. + +
+
+ + + + Digite o e-mail do responsável pelo participante da oficina. +
- O participante também é convidado a contribuir com a pesquisa do Museu. Se quiser contribuir, clique no botão a seguir para ver mais detalhes e decidir sobre sua participação: + O participante também é convidado a contribuir com a pesquisa do Museu. Se concordar, durante a aplicação da oficina, os dados da sua atuação serão coletados de forma anônima sem interferir na experiência da atividade. Se o participante e o responsável concordarem, o responsável deve clicar na opção a seguir concordando. Há um botão que apresenta todos todos os detalhes sobre o Termo de Consentimento relacionados à pesquisa. + +
+ + +
- + Concordo em participar da pesquisa
+ Não desejo participar da pesquisa
- - - -
-
+
+

+ diff --git a/src/adonisjs/public/user/signup/terms/tcle-responsible.pdf b/src/adonisjs/public/user/signup/terms/tcle-responsible.pdf index f3b1d824..5e8d9326 100644 Binary files a/src/adonisjs/public/user/signup/terms/tcle-responsible.pdf and b/src/adonisjs/public/user/signup/terms/tcle-responsible.pdf differ