-
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.
Change the compression library from lz-string to gzip.js to make it simpler to be implemented in server side Added the PHP class to inflate the compressed data in PHP server. Replace the static example demo with a dynamic demo to be used in a PHP server.
- Loading branch information
Showing
24 changed files
with
11,845 additions
and
825 deletions.
There are no files selected for viewing
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
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
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
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( $data ) ), true ); | ||
if ( is_null( $json ) ) | ||
{ | ||
$json = json_decode( $data, true ); | ||
} | ||
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); | ||
} |
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,38 @@ | ||
#accordion_data div | ||
{ | ||
max-height: 200px; | ||
} | ||
.size | ||
{ | ||
font-family: monospace; | ||
font-size: 20px; | ||
font-weight: bold; | ||
} | ||
.code | ||
{ | ||
font-family: monospace; | ||
font-size: 9px; | ||
} | ||
.fright | ||
{ | ||
float: right; | ||
width: 300px; | ||
} | ||
#accordion_usage .ui-accordion-header | ||
{ | ||
height: 50px; | ||
} | ||
input[type=button], input[type=submit] | ||
{ | ||
font-size: 11px; | ||
} | ||
form div | ||
{ | ||
font-size: 12px; | ||
} | ||
ul | ||
{ | ||
list-style-type: none; | ||
margin: 0; | ||
padding: 0; | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.