﻿chichiReadInfo ={
"addHotKeyForChichi" :function (keySet_id){
let o = document.getElementById ("key_expandAllThreads" )
o.parentNode.removeChild (o.nextSibling)
o.parentNode.removeChild (o)
let objStringBundle =document.getElementById ("str_bundle_topRow_key")

let ns ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
let objMailKeys =document.getElementById (keySet_id)
//let keys ="&é"+'"'+"'"+"(-è_çà)="
//let keys =[",!@#$%^&*()_+"
let keys_without_shift ="1234567890-="
let keys =["!","@","#","$","%","^","&",String.fromCharCode("0x2a"),"(",")","-","="]


let iKey =-1
let max =keys.length 
for (let i =1 ;i <13; i++)
{
let e=2
//modification de l'ajout -suppression des étiquettes
let objTag =document.getElementById ("key_tag"+(i))
if (objTag)
{objTag.removeAttribute ("modifiers")
objTag.removeAttribute ("key")
}
//fin 
//ajout des raccoucis alt +1 à 9
let objKey =document.createElementNS (ns,"key")
objKey.setAttribute ("modifiers","alt")
if (i<10)k=i
else if (i ==10) k=0
else k=objStringBundle.getString ("key_without_shiftKey_"+i)

objKey.setAttribute ("key",k)
let cmd ="cmd_chichi_variousAction_"+(i+29)
objKey.setAttribute ("oncommand","goDoCommand ('"+cmd+"')")
objMailKeys.appendChild (objKey)


// fin pour alt +...

while (e){
iKey+=1
let objKey =document.createElementNS (ns, "key")
if (e==2) 
{//with shift key 
if (i != 10)k = objStringBundle.getString ("key_with_shiftKey_"+i)
else 
{//on va garder shift +0 pour les étiquettes
e-=1
continue
}
}
else // without key shift 
{k=(i!=10)?objStringBundle.getString ("key_without_shiftKey_"+i):"0"
}

objKey.setAttribute ("key",k)
let cmd ="cmd_chichi_variousAction_"+iKey
objKey.setAttribute ("oncommand","goDoCommand ('"+cmd+"')")
if (e ==2) objKey.setAttribute ("modifiers","shift")
objMailKeys.appendChild (objKey)
e=e-1
}
}
o =document.getElementById ("key_tag0")
o.setAttribute ("modifiers","shift")
o.setAttribute ("key",objStringBundle.getString ("key_with_shiftKey_10"))

},// end func 
}
chichiKeyCounter ={
"lastKey":-1,
"lastTime":-1,
"lastScriptRepeatCount":0,
"getLastScriptRepeatCount": function (currentKey){
let date  =new Date ()
let currentTime =date.getTime ()
this.lastScriptRepeatCount = (currentTime - this.lastTime <=500 && currentKey == this.lastKey)?this.lastScriptRepeatCount+1:0
this.lastKey =currentKey
this.lastTime =currentTime
return  this.lastScriptRepeatCount
}
}//end keyCounter
