Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: a421c6e8de
Fetching contributors…

Cannot retrieve contributors at this time

334 lines (316 sloc) 7.29 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=UTF-8>
<title>$.getContent() tests</title>
<style type="text/css">
textarea {
position: fixed; top: 2em; right: 0;
font-family: monospace;
white-space: nowrap;
}
.support {
color: #080;
}
.not_support {
color: #800;
}
</style>
</head>
<body>
<h2>Support</h2>
<p id="feedSupported">$.getContent.feedSupported</p>
<p id="htmlSupported">$.getContent.htmlSupported</p>
<p id="fileSupported" >$.getContent.fileSupported</p>
<p id="fbSupported" >$.getContent.fbSupported</p>
<p id="supported">$.getContentSupported</p>
<h2>$.getContent(feed);</h2>
<form method="get" action="#" id="feed">
<p>
<label>Feed URL: <input type="url" id="feed_url" size="30" value="http://blog.timc.idv.tw/feed/" /></label>
<input type="submit" value="test" />
</p>
</form>
<h2>$.getContent(html);</h2>
<form method="get" action="#" id="html">
<p>
<label>URL: <input type="url" id="html_url" size="30" value="http://tw.yahoo.com/" /></label>
<input type="submit" value="test" />
</p>
</form>
<h2>$.getContent(file.text);</h2>
<form method="get" action="#" id="file_text">
<p>
<label>File: <input type="file" id="file_text_file" multiple="true" /></label>
<input type="submit" value="test" />
</p>
</form>
<h2>$.getContent(file.html);</h2>
<form method="get" action="#" id="file_html">
<p>
<label>File: <input type="file" id="file_html_file" multiple="true" /></label>
<input type="submit" value="test" />
</p>
</form>
<h2>$.getContent(facebook:me);</h2>
<form method="get" action="#" id="facebook">
<p>
<div id='fb-root'></div>
<input type="submit" value="test" />
</p>
</form>
<h2>$.getContent(facebook:id);</h2>
<form method="get" action="#" id="facebook_id">
<p>
<label>ID: <input type="text" id="facebook_id_uid" size="20" value="109362359103769" /></label>
<input type="submit" value="test" />
</p>
</form>
<h2>$.getContent(googleplus:me);</h2>
<form method="get" action="#" id="googleplus">
<p>
<div id='fb-root'></div>
<input type="submit" value="test" />
</p>
</form>
<h2>$.getContent(googleplus:userid);</h2>
<form method="get" action="#" id="googleplus_id">
<p>
<label>ID: <input type="text" id="googleplus_id_userid" size="20" value="106189723444098348646" /></label>
<input type="submit" value="test" />
</p>
</form>
<textarea id="result" readonly="true" cols="80" rows="30">
</textarea>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="../jquery.getcontent.js"></script>
<script type="text/javascript" src="../go2.js"></script>
<script type="text/javascript">
var FB_app_id = '';
var googleAPIKey = '';
var googleClientId = '';
jQuery(function ($) {
if (!FB_app_id) {
alert('Add your own Facebook App ID to enable Facebook status fetching.');
}
if (!googleAPIKey) {
alert('Add your own Google API Key to enable Google+ posts fetching.');
}
if (!googleClientId) {
alert('Add your own Google Client Id to enable private Google+ posts fetching.');
}
FB.init({
appId : FB_app_id,
status: true,
cookie: true,
xfbml: true
});
GO2.init(
googleClientId
);
$('#feedSupported').addClass(($.getContent.feedSupported?'':'not_') + 'support');
$('#htmlSupported').addClass(($.getContent.htmlSupported?'':'not_') + 'support');
$('#fileSupported').addClass(($.getContent.fileSupported?'':'not_') + 'support');
$('#fbSupported').addClass(($.getContent.fbSupported?'':'not_') + 'support');
$('#supported').addClass(($.getContentSupported?'':'not_') + 'support');
var $r = $('#result');
function start() {
$r.val('start');
}
function beforeComplete (text) {
$r.val('beforeComplete: \n' + text);
}
function complete (text) {
$r.val('Complete: \n' + text);
}
function error(e) {
$r.val(e);
return true;
}
$('#feed').bind(
'submit',
function () {
try {
$.getContent(
$('#feed_url').val(),
{
type: 'feed',
beforeComplete: beforeComplete,
complete: complete
}
);
} catch (e) { error(e); }
start();
return false;
}
);
$('#html').bind(
'submit',
function () {
$.getContent(
$('#html_url').val(),
{
type: 'html',
beforeComplete: beforeComplete,
complete: complete
}
);
start();
return false;
}
);
$('#file_text').bind(
'submit',
function () {
if (!$('#file_text_file')[0].files.length && error('Select a file!')) return false;
try {
$.getContent(
$('#file_text_file')[0].files,
{
type: 'file.text',
beforeComplete: beforeComplete,
complete: complete
}
);
} catch (e) { error(e); }
start();
return false;
}
);
$('#file_html').bind(
'submit',
function () {
if (!$('#file_html_file')[0].files.length && error('Select a file!')) return false;
try {
$.getContent(
$('#file_html_file')[0].files,
{
type: 'file.html',
beforeComplete: beforeComplete,
complete: complete
}
);
} catch (e) { error(e); }
start();
return false;
}
);
$('#facebook').bind(
'submit',
function () {
FB.getLoginStatus(function(response) {
if(response.session) {
test_facebook(response);
} else {
FB.login(
function(response) {
if(response) {
test_facebook(response);
}
},
{
perms:'read_stream'
}
);
}
});
return false;
}
);
function test_facebook(response) {
try {
$.getContent(
response.session.uid,
{
type: 'facebook',
beforeComplete: beforeComplete,
complete: complete
}
);
} catch (e) {error(e); }
start();
return false;
};
$('#facebook_id').bind(
'submit',
function () {
FB.getLoginStatus(function(response) {
if(response.session) {
test_facebook_id();
} else {
FB.login(
function(response) {
if (response) {
test_facebook_id();
}
},
{
perms:'read_stream'
}
);
}
});
return false;
}
);
function test_facebook_id () {
try {
$.getContent(
$('#facebook_id_uid').val(),
{
type: 'facebook',
beforeComplete: beforeComplete,
complete: complete
}
);
} catch (e) {error(e); }
start();
}
$('#googleplus').bind(
'submit',
function () {
GO2.getToken(
test_googleplus
);
return false;
}
);
function test_googleplus(token) {
try {
$.getContent(
'me',
{
type: 'googleplus',
beforeComplete: beforeComplete,
complete: complete,
googleOAuthKey: token//,
//googleAPIKey: googleAPIKey
}
);
} catch (e) {error(e); }
start();
return false;
};
$('#googleplus_id').bind(
'submit',
function () {
try {
$.getContent(
$('#googleplus_id_userid').val(),
{
type: 'googleplus',
beforeComplete: beforeComplete,
complete: complete,
googleAPIKey: googleAPIKey
}
);
} catch (e) {error(e); }
start();
return false;
}
);
});
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.