compute.handlebars 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>SPAMAP</title>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <!--===============================================================================================-->
  8. <!--===============================================================================================-->
  9. <link rel="stylesheet" type="text/css" href="/computeDependencies/vendor/bootstrap/css/bootstrap.min.css">
  10. <!--===============================================================================================-->
  11. <link rel="stylesheet" type="text/css" href="/computeDependencies/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
  12. <!--===============================================================================================-->
  13. <link rel="stylesheet" type="text/css" href="/computeDependencies/vendor/animate/animate.css">
  14. <!--===============================================================================================-->
  15. <link rel="stylesheet" type="text/css" href="/computeDependencies/vendor/css-hamburgers/hamburgers.min.css">
  16. <!--===============================================================================================-->
  17. <link rel="stylesheet" type="text/css" href="/computeDependencies/vendor/select2/select2.min.css">
  18. <!--===============================================================================================-->
  19. <link rel="stylesheet" type="text/css" href="/computeDependencies/css/util.css">
  20. <link rel="stylesheet" type="text/css" href="/computeDependencies/css/main.css">
  21. <!--===============================================================================================-->
  22. </head>
  23. <body>
  24. <div class="bg-contact3" style="background-image: url('/images/home-4.jpg');">
  25. <div class="container-contact3">
  26. <div class="wrap-contact3">
  27. <form class="contact3-form validate-form"
  28. ref="testForm"
  29. id="testForm"
  30. action="/compute"
  31. method="post"
  32. encType="multipart/form-data">
  33. <span class="contact3-form-title">
  34. S P A M A P
  35. </span>
  36. <br>
  37. <div class="label-ligne" data-validate="informations about Method">
  38. <hr width="50%" color="white" align=left size="4" style="margin-right: 10px;">
  39. <label class="label-title">Methods</label>
  40. <hr width="50%" color="white" align=right size="4" style="margin-left:10px;">
  41. </div><br>
  42. <div class="checks">
  43. <label class="label-parameters2"><input type="checkbox" id="constr">With Constraint
  44. <span class="checkmark"></span>
  45. </label>
  46. </div>
  47. <div class="checks" id="born">
  48. <label class="label-parameters2"><input type="checkbox" id="born2">Bounded
  49. <span class="checkmark"></span>
  50. </label>
  51. </div>
  52. <div class="checks" id="aft">
  53. <label class="label-parameters2"><input type="checkbox" id="aft2">After
  54. <span class="checkmark"></span>
  55. </label>
  56. </div>
  57. <br><br><br>
  58. <div class="wrap-input3 input3-select">
  59. <select name="meth" class="selection-2" id="sel">
  60. <option value="0" id="0">alphabetadiv_WNMF</option>
  61. <option value="1" id="1">Fevotte(Ges,Fes)</option>
  62. </select>
  63. <span class="focus-input3"></span>
  64. </div><br>
  65. <span id="info3"></span>
  66. <style type="text/css">
  67. #info3{
  68. color: #fff;
  69. margin-left: 70px;
  70. margin-top: 10px;
  71. text-align: center;
  72. }
  73. </style>
  74. <br><br><br>
  75. <div class="label-ligne">
  76. <hr width="50%" color="white" align=left size="10px" style="margin-right: 10px;">
  77. <label class="label-title">Parameters</label>
  78. <hr width="50%" color="white" align=right size="4" style="margin-left:10px;">
  79. </div><br>
  80. <div class="wrap-input3" data-validate="Name is required">
  81. <label class="label-parameters">Alpha</label>
  82. <input class="input3" type="number" name="alpha" value="0.6" id="alph" onchange="verify()">
  83. <span class="focus-input3"></span>
  84. </div>
  85. <div class="wrap-input3" data-validate="Name is required">
  86. <label class="label-parameters">Beta</label>
  87. <input class="input3" type="number" name="beta" value="0.9" id="bet" onchange="verify()">
  88. <span class="focus-input3"></span>
  89. </div>
  90. <div class="wrap-input3" data-validate="Name is required">
  91. <label class="label-parameters">NumberOfIterations</label>
  92. <input class="input3" type="number" name="nIt" placeholder="NB iter value" id="nbIt" onchange="verify()" min="1" max="100000" maxlength="5" onkeypress="return isNumeric(event)" oninput="maxLengthCheck(this)">
  93. <span class="focus-input3"></span>
  94. </div>
  95. <script type="text/javascript">
  96. function maxLengthCheck(object) {
  97. if (object.value > 100000){
  98. object.value = 100000;
  99. }
  100. }
  101. function isNumeric (evt) {
  102. var theEvent = evt || window.event;
  103. var key = theEvent.keyCode || theEvent.which;
  104. key = String.fromCharCode (key);
  105. var regex = /[0-9]|\./;
  106. if ( !regex.test(key) ) {
  107. theEvent.returnValue = false;
  108. if(theEvent.preventDefault) theEvent.preventDefault();
  109. }
  110. }
  111. </script>
  112. <br><br><br>
  113. <div class="label-ligne">
  114. <hr width="50%" color="white" align=left size="4" style="margin-right: 10px;">
  115. <label class="label-title">Options</label>
  116. <hr width="50%" color="white" align=right size="1114" style="margin-left:10px;">
  117. </div><br>
  118. <div class="checks show-info" info-bulle="informations about compute Ginit">
  119. <label class="label-parameters2"><input type="checkbox" name="ginit" id="ginit">Compute Ginit
  120. <span class="checkmark"></span>
  121. </label>
  122. </div>
  123. <div class="checks show-info" info-bulle="informations about Physical Model">
  124. <label class="label-parameters2"><input type="checkbox" name="modph" id="modph">Physical Model
  125. <span class="checkmark"></span>
  126. </label>
  127. </div>
  128. <div class="checks show-info" info-bulle="informations about Per source">
  129. <label class="label-parameters2"><input type="checkbox">Per source
  130. <span class="checkmark"></span>
  131. </label>
  132. </div>
  133. <br><br>
  134. <div class="container-contact3-form-btn">
  135. <input type="file" name="foo" id="real-btn" hidden="hidden" onchange="verify()">
  136. <button type=button class="contact3-form-btn" id="inp">
  137. Input Data
  138. </button>
  139. <button type="submit" class="contact3-form-btn" id="comp">
  140. Compute
  141. </button>
  142. </form>
  143. <br><br><span id="info" >No File chosen, yet.</span>
  144. <style type="text/css">
  145. #info{
  146. color: #fff;
  147. margin-left: 70px;
  148. margin-top: 10px;
  149. }
  150. </style>
  151. <br>
  152. <span id="info2" ></span>
  153. <style type="text/css">
  154. #info2{
  155. color: #b21818;
  156. margin-left: 70px;
  157. margin-top: 10px;
  158. }
  159. </style>
  160. <span id="NameFile" hidden="hidden"></span>
  161. </div>
  162. </div>
  163. <script type="text/javascript">
  164. const realFileBtn = document.getElementById('real-btn');
  165. inp.addEventListener("click",function() {
  166. realFileBtn.click();
  167. });
  168. </script>
  169. </div>
  170. </div>
  171. <div id="dropDownSelect1"></div>
  172. <!--===============================================================================================-->
  173. <script src="/computeDependencies/vendor/jquery/jquery-3.2.1.min.js"></script>
  174. <!--===============================================================================================-->
  175. <script src="/computeDependencies/vendor/bootstrap/js/popper.js"></script>
  176. <script src="/computeDependencies/vendor/bootstrap/js/bootstrap.min.js"></script>
  177. <script src="/computeDependencies/js/snbutton.js"></script>
  178. <script>
  179. /*$(document).ready(function(){
  180. SNButton.init("comp",{
  181. fields:["radio2","alph","bet","nbIt"],
  182. enabletext: "Compute",
  183. disabletext: "can't Compute"
  184. })
  185. });*/
  186. $('#comp').attr('disabled',true);
  187. $('#comp').text('Can\'t Compute');
  188. function verify(){
  189. var info = document.getElementById('info');
  190. if($('#alph').val().trim() == '' || $('#bet').val().trim() == '' || $('#nbIt').val().trim() == '' || $('#info2').html()=="No File chosen, yet." || $('#info2').html()!="file accepted" )
  191. {
  192. $('#comp').attr('disabled',true);
  193. $('#comp').text('Can\'t Compute');
  194. }
  195. else{
  196. $('#comp').attr('disabled',false);
  197. $('#comp').text('Compute');
  198. }
  199. }
  200. $('#real-btn').change(function(e){
  201. var file=e.target.files[0];
  202. if(file!=null){
  203. var info = document.getElementById('info');
  204. var NameFile = document.getElementById('NameFile');
  205. info.innerHTML=realFileBtn.value.match(/[\/\\]([\w\d\s\.\-\(\)]+)$/)[1];
  206. NameFile.innerHTML=realFileBtn.value.match(/[\/\\]([\w\d\s\.\-\(\)]+)$/)[1];
  207. info.innerHTML+=" is the chosen input file";
  208. var extension=file.name.replace(/^.*\./, "");
  209. if(extension=="xls" || extension=="xlsx"){
  210. if($('#alph').val().trim() == '' || $('#bet').val().trim() == '' || $('#nbIt').val().trim() == '')
  211. {
  212. $('#comp').attr('disabled',true);
  213. $('#comp').text('Can\'t Compute');
  214. $('#info2').css("color", "#0fc643");
  215. $('#info2').html("file accepted");
  216. }else{
  217. $('#comp').attr('disabled',false);
  218. $('#comp').text('Compute');
  219. $('#info2').css("color", "#0fc643");
  220. $('#info2').html("file accepted");
  221. }
  222. }else{
  223. $('#comp').attr('disabled',true);
  224. $('#comp').text('Can\'t Compute');
  225. $('#info2').css("color", "#b21818");
  226. $('#info2').html("error : invalid extension file");
  227. }
  228. }else{
  229. $('#comp').text('Can\'t Compute');
  230. $('#comp').attr('disabled',true);
  231. $('#info2').html("");
  232. $('#info').text("No File chosen, yet.");
  233. }
  234. });
  235. </script>
  236. <!--===============================================================================================-->
  237. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  238. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/xlsx.full.min.js"></script>
  239. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/jszip.js"></script>
  240. <script type="text/javascript">
  241. $(document).ready(function(){
  242. $("body").on("change", "#real-btn", function () {
  243. //Reference the FileUpload element.
  244. var fileUpload = $("#real-btn")[0];
  245. //Validate whether File is valid Excel file.
  246. var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.xls|.xlsx)$/;
  247. if (regex.test(fileUpload.value.toLowerCase())) {
  248. if (typeof (FileReader) != "undefined") {
  249. var reader = new FileReader();
  250. //For Browsers other than IE.
  251. if (reader.readAsBinaryString) {
  252. reader.onload = function (e) {
  253. ProcessExcel(e.target.result);
  254. };
  255. reader.readAsBinaryString(fileUpload.files[0]);
  256. } else {
  257. //For IE Browser.
  258. reader.onload = function (e) {
  259. var data = "";
  260. var bytes = new Uint8Array(e.target.result);
  261. for (var i = 0; i < bytes.byteLength; i++) {
  262. data += String.fromCharCode(bytes[i]);
  263. }
  264. ProcessExcel(data);
  265. };
  266. reader.readAsArrayBuffer(fileUpload.files[0]);
  267. }
  268. } else {
  269. alert("This browser does not support HTML5.");
  270. }
  271. } else {
  272. alert("Please upload a valid Excel file.");
  273. }
  274. });
  275. function ProcessExcel(data) {
  276. //Read the Excel File data.
  277. var workbook = XLSX.read(data, {
  278. type: 'binary'
  279. });
  280. //Fetch the name of First Sheet.
  281. var Sheet1 = workbook.SheetNames[0];
  282. var Sheet2 = workbook.SheetNames[1];
  283. var Sheet3 = workbook.SheetNames[2];
  284. var Sheet4 = workbook.SheetNames[3];
  285. var Sheet5 = workbook.SheetNames[4];
  286. var Sheet6 = workbook.SheetNames[5];
  287. var Sheet7 = workbook.SheetNames[6];
  288. var Sheet8 = workbook.SheetNames[7];
  289. var Sheet9 = workbook.SheetNames[8];
  290. if (Sheet1!="X"||Sheet2!="Incertitude"||Sheet3!="Finit"||Sheet4!="Omega"||Sheet5!="Phi"){
  291. $('#info2').css("color", "#b21818");
  292. $('#info2').html("error : Please upload a valid Excel file.");
  293. $('#comp').attr('disabled',true);
  294. $('#comp').text('Can\'t Compute');
  295. }
  296. if($('#born2').prop("checked")){
  297. if (Sheet6!="OmegaI"||Sheet7!="PhiMax"||Sheet8!="PhiMin"){
  298. $('#info2').css("color", "#b21818");
  299. $('#info2').html("error : Please upload a valid Excel file.");
  300. $('#comp').attr('disabled',true);
  301. $('#comp').text('Can\'t Compute');
  302. }
  303. }
  304. if($('#ginit').prop("checked")){
  305. if (Sheet9!="Ginit"){
  306. $('#info2').css("color", "#b21818");
  307. $('#info2').html("error : Please upload a valid Excel file.");
  308. $('#comp').attr('disabled',true);
  309. $('#comp').text('Can\'t Compute');
  310. }
  311. }
  312. };
  313. });
  314. </script>
  315. <!--===============================================================================================-->
  316. <script src="/computeDependencies/vendor/select2/select2.min.js"></script>
  317. <script>
  318. $(".selection-2").select2({
  319. minimumResultsForSearch: 20,
  320. dropdownParent: $('#dropDownSelect1')
  321. });
  322. $('#born').hide();
  323. $(document).ready(function(){
  324. $('#constr').click(function(){
  325. if($(this).prop("checked")){
  326. $('#born').show();
  327. $("#sel").append('<option value="2" id="2">CWNMF_SGM_S2_AB(Ges,Fes)</option>');
  328. $("#sel").append('<option value="3" id="3">CWNMF_SGM_11(Ges,Fes)</option>');
  329. $("#sel").append('<option value="4" id="4">N1CWNMFV1(Ges, Fes)</option>');
  330. $("#sel").append('<option value="5" id="5">N1CWNMFR(Ges, Fes)</option>');
  331. $("#sel").append('<option value="6" id="6">N2CWNMF(Ges, Fes)</option>');
  332. $("#sel").append('<option value="7" id="7">N2CWNMFR(Ges,Fes)</option>');
  333. $("#sel").append('<option value="8" id="8">CWNMF_Huber_S1_11(Ges,Fes,0.2,0.2)</option>');
  334. $("#sel").append('<option value="9" id="9">CWNMF_Huber_S2_11(Ges,Fes,0.2,0.2)</option>');
  335. }else{
  336. $('#born').hide();
  337. $('#aft').hide();
  338. $('#2').remove();$('#3').remove();$('#4').remove();
  339. $('#5').remove();$('#6').remove();$('#7').remove();
  340. $('#8').remove();$('#9').remove();
  341. }
  342. });
  343. });
  344. $('#aft').hide();
  345. $('#born2').change(function(){
  346. if($(this).prop("checked")){
  347. $("#sel").append('<option value="10" id="10">BN1CWNMF(Ges, Fes)</option>');
  348. $("#sel").append('<option value="11" id="11">BN1CWNMFR(Ges, Fes)</option>');
  349. $("#sel").append('<option value="12" id="12">BN2CWNMF(Ges, Fes)</option>');
  350. $("#sel").append('<option value="13" id="13">BN2CWNMFR(Ges,Fes)</option>');
  351. $('#aft').show();
  352. }else{
  353. $('#aft').hide();
  354. $('#10').remove();$('#11').remove();$('#12').remove();
  355. $('#13').remove();
  356. }
  357. });
  358. $('#aft2').change(function(){
  359. if($(this).prop("checked")){
  360. $("#sel").append('<option value="14" id="14">N1BCWNMF(Ges, Fes)</option>');
  361. $("#sel").append('<option value="15" id="15">N1BCWNMFR(Ges, Fes)</option>');
  362. $("#sel").append('<option value="16" id="16">N2BCWNMF(Ges, Fes)</option>');
  363. $("#sel").append('<option value="17" id="17">N2BCWNMFR(Ges,Fes)</option>');
  364. }else{
  365. $('#14').remove();$('#15').remove();$('#16').remove();
  366. $('#17').remove();
  367. }
  368. });
  369. </script>
  370. <!--===============================================================================================-->
  371. <script type="text/javascript">
  372. $("select.selection-2").change(function(){
  373. $('#info3').text('informations about : '+$('option:selected').text());
  374. if($('option:selected').attr("id")==3 || $('option:selected').attr("id")==8 || $('option:selected').attr("id")==9 ){
  375. $('#alph').val(1);
  376. $('#bet').val(1);
  377. }else{
  378. $('#alph').val(0.6);
  379. $('#bet').val(0.9);
  380. }
  381. });
  382. </script>
  383. <!--========================================command to server=======================================================-->
  384. <script type="text/javascript">
  385. $('#comp').on('click',function(){
  386. //alert("Go ahead");
  387. var command ="./NMFIHM ";
  388. command+="chemin/";
  389. command+=$('#NameFile').html();
  390. command+=" ";
  391. command+=$('#nbIt').val();
  392. command+=" ";
  393. command+=$('option:selected').attr("id");
  394. command+=" ";
  395. if($('#ginit').prop("checked")){
  396. command+=" 1 ";
  397. }else{
  398. command+=" 0 ";
  399. }
  400. if($('#modph').prop("checked")){
  401. command+=" 1 ";
  402. }else{
  403. command+=" 0 ";
  404. }
  405. command+=$('#alph').val();
  406. command+=" ";
  407. command+=$('#bet').val();
  408. command+=" ../res/resv1.xls";
  409. console.log(command);
  410. });
  411. </script>
  412. <!--===============================================================================================-->
  413. <script src="/computeDependencies/js/main.js"></script>
  414. <!-- Global site tag (gtag.js) - Google Analytics -->
  415. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-23581568-13"></script>
  416. <script>
  417. window.dataLayer = window.dataLayer || [];
  418. function gtag(){dataLayer.push(arguments);}
  419. gtag('js', new Date());
  420. gtag('config', 'UA-23581568-13');
  421. </script>
  422. </body>
  423. </html>