keemor.com - Surfin' JavaScript Wave

Prototype Archive



by keemor

Twitter API: Strumień wpisów po słowie kluczowym w PHP, JSON i Prototype

W serwisie Twitter.com pojawia się bardzo dużo wpisów na wiele różnych tematów. Pokażę dzisiaj jak przy pomocy API Twittera, PHP, JSON’a i PrototypeJS zrobić prosty gadżet, który będzie co jakiś czas odpytywać się o nowe wpisy na dany temat i automatycznie je wyświetlać.

ZOBACZ DEMO »

Twitter API: Strumień wpisów po słowie kluczowym w PHP, JSON i Prototype
Read More


by keemor

Simple Edit In Place feature using ierange library

Recently I found ierange library which is a great implementation of W3C DOM Ranges for Internet Explorer.

Using it and PrototypeJS I’ve created edit in place feature to easily change the content of a div element.

Check out the DEMO »


<head>
...
<!--[if IE]>
<script type="text/javascript" src="ierange-m2.js"></script>
< ![endif]-->
...
</head>

<body>	
	<div id="eip">  
		<div id="start">Click to edit and start typing. <br />Enter to confirm. ESC to reset.</div>
		<div id="text">This is some simple text which you can easily change if you want this is some simple text which you can easily change if you want</div>			 
	</div> 
</body>

Read More


by keemor

Load content while scrolling with Prototype and JSON-P via Yahoo API

Today I’d like to present my solution for loading content while scrolling down the page in the DZone style using PrototypeJS library.

Check out simple DEMO »
Demo was tested in Firefox, Chrome, IE7/8 and Opera.

I used Yahoo Local Search API as a JSON data source for keyword kitesurfing.

Here is simple table where data will be put.


<body id="body">
    <table id="table-scroll">
        <tr><th>Name</th><th>Address</th><th>City</th></tr>
        <tbody id="result"></tbody>
    </table>
    <div id="loader">
        <img src="loader.gif" />
    </div>
</body>

Read More


by keemor

Twitter API: Stream of messages for query with PHP, JSON and Prototype

Last week Antonio Lupetti presented on his blog turorial on Twitter API: How to create a stream of messages Monitter-like with PHP and jQuery.

I would like to present how I did such widget using PrototypeJS and JSON.
I left html and css unchanged and you can CHECK OUT DEMO HERE.
I used JSON-PHP library to convert $results list of objects into JSON.

search.php


< ?
header('Content-type: application/json'); 
//Set header to application/json to easily read JSON in javascript
require_once "lib/twitterapi.php";
require_once "lib/JSON.php";

if($_POST['twitterq']){
	$twitter_query= $_POST['twitterq'];
	$search = new TwitterSearch($twitter_query);
	$results = $search->results();
	foreach($results as $result){
		$result->text=toLink($result->text);			
	}	
	$json = new Services_JSON();
	echo $json->encode($results);
 }
?>

Read More