Ignore:
Timestamp:
29/03/16 20:39:03 (4 years ago)
Author:
mjuckes
Message:

Adding basic json download to mipVars.html

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMIP6dreqbuild/trunk/src/framework/websiteExtras/mipVars.html

    r614 r622  
    3636<div id="section"> 
    3737    <h1>MIP Variables -- search</h1> 
     38 
     39<a id="export" class="myButton" download="" href="#">export</a> 
    3840<center><it><sm>Powered bc <a href="https://github.com/mleibman/SlickGrid/">SlickGrid</a> JavaScript</sm></it></center> 
    3941<div> 
     
    6365<script src="/js/SlickGrid/slick.gridP.js"></script> 
    6466 
    65 <script src="data/mipVarsData.js"></script> 
     67<script src="data/data3.js"></script> 
    6668 
    6769<script> 
     
    126128  } 
    127129 
     130  /*** function to enable download of selected items. Passed to dataView below. 
     131  ***/ 
     132  function createDownloadLink(items){ 
     133        var anchorSelector = "#export"; 
     134        var fileName = "selected_json.txt"; 
     135        if(window.navigator.msSaveOrOpenBlob) { 
     136            blobObject = new Blob(items); 
     137            $(anchorSelector).click(function(){ 
     138                window.navigator.msSaveOrOpenBlob(blobObject, fileName); 
     139            }); 
     140        } else { 
     141            var url = "data:text/plain;charset=utf-8," + encodeURIComponent(items); 
     142            $(anchorSelector).attr("download", fileName); 
     143            $(anchorSelector).attr("href", url); 
     144        } 
     145  } 
     146 
    128147  $(function () { 
    129148    dataView = new Slick.Data.DataView(); 
     
    162181    dataView.beginUpdate(); 
    163182    dataView.setItems(data); 
     183    dataView.setDownl(createDownloadLink); 
    164184    dataView.setFilter(filter); 
    165185    dataView.endUpdate(); 
     186 
    166187  }) 
     188 
     189 
    167190 
    168191</script> 
Note: See TracChangeset for help on using the changeset viewer.