OSDN Git Service

wits update
[vem/WITs.git] / JS / log.js
1 //log instance
2 var LoadLogMemory = new LogMemory();
3 var GETLogMemory = LoadLogMemory.LogMemoryInstance();
4 var MemoryAll = LoadLogMemory.GETLog();
5 //URL instance
6 var userSetting = new GetUrlElement();
7 var UrlElement = userSetting.GetUrlElementInstance();
8
9
10 /*
11 LogMemory()
12  Memory()
13 LogCollect()
14 LogSimplePhotoCondtionText()
15 */
16
17 function LogMemory(Log){
18   console.log("log");
19   var arg = new Array();
20   var i=0;
21   return {
22     LogMemoryInstance: function(log) {
23       arg[i] = log;
24       console.log(i);
25       console.log(arg[i]);
26       console.log(JSON.stringify(arg));
27       i = i + 1;
28       return arg;
29     },
30     GETLog: function(){
31       var argall = "";
32       for(var j=1;j<i;j++){
33         argall= JSON.stringify(arg);
34       }
35       console.log(argall);
36       return argall;
37     },
38   }
39 }
40
41 function LogCollect(logsave){
42   var date = new Date();
43   var logArray = new Array(2048);
44   var movex = $("#movex").val();
45   var movey = $("#movey").val();
46   var movez = $("#movez").val();
47   var movea = $("#movea").val();
48   var spotSize = $("#spotSize").val();
49   var magnificationA = $("#magnificationA").val();
50   var magnificationR = $("#magnificationR").val();
51   var binning = $("#binnig").val();
52   var size = $("#size").val();
53   var exptime = $("#exptime").val();
54   var Year = date.getFullYear();
55   var Month = date.getMonth() + 1;
56   var day = date.getDate();
57   var Hours = date.getHours();
58   var Minutes = date.getMinutes();
59   var Seconds = date.getSeconds();
60   var  data = Year.toString() +'_'+ Month.toString() +'_'+ day.toString()+'_'+Hours.toString()+'_'+Minutes.toString()+'_'+Seconds.toString();
61
62   var log =
63   { "time":data ,
64    "x":movex ,
65    "y":movey ,
66    "z":movez ,
67    "a":movea ,
68    "imageSize":size ,
69    "binning":binning ,
70    "exptime":exptime ,
71    "spotSize":spotSize ,
72    "magR":magnificationA ,
73    "magA":magnificationR ,
74   };
75
76   //logArray[i] = log;
77 //  i=i++;
78 console.log(log);
79     logArray.push(log);
80
81     console.log(logArray[2048]);
82     LogMemory(log);
83     LoadLogMemory.LogMemoryInstance(log);
84 /*  if(logsave == 0){
85     logArray.push(log);
86   LogSimplePhotoCondtionText(logArray,data);
87 }*/
88 }
89
90 function LogSimplePhotoCondtionText(logArray,data){
91   //ファイル名を取得、デフォルトは「mytext」
92   //      var name = document.getElementById('saveEmConditionFileName').value = 'mytext';
93   //テキストファイルを作成
94   var blob = new Blob([logArray], {type: 'text/plain'});
95   //リンクを取得
96   var linkcondition = document.getElementById('DL_link_condition');
97   //リンクにダウンロードするファイルをセット
98   linkcondition.href = window.URL.createObjectURL(blob);
99   //もしダウンロード属性に対応していたら
100   if ('download' in linkcondition) {
101     var Data = UrlElement['sendManufacturer'] + "_Log_" + data ;
102     //リンクにダウンロードする名前をセット
103     linkcondition.download = Data + '.txt';
104     //リンクをクリックしてダウンロードさせる
105     linkcondition.click();
106     //もし対応してなかったら
107   } else {
108     //メッセージを表示する
109     linkcondition.textContent = '右クリックから名前を付けて保存してください';
110   }
111 }
112
113 $(function(){
114   $("#logsave").click(function(){
115       var date = new Date();
116     var Year = date.getFullYear();
117     var Month = date.getMonth() + 1;
118     var day = date.getDate();
119     var data = Year.toString() +''+ Month.toString() +''+ day.toString();
120     LogSimplePhotoCondtionText(JSON.stringify(GETLogMemory),data);
121   });
122 });