// JavaScript Document
/* liens spellcheck
http://man.hubwiz.com/docset/HTML.docset/Contents/Resources/Documents/developer.mozilla.org/en-US/docs/Web/HTML/Controlling_spell_checking_in_HTML_forms.html
https://stackoverflow.com/questions/30704264/how-to-access-chrome-spell-check-suggestions-in-javascript
https://www.chrisfinke.com/2011/03/31/announcing-typo-js-client-side-javascript-spellchecking/
théorie
*/
myDebug.line=1;try{
var script_common_base2='js:common_base2',common_base2_stop=0;
jsscriptslist=jsscriptslist.concat(new Array(script_common_base2));
myDebug.checkjsload(script_common_base2);
tagfct={kjsfile:script_common_base2,kjsline:myDebug.line,kjsfct:'load: '+script_common_base2,kjsstop:common_base2_stop};
function create_br(div){
myDebug.line=20;try{
tagfct={kjsfile:script_common_base2,kjsline:myDebug.line,kjsfct:'create_br(div)',kjsstop:common_base2_stop};
var br = document.createElement("br");
div.appendChild(br);
}catch(e){if(myDebug)myDebug.debug_view_e_catch(e,tagfct);}
}
function set_textarea(that){//if textarea change
myDebug.line=28;try{
tagfct={kjsfile:script_common_base2,kjsline:myDebug.line,kjsfct:'set_textarea(that)',kjsstop:common_base2_stop};
///var change=that.getAttribute("data-change");
if(that.getAttribute("onchange")!==""){
that.setAttribute("data-change",true);
that.setAttribute("onchange","");
}
}catch(e){if(myDebug)myDebug.debug_view_e_catch(e,tagfct);}
}
function create_sub_comment(div,step,precedent){
myDebug.line=39;try{
tagfct={kjsfile:script_common_base2,kjsline:myDebug.line,kjsfct:'create_sub_comment(div,step,precedent)',kjsstop:common_base2_stop};
var Class=String(step)+"divc",child = document.createElement("textarea");
div.appendChild(child);
create_br(div);
//var br = document.createElement("br");
//div.appendChild(br);
////step++;
child.style.marginLeft=String(step*30)+"px";
child.setAttribute("spellcheck","true");
child.setAttribute("placeholder","your comment");
child.setAttribute("onclick","set_textarea(this);");
Class=String(step)+"divc";
div.setAttribute("class",Class);
return(child);
}catch(e){if(myDebug)myDebug.debug_view_e_catch(e,tagfct);}
}
function create_a_comment(div,step,precedent,onclick,todo){
myDebug.line=59;try{
tagfct={kjsfile:script_common_base2,kjsline:myDebug.line,kjsfct:'create_a_comment(div,step,precedent,onclick,todo)',kjsstop:common_base2_stop};
var a = document.createElement("a");
div.appendChild(a);
a.setAttribute("href","javascript:void(0);");
a.setAttribute("data-auth",precedent);
a.setAttribute("onclick",onclick);
a.innerHTML=todo;////"envoyer";
a.style.marginLeft=String(step*30)+"px";
}catch(e){if(myDebug)myDebug.debug_view_e_catch(e,tagfct);}
}
function response_to_comment(that,command,tag){
myDebug.line=72;try{
tagfct={kjsfile:script_common_base2,kjsline:myDebug.line,kjsfct:'response_to_comment(that,command,tag)',kjsstop:common_base2_stop};
var texta=null,precedent="",step=0,tparent = that.parentNode;//emptydiv
///alert("ljs:169 "+that.parentNode);
var divs = tparent.getElementsByTagName("div");
var length=divs.length;
if(length>0){
texta=divs[length-1];
var texts = texta.getElementsByTagName("textarea");
//// step=parseInt(texta.getAttribute("class"));
/// precedent=texta.getAttribute("data-auth");
}
else
{
var texts = tparent.getElementsByTagName("textarea");
texta=texts[texts.length-1];
}
precedent=texta.getAttribute("data-auth");
//======
var iarr=precedent.split("|");
step=parseInt(iarr[1]);///tparent.getAttribute("class"));
//======
//$icone='
//'.$codeicone.'';
create_br(tparent);
var a = document.createElement("a");
tparent.appendChild(a);
//iarr[2] destinataire val expéditeur
var val=myDebug.GetId("eauteur").value;
myDebug.GetId("eauteur").value=(!val?"anonymous":val);
a.innerHTML="👤 "+myDebug.GetId("eauteur").value+" "+new Date(Date.now()).toLocaleString();
a.href="javascript:void(0);";
a.onclick="javascript:void(0);";
a.style.marginLeft=((step+1)*30)+"px";
//create_a_comment(div,step,precedent,"","👤 "+iarr[1]+" "+new Date(Date.now()).toLocaleString());
//create_br(div);
//======
var div = document.createElement("div");
tparent.appendChild(div);
step++;
var child = create_sub_comment(div,step,precedent);////+1,precedent);
///step++;
create_a_comment(div,step,precedent,"send_comment(this,'"+command+"','"+tag+"');","envoyer");
///var space = document.createTextNode(' ');
///div.appendChild(space);
///create_a_comment(div,step,precedent,"send_comment(this,'modify');","modifier");
}catch(e){if(myDebug)myDebug.debug_view_e_catch(e,tagfct);}
}
function create_comment(tag){
myDebug.line=124;try{
tagfct={kjsfile:script_common_base2,kjsline:myDebug.line,kjsfct:'create_comment(tag)',kjsstop:common_base2_stop};
var o=null,tparent = myDebug.GetId('totaldiv');//emptydiv
/*
o=myDebug.GetId('storeNum');
///num=(tparent.innerHTML==""?0:1)+parseInt(o.value);
num=parseInt(o.value);
o.value=num;
*/
var child=create_sub_comment(tparent,0,"");
create_a_comment(tparent,0,"","send_comment(this,'putstart','"+tag+"');","envoyer");
create_br(tparent);
}catch(e){if(myDebug)myDebug.debug_view_e_catch(e,tagfct);}
}
/*
function comment_is_selected(that){
alert("ljs:288 "+myDebug.chrrc+that+myDebug.chrrc+that.getAttribute("data-index")+myDebug.chrrc+that.getAttribute("data-index"));
myDebug.GetId('selected').value=parseInt(that.getAttribute("data-index"));
var target=myDebug.GetId('target').value=that.getAttribute("data-index");
var arr=target.split("|");
myDebug.GetId('eauteur').value=arr[1];
myDebug.GetId('email').value=arr[2];
myDebug.GetId('edate').value=new Date(Date.now()).toLocaleString();
}
*/
function send_comment(that,command,tag){
myDebug.line=151;try{
tagfct={kjsfile:script_common_base2,kjsline:myDebug.line,kjsfct:'send_comment(that,command,tag)',kjsstop:common_base2_stop};
///if(!step)step=0;
var ores="",content="",order=0;
var tparent=that.parentNode;
//// alert("ljs:117 "+myDebug.chrrc+textarea.innerHTML+myDebug.chrrc+that.getAttribute("data-auth"));
var length=tparent.getElementsByTagName("textarea").length;
var textarea=tparent.getElementsByTagName("textarea")[length-1];
content=textarea.value;
contentinnerHTML=textarea.innerHTML;
if(command=="response"){
var iarr=that.getAttribute("data-auth").split("|");/// 1divc|1|tartampion|16/04/2021 18:50:05||0
myDebug.GetId('selected').value=iarr[0];///myDebug.GetId('storeNum').value=iarr[1];
order=parseInt(iarr[1])+1;
myDebug.GetId("dauteur").value=iarr[2];
var val=myDebug.GetId("eauteur").value;
myDebug.GetId("eauteur").value=(!val?"anonymous":val);
alert("ljs:117 "+myDebug.chrrc+textarea.value+myDebug.chrrc+that.getAttribute("data-auth"));
}
else{
if(command==="modify"||command==="heart"||command==="likes"||command==="hates"){
/// var textarea=tparent.getElementsByTagName("textarea")[length-1];
if(command==="modify"&&(!textarea.getAttribute("data-change")||textarea.getAttribute("data-change")!=="true")){
alert("Votre commentaire n'a pas été modifié !");return(false);
}
alert("ljs:128 "+myDebug.chrrc+textarea.getAttribute("data-auth"));////return(false);
myDebug.GetId('selected').value=parseInt(textarea.getAttribute("data-auth"));
}
}
if(content===""){alert("Votre commentaire est vide !");return(false);}
////alert("ljs:134 "+myDebug.chrrc+CheckText(content,contentinnerHTML));return(false);
var selected=myDebug.GetId('selected').value;
if(selected===""){alert("Vous n'avez sélectionné aucun commentaire !");return(false);}
var numC=selected;///myDebug.GetId('selected').value;
ores=myDebug.GetId('result');if(ores)ores.value="send";
////myDebug.GetId('edate').value=new Date(Date.now()).toLocaleString();
var action="sendComment";////,time_start;
var xhr=getXMLHttpRequest();
xhr.onreadystatechange=function(){
///if(xhr.responseText==="")return(false);
var arr=checkXMLHttpRequest(xhr);
if(ores)ores.value="échec";
if(arr[0]){
/////alert("ljs:153 likes: "+myDebug.chrrc+tparent.getElementsByTagName("label")[1].getAttribute("data-what"));
length=tparent.getElementsByTagName("label").length;
for(var i = 0; i < length; i++){
alert("ljs:156 heart: "+myDebug.chrrc+length+myDebug.chrrc+tparent.getElementsByTagName("label")[i].getAttribute("data-what")+myDebug.chrrc+command);
if(tparent.getElementsByTagName("label")[i].getAttribute("data-what")===command){
tparent.getElementsByTagName("label")[i].innerHTML=parseInt(tparent.getElementsByTagName("label")[i].innerHTML)+1;
break;
}
}
alert("ljs:148 xhr.responseText: "+myDebug.chrrc+xhr.responseText+myDebug.chrrc+"arr: "+arr+myDebug.chrrc);
if(ores)ores.value="OK";
}
else{
return("");
}
};
////var formDatas=new FormData(that.form);formComment
///var nameform=tag+"formComment";
////alert("ljs:194 nameform: "+myDebug.chrrc+myDebug.GetId("filename").value);
///var formDatas=new FormData(myDebug.GetId(tag+"formComment"));
var formDatas=new FormData(myDebug.GetId("formComment"));
//===
///alert("ljs:323 comment: "+myDebug.GetId('t.'+myDebug.GetId('storeNum').value).value+myDebug.chrrc+"storeNum: "+'t.'+myDebug.GetId('storeNum').value+myDebug.chrrc);
formDatas.append('comment',content);
formDatas.append('command',command);
formDatas.append('step',order);
formDatas.append('edate',new Date(Date.now()).toLocaleString());
formDatas.append('filename',"/atelier/commentaires/cmt.x.php");///myDebug.GetId("filename").value);
///if(!myDebug.GetId('bloque').checked)
sendXMLHttpRequest(xhr,"POST",null,"/atelier/commentaires/ajax_input.php",formDatas,action);
// C:\atelier\commentaires\mycommentaires.php
}catch(e){if(myDebug)myDebug.debug_view_e_catch(e,tagfct);}
}
/*
function add_comment(){
// crée un nouvel élément div
var newDiv = document.createElement("div");
// et lui donne un peu de contenu
var newContent = document.createTextNode('Hi there and greetings!');
// ajoute le nœud texte au nouveau div créé
newDiv.appendChild(newContent);
// ajoute le nouvel élément créé et son contenu dans le DOM
var currentDiv = myDebug.GetId('comment.2');
// document.body.insertBefore(newDiv, myDebug.GetId('comment.2').nextSibling);///currentDiv);
myDebug.GetId('allcomments').insertBefore(newDiv, newDiv.nextSibling);///currentDiv);
myDebug.GetId('edate').value=new Date(Date.now()).toLocaleString();
//// document.body.insertBefore(newDiv, newDiv.nextSibling);///currentDiv);
/// document.body.insertAfter(newDiv, currentDiv);
}
*/
function CheckText(text,inner) {
myDebug.line=261;try{
tagfct={kjsfile:script_common_base2,kjsline:myDebug.line,kjsfct:'CheckText(text,inner)',kjsstop:common_base2_stop};
return(false);
// inner contient texte initial et ne change plus , value contient le texte modifie , ctrl+z revient vers inner
alert("ljs:212 "+myDebug.chrrc+text+myDebug.chrrc+inner+myDebug.chrrc+(text===inner));
return(false);
var result = new Array;
if(!ActiveXObject('Wordpad.Application'))return(false);//com.sun.star.text.MailMerge
var app = new ActiveXObject('Wordpad.Application');
var doc = app.Documents.Add();
doc.Content = text;
for (var i = 1; i <= doc.SpellingErrors.Count; i++) {
var spellingError = doc.SpellingErrors.Item(i);
for (var j = 1; j <= spellingError.Words.Count; j++) {
var word = spellingError.Words.Item(j);
var error = {};
error.word = word.Text;
error.start = word.Start;
error.length = word.Text.length;
error.suggestions = new Array;
var suggestions = word.GetSpellingSuggestions();
for (var k = 1; k <= suggestions.Count; k++) {
error.suggestions.push(suggestions.Item(k).Name);
}
result.push(error);
}
}
return result;
}catch(e){if(myDebug)myDebug.debug_view_e_catch(e,tagfct);}
}
}catch(e){if(myDebug)myDebug.debug_view_e_catch(e,tagfct);}