klenwell information services : JavascriptJedoRfl

Wiki source for JavascriptJedoRfl


Show raw source

===== Javascript JEDO ""RequestFileLite"" Code =====

The code below can be seen in action at [[http://klenwell.googlepages.com/demo.jedo.htm | klenwell googlepages site]].

====code====
%%(html)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

<title>klenwell googlepages : JEDO and RequestFileLite</title>

<meta name="keywords" content="klenwell, design, xhtml, javascript" />
<meta name="description" content="template for http://klenwell.googlepages.com/" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<link rel="stylesheet" type="text/css" href="basic.css" />

<!-- Javascript -->
<script type="text/javascript">
var global_timer_started = 0;
var global_tx0 = 0;
function js_timer()
{
if ( !global_timer_started )
{
global_timer_started = 1;
global_tx0 = new Date();
return;
}
else
{
var tx_now = new Date();
return ( tx_now - global_tx0 ) / 1000;
}
}

// start timer
js_timer();


function div_write(str, inline_style)
{
document.write('<div style="' + inline_style + '">' + str + '</div>');
return;
}
</script>

<!-- Stylesheet -->
<style type="text/css">

/* AkwaForm Settings */
label { font-size:12px; font-weight:bold; display:block; }
.af_textarea { margin:12px 0; }
.af_textarea label { display:block; }

#jedo_akwaform h3 { margin-top:12px; }
#jedo_akwaform h3 a { color:#66cc66; }
#jedo_akwaform h3 a:hover { color:#33ff33; }

</style>
<!-- end Internal Style Sheet -->

</head>

<body>
<div class="page">


<!-- START SCRIPT -->

<!-- load -->
<script type="text/javascript" src="http://klenwell.googlecode.com/svn/trunk/JS/akwaform/akwa.ini.js"></script>
<script type="text/javascript" src="http://klenwell.googlecode.com/svn/trunk/JS/kw.request_file_lite.js"></script>

<!-- RequestFileLite -->
<script type="text/javascript">
var FileLoader = new RequestFileLite();
FileLoader.process_request();
</script>

<!-- Auto Load Data -->
<script type="text/javascript">
if ( FileLoader._GET['include'] != null )
{
//alert("FileLoader._GET['include'] : " + FileLoader._GET['include']);
FileLoader.include_file(FileLoader._GET['include']);
}
</script>

<!-- Data Check (did it load?) -->
<script type="text/javascript">

/*
Notice : this script block separated from that above. I believe this is
necessary for the document to recognize the script/src tag added by
FileLoader.include_file
*/

// look for JEDODEF object
var JEDODEF = ( JEDODEF != null ) ? JEDODEF : null;
var jedo_data_string = '';
var jedo_row_count = 0;
if ( JEDODEF != null )
{
if ( JEDODEF['_i'] == 'jedo-zero' )
{
alert('jedo data successfully loaded');
for ( var i in JEDO )
{
if ( JEDO[i]['blob'] == null ) continue;
jedo_row_count++;
jedo_data_string += '// JEDO ROW #' + jedo_row_count + '\n/* ------------------- */\n';
for ( var key in JEDO[i] )
{
var _type = typeof JEDO[i][key];
//div_write(_type);
if ( _type == 'string' || _type == 'number' ) jedo_data_string += key + ' : ' + JEDO[i][key] + '\n';
}
jedo_data_string += '\n\n';
}
}
}
else if ( FileLoader.requested )
{
alert(FileLoader._GET);
alert('failed to load jedo data');
}
</script>

<!-- END SCRIPT -->






<div id="masthead_panel"><h1>a demonstration of JEDO and RequestFileLite</h1></div>

<!-- CORE PANEL -->
<div id="core_panel">

<div id="core_left">
<div class="child">
<div class="section">
RequestFileLite is designed to offer a simple object interface in javascript
for easily and dependably loading remote data files.
<br /><br />
JEDO (JavaScript/EcmaScript Data Object) is a simple, flexible schema proposed for javascript objects
so that they can be defined and manipulated more like database rows.
</div>

<div class="content">
<div class="section">
<div class="section">
<h4>reference</h4>
<p><a href="http://code.google.com/p/klenwell/">klenwell google code page</a></p>
<p><a href="http://www.klenwell.net/is/">klenwell wiki</a></p>
<p><a href="http://klenwell.googlepages.com/index.htm">klenwell googlepages home</a></p>
</div>
</div>

</div></div></div>

<div id="core_right"><div class="child"><div class="content">

<!-- DEMO SECTION -->
<div id="jedo_akwaform" class="section">
<h4>demo</h4>

<!-- JedoLoaderForm (AkwaForm) -->
<script type="text/javascript">

// load event trigger
function trigger_load_jedo()
{
if ( JedoLoaderForm['jedo_url'].value.search(/^http/) == -1 )
{
alert('please enter a valid data file url (beginning with http...)');
return;
}

var jedo_url = JedoLoaderForm['jedo_url'].value;
var Q_PARAM = new Object();
Q_PARAM['include'] = jedo_url;
var qstring = FileLoader.build_query_string(Q_PARAM);
alert('will load url ' + jedo_url);

// reload window
var autoload_href = FileLoader.base_url + qstring;
window.location = autoload_href;
}

// AkwaForm
var JedoLoaderForm = new AkwaForm(0);
var is_pseudo = 1;
JedoLoaderForm.ini('jloader_form', is_pseudo);

JedoLoaderForm.cx_input_text('jedo_url', 'jedo file url', 0, 60);
// http://klenwell.googlecode.com/svn/trunk/JS/jedo/data.prototype.js or http://localhost/CODE@GOOGLE/KLENWELL/JS/jedo/data.prototype.js
JedoLoaderForm['jedo_url'].value = 'http://klenwell.googlecode.com/svn/trunk/JS/jedo/data.prototype.js';
//JedoLoaderForm.attach_event('jedo_url', 'click', JedoLoaderForm['jedo_url'].select);

JedoLoaderForm.cx_button('load_bx', 'load jedo file');
JedoLoaderForm.attach_event('load_bx', 'click', trigger_load_jedo);

JedoLoaderForm.cx_textarea('jedo_data', 'data', 0, 50, 12);
if ( jedo_data_string != null ) JedoLoaderForm['jedo_data'].value = jedo_data_string;
JedoLoaderForm.publish('jedo_akwaform');

div_write('<h6>js timer: ' + js_timer() + ' s</h6>');
div_write('<h3><a href="'+FileLoader.base_url+'">» start over</a></h3>');
</script>
</div>

<!-- CODE / NOTES -->
<div class="section">
<h4>notes</h4>
<p>Code for this script can be found <a href="http://www.klenwell.net/is/JavascriptJedoRfl">here</a>. The JEDO javascript
file can be viewed directly in the <a href="http://klenwell.googlecode.com/svn/trunk/JS/jedo/data.prototype.js">klenwell code repository</a>. More information
on JEDO is available at the <a href="http://www.klenwell.net/is/JavascriptJedo">klenwell wiki</a>.</p>
<p></p>
</div>

</div></div></div>

<div class="clear"></div>

</div>
<!-- end CORE PANEL -->



<div id="footer_panel" class="clear">
<div class="left"><a href="http://klenwell.googlepages.com/index.htm">klenwell googlepage home</a></div>
<div class="right">
<a href="http://www.spreadfirefox.com/"><img border="0" alt="Get Firefox!" title="Get Firefox!" src="http://sfx-images.mozilla.org/affiliates/Buttons/80x15/firefox_80x15.png"/></a>
</div>
some rights reserved, as always
<div class="clear"></div>
</div>

</div>
</body>
</html>
%%

----
CategoryJavascript