"Added: Add componant feature"
This commit is contained in:
BIN
static/images/save.png
Normal file
BIN
static/images/save.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 357 B |
@@ -15,6 +15,33 @@ function setcookie(cname, cvalue, exdays) {
|
||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||
}
|
||||
|
||||
function getcookie(cname) {
|
||||
var value = "; " + document.cookie;
|
||||
var parts = value.split("; " + cname + "=");
|
||||
if (parts.length == 2) return parts.pop().split(";").shift();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Eye candies
|
||||
///////////////////////////////////////////
|
||||
|
||||
function invalid_input(obj) {
|
||||
obj.style.backgroundColor = light_red;
|
||||
setTimeout( function() {
|
||||
obj.style.backgroundColor = base_bg;
|
||||
}
|
||||
, 2000);
|
||||
}
|
||||
|
||||
function valid_input(obj) {
|
||||
obj.style.backgroundColor = light_green;
|
||||
obj.style.borderColor = base_border;
|
||||
setTimeout( function() {
|
||||
obj.style.backgroundColor = base_bg;
|
||||
}
|
||||
, 2000);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Update result
|
||||
///////////////////////////////////////////
|
||||
@@ -26,18 +53,16 @@ function update_componants() {
|
||||
};
|
||||
|
||||
xhttp.onload = function(){
|
||||
if (xhttp.status == 200) {
|
||||
var response = xhttp.responseText;
|
||||
obj.innerHTML = response;
|
||||
return;
|
||||
if (xhttp.status != 200) {
|
||||
obj.innerHTML = "Erreur lors de la mise à jour de la liste (2)"
|
||||
}
|
||||
obj.innerHTML = "Erreur lors de la mise à jour de la liste (2)"
|
||||
};
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||||
var response = xhttp.responseText;
|
||||
obj.innerHTML = response;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
xhttp.open('POST', '/componants/update', true);
|
||||
@@ -117,51 +142,86 @@ function confirm_delete() {
|
||||
return confirm(msg)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// New componant
|
||||
///////////////////////////////////////////
|
||||
function new_componant() {
|
||||
var err = false;
|
||||
var obj = {};
|
||||
if (getcookie('c_count') > 0){
|
||||
var errr = true;
|
||||
obj[0] = document.getElementById('reference');
|
||||
}
|
||||
if (getcookie('c_designation').length < 1){
|
||||
var err = true;
|
||||
obj[1] = document.getElementById('designation');
|
||||
}
|
||||
if (getcookie('c_place').length < 1){
|
||||
var err = true;
|
||||
obj[2] = document.getElementById('place');
|
||||
}
|
||||
if (err == true) {
|
||||
for (i in obj){
|
||||
invalid_input(obj[i]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
create_componant();
|
||||
update_componants();
|
||||
}
|
||||
|
||||
function create_componant() {
|
||||
var MSG='Erreur lors de la creation de la référence.';
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onerror = function(){
|
||||
alert(MSG);
|
||||
return false;
|
||||
};
|
||||
|
||||
xhttp.onload = function(){
|
||||
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||||
var response = xhttp.responseText;
|
||||
if (response == 'OK'){
|
||||
return true;
|
||||
}
|
||||
alert(MSG);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
xhttp.open('POST', '/componants/new', true);
|
||||
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Update componant
|
||||
///////////////////////////////////////////
|
||||
function update_componant(obj, componant_id, type) {
|
||||
if (type == 'numeric') {
|
||||
if (isNaN(obj.value)) {
|
||||
alert('Valeur numérique uniquement');
|
||||
alert('Valeur numérique uniquement: '+obj.value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onerror = function(){
|
||||
obj.style.backgroundColor = light_red;
|
||||
setTimeout( function() {
|
||||
obj.style.backgroundColor = base_bg;
|
||||
}
|
||||
, 2000);
|
||||
invalid_input(obj);
|
||||
};
|
||||
|
||||
xhttp.onload = function(){
|
||||
var bg_color = light_red;
|
||||
var border_color = red;
|
||||
if (xhttp.status == 200) {
|
||||
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||||
var response = xhttp.responseText;
|
||||
if (response == 'OK'){
|
||||
bg_color = light_green;
|
||||
border_color = base_border;
|
||||
}
|
||||
}
|
||||
obj.style.backgroundColor = bg_color;
|
||||
obj.style.borderColor = border_color;
|
||||
setTimeout( function() {
|
||||
obj.style.backgroundColor = base_bg;
|
||||
valid_input(obj);
|
||||
return;
|
||||
}
|
||||
, 2000);
|
||||
obj.style.borderColor = red;
|
||||
invalid_input(obj);
|
||||
}
|
||||
};
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||||
var reponse = xhttp.responseText;
|
||||
if (xhttp.responseText != 'OK')
|
||||
obj.style.backgroundColor = light_red;
|
||||
}
|
||||
};
|
||||
xhttp.open('POST', '/componants/update/'+componant_id, true);
|
||||
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
xhttp.send('field='+obj.id+'&value='+obj.value);
|
||||
|
||||
@@ -139,16 +139,9 @@ div.content {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
div.git_desc, pre {
|
||||
border-style: solid;
|
||||
border-color: #FF5D00;
|
||||
border-width: 1px;
|
||||
background-color: #FFFFFF;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
div.git_desc {
|
||||
text-align: justify;
|
||||
div.note {
|
||||
font-size: 12px;
|
||||
line-height: 12px;
|
||||
}
|
||||
|
||||
div.error {
|
||||
@@ -206,13 +199,17 @@ div.result_container {
|
||||
border-right-style: solid;
|
||||
}
|
||||
|
||||
div.block {
|
||||
div.block, div.noborder {
|
||||
overflow: hidden;
|
||||
border-top-style: solid;
|
||||
border-top-width: 1px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
div.noborder {
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
div.inner{
|
||||
overflow: hidden;
|
||||
float: center;
|
||||
@@ -260,10 +257,19 @@ div.block text.refresh {
|
||||
|
||||
div.block text.search {
|
||||
background: url(../images/search.png);
|
||||
margin-left: 275px;
|
||||
margin-left: 255px;
|
||||
}
|
||||
|
||||
div.inner text.edit:hover, div.inner text.trash:hover, div.block text.refresh:hover, div.block text.search:hover{
|
||||
div.block text.save {
|
||||
background: url(../images/save.png);
|
||||
margin-left: 32px;
|
||||
}
|
||||
|
||||
div.inner text.edit:hover,
|
||||
div.inner text.trash:hover,
|
||||
div.block text.refresh:hover,
|
||||
div.block text.search:hover,
|
||||
div.block text.save:hover{
|
||||
background-color: #FFB387;
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -277,7 +283,11 @@ div.inner text.edit {
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
div.inner text.trash, div.inner text.edit, div.block text.refresh, div.block text.search {
|
||||
div.inner text.trash,
|
||||
div.inner text.edit,
|
||||
div.block text.refresh,
|
||||
div.block text.search,
|
||||
div.block text.save {
|
||||
width: 8px;
|
||||
float:left;
|
||||
height: 16px;
|
||||
@@ -286,11 +296,11 @@ div.inner text.trash, div.inner text.edit, div.block text.refresh, div.block tex
|
||||
}
|
||||
|
||||
div.even {
|
||||
background-color: #FFFFFF;
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
|
||||
div.odd {
|
||||
background-color: #E5E5E5;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
div.block label {
|
||||
|
||||
Reference in New Issue
Block a user