summaryrefslogtreecommitdiff
path: root/views/gnucapjs/gnucap-io.js
blob: defb5d91e416a1abae5ef64ab8fc99b261950667 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

  
//       var statusElement = document.getElementById('gnucap_scope_display_div');
//       var progressElement = document.getElementById('progress');
//       var spinnerElement = document.getElementById('spinner');
      var spicenetlist="";
 
      Module = {
	preRun: [function(){
	  FS.writeFile("/temp",spicenetlist);
		 }],
        postRun:[function(){
		 }],
	arguments:["-b","/temp"],
        print:function(text) {
	    text = Array.prototype.slice.call(arguments).join(' ');
	    postMessage(text+'\n');
	    },
	printErr: function(text) {
          text = Array.prototype.slice.call(arguments).join(' ');
          if (0) { // XXX disabled for safety typeof dump == 'function') {
            dump(text + '\n'); // fast, straight to the real console
          } else {
            console.log(text);
          }
	      
       },
//        canvas: document.getElementById('canvas'),
        setStatus: function(text) {
	  if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
          if (text === Module.setStatus.text) return;
          var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
          var now = Date.now();
          if (m && now - Date.now() < 30) return; // if this is a progress update, skip it if too soon
       if (m) {
            text = m[1];
          } else {
//code is finished
	      if (!text){
		postMessage("SIMULATION COMPLETED");
		}
          }
        },
      };
      self.addEventListener("message", function(e) {
	spicenetlist=e.data
      // the passed-in data is available via e.data
	importScripts("gnucap-ugly.js");
      }, false);
      Module.TOTAL_MEMORY=67108864;
      Module.setStatus('Downloading...');