Ignore:
Timestamp:
17/08/16 09:23:24 (4 years ago)
Author:
mjuckes
Message:

candiate 01.beta.33

File:
1 edited

Legend:

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

    r622 r714  
    2323    } 
    2424  </style> 
     25 
    2526</head> 
    2627<body> 
     
    6667 
    6768<script src="data/data3.js"></script> 
     69<script> 
     70var urlParams; 
     71(window.onpopstate = function () { 
     72    var match, 
     73        pl     = /\+/g,  // Regex for replacing addition symbol with a space 
     74        search = /([^&=]+)=?([^&]*)/g, 
     75        decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }, 
     76        query  = window.location.search.substring(1); 
     77 
     78    urlParams = {}; 
     79    while (match = search.exec(query)) 
     80       urlParams[decode(match[1])] = decode(match[2]); 
     81})(); 
     82</script> 
    6883 
    6984<script> 
     
    129144 
    130145  /*** function to enable download of selected items. Passed to dataView below. 
     146 ... could replace items with getItems and place assignment in anchorSelector.onclick/click 
    131147  ***/ 
    132148  function createDownloadLink(items){ 
     
    134150        var fileName = "selected_json.txt"; 
    135151        if(window.navigator.msSaveOrOpenBlob) { 
    136             blobObject = new Blob(items); 
     152            blobObject = new Blob(items.json()); 
    137153            $(anchorSelector).click(function(){ 
    138154                window.navigator.msSaveOrOpenBlob(blobObject, fileName); 
    139155            }); 
    140156        } else { 
    141             var url = "data:text/plain;charset=utf-8," + encodeURIComponent(items); 
     157            /*** 
     158             var url = "data:text/plain;charset=utf-8," + encodeURIComponent(items()); 
     159             $(anchorSelector).attr("download", fileName); 
     160             $(anchorSelector).attr("href", url); 
     161           ***/ 
     162            $(anchorSelector).click( function(){ 
     163            var url = "data:text/plain;charset=utf-8," + encodeURIComponent(items.json()); 
    142164            $(anchorSelector).attr("download", fileName); 
    143165            $(anchorSelector).attr("href", url); 
     166           }); 
    144167        } 
    145168  } 
     
    149172    grid = new Slick.Grid("#myGrid", dataView, columns, options); 
    150173 
    151  
    152174    dataView.onRowCountChanged.subscribe(function (e, args) { 
    153175      grid.updateRowCount(); 
     
    159181      grid.render(); 
    160182    }); 
    161  
    162183 
    163184    $(grid.getHeaderRow()).delegate(":input", "change keyup", function (e) { 
     
    181202    dataView.beginUpdate(); 
    182203    dataView.setItems(data); 
     204 
    183205    dataView.setDownl(createDownloadLink); 
    184206    dataView.setFilter(filter); 
     207 
    185208    dataView.endUpdate(); 
    186209 
     210  /*** this writes text to the input box, but fails to trigger the filter action ... 
     211  Multiple variations of trigger, onchange etc tried .... 
     212  Explicit setting of columnFilters appears to be critical here. 
     213  ***/ 
     214    if ("variable" in urlParams) { 
     215      document.getElementsByTagName("input")[0].value = urlParams["variable"] ; 
     216      columnFilters[0] = urlParams["variable"] ; 
     217      dataView.refresh(); 
     218      }; 
     219 
    187220  }) 
    188221 
    189222 
     223</script> 
     224<script> 
    190225 
    191226</script> 
Note: See TracChangeset for help on using the changeset viewer.