main.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. $(document).ready(function(){
  2. Chart.defaults.global.responsive = true;
  3. $('canvas[id^="chart_"]').each(function(i,element){
  4. var graphic = new Chart($(element)[0].getContext("2d"));
  5. var conf = {
  6. labels : eval($(element).data('hours')),
  7. datasets:[
  8. {
  9. label : $(element).data('label'),
  10. fillColor : "rgba(220,220,220,0.2)",
  11. strokeColor : "#FCB150",
  12. data : $(element).data('data')
  13. }
  14. ]
  15. };
  16. graphic.Line(conf);
  17. });
  18. })
  19. //Ajout / Modification
  20. function plugin_propise_save(element){
  21. var form = $(element).closest('fieldset');
  22. var data = form.toData();
  23. data.action = 'propise_save_sensor'
  24. $.action(data,
  25. function(response){
  26. alert(response.message);
  27. form.find('input').val('');
  28. location.reload();
  29. }
  30. );
  31. }
  32. //Supression
  33. function plugin_propise_delete(id,element){
  34. if(!confirm('Êtes vous sûr de vouloir faire ça ?')) return;
  35. $.action(
  36. {
  37. action : 'propise_delete_sensor',
  38. id: id
  39. },
  40. function(response){
  41. $(element).closest('tr').fadeOut();
  42. }
  43. );
  44. }