diff --git a/build/viewer/view/group/group_membersChoice.php b/build/viewer/view/group/group_membersChoice.php index 644625e..d796605 100644 --- a/build/viewer/view/group/group_membersChoice.php +++ b/build/viewer/view/group/group_membersChoice.php @@ -9,8 +9,6 @@ class group_membersChoice{ public static function render($params){ - var_dump('membersChoice'); - debug(); /* [1] On vérifie le type de groupe (user/machine) =========================================================*/ /* (1) On vérifie les paramètres */ diff --git a/public_html/css/font.scss b/public_html/css/font.scss index 8987955..f7915c8 100644 --- a/public_html/css/font.scss +++ b/public_html/css/font.scss @@ -1,11 +1,20 @@ +// Regular @font-face{ font-family: 'Open Sans'; - src: url('/css/font/Open Sans/r.ttf'); + src: url('/css/font/Open Sans/R.ttf'); font-weight: normal; font-style: normal; } +// Semi Bold +@font-face{ + font-family: 'Open Sans sb'; + src: url('/css/font/Open Sans/SB.ttf'); + font-weight: normal; + font-style: normal; +} +// Bold @font-face{ font-family: 'Open Sans'; src: url('/css/font/Open Sans/b.ttf'); @@ -13,7 +22,7 @@ font-style: normal; } - +// Italic @font-face{ font-family: 'Open Sans'; src: url('/css/font/Open Sans/i.ttf'); @@ -21,7 +30,7 @@ font-style: italic; } - +// Bold Italic @font-face{ font-family: 'Open Sans'; src: url('/css/font/Open Sans/bi.ttf'); @@ -29,18 +38,18 @@ font-style: italic; } - +// Light @font-face{ font-family: 'Open Sans'; src: url('/css/font/Open Sans/L.ttf'); - font-weight: lighter; + font-weight: 100; font-style: normal; } - +// Light italic @font-face{ font-family: 'Open Sans'; src: url('/css/font/Open Sans/Li.ttf'); - font-weight: lighter; + font-weight: 100; font-style: italic; } diff --git a/public_html/css/font/Open Sans/SB.ttf b/public_html/css/font/Open Sans/SB.ttf new file mode 100644 index 0000000..1a7679e Binary files /dev/null and b/public_html/css/font/Open Sans/SB.ttf differ diff --git a/public_html/css/min/fonts.css b/public_html/css/min/fonts.css index 7fb19bd..c8faff4 100644 --- a/public_html/css/min/fonts.css +++ b/public_html/css/min/fonts.css @@ -1,38 +1,37 @@ @font-face { font-family: 'Open Sans'; - src: url("/css/font/Open Sans/r.ttf"); + src: url("/css/font/Open Sans/R.ttf"); font-weight: normal; - font-style: normal; -} + font-style: normal; } +@font-face { + font-family: 'Open Sans sb'; + src: url("/css/font/Open Sans/SB.ttf"); + font-weight: normal; + font-style: normal; } @font-face { font-family: 'Open Sans'; src: url("/css/font/Open Sans/b.ttf"); font-weight: bold; - font-style: normal; -} + font-style: normal; } @font-face { font-family: 'Open Sans'; src: url("/css/font/Open Sans/i.ttf"); font-weight: normal; - font-style: italic; -} + font-style: italic; } @font-face { font-family: 'Open Sans'; src: url("/css/font/Open Sans/bi.ttf"); font-weight: bold; - font-style: italic; -} + font-style: italic; } @font-face { font-family: 'Open Sans'; src: url("/css/font/Open Sans/L.ttf"); - font-weight: lighter; - font-style: normal; -} + font-weight: 100; + font-style: normal; } @font-face { font-family: 'Open Sans'; src: url("/css/font/Open Sans/Li.ttf"); - font-weight: lighter; - font-style: italic; -} + font-weight: 100; + font-style: italic; } /*# sourceMappingURL=fonts.css.map */ diff --git a/public_html/css/min/reset.css b/public_html/css/min/reset.css index 4fc9a1f..dc34456 100755 --- a/public_html/css/min/reset.css +++ b/public_html/css/min/reset.css @@ -1,129 +1,374 @@ /*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */ -/** 1. Set default font family to sans-serif. 2. Prevent iOS and IE text size adjust after device orientation change, without disabling user zoom. */ -html { font-family: sans-serif; /* 1 */ -ms-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */ } +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS and IE text size adjust after device orientation change, + * without disabling user zoom. + */ +html { + font-family: sans-serif; + /* 1 */ + -ms-text-size-adjust: 100%; + /* 2 */ + -webkit-text-size-adjust: 100%; + /* 2 */ } -/** Remove default margin. */ -body { margin: 0; font-family: 'Open Sans', 'Ubuntu', 'Verdana', 'Arial'; } +/** + * Remove default margin. + */ +body { + margin: 0; + font-size: 16px; + font-family: 'Open Sans', 'Ubuntu', 'Verdana', 'Arial'; + font-weight: normal; } -/* HTML5 display definitions ========================================================================== */ -/** Correct `block` display not defined for any HTML5 element in IE 8/9. Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox. Correct `block` display not defined for `main` in IE 11. */ -article, aside, details, figcaption, figure, footer, header, main, menu, nav, section, summary { display: block; } +/* HTML5 display definitions + ========================================================================== */ +/** + * Correct `block` display not defined for any HTML5 element in IE 8/9. + * Correct `block` display not defined for `details` or `summary` in IE 10/11 + * and Firefox. + * Correct `block` display not defined for `main` in IE 11. + */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +main, +menu, +nav, +section, +summary { + display: block; } -/** 1. Correct `inline-block` display not defined in IE 8/9. 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. */ -audio, canvas, progress, video { display: inline-block; /* 1 */ vertical-align: baseline; /* 2 */ } +/** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ +audio, +canvas, +progress, +video { + display: inline-block; + /* 1 */ + vertical-align: baseline; + /* 2 */ } -/** Prevent modern browsers from displaying `audio` without controls. Remove excess height in iOS 5 devices. */ -audio:not([controls]) { display: none; height: 0; } +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ +audio:not([controls]) { + display: none; + height: 0; } -/** Address `[hidden]` styling not present in IE 8/9/10. Hide the `template` element in IE 8/9/10/11, Safari, and Firefox < 22. */ -[hidden], template { display: none; } +/** + * Address `[hidden]` styling not present in IE 8/9/10. + * Hide the `template` element in IE 8/9/10/11, Safari, and Firefox < 22. + */ +[hidden], +template { + display: none; } -/* Links ========================================================================== */ -/** Remove the gray background color from active links in IE 10. */ -a { background-color: transparent; } +/* Links + ========================================================================== */ +/** + * Remove the gray background color from active links in IE 10. + */ +a { + background-color: transparent; } -/** Improve readability of focused elements when they are also in an active/hover state. */ -a:active, a:hover { outline: 0; } +/** + * Improve readability of focused elements when they are also in an + * active/hover state. + */ +a:active, +a:hover { + outline: 0; } -/* Text-level semantics ========================================================================== */ -/** Address inconsistent styling of `abbr[title]`. 1. Correct styling in Firefox 39 and Opera 12. 2. Correct missing styling in Chrome, Edge, IE, Opera, and Safari. */ -abbr[title] { border-bottom: none; /* 1 */ text-decoration: underline; /* 2 */ text-decoration: underline dotted; /* 2 */ } +/* Text-level semantics + ========================================================================== */ +/** + * Address inconsistent styling of `abbr[title]`. + * 1. Correct styling in Firefox 39 and Opera 12. + * 2. Correct missing styling in Chrome, Edge, IE, Opera, and Safari. + */ +abbr[title] { + border-bottom: none; + /* 1 */ + text-decoration: underline; + /* 2 */ + text-decoration: underline dotted; + /* 2 */ } -/** Address inconsistent styling of b and strong. 1. Correct duplicate application of `bolder` in Safari 6.0.2. 2. Correct style set to `bold` in Edge 12+, Safari 6.2+, and Chrome 18+. */ -b, strong { font-weight: inherit; /* 1 */ } +/** + * Address inconsistent styling of b and strong. + * 1. Correct duplicate application of `bolder` in Safari 6.0.2. + * 2. Correct style set to `bold` in Edge 12+, Safari 6.2+, and Chrome 18+. + */ +b, +strong { + font-weight: inherit; + /* 1 */ } -b, strong { font-weight: bolder; /* 2 */ } +b, +strong { + font-weight: bolder; + /* 2 */ } -/** Address styling not present in Safari and Chrome. */ -dfn { font-style: italic; } +/** + * Address styling not present in Safari and Chrome. + */ +dfn { + font-style: italic; } -/** Address variable `h1` font-size and margin within `section` and `article` contexts in Firefox 4+, Safari, and Chrome. */ -h1 { font-size: 2em; margin: 0.67em 0; } +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari, and Chrome. + */ +h1 { + font-size: 2em; + margin: 0.67em 0; } -/** Address styling not present in IE 8/9. */ -mark { background-color: #ff0; color: #000; } +/** + * Address styling not present in IE 8/9. + */ +mark { + background-color: #ff0; + color: #000; } -/** Address inconsistent and variable font size in all browsers. */ -small { font-size: 80%; } +/** + * Address inconsistent and variable font size in all browsers. + */ +small { + font-size: 80%; } -/** Prevent `sub` and `sup` affecting `line-height` in all browsers. */ -sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; } -sup { top: -0.5em; } +sup { + top: -0.5em; } -sub { bottom: -0.25em; } +sub { + bottom: -0.25em; } -/* Embedded content ========================================================================== */ -/** Remove border when inside `a` element in IE 8/9/10. */ -img { border: 0; } +/* Embedded content + ========================================================================== */ +/** + * Remove border when inside `a` element in IE 8/9/10. + */ +img { + border: 0; } -/** Correct overflow not hidden in IE 9/10/11. */ -svg:not(:root) { overflow: hidden; } +/** + * Correct overflow not hidden in IE 9/10/11. + */ +svg:not(:root) { + overflow: hidden; } -/* Grouping content ========================================================================== */ -/** Address margin not present in IE 8/9 and Safari. */ -figure { margin: 1em 40px; } +/* Grouping content + ========================================================================== */ +/** + * Address margin not present in IE 8/9 and Safari. + */ +figure { + margin: 1em 40px; } -/** Address inconsistent styling of `hr`. 1. Correct `box-sizing` set to `border-box` in Firefox. 2. Correct `overflow` set to `hidden` in IE 8/9/10/11 and Edge 12. */ -hr { box-sizing: content-box; /* 1 */ height: 0; /* 1 */ overflow: visible; /* 2 */ } +/** + * Address inconsistent styling of `hr`. + * 1. Correct `box-sizing` set to `border-box` in Firefox. + * 2. Correct `overflow` set to `hidden` in IE 8/9/10/11 and Edge 12. + */ +hr { + box-sizing: content-box; + /* 1 */ + height: 0; + /* 1 */ + overflow: visible; + /* 2 */ } -/** Contain overflow in all browsers. */ -pre { overflow: auto; } +/** + * Contain overflow in all browsers. + */ +pre { + overflow: auto; } -/** 1. Correct inheritance and scaling of font-size for preformatted text. 2. Address odd `em`-unit font size rendering in all browsers. */ -code, kbd, pre, samp { font-family: monospace, monospace; /* 1 */ font-size: 1em; /* 2 */ } +/** + * 1. Correct inheritance and scaling of font-size for preformatted text. + * 2. Address odd `em`-unit font size rendering in all browsers. + */ +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + /* 1 */ + font-size: 1em; + /* 2 */ } -/* Forms ========================================================================== */ -/** Known limitation: by default, Chrome and Safari on OS X allow very limited styling of `select`, unless a `border` property is set. */ -/** 1. Correct font properties not being inherited. 2. Address margins set differently in Firefox 4+, Safari, and Chrome. */ -button, input, optgroup, select, textarea { font: inherit; /* 1 */ margin: 0; /* 2 */ } +/* Forms + ========================================================================== */ +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ +/** + * 1. Correct font properties not being inherited. + * 2. Address margins set differently in Firefox 4+, Safari, and Chrome. + */ +button, +input, +optgroup, +select, +textarea { + font: inherit; + /* 1 */ + margin: 0; + /* 2 */ } -/** Address `overflow` set to `hidden` in IE 8/9/10/11. */ -button { overflow: visible; } +/** + * Address `overflow` set to `hidden` in IE 8/9/10/11. + */ +button { + overflow: visible; } -/** Address inconsistent `text-transform` inheritance for `button` and `select`. All other form control elements do not inherit `text-transform` values. Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. Correct `select` style inheritance in Firefox. */ -button, select { text-transform: none; } +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. + * Correct `select` style inheritance in Firefox. + */ +button, +select { + text-transform: none; } -/** 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` and `video` controls. 2. Correct inability to style clickable `input` types in iOS. 3. Improve usability and consistency of cursor style between image-type `input` and others. */ -button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; /* 2 */ cursor: pointer; /* 3 */ } +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ +button, +html input[type="button"], +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; + /* 2 */ + cursor: pointer; + /* 3 */ } -/** Re-set default cursor for disabled elements. */ -button[disabled], html input[disabled] { cursor: default; } +/** + * Re-set default cursor for disabled elements. + */ +button[disabled], +html input[disabled] { + cursor: default; } -/** Remove inner padding and border in Firefox 4+. */ -button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } +/** + * Remove inner padding and border in Firefox 4+. + */ +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; } -/** Address Firefox 4+ setting `line-height` on `input` using `!important` in the UA stylesheet. */ -input { line-height: normal; } +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ +input { + line-height: normal; } -/** It's recommended that you don't attempt to style these elements. Firefox's implementation doesn't respect box-sizing, padding, or width. 1. Address box sizing set to `content-box` in IE 8/9/10. 2. Remove excess padding in IE 8/9/10. */ -input[type="checkbox"], input[type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ } +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; + /* 1 */ + padding: 0; + /* 2 */ } -/** Fix the cursor style for Chrome's increment/decrement buttons. For certain `font-size` values of the `input`, it causes the cursor style of the decrement button to change from `default` to `text`. */ -input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; } +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; } -/** Address `appearance` set to `searchfield` in Safari and Chrome. */ -input[type="search"] { -webkit-appearance: textfield; } +/** + * Address `appearance` set to `searchfield` in Safari and Chrome. + */ +input[type="search"] { + -webkit-appearance: textfield; } -/** Remove inner padding and search cancel button in Safari and Chrome on OS X. Safari (but not Chrome) clips the cancel button when the search input has padding (and `textfield` appearance). */ -input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; } -/** Define consistent border, margin, and padding. */ -fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; } +/** + * Define consistent border, margin, and padding. + */ +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; } -/** 1. Correct `color` not being inherited in IE 8/9/10/11. 2. Remove padding so people aren't caught out if they zero out fieldsets. */ -legend { border: 0; /* 1 */ padding: 0; /* 2 */ } +/** + * 1. Correct `color` not being inherited in IE 8/9/10/11. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ +legend { + border: 0; + /* 1 */ + padding: 0; + /* 2 */ } -/** Remove default vertical scrollbar in IE 8/9/10/11. */ -textarea { overflow: auto; } +/** + * Remove default vertical scrollbar in IE 8/9/10/11. + */ +textarea { + overflow: auto; } -/** Don't inherit the `font-weight` (applied by a rule above). NOTE: the default cannot safely be changed in Chrome and Safari on OS X. */ -optgroup { font-weight: bold; } +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ +optgroup { + font-weight: bold; } -/* Tables ========================================================================== */ -/** Remove most spacing between table cells. */ -table { border-collapse: collapse; border-spacing: 0; } +/* Tables + ========================================================================== */ +/** + * Remove most spacing between table cells. + */ +table { + border-collapse: collapse; + border-spacing: 0; } -td, th { padding: 0; } +td, +th { + padding: 0; } /*# sourceMappingURL=reset.css.map */ diff --git a/public_html/css/reset.scss b/public_html/css/reset.scss index bde343c..8c4e707 100755 --- a/public_html/css/reset.scss +++ b/public_html/css/reset.scss @@ -18,8 +18,9 @@ html { body { margin: 0; - // font-size: 12px; + font-size: 16px; font-family: 'Open Sans', 'Ubuntu', 'Verdana', 'Arial'; + font-weight: normal; } /* HTML5 display definitions diff --git a/public_html/js/action-script.js b/public_html/js/action-script.js index 2ff51ea..671209a 100755 --- a/public_html/js/action-script.js +++ b/public_html/js/action-script.js @@ -10,7 +10,7 @@ DOM = { /* [0] Instanciation ===========================================*/ var pageManager = new pageManagerClass(); -pageManager.setPage(null, '/view', DOM.CONTAINER, ['history', 'profile', 'machines', 'users', 'groups', 'analytics', 'settings'] ); + var api = new APIClass('/api/'); @@ -157,6 +157,8 @@ function navMenu(section, persistence){ navSubMenu(target); }, false); + DOM.HEADER.remClass('loading'); + }; /* (x) Si première ou changement de page, on charge la nouvelle */ @@ -167,11 +169,16 @@ function navMenu(section, persistence){ } -}navMenu(pageManager.page); - - - - +} + + + + +// init page-manager +pageManager.setPage(null, '/view', DOM.CONTAINER, ['history', 'profile', 'machines', 'users', 'groups', 'analytics', 'settings'] ); + +// launch pageManager +navMenu(pageManager.page); @@ -181,9 +188,23 @@ function navMenu(section, persistence){ +// set default refresher +pageManager.refresher = function(){ + /* (1) Loads page */ + navSubMenu( this.vars[0] ); + + /* (2) Set listener for sub-menu nav */ + document.querySelector('#CONTAINER > .sub-menu-side').addEventListener('click', function(e){ + var target = e.target; + while( target != document.body && !target.getData('sublink') ) + target = target.parentNode; + if( target.getData('sublink') ) + navSubMenu(target); + }, false); +}; diff --git a/public_html/js/lib/min/form-deflater.js b/public_html/js/lib/min/form-deflater.js new file mode 100755 index 0000000..f0abc45 --- /dev/null +++ b/public_html/js/lib/min/form-deflater.js @@ -0,0 +1,285 @@ + +/* CONSTRUCTEUR D'UN DEFLATER DE formulaire +* +* @container Formulaire ou autre élément contenant les champs +* @tags Tableau contenant les éléments à prendre en compte +* @attr Tableau contenant les attributs à prendre pour le nom (par ordre de priorité) +* +*/ +function FormDeflater(container, tags, attr){ + /* [0] Vérification des INPUT + =========================================================*/ + var correctParams = container instanceof Element; + correctParams = correctParams && tags instanceof Array; + correctParams = correctParams && attr instanceof Array; + + + /* [1] On formatte les données + =========================================================*/ + // On met les tags en minuscule + for( var i = 0 ; i < tags.length ; i++ ) + tags[i] = tags[i].toLowerCase(); + + // On met les attributs en minuscule + for( var i = 0 ; i < attr.length ; i++ ) + attr[i] = attr[i].toLowerCase(); + + /* [2] On enregistre les attributs + =========================================================*/ + this.container = container; + this.tags = tags; + this.attr = attr; +} + + +FormDeflater.prototype = { + container: this.container, // Contiendra le 'formulaire' (
ou autre) + tags: this.tags, // Contiendra les balises HTML à ne pas prendre en compte + attr: this.attr // Contiendra la liste des attributs à prendre pour nom (par ordre de priorité) +}; + + + +/* RETOURNE UN OBJET CONTENANT LES DONNÉES DU FORMULAIRE +* +* @return form Objet correspondant aux données du formulaire +* +*/ +FormDeflater.prototype.deflate = function(){ + /* [1] On récupère tous les enfants + =========================================================*/ + var children = this.getChildren( this.container ); + + /* [2] On filtre les éléments qui ont pas le bon tag + =========================================================*/ + children = this.filterElements( children ); + + + /* [3] On essaie de trouver les attributs primants (non vides et en premier dans la liste @this.attr) + =========================================================*/ + /* (0) On initialise l'objet de retour */ + var object = {}; + + /* (1) Pour chacun des éléments */ + for( var c = 0 ; c < children.length ; c++ ){ + + /* (2) Pour chacun des attributs par ordre de priorité */ + for( var a = 0 ; a < this.attr.length ; a++ ){ + // On récupère l'attribut + var attr = children[c].getAttribute(this.attr[a]); + + + + /* (3) Si l'attribut est défini (pas null ni vide) */ + if( attr !== null && attr.length > 0 ){ + + /* (4) Si on a pas déja un champ de même nom */ + if( object.hasOwnProperty(attr) ){ + var existing = object[attr]; + + // {1} Si l'existant est un tableau, on ajoute notre valeur // + if( existing instanceof Array ) + object[attr].push( { target: children[c], attr: this.attr[a], value: children[c].value, checked: children[c].checked } ); + + // {2} Sinon, si c'est une valeur seule, on crée un tableau // + else + object[attr] = [ object[attr], { target: children[c], attr: this.attr[a], value: children[c].value, checked: children[c].checked } ]; + + /* (5) Si c'est le premier champ avec ce nom, on le crée */ + }else + object[attr] = { target: children[c], attr: this.attr[a], value: children[c].value, checked: children[c].checked }; + + // On en a fini pour cet élément + break; + } + + + + } + } + + + + /* [4] On met en forme les données + =========================================================*/ + object = this.cleanOutput(object); + + + return object; +}; + + + + +/* RETOURNE SI UN ELEMENT EST UN BOUTON DE TYPE RADIO/CHECKBOX OU NON +* +* @element Element en question +* +* @return result Renvoie si TRUE or FALSE il en est un +* +*/ +FormDeflater.prototype.checkable = function(element){ + if( element.tagName != 'INPUT' ) + return false; + + if( ['radio', 'checkbox'].indexOf( element.getAttribute('type').toLowerCase() ) == -1 ) + return false; + + return true; +}; + + + + +/* NETTOIE LES DONNÉES EN SORTIE POUR QU'ELLES SOIENT UTILISABLES ET OPTIMISÉES +* +* @input Données "brutes" +* +* @return output Données sans les valeurs inutiles et explicitées +* +*/ +FormDeflater.prototype.cleanOutput = function(input){ + var output = {}; + + /* [1] On parcourt toutes les valeurs récupérées + =========================================================*/ + for( var key in input ){ + + /* [2] Si c'est un tableau + =========================================================*/ + if( input[key] instanceof Array ){ + + // VRAI si tous les éléments sont radio/checkbox + var areCheckable = true; + // Contiendra les indices des valeurs ou 'checked=TRUE' + var checkedIndexes = []; + + /* (1) On vérifie si tous les champs sont checkables */ + for( var i in input[key]) + // si pas checkable, on arrête de vérifier + if( !this.checkable(input[key][i].target) ){ + areCheckable = false; + break; + // Sinon si checkable et checked=TRUE, on incrémente @nbChecked + }else if( input[key][i].checked === true ) + checkedIndexes.push(i); + + /* (2) Si c'est que des radio ou des checkbox avec une seule valeur à TRUE */ + if( areCheckable ) + if( checkedIndexes.length == 1 ) + output[key] = input[key][checkedIndexes[0]].value; + + /* (3) Si c'est que des radio ou des checkbox avec plusieurs valeurs à TRUE */ + else{ + output[key] = []; + for( var i in checkedIndexes ) + output[key].push( input[key][checkedIndexes[i]].value ); + } + + /* (4) Si c'est pas que des radio ou des checkbox, on met les valeurs */ + else{ + output[key] = []; + for( var i in input[key] ) + output[key].push( input[key][i].value ); + } + + /* [3] S'il n'y a qu'une donnée (pas un tableau) + =========================================================*/ + }else{ + + /* (1) Si de type 'radio' ou 'checkbox', on met la valeur de 'checked' */ + if( this.checkable(input[key].target) ) + output[key] = input[key].checked ? input[key].value : null; + + /* (2) Sinon, on met la valeur de 'value' */ + else + output[key] = input[key].value; + + } + + } + + + return output; +}; + + + + + + + +/* RETOURNE LA LISTE DE TOUS LES ÉLÉMENTS QUEL QUE SOIT LE NIVEAU HIÉRARCHIQUE +* +* @parent Parent duquel on veut les enfants +* +* @return children Tableau contenant tous les enfants +* +*/ +FormDeflater.prototype.getChildren = function(parent){ + // Si le parent n'est pas un élément, on retourne aucun enfant + if( !(parent instanceof Element) ) return []; + + /* [1] Initialisation des variables + =========================================================*/ + // Contient la liste des enfants directs + var children = [].slice.call(parent.children); + + // Contiendra la liste des enfants directs et indirects + var allChildren = children; + + /* [2] On parcourt tous les enfants + =========================================================*/ + for( var i = 0 ; i < children.length ; i++ ){ + // On relance la fonction récursivement sur tous les enfants + allChildren = allChildren.concat( [].slice.call(this.getChildren(children[i])) ); + } + + /* [3] On retourne le résultat + =========================================================*/ + return allChildren; +}; + + + + +/* FILTRE LES éléments en fonction de @this.tags et @this.attr +* +* @elements Le tableau contenant les éléments à trier +* +* @return filtered Retourne le tableau des éléments filtrés +* +*/ +FormDeflater.prototype.filterElements = function(elements){ + // Contiendra les éléments correspondants aux critères + var filtered = []; + + /* [1] On parcourt tous les éléments + =========================================================*/ + for( var i = 0 ; i < elements.length ; i++ ) + // Si l'élément a le bon tag, on le garde + if( this.tags.indexOf( elements[i].tagName.toLowerCase() ) > -1 ) + filtered.push(elements[i]); + + /* [2] On retourne les éléments filtržés + =========================================================*/ + return filtered; +}; + + + + +/************/ +/* USE CASE */ +/************/ +/* (1) Instanciation */ +/*HIDDEN*/// var instance = new FormDeflater( +/*HIDDEN*/// document.getElementById('myform'), +/*HIDDEN*/// ['input', 'select'], // éléments à prendre en compte (tagName) +/*HIDDEN*/// ['id', 'name', 'data-elementname'] // Attributs par ordre de priorité +/*HIDDEN*/// ); +/*HIDDEN*/// +/* (2) On récupère l'objet */ +/*HIDDEN*/// +/*HIDDEN*/// var object = instance.deflate(); +/*HIDDEN*/// diff --git a/public_html/js/lib/min/page-manager.js b/public_html/js/lib/min/page-manager.js index 06ddc9a..ca2e0e1 100755 --- a/public_html/js/lib/min/page-manager.js +++ b/public_html/js/lib/min/page-manager.js @@ -208,7 +208,6 @@ pageManagerClass.prototype = { pas la page ou si la page de l'URL ne correspond à aucune page de la liste) ========================================================================== */ setPage: function(pName, pPath, pContainer, pPageList, pRoot){ - // liste de pages si c'est un tableau var pageList = ( typeof pPageList == 'object' && pPageList instanceof Array ) ? pPageList : null; // si this.pagelist n'est pas overwrite il vaut null @@ -235,10 +234,18 @@ pageManagerClass.prototype = { // Si on veut just `refresh` la page if( pName === true ){ + // formulaire POST + var fd = new FormData(); + for( var i = 0 ; i < this.vars.length ; i++ ) + fd.append(this.vars[i], null); + + this.updateURL(); // can be useful for content or dep + this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){ this.container.innerHTML = e; this.loadDependencies(); this.refresher.apply(this); + this.updateURL(); // if updated in refresher }.bind(this), 'POST', fd); return this; diff --git a/public_html/js/lib/page-manager.js b/public_html/js/lib/page-manager.js index 06ddc9a..5b39fd5 100755 --- a/public_html/js/lib/page-manager.js +++ b/public_html/js/lib/page-manager.js @@ -208,7 +208,6 @@ pageManagerClass.prototype = { pas la page ou si la page de l'URL ne correspond à aucune page de la liste) ========================================================================== */ setPage: function(pName, pPath, pContainer, pPageList, pRoot){ - // liste de pages si c'est un tableau var pageList = ( typeof pPageList == 'object' && pPageList instanceof Array ) ? pPageList : null; // si this.pagelist n'est pas overwrite il vaut null @@ -235,10 +234,18 @@ pageManagerClass.prototype = { // Si on veut just `refresh` la page if( pName === true ){ + // formulaire POST + var fd = new FormData(); + for( var i = 0 ; i < this.vars.length ; i++ ) + fd.append(this.vars[i], null); + + this.updateURL(); // could be useful for content or dep + this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){ this.container.innerHTML = e; this.loadDependencies(); this.refresher.apply(this); + this.updateURL(); // if updated in refresher }.bind(this), 'POST', fd); return this; diff --git a/public_html/js/min/action-script.js b/public_html/js/min/action-script.js index 2ff51ea..671209a 100755 --- a/public_html/js/min/action-script.js +++ b/public_html/js/min/action-script.js @@ -10,7 +10,7 @@ DOM = { /* [0] Instanciation ===========================================*/ var pageManager = new pageManagerClass(); -pageManager.setPage(null, '/view', DOM.CONTAINER, ['history', 'profile', 'machines', 'users', 'groups', 'analytics', 'settings'] ); + var api = new APIClass('/api/'); @@ -157,6 +157,8 @@ function navMenu(section, persistence){ navSubMenu(target); }, false); + DOM.HEADER.remClass('loading'); + }; /* (x) Si première ou changement de page, on charge la nouvelle */ @@ -167,11 +169,16 @@ function navMenu(section, persistence){ } -}navMenu(pageManager.page); - - - - +} + + + + +// init page-manager +pageManager.setPage(null, '/view', DOM.CONTAINER, ['history', 'profile', 'machines', 'users', 'groups', 'analytics', 'settings'] ); + +// launch pageManager +navMenu(pageManager.page); @@ -181,9 +188,23 @@ function navMenu(section, persistence){ +// set default refresher +pageManager.refresher = function(){ + /* (1) Loads page */ + navSubMenu( this.vars[0] ); + + /* (2) Set listener for sub-menu nav */ + document.querySelector('#CONTAINER > .sub-menu-side').addEventListener('click', function(e){ + var target = e.target; + while( target != document.body && !target.getData('sublink') ) + target = target.parentNode; + if( target.getData('sublink') ) + navSubMenu(target); + }, false); +}; diff --git a/public_html/view/css/admin.css b/public_html/view/css/admin.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/css/analytics.css b/public_html/view/css/analytics.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/css/groups.css b/public_html/view/css/groups.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/css/history.css b/public_html/view/css/history.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/css/machines.css b/public_html/view/css/machines.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/css/profile.css b/public_html/view/css/profile.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/css/settings.css b/public_html/view/css/settings.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/css/users.css b/public_html/view/css/users.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/css/view.css b/public_html/view/css/view.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/css/warehouse.css b/public_html/view/css/warehouse.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/js/admin.js b/public_html/view/js/admin.js new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/js/groups.js b/public_html/view/js/groups.js index d711ab2..7dd0733 100755 --- a/public_html/view/js/groups.js +++ b/public_html/view/js/groups.js @@ -108,9 +108,8 @@ if( section.view.element != null ){ for( i = 0 ; i < section.view.link.edit.length ; i++ ){ section.view.link.edit[i].addEventListener('click', function(e){ - pageManager.vars[1] = e.target.getData('cluster'); - navSubMenu('edit'); - document.location = ''; + pageManager.vars = [ 'edit', e.target.getData('cluster') ]; + pageManager.refresh(); }, false); } @@ -119,9 +118,8 @@ if( section.view.element != null ){ for( i = 0 ; i < section.view.link.remove.length ; i++ ){ section.view.link.remove[i].addEventListener('click', function(e){ - pageManager.vars[1] = e.target.getData('cluster'); - navSubMenu('remove'); - document.location = ''; + pageManager.vars = [ 'remove', e.target.getData('cluster') ]; + pageManager.refresh(); }, false); } @@ -149,7 +147,6 @@ if( section.view.element != null ){ if( response.ModuleError != 0 ) return false; - // {4} Si tout s'est bien passé // e.target.parentNode.parentNode.removeChild( e.target.parentNode ); }); @@ -161,11 +158,10 @@ if( section.view.element != null ){ /* (7) On gere la "modification" des membres d'un groupe */ for( i = 0 ; i < section.view.group.add.length ; i++ ){ - section.view.group.add[i].addEventListener('click', function(e){ + section.view.group.add[i].addEventListener('mouseup', function(e){ pageManager.vars[1] = e.target.getData('cluster'); - navSubMenu('members'); - document.location = ''; + pageManager.refresh(); }, false); @@ -490,18 +486,18 @@ if( section.edit.element != null ){ section.edit.input = { search: { view: document.querySelector(section.edit.text + '.edit_search_view'), - num: document.querySelector(section.edit.text + '.edit_search_num'), - sum: document.querySelector(section.edit.text + '.edit_search_sum'), + num: document.querySelector(section.edit.text + '.edit_search_num'), + sum: document.querySelector(section.edit.text + '.edit_search_sum'), keyword: document.querySelector(section.edit.text + '#edit_search_keyword'), id: document.querySelector(section.edit.text + '#edit_search_id'), submit: document.querySelector(section.edit.text + '#edit_search_submit') }, - name: document.querySelector(section.edit.text + '#edit_name'), - class: document.querySelector(section.edit.text + '#edit_class'), + name: document.querySelector(section.edit.text + '#edit_name'), + class: document.querySelector(section.edit.text + '#edit_class'), - submit: document.querySelector(section.edit.text + '#edit_submit') + submit: document.querySelector(section.edit.text + '#edit_submit') }; var lastkeywords_edit = ''; @@ -766,8 +762,8 @@ if( section.members.element != null && section.members.chooser.element != null ) /* (2) Redirection */ pageManager.vars[1] = data; + console.log(pageManager.vars); pageManager.refresh(); - document.location = ''; }, false); diff --git a/public_html/view/js/machines.js b/public_html/view/js/machines.js index 93cc82c..f1a6ce3 100755 --- a/public_html/view/js/machines.js +++ b/public_html/view/js/machines.js @@ -94,9 +94,8 @@ if( section.view.element != null ){ for( var i = 0 ; i < section.view.link.edit.length ; i++ ){ section.view.link.edit[i].addEventListener('click', function(e){ - pageManager.vars[1] = e.target.getData('machine'); - navSubMenu('edit'); - document.location = ''; + pageManager.vars = [ 'edit', e.target.getData('machine') ]; + pageManager.refresh(); }, false); } @@ -105,9 +104,8 @@ if( section.view.element != null ){ for( var i = 0 ; i < section.view.link.remove.length ; i++ ){ section.view.link.remove[i].addEventListener('click', function(e){ - pageManager.vars[1] = e.target.getData('machine'); - navSubMenu('remove'); - document.location = ''; + pageManager.vars = [ 'remove', e.target.getData('machine') ]; + pageManager.refresh(); }, false); } diff --git a/public_html/view/js/profile.js b/public_html/view/js/profile.js new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/js/settings.js b/public_html/view/js/settings.js new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/js/users.js b/public_html/view/js/users.js index 870dc0e..a573c9d 100755 --- a/public_html/view/js/users.js +++ b/public_html/view/js/users.js @@ -102,9 +102,8 @@ if( section.view.element != null ){ for( var i = 0 ; i < section.view.link.edit.length ; i++ ){ section.view.link.edit[i].addEventListener('click', function(e){ - pageManager.vars[1] = e.target.getData('user'); - navSubMenu('edit'); - document.location = ''; + pageManager.vars = [ 'edit', e.target.getData('user') ]; + pageManager.refresh(); }, false); } @@ -113,9 +112,8 @@ if( section.view.element != null ){ for( var i = 0 ; i < section.view.link.remove.length ; i++ ){ section.view.link.remove[i].addEventListener('click', function(e){ - pageManager.vars[1] = e.target.getData('user'); - navSubMenu('remove'); - document.location = ''; + pageManager.vars = [ 'remove', e.target.getData('user') ]; + pageManager.refresh(); }, false); } @@ -318,11 +316,14 @@ if( section.remove.element != null ){ // Gestion automatique au chargement de la page si ID_MACHINE dans url "/users/remove/:id_user:" if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ){ + console.log('init id', pageManager.vars); + // On récupère la user d'uid donné dans l'URL api.send({path:'userDefault/getById', id_user:pageManager.vars[1]}, function(response){ + console.warn('user to remove', response); // Si aucune erreur et un résultat if( response.ModuleError == 0 ){ - found_remove = [ response.user ]; // On récupère le résultat + found_remove = [ response.user ]; // On récupère le résultat searchindex_remove = 0; // On remet le compteur à 0 autofill_remove(); // On auto-remplit } diff --git a/public_html/view/js/view.js b/public_html/view/js/view.js new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/js/warehouse.js b/public_html/view/js/warehouse.js new file mode 100644 index 0000000..e69de29 diff --git a/public_html/view/view.php b/public_html/view/view.php index 13ca764..844757a 100755 --- a/public_html/view/view.php +++ b/public_html/view/view.php @@ -12,7 +12,7 @@ - +