Guest User

detail

a guest
Jul 9th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.20 KB | None | 0 0
  1. {% extends "base.html" %}
  2.  
  3.  
  4. {% block head %}
  5. <style>
  6. body {
  7. font: 13px verdana, sans-serif;
  8. }
  9.  
  10. select.target {
  11. width: 80px;
  12. //font-size: 14px;
  13. }
  14.  
  15. .unit {
  16. width: 60px;
  17. }
  18.  
  19.  
  20.  
  21. </style>
  22.  
  23.  
  24.  
  25. <script>
  26.  
  27. $(document).ready(function() {
  28.  
  29.  
  30. $('.target').change(function() {
  31.  
  32. parent = $(this).parents();
  33.  
  34. var uneref= $('p.rep .materiau').text(); // formule chimique
  35. var index = parent.find('td.prop input').val(); // propriete
  36.  
  37. var temp = $(this).val();
  38.  
  39. $.getJSON("{% url run_DHM %}", {'temperature': temp, 'propriete': index, 'reference': uneref }, function(data) {
  40.  
  41. donnees = data['val_T'];
  42. donnees_min = data['val_min'];
  43. donnees_max = data['val_max'];
  44. donnees_ref = data['laval_ref'];
  45. valeurmoy = data['valmoy'];
  46.  
  47. nomfichier = data['laval_ref'];
  48.  
  49. document.getElementById('target_ahref').innerHTML = nomfichier
  50.  
  51.  
  52. id = data['id'];
  53.  
  54.  
  55. //alert('id='+id);
  56.  
  57. if(temp== '' ) {
  58.  
  59. $('.target.pinc-'+ id).empty();
  60.  
  61. $('.min.pinc-'+ id).html(donnees_min[0]);
  62. $('.max.pinc-'+ id).html(donnees_max[0]);
  63. $('.moy.pinc-'+ id).html(valeurmoy[0]);
  64. if(donnees != null) {
  65. $.each(donnees, function(ind, item) {
  66. $('.target.pinc-'+ id).append('<option value="'+ ind +'">'+ item +'</option>');
  67.  
  68. }); // each
  69.  
  70. }
  71.  
  72. }
  73.  
  74. else {
  75. parent.children("td.min").html(donnees_min[temp]);
  76. parent.children("td.max").html(donnees_max[temp]);
  77. parent.children('.moy.pinc-'+ id).html(valeurmoy[temp]);
  78. }
  79.  
  80. // $(this).parent().attr("href", donnees_ref);
  81. // $(this).parents().find("td.ref")attr("href", donnees_ref);
  82. // $(this).parent().children("td.ref").attr("href",donnees_ref);
  83. // $("#target_ahref").attr("href",donnees_ref);
  84. // parent.children("td.ref").append($(donnees_ref))
  85.  
  86. }); // getjson
  87.  
  88.  
  89. }); // change(function()
  90.  
  91. $('.target').change();
  92.  
  93. }); // document).ready
  94.  
  95.  
  96.  
  97. </script>
  98.  
  99. {% endblock %}
  100.  
  101. {% block content %}
  102.  
  103.  
  104.  
  105. <body bgcolor="F7FBFA">
  106.  
  107. {% if object.get_physical_properties %}
  108.  
  109. <ul>
  110. <p class= "rep" ><TT>
  111. <strong><font size="4" color="black">Material : </font></strong>
  112.  
  113. <font size="4" color="red"> <strong><span class="materiau">{{ object }}</span></strong></font>
  114.  
  115. </TT></p>
  116. {% for prop in object.get_physical_properties|slice:":1" %}
  117. <TT> {{ prop.name.description|linebreaks }}</TT>
  118. {% endfor %}
  119.  
  120.  
  121. {% for prop in object.get_physical_properties %}
  122.  
  123. {% ifchanged prop.nature_unit %} {# test sur le changement de categorie (mecanique, physique...) avec la precedente #}
  124. <thead>
  125. <p style=background-color:PowderBlue;> <TT><font size="4" color="black"><strong> {{prop.nature_unit}} </strong></font></TT></p>
  126. </thead>
  127.  
  128.  
  129.  
  130. {% for media in object.get_medias %}
  131. {% ifequal prop.nature_unit media.nature %} {# test l'egalite sur la propriete #}
  132. <a href="{{ media.source.url }}">{{ media.name }} {{ media.get_format_display }}</a>
  133. {% endifequal %}
  134. {% endfor %}
  135.  
  136.  
  137.  
  138.  
  139. <form action="/run_DHM/" method="POST">
  140.  
  141. <table width="100%" border="1" style="border: 0.5px;" cellspacing="0" cellpadding="0" >
  142. <thead>
  143. <tr bgcolor="dddddd">
  144. <td width="130" style="text-align:center"><TT><strong>Property </strong></TT></td>
  145. <td width="100" style="text-align:center"><TT><strong>Temperature (&#176C)</strong></TT></td>
  146. <td width="60" style="text-align:center"><TT><strong>min value </strong></TT></td>
  147. <td width="60" style="text-align:center"><TT><strong>max value</strong></TT></td>
  148. <td width="60" style="text-align:center"><TT><strong>average </strong></TT></td>
  149. <td width="200" style="text-align:center"><TT><strong>Reference</strong></TT></td>
  150.  
  151. </tr>
  152. </thead>
  153.  
  154. <tr>
  155.  
  156. <tfoot>
  157.  
  158. <p class= "rep3" width="100" style= "display:none;">{{prop.choix}}</p>
  159. <td class= "prop" width="130" ><TT><INPUT type="text" size="31" value="{{prop.choix}}" id ="driver" name="propriete"/></TT></td>
  160.  
  161. <td width="100"><select class="target pinc-{{prop.id}}" name="temperature" id= "temperature" style="background-color:#EFF0E8;">
  162. <option selected></option>
  163. </select>
  164. </td>
  165.  
  166. <td class= "min pinc-{{prop.id}}" width="60" ><TT> {{ prop.val1|floatformat:2}}</TT> </td>
  167. <td class= "max pinc-{{prop.id}}" width="60" ><TT>{{prop.val2|floatformat:2}}</TT> </td>
  168. <td class= "moy pinc-{{prop.id}}" width="60" ><TT>{{prop.val3|floatformat:2}}</TT> </td>
  169. <td class="ref" width="200" ><TT><a id="target_ahref" href="{{ STATIC_URL }}medias/{{ prop.title }}"> {{ prop.title }} </a></TT></td>
  170.  
  171.  
  172.  
  173.  
  174.  
  175. </tr>
  176. </tfoot>
  177. </table>
  178. </form>
  179.  
  180.  
  181.  
  182. {% else %} {# pas de changement de categorie avec la precedente #}
  183.  
  184. <form action="/run_DHM/" method="POST">
  185.  
  186. <table width="100%" border="1" style="border: 0.5px;" cellspacing="0" cellpadding="0" >
  187.  
  188. <tr>
  189.  
  190.  
  191.  
  192.  
  193.  
  194. <tfoot>
  195.  
  196. <p class= "rep3" width="100" style= "display:none;">{{prop.choix}}</p>
  197.  
  198. <td class= "prop" width="130" ><TT><INPUT type="text" size="31" value="{{prop.choix}}" id ="driver" name="propriete"/></TT></td>
  199.  
  200. <td width="100"><select class= "target pinc-{{prop.id}}" name="temperature" id= "temperature" style="background-color:#EFF0E8;">
  201. <option selected></option>
  202. </select>
  203. </td>
  204.  
  205. <td class= "min pinc-{{prop.id}}" width="60" ><TT> {{ prop.val1|floatformat:2}}</TT> </td>
  206. <td class= "max pinc-{{prop.id}}" width="60" ><TT>{{prop.val2|floatformat:2}} </TT> </td>
  207. <td class= "moy pinc-{{prop.id}}" width="60" ><TT>{{prop.val3|floatformat:2}}</TT> </td>
  208. <td class="ref" width="200" ><TT><a id="target_ahref" href="{{ STATIC_URL }}medias/{{ prop.title }}"> {{ prop.title }} </a></TT></td>
  209.  
  210.  
  211.  
  212. </tr>
  213. </tfoot>
  214. </table>
  215. </form>
  216.  
  217.  
  218. {% endifchanged %}
  219.  
  220. {% endfor %}
  221.  
  222. </ul>
  223.  
  224.  
  225. <a href="javascript:history.go(-1)">back page</a> |
  226.  
  227. <a href="{% url edition_media object.pk %}">Editing form testing temperature </a> | <a href="{% url edition object.id %}">Editing general form </a>
  228.  
  229.  
  230. {% else %}
  231.  
  232. <font size="3" color="black">aucune donnee materiau...</font>
  233. <a href="{% url edition object.pk %}">Editing general form </a> | <a href="{% url material_category_root %}">Back</a>
  234. {#<a href="javascript:history.go(-1)">Back </a>#}
  235.  
  236.  
  237.  
  238.  
  239. {% endif %}
  240.  
  241. {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment