Permalink
Browse files

r2611@opsdev009 (orig r131759): srush | 2008-11-13 19:35:33 -0800

 repackage facebook client lib with json, try 2
  • Loading branch information...
1 parent c2c5306 commit 0bb984f32e6d47ce28ccc6a28617717cda70c6a2 (no author) committed Nov 14, 2008
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,21 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,6 @@
+<?php
+# In PHP 5.2 or higher we don't need to bring this in
+if (!function_exists('json_encode')) {
+ require_once 'jsonwrapper_inner.php';
+}
+?>
@@ -0,0 +1,23 @@
+<?php
+
+require_once 'JSON/JSON.php';
+
+function json_encode($arg)
+{
+ global $services_json;
+ if (!isset($services_json)) {
+ $services_json = new Services_JSON();
+ }
+ return $services_json->encode($arg);
+}
+
+function json_decode($arg)
+{
+ global $services_json;
+ if (!isset($services_json)) {
+ $services_json = new Services_JSON();
+ }
+ return $services_json->decode($arg);
+}
+
+?>
View
@@ -2,10 +2,10 @@
These links demonstrate the Ajax object:<br />
<form id="ajax_form">
-<a href="#" onclick="do_ajax(Ajax.JSON); return false;">JSON</a><br />
-<a href="#" onclick="do_ajax(Ajax.RAW); return false;">RAW</a><br />
-<a href="#" onclick="do_ajax(Ajax.FBML); return false;">FBML</a><br />
-<label><input type="checkbox" id="requirelogin" checked="unchecked" /><span>Require Login?</span></label><br />
+<a href="#" id="json" onclick="do_ajax(Ajax.JSON); return false;">JSON</a><br />
+<a href="#" id="raw" onclick="do_ajax(Ajax.RAW); return false;">RAW</a><br />
+<a href="#" id="fbml" onclick="do_ajax(Ajax.FBML); return false;">FBML</a><br />
+<label><input type="checkbox" id="requirelogin" /><span>Require Login?</span></label><br />
<div><span id="ajax1"></span><span id="ajax2"></span></div>
<input type="hidden" name="array[]" value="1" />
<input type="hidden" name="array[]" value="2" />
@@ -25,8 +25,8 @@ function do_ajax(type) {
switch (type) {
case Ajax.JSON:
ajax.ondone = function(data) {
- document.getElementById('ajax1').setTextValue(data.message + ' The current time is: ' + data.time + '. ');
- document.getElementById('ajax2').setInnerFBML(data.test[0].fbml_test);
+ document.getElementById('ajax1').setTextValue(data.message);
+ document.getElementById('ajax2').setTextValue(data.test[0]);
}
break;
@@ -2,15 +2,10 @@
$user = isset($_POST['fb_sig_user']) ? $_POST['fb_sig_user'] : null;
if ($_GET['t'] == 0) { // Ajax.RAW
- print_r($_POST);
- echo 'This is a raw string. The current time is: '.date('r').', and you are '.($user ? 'uid: #'.$user : 'anonymous').'.';
+ //print_r($_POST);
+ echo 'This is a raw string.';
} else if ($_GET['t'] == 1) { // Ajax.JSON
-// echo '{message: "This is a JSON object.", time: "'.date('r').'", test: [{fbml_test: "Hello, '.($user ? '<fb:name uid='.$user.' useyou=false />' : 'anonymous').'. <a href=\'#\' onclick=\'console.log(1)\'>Click</a>"}]}';
-// echo json_encode(array('message' => range(1,2000)));
- echo '{message: ['.implode(',', range(1,1000)).']}';
+ echo '{message: ['.implode(',', range(1,1000)).'], test: ["1"]}';
} else if ($_GET['t'] == 2) { // Ajax.FBML
- echo '<fb:visible-to-owner>visbile-to-owner</fb:visible-to-owner>This is an FBML string. The current time is: '.date('r').', and you are '.($user ? '<fb:name uid='.$user.' useyou=false />' : 'anonymous').'.<script>function test(){}</script>.';
- echo '<pre>';
- print_r($_POST);
- echo '</pre>';
+ echo 'Hello. There is an event called <fb:eventlink eid="84840295206"/>.';
}
View
@@ -1,12 +1,13 @@
-<a href="#" id="helloWorld" onclick="do_colors(this); return false">Hello World!</a>
+<a href="#" id="helloWorld" onclick="do_colors(this); return false">Hello World</a>
<script><!--
function random_int(lo, hi) {
- return Math.floor((Math.random() * (hi - lo)) + lo)
+ return Math.floor((Math.random() * (hi - lo)) + lo);
}
function do_colors(obj) {
- var r = random_int(0, 255), b = random_int(0, 255), g = random_int(0, 255);
- obj.setStyle({background: 'rgb('+[r, g, b].join(',')+')',
- color: 'rgb('+[r<129?r+128:r-128, g<129?g+128:g-128, b<129?b+128:b-128].join(',')+')'});
+ var r = random_int(0, 255);
+ var other = r<129?r+128:r-128;
+ obj.setInnerXHTML("<div>" + r + "," + other + "</div>");
}
-//--></script>
+//-->
+</script>

0 comments on commit 0bb984f

Please sign in to comment.