-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix README.md
- Loading branch information
Showing
111 changed files
with
92,362 additions
and
592 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions
32
Benchmark/obj/demo_pack_gzip_compress_with_base64/GzipJSON.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Class GzipJSON | ||
* Class to decompress gzipped string to JSON. | ||
*/ | ||
class GzipJSON { | ||
/** | ||
* Private method that implements the inflate of the data. | ||
* @param $data | ||
* @private | ||
* @return string | ||
*/ | ||
private function decode_gzip( $data ) | ||
{ | ||
return gzinflate( substr( $data, 10, -8 ) ); | ||
} | ||
|
||
/** | ||
* Method that returns an associated array via json_decode; | ||
* @param $data | ||
* @return mixed | ||
*/ | ||
function decompress( $data ) | ||
{ | ||
$json = json_decode( $this->decode_gzip( utf8_decode( base64_decode( $data ) ) )); | ||
if ( is_null( $json ) ) | ||
{ | ||
$json = json_decode( $data ); | ||
} | ||
return $json; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
include_once('GzipJSON.php'); | ||
|
||
if ( isset( $_POST['json'] ) ) | ||
{ | ||
$gzjson = new GzipJSON(); | ||
$json = $gzjson->decompress($_POST['json']); | ||
$json->test2 = 3; | ||
echo json_encode($json); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
Benchmark/obj/demo_pack_gzip_compress_with_base64/js/app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
$(function() { | ||
$( "#accordion_data, #accordion_usage, #accordion_server" ).accordion( { active: false, collapsible: true } ); | ||
$("#clean_compress_json_data_button").click(function() | ||
{ | ||
$("#results_compress_json_data").html(""); | ||
return false; | ||
}); | ||
$("#compress_json_data_1_button").click(function(event) | ||
{ | ||
var compressedJSON = JSONC.compress( obj ); | ||
var stringCompressedJSON = JSON.stringify(compressedJSON); | ||
$("#results_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>"); | ||
return false; | ||
}); | ||
$("#compress_json_data_2_button").click(function(event) | ||
{ | ||
var compressedJSON = JSONC.compress( obj2 ); | ||
var stringCompressedJSON = JSON.stringify(compressedJSON); | ||
$("#results_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" ); | ||
return false; | ||
}); | ||
$("#clean_pack_json_data_button").click(function() | ||
{ | ||
$("#results_pack_json_data").html(""); | ||
return false; | ||
}); | ||
$("#pack_json_data_1_button").click(function(event) | ||
{ | ||
var stringCompressedJSON = JSONC.pack( obj ); | ||
$("#results_pack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>"); | ||
return false; | ||
}); | ||
$("#pack_json_data_2_button").click(function(event) | ||
{ | ||
var stringCompressedJSON = JSONC.pack( obj2 ); | ||
$("#results_pack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" ); | ||
return false; | ||
}); | ||
|
||
$("#clean_pack_compress_json_data_button").click(function() | ||
{ | ||
$("#results_pack_compress_json_data").html(""); | ||
return false; | ||
}); | ||
$("#pack_compress_json_data_1_button").click(function(event) | ||
{ | ||
var stringCompressedJSON = JSONC.pack( obj, true ); | ||
$("#results_pack_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>"); | ||
return false; | ||
}); | ||
$("#pack_compress_json_data_2_button").click(function(event) | ||
{ | ||
var stringCompressedJSON = JSONC.pack( obj2, true ); | ||
$("#results_pack_compress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" ); | ||
return false; | ||
}); | ||
|
||
$("#clean_decompress_json_data_button").click(function() | ||
{ | ||
$("#results_decompress_json_data").html(""); | ||
return false; | ||
}); | ||
$("#decompress_json_data_1_button").click(function(event) | ||
{ | ||
var oComp = JSONC.compress( obj ); | ||
var stringCompressedJSON = JSON.stringify( JSONC.decompress( oComp ) ); | ||
$("#results_decompress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>"); | ||
return false; | ||
}); | ||
$("#decompress_json_data_2_button").click(function(event) | ||
{ | ||
var oComp = JSONC.compress( obj2 ); | ||
var stringCompressedJSON = JSON.stringify( JSONC.decompress( oComp ) ); | ||
$("#results_decompress_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" ); | ||
return false; | ||
}); | ||
|
||
$("#clean_unpack_json_data_button").click(function() | ||
{ | ||
$("#results_unpack_json_data").html(""); | ||
return false; | ||
}); | ||
$("#unpack_json_data_1_button").click(function(event) | ||
{ | ||
var gzipped = JSONC.pack( obj ); | ||
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped ) ); | ||
$("#results_unpack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>"); | ||
return false; | ||
}); | ||
$("#unpack_json_data_2_button").click(function(event) | ||
{ | ||
var gzipped = JSONC.pack( obj2 ); | ||
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped ) ); | ||
$("#results_unpack_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" ); | ||
return false; | ||
}); | ||
|
||
|
||
$("#clean_unpack_compress_json_data_button").click(function() | ||
{ | ||
$("#results_unpack_compressed_json_data").html(""); | ||
return false; | ||
}); | ||
$("#unpack_compress_json_data_1_button").click(function(event) | ||
{ | ||
var gzipped = JSONC.pack( obj, true ); | ||
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped, true ) ); | ||
$("#results_unpack_compressed_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>"); | ||
return false; | ||
}); | ||
$("#unpack_compress_json_data_2_button").click(function(event) | ||
{ | ||
var gzipped = JSONC.pack( obj2, true ); | ||
var stringCompressedJSON = JSON.stringify( JSONC.unpack( gzipped, true ) ); | ||
$("#results_unpack_compressed_json_data").html( "<div class='size'>" + stringCompressedJSON.length + " bytes.</div> <div>" + stringCompressedJSON + "</div>" ); | ||
return false; | ||
}); | ||
}); | ||
$("form").submit(function(event) | ||
{ | ||
var sObj, nLenObjStr, sZipped, nLenZipped; | ||
sObj = JSON.stringify( obj ); | ||
nLenObjStr = sObj.length; | ||
sZipped = JSONC.pack( obj, true ); | ||
nLenZipped = sZipped.length; | ||
|
||
console.log( 'Original:', sObj, nLenObjStr ); | ||
console.log( 'Send:', sZipped, nLenZipped ); | ||
$.ajax({ | ||
url: "/obj/demo_pack_gzip_compress_with_base64/alo.php", | ||
type: "POST", | ||
data: { json: sZipped }, | ||
dataType: 'json', | ||
success: function( data ) | ||
{ | ||
document.getElementById('info_server').innerHTML = 'Press F12 to open developer tools and check the console tab'; | ||
data = JSONC.decompress( data ); //version compact | ||
console.log('Data:', data, JSON.stringify(data).length); | ||
}, | ||
error: function() | ||
{ | ||
console.log.apply(console, arguments); | ||
} | ||
}); | ||
event.preventDefault(); | ||
}); |
Oops, something went wrong.