import initial des scripts javascript
darcs-hash:20061009173329-f46e9-611debe6ac89ea14f4a855dfceaeec2930ccb1a9.gz
This commit is contained in:
parent
bd9ead0d89
commit
ec379f2c93
6 changed files with 1047 additions and 0 deletions
193
intranet/static/scripts/crans.js
Normal file
193
intranet/static/scripts/crans.js
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
function askForName(oldName) {
|
||||||
|
var c = '';
|
||||||
|
while ( c == '')
|
||||||
|
c = prompt("Votre nom :",oldName);
|
||||||
|
if (c == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
window.location.href= 'changeNomAdherent?nouveauNom=' + c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function askForSurname(oldSurname) {
|
||||||
|
var c = '';
|
||||||
|
while ( c == '')
|
||||||
|
c = prompt("Votre prénom :",oldSurname);
|
||||||
|
if (c == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
window.location.href= 'changePrenomAdherent?nouveauPrenom=' + c;
|
||||||
|
}
|
||||||
|
|
||||||
|
function askForTel(oldTel) {
|
||||||
|
var c = '';
|
||||||
|
while ( c == '')
|
||||||
|
c = prompt("Votre numéro de téléphone :",oldTel);
|
||||||
|
if (c == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
window.location.href= 'changeTelAdherent?nouveauTel=' + c;
|
||||||
|
}
|
||||||
|
|
||||||
|
function askForMachineMac(oldMac, mid) {
|
||||||
|
var c = '';
|
||||||
|
while ( c == '')
|
||||||
|
c = prompt("Adresse MAC de la machine :",oldMac);
|
||||||
|
if (c == null)
|
||||||
|
return false;
|
||||||
|
var e = loadJSONDoc('changeMACMachine?nouvelleMAC=' + c + '&mid=' + mid);
|
||||||
|
e.addCallback(machineModifHandler);
|
||||||
|
e.addErrback(ajaxErrorHandler);
|
||||||
|
loading(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
function askForMachineName(oldName, mid) {
|
||||||
|
var c = '';
|
||||||
|
while ( c == '')
|
||||||
|
c = prompt("Nom de la machine :",oldName);
|
||||||
|
if (c == null)
|
||||||
|
return false;
|
||||||
|
var e = loadJSONDoc("changeNomMachine?nouveauNom=" + c + "&mid=" + mid);
|
||||||
|
e.addCallback(machineModifHandler);
|
||||||
|
e.addErrback(ajaxErrorHandler);
|
||||||
|
loading(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function askForDeleteMachine(mid, nom) {
|
||||||
|
if (confirm("Supprimer la machine ?")) {
|
||||||
|
var e = loadJSONDoc('supprimeMachine?mid=' + mid);
|
||||||
|
e.addCallback(machineModifHandler);
|
||||||
|
e.addErrback(ajaxErrorHandler);
|
||||||
|
loading(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function newAlias() {
|
||||||
|
var c = '';
|
||||||
|
while ( c == '')
|
||||||
|
c = prompt("Nouvel alias :");
|
||||||
|
if (c == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
window.location.href= 'newAlias?alias=' + c + "#mailTab";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function newMachineNode(name, shortName, mac, ip, mid, type, ipsec) {
|
||||||
|
machineName = H3({},shortName);
|
||||||
|
|
||||||
|
var propertiesList = createDOM("DL",{'class':'machineInfos'});
|
||||||
|
valuesList = [
|
||||||
|
{'label':'Type : ', 'value':type},
|
||||||
|
{'label':'Mac : ', 'value':mac},
|
||||||
|
{'label':'IP : ', 'value':ip},
|
||||||
|
{'label':'ipsec : ', 'value':ipsec},
|
||||||
|
] ;
|
||||||
|
for (var i=0; i<valuesList.length; i++) {
|
||||||
|
var item = valuesList[i];
|
||||||
|
if (item.value) {
|
||||||
|
propertiesList.appendChild(createDOM("DT",item.label));
|
||||||
|
propertiesList.appendChild(createDOM("DD",item.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var actions = SPAN({'class':'actions'},[
|
||||||
|
A({'href':'#','onclick':"return askForMachineName('"+shortName+"','"+mid+"');"},'Renommer'),
|
||||||
|
A({'href':'#','onclick':"return askForMachineMac('"+mac+"','"+mid+"');"},'Changer de MAC'),
|
||||||
|
A({'href':'#','onclick':"return askForDeleteMachine('"+mid+"');"},'Supprimer'),
|
||||||
|
]);
|
||||||
|
return LI({},[
|
||||||
|
machineName,
|
||||||
|
propertiesList,
|
||||||
|
DIV({'class':'clear'},''),
|
||||||
|
actions,
|
||||||
|
DIV({'class':'clear'},''),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function newMachineLiNodeFromDict(adict) {
|
||||||
|
return LI({},newMachineNode(adict.nom, adict.nomCourt, adict.mac, adict.ip, adict.mid, adict.type, adict.ipsec));
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderMachineList(result) {
|
||||||
|
replaceChildNodes('machineList',map(newMachineLiNodeFromDict,result.machines));
|
||||||
|
}
|
||||||
|
function loadMachineList() {
|
||||||
|
var e = loadJSONDoc('listeMachines');
|
||||||
|
e.addCallback(renderMachineList);
|
||||||
|
e.addErrback(ajaxErrorHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ajaxErrorHandler(d) {
|
||||||
|
loading(false);
|
||||||
|
alert(d)
|
||||||
|
logError("AJAX Error");
|
||||||
|
logerror(d);
|
||||||
|
window.location.href= "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function machineModifHandler(result) {
|
||||||
|
loading(false);
|
||||||
|
if (result.message){
|
||||||
|
setMessage(result.message);
|
||||||
|
addMachineForm.clear();
|
||||||
|
logDebug("AJAX Succed");
|
||||||
|
}
|
||||||
|
if (result.error){
|
||||||
|
alert(result.error);
|
||||||
|
logError("AJAX error");
|
||||||
|
}
|
||||||
|
loadMachineList();
|
||||||
|
}
|
||||||
|
|
||||||
|
addMachineForm = {}
|
||||||
|
|
||||||
|
addMachineForm.setFieldValue = function(fieldName, newValue) {
|
||||||
|
document.addMachineForm[fieldName] = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
addMachineForm.clear = function() {
|
||||||
|
document.addMachineForm.reset();
|
||||||
|
logDebug("addMachineForm cleared");
|
||||||
|
}
|
||||||
|
|
||||||
|
function creerMachine(nom, mac, estMachineWifi) {
|
||||||
|
var e = loadJSONDoc("creerMachine?nomNouvelleMachine=" + nom + "&MACNouvelleMachine=" + mac + "&estMachineWifi="+estMachineWifi);
|
||||||
|
e.addCallback(machineModifHandler);
|
||||||
|
e.addErrback(ajaxErrorHandler);
|
||||||
|
loading(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setMessage(m, messageClass) {
|
||||||
|
if (m == null) {
|
||||||
|
var messagePlace = document.getElementById("messagePlaceHolder");
|
||||||
|
replaceChildNodes(messagePlace,'');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (messageClass==null)
|
||||||
|
messageClass='message'
|
||||||
|
var textHolder = SPAN({'class':'messageText'},m);
|
||||||
|
var messageBox = DIV({'class':messageClass},textHolder);
|
||||||
|
var messagePlace = document.getElementById("messagePlaceHolder");
|
||||||
|
replaceChildNodes(messagePlace,messageBox);
|
||||||
|
roundElement(messageBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loading(bool) {
|
||||||
|
var loadingEl = document.getElementById("loadings");
|
||||||
|
if (loadingEl) {
|
||||||
|
if (bool) {
|
||||||
|
loadingEl.style.display='block';
|
||||||
|
} else {
|
||||||
|
loadingEl.style.display='none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
259
intranet/static/scripts/crans_domtab.js
Normal file
259
intranet/static/scripts/crans_domtab.js
Normal file
|
@ -0,0 +1,259 @@
|
||||||
|
/*
|
||||||
|
DOMtab Version 3.1415927
|
||||||
|
Updated March the First 2006
|
||||||
|
written by Christian Heilmann
|
||||||
|
check blog for updates: http://www.wait-till-i.com
|
||||||
|
free to use, not free to resell
|
||||||
|
*/
|
||||||
|
|
||||||
|
domtab={
|
||||||
|
tabClass:'domtab', // class to trigger tabbing
|
||||||
|
listClass:'domtabs', // class of the menus
|
||||||
|
activeClass:'active', // class of current link
|
||||||
|
contentElements:'div', // elements to loop through
|
||||||
|
backToLinks:/#top/, // pattern to check "back to top" links
|
||||||
|
printID:'domtabprintview', // id of the print all link
|
||||||
|
showAllLinkText:'show all content', // text for the print all link
|
||||||
|
prevNextIndicator:'doprevnext', // class to trigger prev and next links
|
||||||
|
prevNextClass:'prevnext', // class of the prev and next list
|
||||||
|
prevLabel:'previous', // HTML content of the prev link
|
||||||
|
nextLabel:'next', // HTML content of the next link
|
||||||
|
prevClass:'prev', // class for the prev link
|
||||||
|
nextClass:'next', // class for the next link
|
||||||
|
init:function(){
|
||||||
|
var temp;
|
||||||
|
if(!document.getElementById || !document.createTextNode){return;}
|
||||||
|
var tempelm=document.getElementsByTagName('div');
|
||||||
|
for(var i=0;i<tempelm.length;i++){
|
||||||
|
if(!domtab.cssjs('check',tempelm[i],domtab.tabClass)){continue;}
|
||||||
|
domtab.initTabMenu(tempelm[i]);
|
||||||
|
domtab.removeBackLinks(tempelm[i]);
|
||||||
|
if(domtab.cssjs('check',tempelm[i],domtab.prevNextIndicator)){
|
||||||
|
domtab.addPrevNext(tempelm[i]);
|
||||||
|
}
|
||||||
|
domtab.checkURL();
|
||||||
|
}
|
||||||
|
if(document.getElementById(domtab.printID)
|
||||||
|
&& !document.getElementById(domtab.printID).getElementsByTagName('a')[0]){
|
||||||
|
var newlink=document.createElement('a');
|
||||||
|
newlink.setAttribute('href','#');
|
||||||
|
domtab.addEvent(newlink,'click',domtab.showAll,false);
|
||||||
|
newlink.onclick=function(){return false;} // safari hack
|
||||||
|
newlink.appendChild(document.createTextNode(domtab.showAllLinkText));
|
||||||
|
document.getElementById(domtab.printID).appendChild(newlink);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
checkURL:function(){
|
||||||
|
var id;
|
||||||
|
var loc=window.location.toString();
|
||||||
|
loc=/#/.test(loc)?loc.match(/#(\w.+)/)[1]:'';
|
||||||
|
if(loc==''){return;}
|
||||||
|
var elm=document.getElementById(loc);
|
||||||
|
if(!elm){return;}
|
||||||
|
var parentMenu=elm.parentNode.parentNode.parentNode;
|
||||||
|
parentMenu.currentSection=loc;
|
||||||
|
parentMenu.getElementsByTagName(domtab.contentElements)[0].style.display='none';
|
||||||
|
domtab.cssjs('remove',parentMenu.getElementsByTagName('a')[0].parentNode,domtab.activeClass);
|
||||||
|
var links=parentMenu.getElementsByTagName('a');
|
||||||
|
for(i=0;i<links.length;i++){
|
||||||
|
if(!links[i].getAttribute('href')){continue;}
|
||||||
|
if(!/#/.test(links[i].getAttribute('href').toString())){continue;}
|
||||||
|
id=links[i].href.match(/#(\w.+)/)[1];
|
||||||
|
if(id==loc){
|
||||||
|
var cur=links[i].parentNode.parentNode;
|
||||||
|
domtab.cssjs('add',links[i].parentNode,domtab.activeClass);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
domtab.changeTab(elm,1);
|
||||||
|
elm.focus();
|
||||||
|
cur.currentLink=links[i];
|
||||||
|
cur.currentSection=loc;
|
||||||
|
},
|
||||||
|
showAll:function(e){
|
||||||
|
document.getElementById(domtab.printID).parentNode.removeChild(document.getElementById(domtab.printID));
|
||||||
|
var tempelm=document.getElementsByTagName('div');
|
||||||
|
for(var i=0;i<tempelm.length;i++){
|
||||||
|
if(!domtab.cssjs('check',tempelm[i],domtab.tabClass)){continue;}
|
||||||
|
var sec=tempelm[i].getElementsByTagName(domtab.contentElements);
|
||||||
|
for(var j=0;j<sec.length;j++){
|
||||||
|
sec[j].style.display='block';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var tempelm=document.getElementsByTagName('ul');
|
||||||
|
for(i=0;i<tempelm.length;i++){
|
||||||
|
if(!domtab.cssjs('check',tempelm[i],domtab.prevNextClass)){continue;}
|
||||||
|
tempelm[i].parentNode.removeChild(tempelm[i]);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
domtab.cancelClick(e);
|
||||||
|
},
|
||||||
|
addPrevNext:function(menu){
|
||||||
|
var temp;
|
||||||
|
var sections=menu.getElementsByTagName(domtab.contentElements);
|
||||||
|
for(var i=0;i<sections.length;i++){
|
||||||
|
temp=domtab.createPrevNext();
|
||||||
|
if(i==0){
|
||||||
|
temp.removeChild(temp.getElementsByTagName('li')[0]);
|
||||||
|
}
|
||||||
|
if(i==sections.length-1){
|
||||||
|
temp.removeChild(temp.getElementsByTagName('li')[1]);
|
||||||
|
}
|
||||||
|
temp.i=i; // h4xx0r!
|
||||||
|
temp.menu=menu;
|
||||||
|
sections[i].appendChild(temp);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeBackLinks:function(menu){
|
||||||
|
var links=menu.getElementsByTagName('a');
|
||||||
|
for(var i=0;i<links.length;i++){
|
||||||
|
if(!domtab.backToLinks.test(links[i].href)){continue;}
|
||||||
|
links[i].parentNode.removeChild(links[i]);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initTabMenu:function(menu){
|
||||||
|
var id;
|
||||||
|
var lists=menu.getElementsByTagName('ul');
|
||||||
|
for(var i=0;i<lists.length;i++){
|
||||||
|
if(domtab.cssjs('check',lists[i],domtab.listClass)){
|
||||||
|
var thismenu=lists[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!thismenu){return;}
|
||||||
|
thismenu.currentSection='';
|
||||||
|
thismenu.currentLink='';
|
||||||
|
var links=thismenu.getElementsByTagName('a');
|
||||||
|
for(i=0;i<links.length;i++){
|
||||||
|
if(!/#/.test(links[i].getAttribute('href').toString())){continue;}
|
||||||
|
id=links[i].href.match(/#(\w.+)/)[1];
|
||||||
|
if(document.getElementById(id)){
|
||||||
|
domtab.addEvent(links[i],'click',domtab.showTab,false);
|
||||||
|
links[i].onclick=function(){return false;} // safari hack
|
||||||
|
domtab.changeTab(document.getElementById(id),0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
id=links[0].href.match(/#(\w.+)/)[1];
|
||||||
|
if(document.getElementById(id)){
|
||||||
|
domtab.changeTab(document.getElementById(id),1);
|
||||||
|
thismenu.currentSection=id;
|
||||||
|
thismenu.currentLink=links[0];
|
||||||
|
domtab.cssjs('add',links[0].parentNode,domtab.activeClass);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
createPrevNext:function(){
|
||||||
|
// this would be so much easier with innerHTML, darn you standards fetish!
|
||||||
|
var temp=document.createElement('ul');
|
||||||
|
temp.className=domtab.prevNextClass;
|
||||||
|
temp.appendChild(document.createElement('li'));
|
||||||
|
temp.getElementsByTagName('li')[0].appendChild(document.createElement('a'));
|
||||||
|
temp.getElementsByTagName('a')[0].setAttribute('href','#');
|
||||||
|
temp.getElementsByTagName('a')[0].innerHTML=domtab.prevLabel;
|
||||||
|
temp.getElementsByTagName('li')[0].className=domtab.prevClass;
|
||||||
|
temp.appendChild(document.createElement('li'));
|
||||||
|
temp.getElementsByTagName('li')[1].appendChild(document.createElement('a'));
|
||||||
|
temp.getElementsByTagName('a')[1].setAttribute('href','#');
|
||||||
|
temp.getElementsByTagName('a')[1].innerHTML=domtab.nextLabel;
|
||||||
|
temp.getElementsByTagName('li')[1].className=domtab.nextClass;
|
||||||
|
domtab.addEvent(temp.getElementsByTagName('a')[0],'click',domtab.navTabs,false);
|
||||||
|
domtab.addEvent(temp.getElementsByTagName('a')[1],'click',domtab.navTabs,false);
|
||||||
|
// safari fix
|
||||||
|
temp.getElementsByTagName('a')[0].onclick=function(){return false;}
|
||||||
|
temp.getElementsByTagName('a')[1].onclick=function(){return false;}
|
||||||
|
return temp;
|
||||||
|
},
|
||||||
|
navTabs:function(e){
|
||||||
|
var li=domtab.getTarget(e);
|
||||||
|
var menu=li.parentNode.parentNode.menu;
|
||||||
|
var count=li.parentNode.parentNode.i;
|
||||||
|
var section=menu.getElementsByTagName(domtab.contentElements);
|
||||||
|
var links=menu.getElementsByTagName('a');
|
||||||
|
var othercount=(li.parentNode.className==domtab.prevClass)?count-1:count+1;
|
||||||
|
section[count].style.display='none';
|
||||||
|
domtab.cssjs('remove',links[count].parentNode,domtab.activeClass);
|
||||||
|
section[othercount].style.display='block';
|
||||||
|
domtab.cssjs('add',links[othercount].parentNode,domtab.activeClass);
|
||||||
|
var parent=links[count].parentNode.parentNode;
|
||||||
|
parent.currentLink=links[othercount];
|
||||||
|
parent.currentSection=links[othercount].href.match(/#(\w.+)/)[1];
|
||||||
|
domtab.cancelClick(e);
|
||||||
|
},
|
||||||
|
changeTab:function(elm,state){
|
||||||
|
do{
|
||||||
|
elm=elm.parentNode;
|
||||||
|
} while(elm.nodeName.toLowerCase()!=domtab.contentElements)
|
||||||
|
elm.style.display=state==0?'none':'block';
|
||||||
|
},
|
||||||
|
showTab:function(e){
|
||||||
|
var o=domtab.getTarget(e);
|
||||||
|
if(o.parentNode.parentNode.currentSection!=''){
|
||||||
|
domtab.changeTab(document.getElementById(o.parentNode.parentNode.currentSection),0);
|
||||||
|
domtab.cssjs('remove',o.parentNode.parentNode.currentLink.parentNode,domtab.activeClass);
|
||||||
|
}
|
||||||
|
var id=o.href.match(/#(\w.+)/)[1];
|
||||||
|
o.parentNode.parentNode.currentSection=id;
|
||||||
|
o.parentNode.parentNode.currentLink=o;
|
||||||
|
domtab.cssjs('add',o.parentNode,domtab.activeClass);
|
||||||
|
domtab.changeTab(document.getElementById(id),1);
|
||||||
|
document.getElementById(id).focus();
|
||||||
|
domtab.cancelClick(e);
|
||||||
|
},
|
||||||
|
/* helper methods */
|
||||||
|
getTarget:function(e){
|
||||||
|
var target = window.event ? window.event.srcElement : e ? e.target : null;
|
||||||
|
if (!target){return false;}
|
||||||
|
if (target.nodeName.toLowerCase() != 'a'){target = target.parentNode;}
|
||||||
|
return target;
|
||||||
|
},
|
||||||
|
cancelClick:function(e){
|
||||||
|
if (window.event){
|
||||||
|
window.event.cancelBubble = true;
|
||||||
|
window.event.returnValue = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e){
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
addEvent: function(elm, evType, fn, useCapture){
|
||||||
|
if (elm.addEventListener)
|
||||||
|
{
|
||||||
|
elm.addEventListener(evType, fn, useCapture);
|
||||||
|
return true;
|
||||||
|
} else if (elm.attachEvent) {
|
||||||
|
var r = elm.attachEvent('on' + evType, fn);
|
||||||
|
return r;
|
||||||
|
} else {
|
||||||
|
elm['on' + evType] = fn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cssjs:function(a,o,c1,c2){
|
||||||
|
switch (a){
|
||||||
|
case 'swap':
|
||||||
|
o.className=!domtab.cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
|
||||||
|
break;
|
||||||
|
case 'add':
|
||||||
|
if(!domtab.cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
|
||||||
|
break;
|
||||||
|
case 'remove':
|
||||||
|
var rep=o.className.match(' '+c1)?' '+c1:c1;
|
||||||
|
o.className=o.className.replace(rep,'');
|
||||||
|
break;
|
||||||
|
case 'check':
|
||||||
|
var found=false;
|
||||||
|
var temparray=o.className.split(' ');
|
||||||
|
for(var i=0;i<temparray.length;i++){
|
||||||
|
if(temparray[i]==c1){found=true;}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
domtab.addEvent(window, 'load', domtab.init, false);
|
||||||
|
|
||||||
|
document.write('<style type="text/css">');
|
||||||
|
document.write('div.domtab>div{display:none;}<');
|
||||||
|
document.write('/s'+'tyle>');
|
161
intranet/static/scripts/digicode.js
Normal file
161
intranet/static/scripts/digicode.js
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
/* ************************************************************
|
||||||
|
* Digicode
|
||||||
|
************************************************************
|
||||||
|
* Digicode.init : initialisation de la page
|
||||||
|
* Digicode.makeCode : creation de codes
|
||||||
|
* Digicode.codelist : liste des codes
|
||||||
|
* Digicode.AJAX : ajax
|
||||||
|
*/
|
||||||
|
Digicode = {};
|
||||||
|
|
||||||
|
/*****************************
|
||||||
|
Digicode.init
|
||||||
|
*****************************/
|
||||||
|
Digicode.init = function()
|
||||||
|
{
|
||||||
|
// afficher le tableau codelist
|
||||||
|
appendChildNodes("globalDiv", Digicode.codelist.create())
|
||||||
|
// recuperer la liste des codes
|
||||||
|
this.codelist.load();
|
||||||
|
// afficher le formulaire de creation de code
|
||||||
|
appendChildNodes("globalDiv", DIV({"id":"addCodeBox"}));
|
||||||
|
Digicode.makeCode.displayForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************
|
||||||
|
Digicode.makeCode
|
||||||
|
*****************************/
|
||||||
|
Digicode.makeCode = {}
|
||||||
|
|
||||||
|
Digicode.makeCode.displayForm = function()
|
||||||
|
{
|
||||||
|
|
||||||
|
var myForm = FORM({'id':'createCodeForm', 'name':'createCodeForm','onsubmit':"Digicode.makeCode.createCode(document.createCodeForm.newCode.value); return false;", 'style':'display: none;'},
|
||||||
|
BUTTON({"type":"button","onclick":"Digicode.makeCode.createCode(document.createCodeForm.newCode.value)", "style":"float:right;"},"Créer code"),
|
||||||
|
INPUT({"name":"newCode", "size":"6", "maxlength":"6", "style":"float:right;"}),
|
||||||
|
BUTTON({"type":"button","onclick":"Digicode.makeCode.createCode()", "style":"float:right;clear:both;"},"Code aléatoire")
|
||||||
|
);
|
||||||
|
replaceChildNodes("addCodeBox", H1({},"Nouveau code"), myForm );
|
||||||
|
appear(myForm);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Digicode.makeCode.restoreForm = function()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
removeElement("newCodeDisplay");
|
||||||
|
removeElement("loading");
|
||||||
|
} catch (error){}
|
||||||
|
appear("createCodeForm");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Digicode.makeCode.createCode = function(code)
|
||||||
|
{
|
||||||
|
var image = createDOM("IMG",{'style':'margin-right:2px;float:right;','src':'/static/images/indicator.gif'});
|
||||||
|
appendChildNodes("addCodeBox", DIV({'id':"loading",'style':'display:none;max-height:1em;float:left;'},image,"Loading"))
|
||||||
|
removeElement("createCodeForm");
|
||||||
|
appear("loading");
|
||||||
|
if (code)
|
||||||
|
Digicode.AJAX.call("createCode?code="+code, this.handleNewCode);
|
||||||
|
else
|
||||||
|
Digicode.AJAX.call("createCode", this.handleNewCode);
|
||||||
|
|
||||||
|
}
|
||||||
|
Digicode.makeCode.handleNewCode = function(res)
|
||||||
|
{
|
||||||
|
if (res.code)
|
||||||
|
{
|
||||||
|
appendChildNodes("addCodeBox",
|
||||||
|
DIV({'id':"newCodeDisplay",
|
||||||
|
'style':'display:none;font-size:2em;maring:1em;font-weight:bold;text-align:center;',
|
||||||
|
'onclick':"Digicode.makeCode.displayForm();"},res.code));
|
||||||
|
appear("newCodeDisplay");
|
||||||
|
removeElement("loading")
|
||||||
|
Digicode.codelist.addCode(res);
|
||||||
|
} else if (res.erreur) {
|
||||||
|
logError("Erreur distante : " + res.erreur);
|
||||||
|
alert("Erreur sur le serveur, le code est peut-être déjà pris.")
|
||||||
|
Digicode.makeCode.displayForm();
|
||||||
|
} else if (res.formatErreur) {
|
||||||
|
alert("Ceci n'est pas un code valide");
|
||||||
|
Digicode.makeCode.displayForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/*****************************
|
||||||
|
Digicode.codelist
|
||||||
|
*****************************/
|
||||||
|
Digicode.codelist = {};
|
||||||
|
|
||||||
|
Digicode.codelist.create = function ()
|
||||||
|
{
|
||||||
|
var thead = createDOM("thead", {},
|
||||||
|
createDOM("th", {'class':'code'}, "Code" ),
|
||||||
|
createDOM("th", {'class':'age'}, "Age")
|
||||||
|
);
|
||||||
|
var tbody = createDOM("tbody", {"id":"codeList"});
|
||||||
|
return TABLE({"id":"codesTable", "cellspacing":"0"}, thead, tbody)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Digicode.codelist.load = function()
|
||||||
|
{
|
||||||
|
Digicode.AJAX.call("codeList", Digicode.codelist.displayCodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
Digicode.codelist.displayCodes = function(result)
|
||||||
|
{
|
||||||
|
if (result.codes)
|
||||||
|
replaceChildNodes('codeList',map(Digicode.codelist.newCodeTrNodeFromDict,result.codes));
|
||||||
|
else if (result.erreur)
|
||||||
|
logError("Erreur distante : " + result.erreur);
|
||||||
|
}
|
||||||
|
|
||||||
|
Digicode.codelist.newCodeTrNodeFromDict = function (aDict, style)
|
||||||
|
{
|
||||||
|
if (style) {
|
||||||
|
var aRow = createDOM("TR", {'id':'code'+aDict.code,"style":style});
|
||||||
|
} else
|
||||||
|
var aRow = createDOM("TR", {'id':'code'+aDict.code});
|
||||||
|
appendChildNodes(aRow, createDOM("TD", {'class':'code'}, aDict.code, SPAN({'style':'color:gray;margin-left:2em;'}, aDict.desc ) ) );
|
||||||
|
appendChildNodes(aRow, createDOM("TD", {'class':'age'}, aDict.age) );
|
||||||
|
return aRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
Digicode.codelist.addCode = function (aDict)
|
||||||
|
{
|
||||||
|
var newLine = this.newCodeTrNodeFromDict(aDict)
|
||||||
|
appendChildNodes("codeList", newLine);
|
||||||
|
pulsate(newLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************
|
||||||
|
Digicode.AJAX
|
||||||
|
*****************************/
|
||||||
|
Digicode.AJAX = {}
|
||||||
|
|
||||||
|
Digicode.AJAX.call = function(page, callBack) {
|
||||||
|
logDebug("calling AJAX : " + page)
|
||||||
|
var e = loadJSONDoc(page);
|
||||||
|
e.addCallback(callBack);
|
||||||
|
e.addErrback(this.errorHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
Digicode.AJAX.errorHandler = function(d) {
|
||||||
|
//Digicode.AJAX..modifPrix("Erreur", false);
|
||||||
|
logError("AJAX Error: " + d);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setInterval(Digicode.codelist.load, 30000);
|
334
intranet/static/scripts/impression.js
Normal file
334
intranet/static/scripts/impression.js
Normal file
|
@ -0,0 +1,334 @@
|
||||||
|
/* ************************************************************
|
||||||
|
* Impression
|
||||||
|
************************************************************
|
||||||
|
* Impression.settings : panneau de configuration
|
||||||
|
* Impression.popup : popup
|
||||||
|
* Impression.AJAX : ajax
|
||||||
|
*/
|
||||||
|
Impression = {};
|
||||||
|
|
||||||
|
/*****************************
|
||||||
|
Impression.settings
|
||||||
|
*****************************/
|
||||||
|
|
||||||
|
Impression.settings = {};
|
||||||
|
|
||||||
|
//
|
||||||
|
//// images : images used for previewing
|
||||||
|
//
|
||||||
|
Impression.settings.images = [
|
||||||
|
"portrait_couleurs_agraphediagonale.png",
|
||||||
|
"portrait_couleurs_pasdagraphes.png",
|
||||||
|
"portrait_couleurs_uneagraphe.png",
|
||||||
|
"portrait_couleurs_Deuxagraphes.png",
|
||||||
|
"portrait_couleurs_troisAgraphes.png",
|
||||||
|
"portrait_couleurs_stitching.png",
|
||||||
|
"portrait_nb_agraphediagonale.png",
|
||||||
|
"portrait_nb_pasdagraphes.png",
|
||||||
|
"portrait_nb_uneagraphe.png",
|
||||||
|
"portrait_nb_Deuxagraphes.png",
|
||||||
|
"portrait_nb_troisAgraphes.png",
|
||||||
|
"portrait_nb_stitching.png",
|
||||||
|
"portrait_transparent_couleurs.png",
|
||||||
|
"portrait_transparent_nb.png",
|
||||||
|
];
|
||||||
|
|
||||||
|
Impression.settings.preloadImage = function(imageName) {
|
||||||
|
var image = new Image();
|
||||||
|
image.src = "/static/images/"+imageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.settings.preloadAllImages = function() {
|
||||||
|
log("Preloading images...");
|
||||||
|
map(this.preloadImage,this.images);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//// init : parse every field and display preview
|
||||||
|
//
|
||||||
|
Impression.settings.init = function () {
|
||||||
|
log("Init settings...");
|
||||||
|
this.theform = document.form_impression;
|
||||||
|
this.disableForm(false);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//// reset : reset form and then re-init settings
|
||||||
|
//
|
||||||
|
Impression.settings.reset = function () {
|
||||||
|
log("Reset form");
|
||||||
|
this.theform.reset();
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.settings.disableForm = function(bool)
|
||||||
|
{
|
||||||
|
log("Set Disable Form : " + bool);
|
||||||
|
var fields = this.theform.elements;
for( var i=0; i< fields.length; i++)
|
||||||
|
{
|
||||||
|
this.setDisableField( fields[i], bool );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//// getValue : parse a field and store value in fielld.name
|
||||||
|
//
|
||||||
|
Impression.settings.getValue = function(field)
|
||||||
|
{
|
||||||
|
if (field.value)
|
||||||
|
{
|
||||||
|
this[field.name] = field.value;
|
||||||
|
log( field.name + " is now " + this[field.name]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logError("Can't get fieldValue");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//// getCopies : parse copies field
|
||||||
|
//
|
||||||
|
Impression.settings.getCopies = function(field) {
|
||||||
|
if ( (!field.value) || (parseInt(field.value)!=field.value-0) || (parseInt(field.value) < 1) )
|
||||||
|
{
|
||||||
|
this.copies = 1;
|
||||||
|
logError("Can't get copies");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.copies = parseInt(field.value);
|
||||||
|
}
|
||||||
|
log("copies is now " + this.copies);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//// setValue : set field value
|
||||||
|
//
|
||||||
|
Impression.settings.setValue = function(afield, avalue) {
|
||||||
|
afield.value = avalue;
|
||||||
|
this.getValue(afield)
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//// setDisableField : set field disabled on/off
|
||||||
|
//
|
||||||
|
Impression.settings.setDisableField = function( afield, isdisabled ) {
|
||||||
|
afield.disabled = isdisabled ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//// disableField : set field disabled on
|
||||||
|
//
|
||||||
|
Impression.settings.disableField = function(afield) {
|
||||||
|
this.setDisableField(afield, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//// fieldChanges : when a field is changed
|
||||||
|
//
|
||||||
|
Impression.settings.update = function (field) {
|
||||||
|
var orientation = "portrait";
|
||||||
|
if (this.theform.type_impression_couleur.checked)
|
||||||
|
this.getValue(this.theform.type_impression_couleur);
|
||||||
|
else
|
||||||
|
this.getValue(this.theform.type_impression_nb);
|
||||||
|
|
||||||
|
if (this.theform.disposition_recto.checked)
|
||||||
|
this.getValue(this.theform.disposition_recto);
|
||||||
|
else
|
||||||
|
this.getValue(this.theform.disposition_recto_verso);
|
||||||
|
this.getValue(this.theform.papier);
|
||||||
|
this.getCopies(this.theform.nb_copies);
|
||||||
|
this.getValue(this.theform.agrafes);
|
||||||
|
// Contraintes
|
||||||
|
if (
|
||||||
|
( this.papier != "A4" ) ||
|
||||||
|
( (this.disposition == "recto") && (this.nb_pages>50) ) ||
|
||||||
|
( (this.disposition == "rectoverso") && (this.nb_pages>100) ) ) {
|
||||||
|
this.setValue(this.theform.agrafes, "pasdagraphes");
|
||||||
|
this.disableField(this.theform.agrafes);
|
||||||
|
this.getValue(this.theform.agrafes);
|
||||||
|
} else {
|
||||||
|
this.setDisableField(this.theform.agrafes, false);
|
||||||
|
}
|
||||||
|
if (this.papier == "A4tr")
|
||||||
|
{
|
||||||
|
this.theform.disposition_recto.checked = true;
|
||||||
|
this.disableField(this.theform.disposition_recto);
|
||||||
|
this.disableField(this.theform.disposition_recto_verso);
|
||||||
|
this.getValue(this.theform.disposition_recto);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setDisableField(this.theform.disposition_recto, false);
|
||||||
|
this.setDisableField(this.theform.disposition_recto_verso, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
logError("eee");
|
||||||
|
this.updatePreview();
|
||||||
|
logError("eee");
|
||||||
|
Impression.AJAX.recalcPrix();
|
||||||
|
logError("eee");
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//// updatePreview : update preview with new value
|
||||||
|
//
|
||||||
|
Impression.settings.updatePreview = function()
|
||||||
|
{
|
||||||
|
var image_name = "";
|
||||||
|
if (this.papier == "A4tr")
|
||||||
|
image_name = "portrait_transparent_" + this.type_impression + ".png";
|
||||||
|
else
|
||||||
|
image_name = "portrait_" + this.type_impression + '_' + this.agrafes + ".png";
|
||||||
|
var image = createDOM("IMG",{'src':'/static/images/'+image_name});
|
||||||
|
log("Updating preview (new image : " + image_name + ")");
|
||||||
|
replaceChildNodes("preview",image)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************
|
||||||
|
Impression.popup
|
||||||
|
*****************************/
|
||||||
|
Impression.popup = {};
|
||||||
|
|
||||||
|
Impression.popup.popupImpression = function(code) {
|
||||||
|
Popup.hide();
|
||||||
|
Popup.create({}, "Impression en cours...",
|
||||||
|
DIV(
|
||||||
|
{"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-printer.png)"},
|
||||||
|
SPAN("code: "+code),
|
||||||
|
A({"href":"https://wiki.crans.org/VieCrans/ImpressionReseau", "class":"aide", "target":"_blank"}, "Comment récupérer mon impression ? ")));
|
||||||
|
Popup.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.popup.popupError = function(erreur) {
|
||||||
|
Popup.hide();
|
||||||
|
Popup.create({}, "Erreur",
|
||||||
|
DIV({"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-warning.png)"},
|
||||||
|
SPAN(erreur),
|
||||||
|
A({"href":"#", "class":"aide", "target":"_blank"}, "Envoyer un rapport aux nounous"),
|
||||||
|
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
|
||||||
|
Popup.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.popup.popupSolde = function(code) {
|
||||||
|
Popup.hide();
|
||||||
|
Popup.create({}, "Solde insuffisant",
|
||||||
|
DIV(
|
||||||
|
{"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-solde.png)"},
|
||||||
|
SPAN("pas assez de sous"),
|
||||||
|
A({"href":"#", "class":"aide", "target":"_blank"}, "Comment recharger mon compte ? "),
|
||||||
|
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
|
||||||
|
Popup.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************
|
||||||
|
Impression.AJAX
|
||||||
|
*****************************/
|
||||||
|
|
||||||
|
Impression.AJAX = {};
|
||||||
|
|
||||||
|
|
||||||
|
Impression.AJAX.modifPrix = function( text, wheel )
|
||||||
|
{
|
||||||
|
if (wheel)
|
||||||
|
{
|
||||||
|
var image = createDOM("IMG",{'src':'/static/images/indicator.gif'});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var image = new DIV({});
|
||||||
|
}
|
||||||
|
var item = new DIV({'onclick':'Impression.AJAX.recalcPrix();'}, image, text);
|
||||||
|
replaceChildNodes("prix_placeholder",item);
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.AJAX.modifNbPages = function( nbpages )
|
||||||
|
{
|
||||||
|
Impression.settings.nb_pages = nbpages;
|
||||||
|
replaceChildNodes("fileNbPages",nbpages);
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.AJAX.call = function(page, callBack) {
|
||||||
|
logDebug("calling AJAX : " + page)
|
||||||
|
var e = loadJSONDoc(page);
|
||||||
|
e.addCallback(callBack);
|
||||||
|
e.addErrback(this.errorHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.AJAX.errorHandler = function(d) {
|
||||||
|
//Impression.AJAX..modifPrix("Erreur", false);
|
||||||
|
logError("AJAX Error: " + d);
|
||||||
|
Impression.AJAX.modifPrix("Erreur...", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Impression.AJAX.usefile = function(filename) {
|
||||||
|
var item = new DIV({}, "Calculs en cours...");
|
||||||
|
this.modifPrix("Analyse du fichier...", true);
|
||||||
|
this.call('useFile?fileName=' + filename,this.analysefini );
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.AJAX.analysefini = function(AJAXResp)
|
||||||
|
{
|
||||||
|
logDebug('AJAX terminated (usefile)');
|
||||||
|
if (AJAXResp.erreur) {
|
||||||
|
Impression.AJAX.modifPrix(AJAXResp.erreur, false);
|
||||||
|
Impression.popup.popupError(AJAXResp.erreur);
|
||||||
|
Impression.settings.disableForm(true);
|
||||||
|
logWarning('Erreur distante : ' + AJAXResp.erreur);
|
||||||
|
} else {
|
||||||
|
Impression.AJAX.modifPrix("Analyse terminée", true);
|
||||||
|
Impression.settings.update();
|
||||||
|
Impression.AJAX.modifNbPages(AJAXResp.nbPages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.AJAX.recalcPrix = function()
|
||||||
|
{
|
||||||
|
settings = Impression.settings;
|
||||||
|
var url = "changeSettings?copies=" + settings.copies
|
||||||
|
+"&couleurs="+ settings.type_impression
|
||||||
|
+"&papier="+ settings.papier
|
||||||
|
+"&recto_verso="+ settings.disposition
|
||||||
|
+"&agrafes="+ settings.agrafes;
|
||||||
|
this.modifPrix("Calcul en cours", true);
|
||||||
|
this.call(url, this.changePrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.AJAX.changePrix = function(AJAXResp)
|
||||||
|
{
|
||||||
|
logDebug('AJAX terminated (recalcPrix)');
|
||||||
|
if (AJAXResp.erreur) {
|
||||||
|
Impression.AJAX.modifPrix(AJAXResp.erreur, false);
|
||||||
|
Impression.popup.popupError(AJAXResp.erreur);
|
||||||
|
Impression.settings.disableForm(true);
|
||||||
|
logWarning('Erreur distante : ' + AJAXResp.erreur);
|
||||||
|
} else {
|
||||||
|
Impression.AJAX.modifPrix("Coût : " + AJAXResp.nouvPrix + "€", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.AJAX.lancerImpression = function(AJAXResp)
|
||||||
|
{
|
||||||
|
var url = "lancerImpression";
|
||||||
|
Impression.settings.disableForm(true);
|
||||||
|
this.call(url, this.etatImpression);
|
||||||
|
}
|
||||||
|
|
||||||
|
Impression.AJAX.etatImpression = function(AJAXResp)
|
||||||
|
{
|
||||||
|
logDebug('AJAX terminated (lancerImpression)');
|
||||||
|
if (AJAXResp.erreur) {
|
||||||
|
Impression.popup.popupError(AJAXResp.erreur);
|
||||||
|
logWarning('Erreur distante : ' + AJAXResp.erreur);
|
||||||
|
} else if (AJAXResp.SoldeInsuffisant) {
|
||||||
|
Impression.popup.popupSolde();
|
||||||
|
Impression.settings.disableForm(false);
|
||||||
|
Impression.settings.update();
|
||||||
|
} else {
|
||||||
|
Impression.popup.popupImpression(AJAXResp.code);
|
||||||
|
}
|
||||||
|
}
|
66
intranet/static/scripts/passwordGenerator.js
Normal file
66
intranet/static/scripts/passwordGenerator.js
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/************************************************************************
|
||||||
|
Password generator
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
function GeneratePassword() {
|
||||||
|
|
||||||
|
if (parseInt(navigator.appVersion) <= 3) {
|
||||||
|
alert("Sorry this only works in 4.0 browsers");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var length=8;
|
||||||
|
var sPassword = "";
|
||||||
|
length = 10;//document.aForm.charLen.options[document.aForm.charLen.selectedIndex].value;
|
||||||
|
|
||||||
|
var noPunction = false;//(document.aForm.punc.checked);
|
||||||
|
var randomLength = true;//(document.aForm.rLen.checked);
|
||||||
|
|
||||||
|
if (randomLength) {
|
||||||
|
length = Math.random();
|
||||||
|
|
||||||
|
length = parseInt(length * 100);
|
||||||
|
length = (length % 7) + 6
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (i=0; i < length; i++) {
|
||||||
|
|
||||||
|
numI = getRandomNum();
|
||||||
|
if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }
|
||||||
|
|
||||||
|
sPassword = sPassword + String.fromCharCode(numI);
|
||||||
|
}
|
||||||
|
|
||||||
|
//document.aForm.passField.value = sPassword
|
||||||
|
c = prompt('Mot de passe généré : ', sPassword)
|
||||||
|
if (c!= null) {
|
||||||
|
document.changePasswordForm.nouveauPassword1.value = c
|
||||||
|
document.changePasswordForm.nouveauPassword2.value = c
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRandomNum() {
|
||||||
|
|
||||||
|
// between 0 - 1
|
||||||
|
var rndNum = Math.random()
|
||||||
|
|
||||||
|
// rndNum from 0 - 1000
|
||||||
|
rndNum = parseInt(rndNum * 1000);
|
||||||
|
|
||||||
|
// rndNum from 33 - 127
|
||||||
|
rndNum = (rndNum % 94) + 33;
|
||||||
|
|
||||||
|
return rndNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkPunc(num) {
|
||||||
|
|
||||||
|
if ((num >=33) && (num <=47)) { return true; }
|
||||||
|
if ((num >=58) && (num <=64)) { return true; }
|
||||||
|
if ((num >=91) && (num <=96)) { return true; }
|
||||||
|
if ((num >=123) && (num <=126)) { return true; }
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
34
intranet/static/scripts/popup.js
Normal file
34
intranet/static/scripts/popup.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
Popup = {};
|
||||||
|
Popup.popupNode = null;
|
||||||
|
Popup.visible = false;
|
||||||
|
|
||||||
|
Popup.display = function() {
|
||||||
|
if (this.popupNode == null) {
|
||||||
|
logError("Popup not created, cannot be displayed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
appendChildNodes("pageContent", this.popupNode);
|
||||||
|
this.visible = true;
|
||||||
|
// logDebug("popup visible");
|
||||||
|
}
|
||||||
|
|
||||||
|
Popup.create = function(options, title_popup, content) {
|
||||||
|
var inPopup = DIV({"id":"__popupInDivId", "style":"background:white;margin:2px 5px;"}, content);
|
||||||
|
var outPopup = DIV({"id":"__popupOutDivId","style":"background:#AE0F3E;z-index:500;float:left;padding:0;min-width:300px;position:fixed;top:30%;left:30%;right:30%;"}, H1({"style":"font-size:1em;margin:0;text-align:center;color:white;"}, IMG({"src":"/static/images/WindowTitleLogo.png","alt":"icon", "style":"margin:0 5px;"}), title_popup), inPopup );
|
||||||
|
roundElement(outPopup);
|
||||||
|
logDebug("Popup \""+ title_popup +"\" created");
|
||||||
|
this.popupNode = outPopup;
|
||||||
|
}
|
||||||
|
|
||||||
|
Popup.hide = function() {
|
||||||
|
if (this.visible) {
|
||||||
|
removeElement(this.popupNode);
|
||||||
|
this.visible = false;
|
||||||
|
}
|
||||||
|
// logDebug("popup not visible");
|
||||||
|
}
|
||||||
|
Popup.closeLink = function(options, text_link) {
|
||||||
|
options["href"] = "#";
|
||||||
|
options["onclick"] = "Popup.hide()";
|
||||||
|
return A(options, text_link);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue