Jump to: navigation, search

Storage API HTML Sample

<meta http-equiv="content-script-type" content="text/javascript">
<script src="http://code.jquery.com/jquery-1.7.1.min.js"
   type="text/javascript"></script>
<script type="text/javascript">
jQuery.support.cors = true;
   
var storageId = "";
var defaults = {
      Key1: 'Value1',
      Key2: 'Value2',
      Key3: 'Value3',
      FileKey: 'FileKey',
   ttl: 3600,
    CreateData: '{ "a":"valuea", "b":"valueb", "c":"valuec" }',
   UpdateData: '{ "a":"new_valuea", "d":"new_valued" }'
};
function doPost( url, callback )
{
   var data = new Object();
   data[ 'a' ] = $("#Key1").val();
   data[ 'b' ] = $("#Key2").val();
   data[ 'c' ] = $("#Key3").val();
   
   $.post( url, data, callback );
   return;
}
function query() {
   $.get( '/genesys/1/storage/' + storageId, function(data) {
         $("#query_result_label").text( JSON.stringify( data ) );
      });
}
function create() {
   doPost('/genesys/1/storage/' + $("#ttl").val(), function( result ) {
      storageId = result.id;
      $("#storage_id_label").text( storageId );
   });
}
function update() {
   if ( storageId == '' ) return;
   doPost('/genesys/1/storage/' + storageId + "/" + $("#ttl").val() );
}
function del() {
   $.ajax({
        type: 'DELETE',
        url: '/genesys/1/storage/' + storageId
      });
}
$(function(){
    $("#Control input").each(function () {
        $(this).val(defaults[this.id]);
    });
    $("#create").click(function () {     
      create();
    });
    $("#query").click(function () {
      query();
    });
    $("#update").click(function () {
      update();
    });
    $("#delete").click(function () {
      del();
    });
});
</script>
<b>GSG Storage Test Controls</b>
<div id="Control">
   <div>
      <label for="ttl">TTL</label><input id="ttl">
   </div>
   <div>
      <label for="Key1">Key1</label><input id="Key1">
   </div>
   <div>
      <label for="Key2">Key2</label><input id="Key2">
   </div>
   <div>
      <label for="Key3">Key3</label><input id="Key3">
   </div>
</div>
<button id="create">Create</button>
<button id="update">Update</button>
<button id="query">Query</button>
<button id="delete">Delete</button>
<p />
<div>Storage id:</div>
<div id="storage_id_label"></div>
<div>Query results:</div>
<div id="query_result_label"></div>
<div></div>
This page was last edited on April 11, 2018, at 17:30.
Comments or questions about this documentation? Contact us for support!