Plugins  LAST
 All Data Structures Files Functions Variables Pages
importcard.js
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Dany De Bontridder <dany@alchimerys.be>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 Format = {
19  save:function() {
20  var p_name=$("format_name").value;
21  if (String.trim(p_name)==0) {
22  smoke.alert("Nom est vide");
23  return false;
24  }
25  if ( ! $('format_save_id') )
26  {
27  smoke.alert("format_save_id not found");
28  return false;
29  }
30  var request={
31  ac:js_ac,
32  gDossier:js_dossier,
33  plugin_code:js_plugin_code,
34  format_name:p_name,
35  format_id:$('format_save_id').value,
36  "format_save":1
37  };
38  new Ajax.Request("ajax.php",{
39  method:"post",
40  parameters:request,
41  onSuccess:function(req) {
42  $('format_save_div').update(req.responseText);
43  }
44  });
45  return false;
46  } ,
47  /**
48  * Apply the format and show the result
49  * @returns {Boolean}
50  */
51  apply:function () {
52  // Take the selected format_id
53  // // var fiche_def=$('rfichedef').options[$('rfichedef').selectedIndex].value;
54 
55  var format_id=$('template_id').options[$('template_id').selectedIndex].value;
56 
57  // create request
58  var request={
59  ac:js_ac,
60  gDossier:js_dossier,
61  plugin_code:js_plugin_code,
62  format_id:format_id,
63  getFormat:1
64  };
65 
66  // Send it to ajax
67  new Ajax.Request("ajax.php",{
68  method:"get",
69  parameters:request,
70  onSuccess:function(req) {
71  // Parse the answer
72  var json=req.responseText.evalJSON(true);
73  $("rdelimiter").value=json.rdelimiter;
74  $("encodage").checked=(json.encodage=="Y")?true:false;
75  // Problème avec le double quote
76  // $("rsurround").value=json.rsurround;
77  $("skip_row").value=json.skip_row;
78  var i=0;var e=0;
79  var header=document.getElementsByName("head_col[]");
80  for (i=0;i<header.length;i++){
81  var t=header[i];
82  if ( json.f_position[i] <= header.length)
83  {
84 
85  for (e=0;e<t.options.length;e++ ) {
86  if ( t.options[e].value==json.f_position[i]) {
87  t.selectedIndex=e;
88  }
89  }
90  } else {
91  t.selectedIndex=-1;
92  }
93  }
94 
95  }
96  });
97  return true;
98 
99  }
100 
101 };
$p_year value
Format
Definition: importcard.js:18