"; if( ("body" in document) && (document.body != null) ) { document.body.appendChild( tmp ); document.body.removeChild( tmp ); } else { if( ("documentElement" in document) && (document.documentElement != null) ) { document.documentElement.appendChild( tmp ); document.documentElement.removeChild( tmp ); } else { var body = document.getElementsByTagName( "body" )[ 0 ]; body.appendChild( tmp ); body.removeChild( tmp ); } } } catch( e ) { ; } function hop_properties_to_string( obj ) { var res = ""; var i = 0; for( var p in obj ) { if( i === 10 ) { res += p + "\n"; i = 0; } else { i++; res += p + " "; } } return res; } function hop_properties_values_to_string( obj ) { var res = ""; var i = 0; for( var p in obj ) { if( i === 10 ) { res += p + "=" + obj[ p ] + "\n"; i = 0; } else { i++; res += p + "=" + obj[ p ] + " "; } } return res; } var hop_is_html_element; if( !("HTMLElement" in window) ) { hop_is_html_element = function hop_is_html_element( obj ) { return (obj != null) && (((obj instanceof Object) || (typeof obj == "object")) && (typeof obj.innerHTML == "string")); } } else { var ifr = document.createElement( "iframe" ); if( ifr instanceof HTMLElement ) { hop_is_html_element = function hop_is_html_element( obj ) { return (obj != null) && (obj instanceof HTMLElement); } } else { var ifproto = ifr.__proto__; hop_is_html_element = function hop_is_html_element( obj ) { return (obj instanceof HTMLElement) || (obj.__proto__ == ifproto); } } } var hop_is_dom_form_element; try { if( undefined instanceof HTMLFormElement ) { hop_is_dom_form_element = function hop_is_dom_form_element( obj ) { return false; }; } else { hop_is_dom_form_element = function hop_is_dom_form_element( obj ) { return obj instanceof HTMLFormElement; }; } } catch( e ) { hop_is_dom_form_element = function hop_is_dom_form_element( obj ) { return hop_is_html_element( obj ) && (obj.tagName === "form"); }; } if( !("HTMLCollection" in window) ) { window.HTMLCollection = function() { return false; }; } if( !("HTMLInputElement" in window) ) { window.HTMLInputElement = function() { return false; }; } if( !("HTMLTextAreaElement" in window) ) { window.HTMLTextAreaElement = function() { return false; }; } if( !("HTMLSelectElement" in window) ) { window.HTMLSelectElement = function() { return false; }; } var hop_make_xml_http_request; if( "XMLHttpRequest" in window ) { var req = new XMLHttpRequest(); if( "overrideMimeType" in req ) { hop_make_xml_http_request = function hop_make_xml_http_request() { var req = new XMLHttpRequest(); return req; } } else { hop_make_xml_http_request = function hop_make_xml_http_request() { return new XMLHttpRequest(); } } } else { if( "ActiveXObject" in window ) { hop_make_xml_http_request = function hop_make_xml_http_request() { try { return new ActiveXObject( "Msxml2.XMLHTTP" ); } catch( e ) { try { return new ActiveXObject( "Microsoft.XMLHTTP" ); } catch( e ) { alert( "*** ERROR: Don't know how to create XMLHttpRequest" ); } } } } else { if( "XMLHttpRequest" in window ) { hop_make_xml_http_request = function hop_make_xml_http_request() { return new XMLHttpRequest(); } } else { hop_make_xml_http_request = function hop_make_xml_http_request() { alert( "*** ERROR: Don't know how to create XMLHttpRequest" ); } } } } var hop_header_content_type; var hop_header_autoconf = hop_make_xml_http_request(); if( typeof hop_header_autoconf.getResponseHeader == "function" ) { hop_header_content_type = function hop_header_content_type( http ) { var h = http.getResponseHeader( "Content-Type" ); if( h ) { var i = h.indexOf( ";" ); if( i >= 0 ) { return h.substring( 0, i ); } else { return h; } } else { return "application/text"; } } } else { hop_header_content_type = function hop_header_content_type( http ) { var hds = http.getAllResponseHeaders(); var i = hds.indexOf( "Content-Type" ); if( i < 0 ) i = hds.indexOf( "content-type" ); if( i < 0 ) i = hds.indexOf( "Content-type" ); if( i < 0 ) return "application/text"; var j = hds.indexOf( "\n", i + 1 ); var s = (j >= 0) ? hds.substring( i, j ) : hds.substring( i, s.length ); var m = s.match( "[ \t:]+([^ \n;]*)" ); if( m ) return m[ 1 ]; else return "application/text"; } } function node_style_set_native( obj, prop, value ) { if( (obj instanceof String) || (typeof obj === "string") ) obj = document.getElementById( obj ); if( sc_isKeyword( prop ) ) prop = sc_keyword2jsstring( prop ); if( !(value instanceof String) && (typeof value !== "string") ) { if( !value && (value != 0) ) { throw new Error( "node-style-set: illegal \"" + prop + "\" value: " + value + " obj: " + obj ); } else { value = value.toString(); } } obj.style.setProperty( prop, value, "" ); } function node_style_set_array( obj, prop, value ) { if( (obj instanceof String) || (typeof obj === "string") ) obj = document.getElementById( obj ); if( sc_isKeyword( prop ) ) prop = sc_keyword2jsstring( prop ); if( !(value instanceof String) && (typeof value !== "string") ) { if( !value && (value != 0) ) { throw new Error( "node-style-set: illegal \"" + prop + "\" value: " + value + " obj: " + obj ); } else { value = value.toString(); } } obj.style[ prop ] = value; } var node_style_set = function( obj, property, value ) { if( (obj instanceof String) || (typeof obj === "string") ) obj = document.getElementById( obj ); if( "setProperty" in obj.style ) { node_style_set = node_style_set_native; return node_style_set_native( obj, property, value ); } else { node_style_set = node_style_set_array; return node_style_set_array( obj, property, value ); } } var hop_active_location_timeout = ((hop_config.cpu_speed < 66) ? 100 : 250); var hop_has_setInterval = true; try { var i = setInterval( function() { ; }, 1000 ); clearInterval( i ); } catch( e ) { var hop_has_setInterval = false; } var hop_add_native_event_listener = undefined; var hop_remove_native_event_listener = undefined; var hop_stop_propagation = undefined; var hop_has_event20 = false; try { hop_has_event20 = document.implementation.hasFeature( "Events" , "2.0" ); } catch( e ) { ; } if( hop_has_event20 ) { hop_add_native_event_listener = function( obj, event, proc, capture ) { if( "addEventListener" in obj ) { return obj.addEventListener( event, proc, capture ); } else { throw new Error( "add-event-listener!: cannot add `" + event + "' listener for object: " + obj ); } } hop_remove_native_event_listener = function( obj, event, proc, capture ) { if( "removeEventListener" in obj ) { return obj.removeEventListener( event, proc, capture ); } else { throw new Error( "remove-event-listener!: cannot remove `" + event + "' listener for object: " + obj ); } } hop_stop_propagation = function( event, def ) { if( !def ) event.preventDefault(); event.stopPropagation(); event.isStopped = true; } } else { hop_add_native_event_listener = function( obj, event, proc, capture ) { var p = function(_) { return proc( window.event ) }; var i = "on" + event + "hdl"; if( obj[ i ] === undefined ) obj[ i ] = []; obj[ i ][ proc ] = p; return obj.attachEvent( "on" + event, p ); } hop_remove_native_event_listener = function( obj, event, proc, capture ) { var i = "on" + event + "hdl"; var h = obj[ i ]; if( h !== undefined ) { var p = obj[ i ][ proc ]; if( p !== undefined ) { h[ p ] = undefined; return obj.detachEvent( "on" + event, p ); } } return false; } hop_stop_propagation = function( event, def ) { if( !def ) event.cancelBubble = true; event.returnValue = false; event.isStopped = true; } } function hop_deinline_image( el, src ) { if( !el.deinlined ) { el.deinlined = true; el.src = src; } } var hop_event_mouse_x = undefined; var hop_event_mouse_y = undefined; var hop_event_mouse_button = undefined; var hop_event_key_code = undefined; /*** META ((export event-value) (peephole: (postfix ".value"))) */ function hop_event_value( evt ) { return evt.value; } /*** META ((export event-response-text) (peephole: (postfix ".responseText"))) */ function hop_event_response_text( evt ) { return evt.responseText; } if( hop_has_event20 ) { hop_event_mouse_x = function hop_event_mouse_x( event ) { return event.pageX; } hop_event_mouse_y = function hop_event_mouse_y( event ) { return event.pageY; } hop_event_key_code = function hop_event_key_code( event ) { return event.which; } } else { hop_event_mouse_x = function hop_event_mouse_x( event ) { if( (document.body != null) && (document.documentElement.scrollLeft != null) ) { return event.clientX + document.documentElement.scrollLeft; } else { return event.clientX + document.body.scrollLeft; } } hop_event_mouse_y = function hop_event_mouse_y( event ) { if( (document.body != null) && (document.documentElement.scrollTop != null) ) { return event.clientY + document.documentElement.scrollTop; } else { return event.clientY + document.body.scrollTop; } } hop_event_key_code = function hop_event_key_code( event ) { return event.keyCode; } } switch( hop_config.mouse_left_button ) { case 0: hop_event_mouse_button = function hop_event_mouse_button( e ) { return e.button + 1; }; break; case 1: hop_event_mouse_button = function hop_event_mouse_button( e ) { return e.button; } break; default: hop_event_mouse_button = function hop_event_mouse_button( e ) { return e.button + (1 - hop_config.mouse_left_button); } } var hop_window_width = undefined; var hop_window_height = undefined; if( isNaN( window.innerWidth ) ) { hop_window_width = function hop_window_width() { return document.documentElement.clientWidth; } hop_window_height = function hop_window_height() { return document.documentElement.clientHeight; } } else { hop_window_width = function hop_window_width() { return window.innerWidth; } hop_window_height = function hop_window_height() { return window.innerHeight; } } function hop_iframe_scroll_height( e ) { if( "contentDocument" in e ) { return e.contentDocument.body.scrollHeight; } else { if( "document" in e ) { return e.document.body.scrollHeight; } else { return iframe.height; } } } function hop_iframe_scroll_width( e ) { if( "contentDocument" in e ) { return e.contentDocument.body.scrollWidth; } else { if( "document" in e ) { return e.document.body.scrollWidth; } else { return iframe.width; } } } var hop_get_selection; if( window.getSelection ) { hop_get_selection = function hop_get_selection() { return window.getSelection().toString(); } } else { if( document.getSelection ) { hop_get_selection = function hop_get_selection() { return document.getSelection().toString(); } } else { hop_get_selection = function hop_get_selection() { if( document.selection ) { return document.selection.createRange().text; } else { return ""; } } } } /* * To use write/prints/... the default-output port has to be set first. * Simply setting SC_DEFAULT_OUT and SC_ERROR_OUT to the desired values * should do the trick. * In the following example the std-out and error-port are redirected to * a DIV. function initRuntime() { function escapeHTML(s) { var tmp = s; tmp = tmp.replace(/&/g, "&"); tmp = tmp.replace(//g, ">"); tmp = tmp.replace(/ /g, " "); tmp = tmp.replace(/\n/g, ""); tmp = tmp.replace(/\t/g, "  "); return tmp; } document.write("
. args) `(hop_dom_create "blockquote" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "body" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "br" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "button" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "canvas" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "caption" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "center" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "cite" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "code" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "col" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "colgroup" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dd" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "del" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dfn" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dir" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "div" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dl" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dt" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "em" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "fieldset" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "font" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "form" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "frame" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "frameset" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h1" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h2" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h3" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h4" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h5" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h6" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "hr" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "html" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "i" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "iframe" ,@args)) */ /*** META (define-macro ( . args) (let ((k (memq :type args))) (if (and (pair? k) (pair? (cdr k)) (or (eq? (cadr k) 'url)) (or (equal? (cadr k) "url"))) `(hop_dom_create "input" :onkeydown (hop_inputurl_keydown this event) ,@args) `(hop_dom_create "input" ,@args)))) */ /*** META (define-macro ( . args) `(hop_dom_create "ins" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "isindex" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "kbd" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "label" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "legend" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "li" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "link" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "map" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "marquee" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "menu" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "meta" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "noframes" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "noscript" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "object" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "ol" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "optgroup" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "option" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "p" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "param" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "pre" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "q" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "s" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "samp" ,@args)) */ /*** META (define-macro (", start ); if( end == -1 ) end = text.indexOf( "", start ); if( (end > start) ) { res = eval( text.substr( start, end - start ) ); } } return res; } try { if( "getElementsByTagName" in node ) { var scripts = node.getElementsByTagName( "script" ); if( scripts && scripts.length > 0 ) { for ( var j = 0; j < scripts.length; j++ ) { if( false && scripts[ j ].childNodes.length > 0 ) { res = eval( scripts[ j ].childNodes[ 0 ].nodeValue ); } else { res = eval( scripts[ j ].innerHTML ); } } } else { return hop_node_eval_from_text( text ); } } else { return hop_node_eval_from_text( text ); } } catch( e ) { alert( e ); throw e; } return res; } function node_style_get( obj, prop ) { if( (obj instanceof String) || (typeof obj === "string") ) obj = document.getElementById( obj ); if( sc_isKeyword( prop ) ) prop = sc_keyword2jsstring( prop ); return obj.style[ prop ]; } function hop_create_element( html ) { var div = document.createElement( 'div' ); div.innerHTML = "IE7 bug" + html; return div.childNodes[ 1 ]; } function hop_create_encoded_element( html ) { return hop_create_element( decodeURIComponent( html ) ); } function hop_innerHTML_set( nid, html ) { var el; if( (nid instanceof String) || (typeof nid == "string") ) { el = document.getElementById( nid ); if( el == undefined ) { alert( "*** ERROR:innerHTML-set! -- cannot find element \"" + nid + "\""); return; } } else { if( !nid ) { alert( "*** ERROR:innerHTML-set! -- illegal element \"" + nid + "\""); return; } el = nid; } if( (html instanceof String) || (typeof html == "string") ) { el.innerHTML = html; hop_node_eval( el, html ); } else if( hop_is_html_element( html ) || sc_isPair( html ) ) { dom_set_child_node( el, html ); if( hop_innerHTML_need_evalp ) hop_node_eval( el, html ); } else { el.innerHTML = html; } } function hop_style_attribute_set( obj, val ) { var expr; if( (val instanceof String) || (typeof val == "string") ) expr = eval( val ); for( var p in expr ) { node_style_set( obj, p, expr[ p ] ); } } function hop_element_x( obj ) { var res = 0; while( obj != null ) { if( typeof obj.offsetLeft == "number" ) res += obj.offsetLeft; else { break; } obj = obj.offsetParent; } return res; } function hop_element_y( obj ) { var res = 0; while( obj != null ) { if( typeof obj.offsetTop == "number" ) res += obj.offsetTop; else { break; } obj = obj.offsetParent; } return res; } function hop_bounding_box( e, m ) { var n; if( (e instanceof String) || (typeof e == "string") ) { n = document.getElementById( e ); } else { n = e; } if( !m ) m = 0; return [ hop_element_x( n ) - m, hop_element_y( n ) - m, n.offsetWidth + (2*m), n.offsetHeight + (2*m) ]; } function hop_bounding_box_to_list( bbox ) { return sc_vector2list( bbox ); } function hop_bounding_box_x( bbox, loc ) { if( arguments.length == 1 ) return bbox[ 0 ]; if( (loc == "w") || (loc == "nw") || (loc == "sw") ) return bbox[ 0 ]; if( (loc == "n") || (loc == "s")) return bbox[ 0 ] + (bbox[ 2 ]/2); if( (loc == "ne") || (loc == "e") || (loc == "se") ) return bbox[ 0 ] + bbox[ 2 ]; return 0; } function hop_bounding_box_y( bbox, loc ) { if( arguments.length == 1 ) return bbox[ 1 ]; if( (loc == "nw") || (loc == "n") || (loc == "ne") ) return bbox[ 1 ]; if( (loc == "e") || (loc == "w")) return bbox[ 1 ] + (bbox[ 3 ]/2); if( (loc == "se") || (loc == "s") || (loc == "sw") ) return bbox[ 1 ] + bbox[ 3 ]; return 0; } function hop_add_event_listener( obj, event, proc, capture ) { if( event == "location" ) return hop_add_active_location_listener( obj, proc ); if( event == "server" ) return hop_add_server_listener( obj, proc, capture ); if( event == "serverready" ) return hop_add_serverready_listener( obj, proc ); if( event == "serverclose" ) return hop_add_serverclose_listener( obj, proc ); if( event == "timeout" ) return hop_add_timeout_listener( obj, proc ); if( (obj.hop_add_event_listener != undefined) && (obj.hop_add_event_listener != hop_add_event_listener) ) return obj.hop_add_event_listener( event, proc, capture ); return hop_add_native_event_listener( obj, event, proc, capture ); } function hop_remove_event_listener( obj, event, proc, capture ) { if( event == "location" ) return hop_remove_active_location_listener( obj, proc ); if( event == "server" ) return hop_remove_server_listener( obj, proc ); if( event == "serverready" ) return hop_remove_serverready_listener( obj, proc ); if( event == "serverclose" ) return hop_remove_serverclose_listener( obj, proc ); if( event == "timeout" ) return hop_remove_timeout_listener( proc ); if( (obj.hop_remove_event_listener != undefined) && (obj.hop_remove_event_listener != hop_remove_event_listener) ) return obj.hop_remove_event_listener( event, proc, capture ); return hop_remove_native_event_listener( obj, event, proc, capture ); } function hop_add_active_location_listener( obj, proc ) { obj.hop_active_location_proc = proc; var i = window.location.href.indexOf( "#" ); if( i === -1 ) { obj.hop_active_location_href = window.location.href; } else { obj.hop_active_location_href = window.location.href.substring( 0, i-1 ); } if( obj.hop_active_location_interval === undefined ) { var check = function() { if( obj.hop_active_location_href !== window.location.href ) { if( obj.hop_active_location_href != window.location.href ) { obj.hop_active_location_href = window.location.href; obj.hop_active_location_proc( window.location ); } } return true; } obj.hop_active_location_interval = setInterval( check, hop_active_location_timeout ); } return false; } function hop_remove_active_location_listener( obj, proc ) { if( obj.hop_active_location_interval != undefined ) { clearInterval( obj.hop_active_location_interval ); obj.hop_active_location_interval = undefined; } } function hop_active_location_set( obj, href ) { window.location.href = href; obj.hop_active_location_href = window.location.href; } var hop_servevt_id = "__hop_serevt_proxy"; var hop_server_event_count = 0; var re = new RegExp( "<[\/]?event[^>]*>", "g" ); function HopServerEvent( n, text, val ) { this.isStopped = false; this.name = n; this.value = val; this.id = hop_server_event_count++; if( typeof text == "string" ) { this.responseText = text.replace( re, "" ); } else { this.responseText = ""; } } var hop_servevt_proxy = false; var hop_servevt_table = {}; var hop_servevt_ctable = {}; var hop_servevt_dlist = null; function start_servevt_ajax_proxy( key ) { if( !hop_servevt_proxy.httpreq ) { var xhr_error_ttl = 6 * 3; var server_ready = false; var register = function( id ) { var svc = hop_service_base() + "/server-event/register?event=" + id + "&key=" + key; var success = function( val, xhr ) { if( !server_ready ) { server_ready = true; hop_trigger_serverready_event( new HopServerReadyEvent() ); } if( val != null ) { xhr_error_ttl = 6 * 3; register( "" ); while( val != null ) { var v = val.car; var id = v.car; var vals = v.cdr; while( vals != null ) { hop_trigger_servevt( id, vals.car, vals.car, false ); vals = vals.cdr; } val = val.cdr; } } } var failure = function( xhr ) { if( !xhr.status && (xhr_error_ttl > 0) && !xhr.getAllResponseHeaders() ) { xhr_error_ttl--; register( id ); } else { hop_servevt_onclose(); } } hop_servevt_proxy.httpreq = hop_send_request( svc, false, success, failure, false, [] ); } var unregister = function( id ) { hop_servevt_proxy.httpreq.abort(); var svc = hop_service_base() + "/server-event/unregister?event=" + id + "&key=" + hop_servevt_proxy.key; hop_servevt_proxy.httpreq = hop_send_request( svc, false, function() { ; }, false, false, [] ); }; hop_servevt_proxy.register = register; hop_servevt_proxy.unregister = unregister; for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { register( p ); } } } } function start_servevt_flash_proxy( key, host, port ) { var object_proxy = function() { return "" + "" + "" + "" + ""; } var embed_proxy = function() { var embed = document.createElement( "embed" ); embed.id = hop_servevt_id; embed.className = "hop-servevt-proxy"; embed.setAttribute( "width", "1px" ); embed.setAttribute( "height", "1px" ); embed.setAttribute( "src", hop_share_directory() + "/flash/HopServevt.swf" ); embed.setAttribute( "type", "application/x-shockwave-flash" ); embed.setAttribute( "name", "__hop_servevt_proxy" ); embed.setAttribute( "swliveconnect", "true" ); embed.setAttribute( "allowScriptAccess", "always" ); embed.setAttribute( "FlashVars", "init=hop_servevt_proxy_flash_init" + "&host=" + host + "&port=" + port + "&key=" + key + "&onevent=hop_trigger_servevt" + "&onclose=hop_servevt_onclose" + "&onerror=hop_servevt_onerror" ); return embed; } var proxy = document.createElement( "div" ); node_style_set( proxy, "position", "fixed" ); node_style_set( proxy, "top", "0" ); node_style_set( proxy, "right", "0" ); node_style_set( proxy, "background", "transparent" ); if( hop_config.flash_markup === "embed" ) { proxy.appendChild( embed_proxy() ); } else { proxy.innerHTML = object_proxy(); } document.body.appendChild( proxy ); document.getElementById( hop_servevt_id ).key = key; return proxy; } function hop_servevt_onerror( msg ) { hop_error( "servevt", new Error( msg ), "internal server event error" ); } function hop_servevt_proxy_flash_init() { hop_flash_minversion_set( 8 ); var pending_events = 0; hop_servevt_proxy = document.getElementById( hop_servevt_id ); var abort = function( id ) { var svc = hop_service_base() + "/server-event/unregister?event=" + id + "&key=" + hop_servevt_proxy.key; hop_servevt_proxy.httpreq = hop_send_request( svc, false, function() {;}, false, false, [] ); } var failure = function( e ) { hop_servevt_onclose(); for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { abort( p ); } } hop_send_request( hop_service_base() + "/server-event/close?key=" + hop_servevt_proxy.key, false, function() {;}, false, false, [] ); } var register = function( id ) { var svc = hop_service_base() + "/server-event/register?event=" + id + "&key=" + hop_servevt_proxy.key + "&flash=true"; var success = function( e ) { if( pending_events > 0 ) { if( pending_events == 1 ) { hop_trigger_serverready_event( new HopServerReadyEvent() ); } pending_events--; } } hop_servevt_proxy.httpreq = hop_send_request( svc, false, success, failure, false, [] ); } hop_servevt_proxy.register = register; hop_servevt_proxy.unregister = function( id ) { abort( id ); } hop_window_onunload_add( failure ); for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { pending_events++; } } if( pending_events > 0 ) { for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { register( p ); } } } else { hop_trigger_serverready_event( new HopServerReadyEvent() ); } } function servevt_flashp( port ) { return port && (hop_config.flash_version >= 8) && (hop_config.flash_external_interface); } function hop_start_servevt_proxy() { hop_servevt_proxy = new Object(); hop_servevt_proxy.register = function( x ) {}; hop_send_request( hop_service_base() + "/server-event/info", false, function( v ) { var host = v[ 0 ]; var port = v[ 1 ]; var key = v[ 2 ]; if( servevt_flashp( port ) ) { try { start_servevt_flash_proxy( key, host, port ); } catch( e ) { hop_error( "hop_start_servevt_proxy", e, "Cannot start flash proxy, port=" + port); } } else { start_servevt_ajax_proxy( key ); } }, function( v ) { throw new Error( "Cannot get server event port number" ); }, true, [] ); } function hop_trigger_servevt( id, text, value, json ) { try { var v = (json ? eval( value, text ) : value); var evt = new HopServerEvent( id, text, v ); var p2 = hop_servevt_table[ id ]; if( sc_isPair( hop_servevt_dlist ) && sc_isPair( hop_servevt_ctable[ id ] ) ) { var p1 = hop_servevt_dlist; while( sc_isPair( p1 ) ) { p1.car( evt ); p1 = p1.cdr; } } evt.isStopped = false; while( sc_isPair( p2 ) ) { try { p2.car( evt ); } catch( exc ) { hop_error( "hop_trigger_servevt [event " + id + "]", exc, p2.car ); } if( evt.isStopped ) break; p2 = p2.cdr; } } catch( exc ) { hop_error( "hop_trigger_servevt [event " + id + "]", exc, value ); } } var hop_serverclose_list = null; var hop_serverclose_triggered = false; function hop_add_serverclose_listener( obj, proc ) { if( obj === document ) { if( hop_serverclose_triggered ) { var evt = new HopServerEvent( "serverclose", false, false ); proc( evt ); } else { hop_serverclose_list = sc_cons( proc, hop_serverclose_list ); } } else { throw new Error( "add-event-listener!: Illegal `serverclose' recipient" + obj ); } } function hop_remove_serverclose_listener( obj, proc ) { if( obj === document ) { hop_serverclose_list = sc_remqBang( proc, hop_serverclose_list ); return true; } else { throw new Error( "remove-event-listener!: Illegal `serverclose' recipient" + obj ); return false; } } function hop_servevt_onclose() { var evt = new HopServerEvent( "serverclose", false, false ); var p = hop_serverclose_list; while( sc_isPair( p ) ) { p.car( evt ); if( evt.isStopped ) break; p = p.cdr; } hop_serverclose_triggered = true; } function hop_add_server_listener( obj, proc, capture ) { if( typeof proc != "function" ) { throw new Error( "Illegal procedure: " + proc ); } if( obj === document ) { hop_servevt_dlist = sc_cons( proc, hop_servevt_dlist ); } else { if( !document.body ) { hop_window_onload_add( function( e ) { hop_add_server_listener( obj, proc, capture ); } ); } else { var o = hop_servevt_table[ obj ]; hop_servevt_table[ obj ] = sc_cons( proc, sc_isPair( o ) ? o : null ); hop_servevt_table[ obj ].hop_servevt = true; if( capture ) { var o = hop_servevt_ctable[ obj ]; hop_servevt_ctable[ obj ] = sc_cons( proc, sc_isPair( o ) ? o : null ); } if( !hop_servevt_proxy ) { hop_start_servevt_proxy(); } else { hop_servevt_proxy.register( obj ); } } } } function hop_remove_server_listener( obj, proc ) { if( obj === document ) { hop_servevt_dlist = sc_remqBang( proc, hop_servevt_dlist ); } else { if( sc_isPair( hop_servevt_table[ obj ] ) ) hop_servevt_table[ obj ] = sc_remqBang( proc, hop_servevt_table[ obj ] ); if( sc_isPair( hop_servevt_ctable[ obj ] ) ) hop_servevt_ctable[ obj ] = sc_remqBang( proc,hop_servevt_ctable[ obj ] ); for( id in hop_servevt_table ) { if( sc_isPair( hop_servevt_table[ obj ] ) ) return; } hop_servevt_proxy.unregister( obj ); } } var hop_serverready_list = null; var hop_serverready_triggered = false; function HopServerReadyEvent() { var o = new Object(); o.isStopped = false; return o; } function hop_trigger_serverready_event( evt ) { while( sc_isPair( hop_serverready_list ) ) { hop_serverready_list.car( evt ); if( evt.isStopped ) break; hop_serverready_list = hop_serverready_list.cdr; } hop_serverready_triggered = true; } function hop_add_serverready_listener( obj, proc ) { if( obj === document ) { if( hop_serverready_triggered ) { proc(); } else { hop_serverready_list = sc_cons( proc, hop_serverready_list ); } } else { throw new Error( "add-event-listener!: Illegal `serverready' recipient" + obj ); } } function hop_remove_serverready_listener( obj, proc ) { if( obj === document ) { hop_serverready_list = sc_remqBang( proc, hop_serverready_list ); return true; } else { throw new Error( "remove-event-listener!: Illegal `serverready' recipient" + obj ); return false; } } var hop_timeout_listeners = null; function hop_add_timeout_listener( obj, proc ) { hop_timeout_listeners = sc_cons( sc_cons( proc, setInterval( proc, obj ) ), hop_timeout_listeners ); } function hop_remove_timeout_listener( proc ) { var p = hop_timeout_listeners; if( sc_isPair( p ) ) { if( p.car.car === proc ) { clearInterval( p.car.cdr ); hop_timeout = p.cdr; } else { while( sc_isPair( p.cdr ) ) { if( p.cdr.car === proc ) { clearInterval( p.cdr.cdr ); p.cdr = p.cdr.cdr; break; } else { p = p.cdr; } } } } } function hop_bigloo_serialize( item ) { var tname = typeof item; if( (item instanceof String) || (tname == "string") ) { if( sc_isSymbol( item ) ) { return "%27" + hop_serialize_string( '%22', sc_symbol2jsstring( item ) ); } else if( sc_isKeyword( item ) ) { return "%3a" + hop_serialize_string( '%22', sc_keyword2jsstring( item ) ); } else { return hop_serialize_string( '%22', item ); } } if( (typeof item) == "number" ) return hop_serialize_number( item ); if( (item instanceof Boolean) || (tname == "boolean") ) return hop_serialize_boolean( item ); if( item instanceof Array ) return hop_serialize_array( item ); if( item === undefined ) return ";"; if( item === null ) return "."; if( item instanceof Date ) return hop_serialize_date( item ); if( (item instanceof Object) && (typeof item.hop_bigloo_serialize == "function") ) return item.hop_bigloo_serialize(); if( (HTMLCollection != undefined) && (item instanceof HTMLCollection) ) return hop_serialize_array( item ); if( (HTMLInputElement != undefined) && (item instanceof HTMLInputElement) ) return hop_bigloo_serialize( item.value ); if( (HTMLTextAreaElement != undefined) && (item instanceof HTMLTextAreaElement) ) return hop_bigloo_serialize( item.value ); if( (HTMLSelectElement != undefined) && (item instanceof HTMLSelectElement) ) return hop_bigloo_serialize( item.value ); if( (item.callee != undefined) && (item.length > -1) ) return hop_serialize_array( item ); if( hop_is_html_element( item ) ) return hop_serialize_html( item ); return hop_bigloo_serialize( "#<" + tname + ">" ); } function hop_size_of_word( word ) { var s = 0; while( word > 0 ) { s++; word >>= 8; } return s; } function hop_serialize_word( word ) { var s = hop_size_of_word( word ); if( s == 0 ) { return "%00"; } else { var i1 = (s >> 4); var i2 = (s & 0xf); var c1 = i1 + ((i1 < 10) ? 48 : 55); var c2 = i2 + ((i2 < 10) ? 48 : 55); var rw = String.fromCharCode( 37, c1, c2 ); s--; while( s >= 0 ) { var c = ((word >> (s << 3)) & 0xff); if( (c < 127) && (c >= 46) ) { rw += String.fromCharCode( c ); } else { var i1 = (c >> 4); var i2 = (c & 0xf); var c1 = i1 + ((i1 < 10) ? 48 : 55); var c2 = i2 + ((i2 < 10) ? 48 : 55); rw += String.fromCharCode( 37, c1, c2 ); } s--; } return rw; } } function ucs2_to_utf8( s ) { var len = s.length; for( var i = 0; i < len; i++ ) { var c = s.charCodeAt( i ); if( c >= 128 ) { var utf = s.substring( 0, i ); for( ; i< len; i++, c = s.charCodeAt( i ) ) { if( c < 128 ) { utf += String.fromCharCode( c ); } else { if( (c > 127) && (c < 2048) ) { utf += String.fromCharCode((c >> 6) | 192); utf += String.fromCharCode((c & 63) | 128); } else { utf += String.fromCharCode((c >> 12) | 224); utf += String.fromCharCode(((c >> 6) & 63) | 128); utf += String.fromCharCode((c & 63) | 128); } } } return utf; } } return s; } function utf_length( s ) { var len = s.length; var res = len; for( var i = 0; i < len; i++ ) { var c = s.charCodeAt( i ); if( c >= 128 ) { if( (c > 127) && (c < 2048) ) { res++; } else { res += 2; } } } return res; } function hop_serialize_string( mark, item ) { return mark + hop_serialize_word( utf_length( item ) ) + encodeURIComponent( item ); } function hop_serialize_number( item ) { var sitem = item + ""; if( sitem.indexOf( "." ) == -1 ) { if( item < 0 ) return '-' + hop_serialize_word( -item ); else return hop_serialize_word( item ); } else { return 'f' + hop_serialize_word( sitem.length ) + sitem; } } function hop_serialize_boolean( item ) { return item ? 'T' : 'F'; } function hop_serialize_array( item ) { var l = item.length; var ra = '[' + hop_serialize_word( l ); var i = 0; for( i = 0; i < l; i++ ) { ra += hop_bigloo_serialize( item[ i ] ); } return ra; } function hop_serialize_date( item ) { var utc = Date.UTC( item.getUTCFullYear(), item.getUTCMonth(), item.getUTCDate(), item.getUTCHours(), item.getUTCMinutes(), item.getUTCSeconds() ) + ""; var ms = utc.substring( 0, utc.length - 3 ); return 'd' + hop_serialize_word( ms.length ) + encodeURIComponent( ms ); } function hop_serialize_html( item ) { if( "outerHTML" in item ) { return hop_serialize_string( '%22', item.outHTML ); } else { if( item.nodeType == 1 ) { var str = "<" + item.tagName + " id='" + item.id + "' " + (item.className ? ("class='" + item.className + "'") : "") + ">" + item.innerHTML + "" + item.tagName + ">"; return hop_serialize_string( '%22', str ); } else { if( item.nodeType == 3 ) { return hop_serialize_string( '%22', item.nodeValue ); } else { return hop_bigloo_serialize( "#<" + tname + ">" ); } } } } function hop_obj_to_string( item ) { return decodeURIComponent( hop_bigloo_serialize( item ) ); } function hop_string_to_obj( s ) { var pointer = 0; var definitions = []; var defining = false; function read_integer( s ) { return read_size( s ); } function read_float( s ) { var szf = read_size( s ); var res = s.substring( pointer, pointer + szf ); pointer += szf; return +res; } function read_char( s ) { new sc_Char(String.fromCharCode(n)); } function read_word( s, sz ) { var acc = 0; for( var iw = 0; iw < sz; iw++ ) { acc = (256 * acc) + s.charCodeAt( pointer++ ); } return acc; } function read_long_word( s, szlw ) { return read_word( szlw ); } function read_size( s ) { var szs = s.charCodeAt( pointer++ ); return read_word( s, szs ); } function read_string( s ) { var sz = read_size( s ); var res = s.substring( pointer, pointer + sz ); if( defining ) { definitions[ defining ] = res; defining = false; } pointer += sz; return res; } function read_definition() { defining = read_item(); return read_item(); } function read_reference() { return definitions[ read_item() ]; } function read_symbol() { return sc_jsstring2symbol( read_item() ); } function read_keyword() { return sc_jsstring2keyword( read_item() ); } function read_cnst() { switch( read_integer( s ) ) { default: alert( "read_cnst: not implemented: " + s ); } } function read_vector( sz ) { var res = sc_makeVector( sz ); if( defining ) { definitions[ defining ] = res; defining = false; } for( var iv = 0; iv < sz; iv++ ) { res[ iv ] = read_item(); } return res; } function read_list( sz ) { var res = sc_cons( null, null ); var hd = res; if( defining ) { definitions[ defining ] = res; defining = false; } for( var i = 0; i < (sz - 2); i++, hd = hd.cdr ) { hd.car = read_item(); hd.cdr = sc_cons( null, null ); } hd.car = read_item(); hd.cdr = read_item(); return res; } function read_extended_list( sz ) { var res = sc_cons( null, null ); var hd = res; if( defining ) { definitions[ defining ] = res; defining = false; } for( var i = 0; i < (sz - 2); i++, hd = hd.cdr ) { hd.car = read_item(); read_item(); hd.cdr = sc_cons( null, null ); } hd.car = read_item(); read_item(); hd.cdr = read_item(); return res; } function read_item() { switch( s.charAt( pointer++ ) ) { case '=': return read_definition(); case '#': return read_reference(); case "'": return read_symbol(); case ":": return read_keyword(); case "a": return read_char( s ); case "F": return false; case "T": return true; case ";": return undefined; case ".": return null; case "<": return read_cnst(); case '"': return read_string( s ) case '(': return read_list( read_size( s ) ); case '^': return read_extended_list( read_size( s ) ); case '[': return read_vector( read_size( s ) ); case "f": return read_float( s ); case "-": return -read_integer( s ); default: pointer--; return read_integer( s ); } } if( s.charAt( pointer ) == 'c' ) { pointer++; definitions = new Array( read_size( s ) ); } return read_item(); } var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; function base64_encode( input ) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt( i++ ); chr2 = input.charCodeAt( i++ ); chr3 = input.charCodeAt( i++ ); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if( isNaN( chr2 ) ) { enc3 = enc4 = 64; } else if( isNaN( chr3 ) ) { enc4 = 64; } output = output + keyStr.charAt( enc1 ) + keyStr.charAt( enc2 ) + keyStr.charAt( enc3 ) + keyStr.charAt( enc4 ); } while( i < input.length ); return output; } function utf8_decode( input ) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < input.length ) { c = input.charCodeAt(i); if( c < 128 ) { string += String.fromCharCode( c ); i++; } else if( (c > 191) && (c < 224) ) { c2 = input.charCodeAt( i + 1 ); string += String.fromCharCode( ((c & 31) << 6) | (c2 & 63) ); i += 2; } else { c2 = input.charCodeAt( i + 1 ); c3 = input.charCodeAt( i + 2 ); string += String.fromCharCode( ((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63) ); i += 3; } } return string; } function base64_decode( input ) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace( /[^A-Za-z0-9\+\/\=]/g, "" ); do { enc1 = keyStr.indexOf( input.charAt( i++ ) ); enc2 = keyStr.indexOf( input.charAt( i++ ) ); enc3 = keyStr.indexOf( input.charAt( i++ ) ); enc4 = keyStr.indexOf( input.charAt( i++ ) ); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode( chr1 ); if( enc3 != 64 ) { output = output + String.fromCharCode( chr2 ); } if( enc4 != 64 ) { output = output + String.fromCharCode( chr3 ); } } while( i < input.length ); return utf8_decode( output ); } var hop_anim_latency = 400; var hop_busy_anim_16_16 = "data:image/gif;base64,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"; function hop_service_url( service, formals, args ) { var len = formals.length; if( len == 0 ) { return service + "?hop-encoding=hop"; } else { var url = service + "?hop-encoding=hop"; var i; if( (args.length == 1) && hop_is_dom_form_element( args[ 0 ] ) ) { var els = args[ 0 ].elements; for( i = 0; i < els.length; i++ ) { if( els[ i ].type == "checkbox" ) { var val = els[ i ].checked ? els[ i ].value : false; url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( val ); } else { if( els[ i ].type == "radio" ) { if( els[ i ].checked ) { url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( els[ i ].value ); } } else { url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( els[ i ].value ); } } } return url; } else { for( i = 0; i < len; i++ ) { url += "&" + formals[ i ] + "=" + hop_bigloo_serialize( args[ i ] ); } return url; } } } function hop_service_url_varargs( service, args ) { var len = (arguments.length - 1); if( len == 0 ) { return service; } else { var url = service + "?hop-encoding=hop"; var i; for( i = 0; i < len; i++ ) { url += "&a" + i + "=" + hop_bigloo_serialize( arguments[ i + 1 ] ); } return url; } } function hop_default_failure( http ) { var t = http.responseText; if( !t ) { alert( "http error " + http.status ); return; } var div = document.getElementById( "hop_default_failure" ); var div2 = document.getElementById( "hop_default_failure_background" ); t = t.replace( /]*>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/head>/g, "" ); t = t.replace( /<(meta|link)[^>]*>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/html>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/body>/g, "" ); t = t.replace( /"/g, "\"" ); if( !div2 ) { div2 = document.createElement( "div" ); div2.id = "hop_default_failure_background"; node_style_set( div2, "position", "fixed" ); node_style_set( div2, "top", "0" ); node_style_set( div2, "bottom", "0" ); node_style_set( div2, "left", "0" ); node_style_set( div2, "right", "0" ); node_style_set( div2, "background", "#000" ); node_style_set( div2, "opacity", "0.5" ); node_style_set( div2, "overflow", "hidden" ); node_style_set( div2, "text-align", "center" ); node_style_set( div2, "z-index", "9999" ); document.body.appendChild( div2 ); } if( !div ) { div = document.createElement( "div" ); div.id = "hop_default_failure"; node_style_set( div, "position", "fixed" ); node_style_set( div, "top", "100px" ); node_style_set( div, "left", "0" ); node_style_set( div, "right", "0" ); node_style_set( div, "text-align", "center" ); node_style_set( div, "border", "0" ); node_style_set( div, "z-index", "10000" ); node_style_set( div, "opacity", "1" ); div.align = "center"; div.innerHTML = t; document.body.appendChild( div ); } else { div.innerHTML = t; } } function hop_anim_16_16( title ) { var vis = document.createElement( "div" ); node_style_set( vis, "position", "fixed" ); node_style_set( vis, "top", "5px" ); node_style_set( vis, "right", "5px" ); node_style_set( vis, "z-index", "100" ); node_style_set( vis, "background", "#eeeeee" ); node_style_set( vis, "border-color", "black" ); node_style_set( vis, "border-style", "outset" ); node_style_set( vis, "border-width", "1px" ); node_style_set( vis, "padding-top", "3px" ); node_style_set( vis, "width", "20px" ); node_style_set( vis, "height", "20px" ); node_style_set( vis, "-moz-border-radius", "0.2em" ); node_style_set( vis, "-moz-opacity", "0.7" ); vis.title = title; vis.align = "center"; var img = document.createElement( "img" ); img.className = "hop-busy-anim"; if( !hop_config.inline_image ) { img.src = hop_share_directory() + "/icons/busy-anim-16.gif"; } else { img.src = hop_busy_anim_16_16; } vis.appendChild( img ); return vis; } var hop_default_anim = hop_anim_16_16; function hop_default_anim_set( anim ) { var old = hop_default_anim; hop_default_anim = anim; return old; } function hop_default_anim_get( ) { return hop_default_anim; } var hop_anim_vis = false; var hop_anim_service = false; var hop_anim_interval; var hop_anim_fun = false; function hop_stop_anim() { if( hop_anim_interval ) { if( hop_has_setInterval ) clearInterval( hop_anim_interval ); hop_anim_interval = false; } } function hop_anim( service, user_anim ) { hop_stop_anim(); if( hop_anim_service == service ) { if( hop_anim_vis && (hop_anim_fun == user_anim) ) { hop_anim_vis.title = service; // node_style_set( hop_anim_vis, "visibility", "visible" ); node_style_set( hop_anim_vis, "display", "block" ); return hop_anim_vis; } else { hop_anim_vis = user_anim( service ); document.body.appendChild( hop_anim_vis ); return hop_anim_vis; } } return false; } function hop_responsetext_error( xhr ) { if( xhr.responseText.length > 80 ) return xhr.responseText.substring( 0, 80 ); else return xhr.responseText; } function hop_send_request( svc, sync, success, failure, anim, henv, auth ) { var xhr = hop_make_xml_http_request(); var hop_err = hop_error; var hop_reperror = hop_responsetext_error; var hop_header_ctype = hop_header_content_type; var err = function( exc, xhr, ctype ) { var txt = hop_reperror( xhr ); var fun = ctype ? ("with-hop [content-type=" + ctype + "]") : "with-hop"; return hop_err( fun, exc, txt, svc ); } function onreadystatechange() { if( xhr.readyState == 4 ) { try { var status = xhr.status; switch( status ) { case 200: try { var ctype = hop_header_ctype( xhr ); var expr; if( ctype === "application/x-javascript" ) { try { expr = eval( xhr.responseText ); } catch( exc ) { err( exc, xhr ); expr = false; } return success( expr, xhr ); } else if( ctype === "text/html" ) { var el = hop_create_element( xhr.responseText ); return success( el, xhr ); } else { return success( xhr.responseText, xhr ); } } catch( exc ) { err( exc, xhr, ctype ); } case 202: return success( hop_unserialize( xhr.responseText ), xhr ); case 204: return false; case 257: return hop_js_eval( xhr ); case 258: if( xhr.responseText != null ) return eval( xhr.responseText ); else return false; case 259: hop_set_cookie( xhr ); return false; case 407: err( "Bad authentication", xhr ); return false; default: if( (typeof status == "number") && (status > 200) && (status < 300) ) { if( success ) { return success( xhr.responseText, xhr ); } } else { if( failure ) { return failure( xhr ); } else { return hop_default_failure( xhr ); } } } } catch( exc ) { if( typeof failure == "function" ) { failure( xhr ); } else { err( exc, xhr ); } } finally { try { if( hop_anim_vis != false ) { node_style_set( hop_anim_vis, "display", "none" ); } hop_anim_service = false; } catch( e ) { } } } return false; } if( !sync ) { xhr.onreadystatechange = onreadystatechange; } xhr.open( "GET", svc, (sync != true) ); xhr.setRequestHeader( 'Connection', 'close' ); xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1' ); if( henv.length > 0 ) { xhr.setRequestHeader( 'Hop-Env', hop_serialize_request_env() ); } if( auth ) { xhr.setRequestHeader( 'Authorization', auth ); } try { if( anim ) hop_anim_service = svc; xhr.send( null ); hop_stop_anim(); if( anim && hop_has_setInterval ) { var a = (anim instanceof Function) ? anim : hop_default_anim; hop_anim_interval = setInterval( function() { hop_anim( svc, a ) }, hop_anim_latency ); } if( sync ) { if( xhr.readyState == 4 ) { onreadystatechange(); } else { hop_error( "with-hop", "synchronous call failed", "readyState: " + xhr.readyState, svc ); } } } catch( e ) { if( hop_anim_vis != false ) { node_style_set( hop_anim_vis, "display", "none" ); } hop_anim_service = false; hop_error( "with-hop", e, "Cannot call server", svc ); } return xhr; } function with_hop( svc, success, failure, sync, anim ) { if( !success ) success = function( h ) { return h }; if( !failure ) failure = hop_default_failure; return hop_send_request( svc, sync, success, failure, true, hop_serialize_request_env(), false ); } /*** META (define-macro (with-hop svc . rest) (let ((success #f) (fail #f) (sync #f) (anim #t) (user #f) (password #f) (authorization #f)) (let loop ((rest rest)) (cond ((null? rest) `(hop_send_request ,svc ,sync ,(or success '(lambda (h) h)) ,(or fail 'hop_default_failure) ,anim (hop_serialize_request_env) ,(cond (authorization authorization) ((and (string? user) (string? password)) (string-append "Basic " (base64-encode (string-append user ":" password))))))) ((eq? (car rest) :anim) (if (null? (cdr rest)) (error 'with-hop "Illegal :anim argument" rest) (set! anim (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :authorization) (if (null? (cdr rest)) (error 'with-hop "Illegal :authorization argument" rest) (set! authorization (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :user) (if (null? (cdr rest)) (error 'with-hop "Illegal :user argument" rest) (set! user (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :password) (if (null? (cdr rest)) (error 'with-hop "Illegal :password argument" rest) (set! password (cadr rest))) (loop (cddr rest))) ((not success) (set! success (car rest)) (loop (cdr rest))) ((not fail) (set! fail (car rest)) (loop (cdr rest))) (else (set! sync (car rest)) (loop (cdr rest))))))) */ function hop( svc, success, failure, sync ) { if( success == true ) { location.href = svc; return true; } if( !success ) success = function( h ) { return h; } if( !failure ) failure = hop_default_failure; return hop_send_request( svc, sync, success, failure, true, hop_serialize_request_env() ); } var hop_request_env = []; var hop_request_env_string = ""; var hop_request_env_invalid = false; function hop_serialize_request_env() { if( hop_request_env_invalid ) { var tmp = null; for( var p in hop_request_env ) { if( (typeof hop_request_env[ p ] != "function") && (hop_request_env[ p ] != undefined) ) { tmp = sc_cons( sc_cons( p, hop_request_env[ p ] ), tmp ); } } hop_request_env_string = hop_bigloo_serialize( tmp ); } return hop_request_env_string; } function hop_request_reset() { hop_request_env_string = ""; hop_request_env_set = false; return null; } function hop_request_set( key, val ) { hop_request_env_invalid = true; hop_request_env[ key ] = val; return val; } /*** META ((export request-get) (peephole: (hole 1 "hop_request[" key"]"))) */ function hop_request_get( key ) { return hop_request[ key ]; } var hop_client_debug = 0; function hop_error( fun, exc, msg, svc ) { var emsg = exc ? exc.toString() : "???"; if( exc ) { if( "message" in exc ) { emsg = exc.message; } else { if( "description" in exc ) { emsg = exc.description; } } if( "line" in exc ) { emsg = emsg + " (line " + exc.line + ")"; } } if( typeof svc === "string" || svc instanceof String ) fun = fun + ", " + svc; alert( "*** ERROR " + fun + ": " + emsg + " -- " + msg ); throw exc; } function hop_debug() { return hop_client_debug; } function hop_debug_set( v ) { if( sc_isNumber( v ) ) hop_client_debug = v; } function hop_trace() { if( hop_client_debug > 0 ) { var svc = hop_service_url( hop_service_base() + "/trace", [ "args" ], new Array( sc_vector2list( arguments ) ) ); hop_send_request( svc, true, function() {}, function() {}, false, [] ); } } function hop_tprint( file, pos, rest ) { var svc = hop_service_url( hop_service_base() + "/trace/tprint", [ "file", "pos", "args" ], [ file, pos, rest ] ); hop_send_request( svc, true, function() {}, function() {}, false, [] ); } /*** META (define-macro (tprint . rest) (if (epair? rest) (match-case (cer rest) ((at ?name ?pos) `(hop_tprint ,(relative-file-name name (pwd)) ,(file-position->line pos name) (list ,@rest))) (else `(hop_tprint #f #f (list ,@rest)))) `(hop_tprint #f #f (list ,@rest)))) */ function hop_replace_inner( el ) { if( el != undefined ) { return function( html ) { if( html ) { hop_innerHTML_set( el, html ); } } } else { alert( "*** Hop Error, Can't find element" ); return function( http ) { }; } } function hop_replace_inner_id( id ) { return hop_replace_inner( document.getElementById( id ) ); } function hop_set_cookie( http ) { try { var cookie = http.getResponseHeader( "set-cookie" ); if( cookie ) document.cookie = cookie; } catch( e ) { ; } } function hop_cookie_remove( name, path, domain ) { if( hop_cookie_get_value( name ) ) { hop_cookie_set_value( name, "", path, domain ); } } function hop_cookie_get_value( name ) { var cookies = document.cookie; var i = cookies.indexOf( name + "=" ); if( i !== -1 ) { var start = i + name.length + 1; var end = cookies.indexOf( ";", start ); if( end == -1 ) end = cookies.length; return unescape( cookies.substring( start, end ) ); } else { return null; } } function hop_cookie_set_value( name, val, path, domain, expires ) { var cookie = name + "=" + val; if( (path instanceof String) || (typeof path == "string") ) { cookie += "; path=" + path; } else { cookie += "; path=/"; } if( (expires instanceof String) || (typeof expires == "string") ) { cookie += "; expires=" + expires; } else { if( expires instanceof Date ) { cookie += "; expires=" + expires.toGMTString(); } } if( (domain instanceof String) || (typeof domain == "string") ) { cookie += "; domain=" + domain; } document.cookie = cookie; } var hop_load_frequency = 100; function HopLoadError( file ) { var e = new Error( "hop-load error" ); e.file = file; return e; } function hop_load( src, timeout ) { var script = document.createElement( "script" ); script.src = src; var loaded = false; var holder = document.getElementsByTagName( "head" ); if( !timeout || (timeout == undefined) ) timeout = -1; if( holder != null ) { if( timeout != 0 ) script.onload = function( e ) { loaded = true; }; holder[ 0 ].appendChild( script ); if( timeout != 0 ) { var it; var p = function() { if( loaded == true ) { clearInterval( it ); } else { if( timeout > 0 ) { timeout -= hop_load_frequency; if( timeout <= 0 ) { clearInterval( it ); throw( new HopLoadError( src ) ); } } } }; it = setInterval( p, hop_load_frequency ); } } else { alert( "*** Hop Error, Can't find HEAD element" ); } } var hop_window_onload_add = function( proc ) { var oldonload = window.onload; if( typeof oldonload != 'function' ) { window.onload = proc; } else { window.onload = function( e ) { oldonload( e ); proc( e ); } } } hop_window_onload_add( function( e ) { hop_window_onload_add = function( proc ) { proc( e ); } } ); function hop_window_onload_cons( proc ) { var oldonload = window.onload; if( typeof oldonload != 'function' ) { window.onload = proc; } else { window.onload = function( e ) { proc( e ); oldonload( e ); } } } function hop_window_onunload_add( proc ) { if( typeof( window.onunload ) != 'function' ) { window.onunload = proc; } else { var oldonunload = window.onunload; window.onunload = function( e ) { oldonunload( e ); proc( e ); } } } function hop_update( node ) { if( node.hop_update != undefined ) { node.hop_update(); } for( var i = 0; i < node.childNodes.length; i++ ) { hop_update( node.childNodes[ i ] ); } } function hop_find_runtime_type( obj ) { if( obj instanceof Object ) { if( obj instanceof Date ) { return "date"; } else { if( obj instanceof RegExp ) { return "regexp"; } else { if( typeof obj.hop_find_runtime_type == "function" ) return obj.hop_find_runtime_type(); else return "object"; } } } else { var tname = typeof obj; if( tname == "string" ) { if( sc_isSymbol( obj ) ) return "symbol"; if( sc_isKeyword( obj ) ) return "keyword"; return tname; } return tname; } } function after( timeout, proc ) { var tm = sc_isNumber( timeout ) ? timeout : 1; var i = setInterval( function() { clearInterval( i ); proc() }, tm ); return true; } function timeout( tm, proc ) { var i = setInterval( function() { if( !proc() ) clearInterval( i )}, tm ); } function url_decode( s ) { try { return decodeURI( s ); } catch( e ) { return s; } } function url_encode( s ) { return encodeURI( s ); } function string_hex_extern( str ) { var res = ""; var l = str.length; for( var i = 0; i < l; i++ ) { res += "0123456789abcdef".charAt( (str.charCodeAt( i ) >> 4) & 15 ) + "0123456789abcdef".charAt( (str.charCodeAt( i ) & 15) ); } return res; } function string_hex_intern( s ) { var res = ""; var l = s.length; var z = '0'.charCodeAt( 0 ); var n = '9'.charCodeAt( 0 ); var a = 'a'.charCodeAt( 0 ); var f = 'f'.charCodeAt( 0 ); var A = 'A'.charCodeAt( 0 ); function hex_to_num( c ) { if( (c >= z) && ( c<= n) ) { return c - z; } if( (c >= a) && ( c<= f) ) { return (c - a) + 10;; } return (c - A) + 10; } for( var i = 0; i < l; i += 2 ) { var d1 = hex_to_num( s.charCodeAt( i ) ); var d2 = hex_to_num( s.charCodeAt( i + 1 ) ); res += String.fromCharCode( (d1 << 4) + d2 ); } return res; } function date_year( d ) { return d.getYear(); } function date_month( d ) { return d.getMonth(); } function date_day( d ) { return d.getDay(); } function date_hour( d ) { return d.getHours(); } function date_minute( d ) { return d.getMinutes(); } function date_second( d ) { return d.getSeconds(); } var hop_current_state_history = undefined; var hop_state_history_handler = {}; function hop_state_history_register_handler( key, reset, proc ) { hop_state_history_handler[ key ] = { reset: reset, proc: proc }; } function _hop_state_entry( op, val ) { this.op = op; this.val = val; this.close = false; } function hop_state_history_to_location( state ) { var loc = undefined; for( p in state ) { if( state[ p ] instanceof _hop_state_entry ) { if( loc == undefined ) { loc = "#" + p + "=" + state[ p ].op + ":" + state[ p ].val; } else { loc += "," + p + "=" + state[ p ].op + ":" + state[ p ].val; } } } return loc; } var hop_hash_history_regexp = /#?([^=]+)=([^:]+):([^,]+)+/; function hop_location_to_state_history( hash ) { var state = {}; var split = hash.split( "," ); for( var i = 0; i < split.length; i++ ) { var el = split[ i ].match( hop_hash_history_regexp ); if( el ) { var id = el[ 1 ]; var op = el[ 2 ]; var val = el [ 3 ]; state[ id ] = new _hop_state_entry( op, val ); } } return state; } function hop_state_history_push( id, op, val ) { if( hop_current_state_history == undefined ) { hop_current_state_history = {}; hop_current_state_history[ id ] = new _hop_state_entry( op, val ); } else { var olde = hop_current_state_history[ id ]; if( olde == undefined ) { hop_current_state_history[ id ] = new _hop_state_entry( op, val ); } else { if( (olde.op != op) || (olde.val != val) ) { olde.op = op; olde.val = val; } } } } function hop_state_history_flush() { var loc = hop_state_history_to_location( hop_current_state_history ); var old = window.location.href; var i = old.indexOf( "#" ); if( i == -1 ) { hop_active_location_set( document, old + loc ); } else { hop_active_location_set( document, old.substring( 0, i ) + loc ); } } var hop_state_history_transaction = 0; function hop_state_history_add( id, op, val ) { hop_state_history_push( id, op, val ); if( hop_state_history_transaction == 0 ) { hop_state_history_flush(); } } function hop_with_history( proc ) { var res; hop_state_history_transaction++; try { res = proc(); } finally { hop_state_history_transaction--; } hop_state_history_flush(); return res; } function hop_state_history_reset() { if( hop_current_state_history != undefined ) { for( p in hop_current_state_history ) { if( hop_current_state_history[ p ] instanceof _hop_state_entry ) { var op = hop_current_state_history[ p ].op; var handler = hop_state_history_handler[ op ]; if( handler != undefined ) { handler.proc( p, handler.reset ); } } } hop_current_state_history = undefined; } } function hop_state_history_update( olds, news ) { var res = 0; if( olds == undefined ) { for( p in news ) { var state = news[ p ]; if( state instanceof _hop_state_entry ) { var op = state.op; var handler = hop_state_history_handler[ op ]; if( (handler != undefined) && !state.close ) { if( handler.proc( p, state.val ) ) { state.close = true; } else { res++; } } } } } else { for( p in olds ) { if( (olds[ p ] instanceof _hop_state_entry) && !(news[ p ] instanceof _hop_state_entry) ) { var op = olds[ p ].op; var handler = hop_state_history_handler[ op ]; if( handler != undefined ) { handler.proc( p, handler.reset ); } } } for( p in news ) { var state = news[ p ]; if( state instanceof _hop_state_entry ) { if( !(olds[ p ] instanceof _hop_state_entry) || (state.op != olds[ p ].op) || (state.val != olds[ p ].val) ) { var op = state.op; var handler = hop_state_history_handler[ op ]; if( (handler != undefined) && !state.close ) { if( handler.proc( p, state.val ) ) { state.close = true; } else { res++; } } } } } } return res; } var hop_hash_history_check_regexp = new RegExp( "^#(?:[^=]+=[^:]+:[^,]+,?)+$" ); function hop_hash_historyp( hash ) { return hop_hash_history_check_regexp.exec( hash ); } var hop_eval_history_interval = false; function hop_retry_eval_history_state( count, old_state, new_state ) { var fun = function() { var c = hop_state_history_update( old_state, new_state ); if( (c == 0) || (c == count) || hop_eval_history_interval.invalid ) { clearInterval( hop_eval_history_interval ); } } hop_eval_history_interval = setInterval( fun, 200 ); hop_eval_history_interval.invalid = false; } function hop_eval_history_state( location ) { var hash = location.hash; if( hop_eval_history_interval ) hop_eval_history_interval.invalid = true; if( hash.length == 0 ) { hop_state_history_reset(); } else { if( hop_hash_historyp( hash ) ) { var new_state = hop_location_to_state_history( hash ); var old_state = hop_current_state_history; var count = hop_state_history_update( old_state, new_state ); if( count == 0 ) { hop_current_state_history = new_state; } else { hop_retry_eval_history_state( count, old_state, new_state ); } } } } function hop_current_history() { var hash = location.hash; if( hash.length == 0 ) { return false; } if( hop_hash_historyp( hash ) ) { return hop_location_to_state_history( hash ); } return false; } function hop_replay_history( hist ) { hop_current_state_history = undefined; var loc = function( v ) { this.hash = v; } hop_eval_history_state( new loc( hop_state_history_to_location( hist ) ) ); } function _hop_history( key ) { this.key = key; } function hop_make_history( key, handler, reset ) { hop_state_history_register_handler( key, reset, handler ); return new _hop_history( key ); } function hop_history_add( history, id, val ) { if( !history instanceof _hop_history ) { alert( "*** ERROR: Illegal history object -- " + history ); return false; } else { return hop_state_history_add( id, history.key, val ); } } if( hop_enable_location_event ) { hop_window_onload_add( function( e ) { hop_add_event_listener( document, "location", hop_eval_history_state ); } ); } function hop_bigloo_serialize_pair( l ) { var res = ""; var len = 0; while (sc_isPair( l ) ) { res += hop_bigloo_serialize( l.car ); l = l.cdr; len++; } if( l == null ) { return hop_serialize_word( len + 1 ) + res + "."; } else { return hop_serialize_word( len + 1 ) + res + hop_bigloo_serialize( l ); } } sc_Pair.prototype.hop_bigloo_serialize = function() { return '(' + hop_bigloo_serialize_pair( this ); }; sc_Pair.prototype.hop_find_runtime_type = function() { return "pair"; }; sc_Vector.prototype.hop_find_runtime_type = function() { return "vector"; }; sc_Struct.prototype.hop_find_runtime_type = function() { return "struct"; }; sc_OutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_StringOutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_GenericOutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_InputPort.prototype.hop_find_runtime_type = function() { return "input-port"; }; Boolean.prototype.hop_find_runtime_type = function() { return "bbool"; }; String.prototype.hop_find_runtime_type = function() { return hop_find_runtime_type(this.toString()); }; sc_Char.prototype.hop_find_runtime_type = function() { return "bchar"; }; ]]> TPAC 08, W3C Technical Plenary 2008 ...Start...Title Preludeapplications demand languageshop HopHOP...The Web...Architecture ApplicationAn applicationA Diffuse Music PlayerHopAudio (architecture) ConclusionConclusionWhy Using Hop?hop.inria.frendHopSlide v1.5.121 October 2008HopSlide Help (v1.5.1)KeyboardToggle this helpalt-hReload slidesalt-rToggle slide selectoralt-sOpen a full screen windowalt-wUpdate sizealt-uToggle big cursoralt-mToggle focusalt-fToggle drawing areaalt-cNext slidePgDn↓alt-nRetEnterSpacePrevious slidePgUp↑alt-pFirst slideHomeLast slideEndClose slideEscMouseReload slidesshift Button1Slides selectorcrtl Button1Focus enlarge/shrinkButton4Button5 image/svg+xmlPress [Space] to start... Hop, an Everyware Development KitManuel SerranoMimosa TeamInria Sophia-Antipolishttp://hop.inria.fr Prelude Applications demand Languages X= 27.3 DATA A, B / 5.0, 12.0. / IF (X) 10, 20, 30 DO 9 J= 1, 10 DO 9 K= 1, 10 9 L= J + K 60 FORMAT ( 9H1GOODBYE. )?module ABRO: input A, B, R; output O; loop [ await A || await B ]; emit O each R end module#include <iostream> class Bird { public: virtual void OutName() { std::cout << "a bird"; } virtual ~Bird() {} }; int main() { Swan mySwan; Bird* myBird = &mySwan; myBird->OutName(); return 0; }
. args) `(hop_dom_create "code" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "col" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "colgroup" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dd" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "del" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dfn" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dir" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "div" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dl" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "dt" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "em" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "fieldset" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "font" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "form" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "frame" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "frameset" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h1" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h2" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h3" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h4" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h5" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "h6" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "hr" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "html" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "i" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "iframe" ,@args)) */ /*** META (define-macro ( . args) (let ((k (memq :type args))) (if (and (pair? k) (pair? (cdr k)) (or (eq? (cadr k) 'url)) (or (equal? (cadr k) "url"))) `(hop_dom_create "input" :onkeydown (hop_inputurl_keydown this event) ,@args) `(hop_dom_create "input" ,@args)))) */ /*** META (define-macro ( . args) `(hop_dom_create "ins" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "isindex" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "kbd" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "label" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "legend" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "li" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "link" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "map" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "marquee" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "menu" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "meta" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "noframes" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "noscript" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "object" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "ol" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "optgroup" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "option" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "p" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "param" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "pre" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "q" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "s" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "samp" ,@args)) */ /*** META (define-macro (", start ); if( end == -1 ) end = text.indexOf( "", start ); if( (end > start) ) { res = eval( text.substr( start, end - start ) ); } } return res; } try { if( "getElementsByTagName" in node ) { var scripts = node.getElementsByTagName( "script" ); if( scripts && scripts.length > 0 ) { for ( var j = 0; j < scripts.length; j++ ) { if( false && scripts[ j ].childNodes.length > 0 ) { res = eval( scripts[ j ].childNodes[ 0 ].nodeValue ); } else { res = eval( scripts[ j ].innerHTML ); } } } else { return hop_node_eval_from_text( text ); } } else { return hop_node_eval_from_text( text ); } } catch( e ) { alert( e ); throw e; } return res; } function node_style_get( obj, prop ) { if( (obj instanceof String) || (typeof obj === "string") ) obj = document.getElementById( obj ); if( sc_isKeyword( prop ) ) prop = sc_keyword2jsstring( prop ); return obj.style[ prop ]; } function hop_create_element( html ) { var div = document.createElement( 'div' ); div.innerHTML = "IE7 bug" + html; return div.childNodes[ 1 ]; } function hop_create_encoded_element( html ) { return hop_create_element( decodeURIComponent( html ) ); } function hop_innerHTML_set( nid, html ) { var el; if( (nid instanceof String) || (typeof nid == "string") ) { el = document.getElementById( nid ); if( el == undefined ) { alert( "*** ERROR:innerHTML-set! -- cannot find element \"" + nid + "\""); return; } } else { if( !nid ) { alert( "*** ERROR:innerHTML-set! -- illegal element \"" + nid + "\""); return; } el = nid; } if( (html instanceof String) || (typeof html == "string") ) { el.innerHTML = html; hop_node_eval( el, html ); } else if( hop_is_html_element( html ) || sc_isPair( html ) ) { dom_set_child_node( el, html ); if( hop_innerHTML_need_evalp ) hop_node_eval( el, html ); } else { el.innerHTML = html; } } function hop_style_attribute_set( obj, val ) { var expr; if( (val instanceof String) || (typeof val == "string") ) expr = eval( val ); for( var p in expr ) { node_style_set( obj, p, expr[ p ] ); } } function hop_element_x( obj ) { var res = 0; while( obj != null ) { if( typeof obj.offsetLeft == "number" ) res += obj.offsetLeft; else { break; } obj = obj.offsetParent; } return res; } function hop_element_y( obj ) { var res = 0; while( obj != null ) { if( typeof obj.offsetTop == "number" ) res += obj.offsetTop; else { break; } obj = obj.offsetParent; } return res; } function hop_bounding_box( e, m ) { var n; if( (e instanceof String) || (typeof e == "string") ) { n = document.getElementById( e ); } else { n = e; } if( !m ) m = 0; return [ hop_element_x( n ) - m, hop_element_y( n ) - m, n.offsetWidth + (2*m), n.offsetHeight + (2*m) ]; } function hop_bounding_box_to_list( bbox ) { return sc_vector2list( bbox ); } function hop_bounding_box_x( bbox, loc ) { if( arguments.length == 1 ) return bbox[ 0 ]; if( (loc == "w") || (loc == "nw") || (loc == "sw") ) return bbox[ 0 ]; if( (loc == "n") || (loc == "s")) return bbox[ 0 ] + (bbox[ 2 ]/2); if( (loc == "ne") || (loc == "e") || (loc == "se") ) return bbox[ 0 ] + bbox[ 2 ]; return 0; } function hop_bounding_box_y( bbox, loc ) { if( arguments.length == 1 ) return bbox[ 1 ]; if( (loc == "nw") || (loc == "n") || (loc == "ne") ) return bbox[ 1 ]; if( (loc == "e") || (loc == "w")) return bbox[ 1 ] + (bbox[ 3 ]/2); if( (loc == "se") || (loc == "s") || (loc == "sw") ) return bbox[ 1 ] + bbox[ 3 ]; return 0; } function hop_add_event_listener( obj, event, proc, capture ) { if( event == "location" ) return hop_add_active_location_listener( obj, proc ); if( event == "server" ) return hop_add_server_listener( obj, proc, capture ); if( event == "serverready" ) return hop_add_serverready_listener( obj, proc ); if( event == "serverclose" ) return hop_add_serverclose_listener( obj, proc ); if( event == "timeout" ) return hop_add_timeout_listener( obj, proc ); if( (obj.hop_add_event_listener != undefined) && (obj.hop_add_event_listener != hop_add_event_listener) ) return obj.hop_add_event_listener( event, proc, capture ); return hop_add_native_event_listener( obj, event, proc, capture ); } function hop_remove_event_listener( obj, event, proc, capture ) { if( event == "location" ) return hop_remove_active_location_listener( obj, proc ); if( event == "server" ) return hop_remove_server_listener( obj, proc ); if( event == "serverready" ) return hop_remove_serverready_listener( obj, proc ); if( event == "serverclose" ) return hop_remove_serverclose_listener( obj, proc ); if( event == "timeout" ) return hop_remove_timeout_listener( proc ); if( (obj.hop_remove_event_listener != undefined) && (obj.hop_remove_event_listener != hop_remove_event_listener) ) return obj.hop_remove_event_listener( event, proc, capture ); return hop_remove_native_event_listener( obj, event, proc, capture ); } function hop_add_active_location_listener( obj, proc ) { obj.hop_active_location_proc = proc; var i = window.location.href.indexOf( "#" ); if( i === -1 ) { obj.hop_active_location_href = window.location.href; } else { obj.hop_active_location_href = window.location.href.substring( 0, i-1 ); } if( obj.hop_active_location_interval === undefined ) { var check = function() { if( obj.hop_active_location_href !== window.location.href ) { if( obj.hop_active_location_href != window.location.href ) { obj.hop_active_location_href = window.location.href; obj.hop_active_location_proc( window.location ); } } return true; } obj.hop_active_location_interval = setInterval( check, hop_active_location_timeout ); } return false; } function hop_remove_active_location_listener( obj, proc ) { if( obj.hop_active_location_interval != undefined ) { clearInterval( obj.hop_active_location_interval ); obj.hop_active_location_interval = undefined; } } function hop_active_location_set( obj, href ) { window.location.href = href; obj.hop_active_location_href = window.location.href; } var hop_servevt_id = "__hop_serevt_proxy"; var hop_server_event_count = 0; var re = new RegExp( "<[\/]?event[^>]*>", "g" ); function HopServerEvent( n, text, val ) { this.isStopped = false; this.name = n; this.value = val; this.id = hop_server_event_count++; if( typeof text == "string" ) { this.responseText = text.replace( re, "" ); } else { this.responseText = ""; } } var hop_servevt_proxy = false; var hop_servevt_table = {}; var hop_servevt_ctable = {}; var hop_servevt_dlist = null; function start_servevt_ajax_proxy( key ) { if( !hop_servevt_proxy.httpreq ) { var xhr_error_ttl = 6 * 3; var server_ready = false; var register = function( id ) { var svc = hop_service_base() + "/server-event/register?event=" + id + "&key=" + key; var success = function( val, xhr ) { if( !server_ready ) { server_ready = true; hop_trigger_serverready_event( new HopServerReadyEvent() ); } if( val != null ) { xhr_error_ttl = 6 * 3; register( "" ); while( val != null ) { var v = val.car; var id = v.car; var vals = v.cdr; while( vals != null ) { hop_trigger_servevt( id, vals.car, vals.car, false ); vals = vals.cdr; } val = val.cdr; } } } var failure = function( xhr ) { if( !xhr.status && (xhr_error_ttl > 0) && !xhr.getAllResponseHeaders() ) { xhr_error_ttl--; register( id ); } else { hop_servevt_onclose(); } } hop_servevt_proxy.httpreq = hop_send_request( svc, false, success, failure, false, [] ); } var unregister = function( id ) { hop_servevt_proxy.httpreq.abort(); var svc = hop_service_base() + "/server-event/unregister?event=" + id + "&key=" + hop_servevt_proxy.key; hop_servevt_proxy.httpreq = hop_send_request( svc, false, function() { ; }, false, false, [] ); }; hop_servevt_proxy.register = register; hop_servevt_proxy.unregister = unregister; for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { register( p ); } } } } function start_servevt_flash_proxy( key, host, port ) { var object_proxy = function() { return "" + "" + "" + "" + ""; } var embed_proxy = function() { var embed = document.createElement( "embed" ); embed.id = hop_servevt_id; embed.className = "hop-servevt-proxy"; embed.setAttribute( "width", "1px" ); embed.setAttribute( "height", "1px" ); embed.setAttribute( "src", hop_share_directory() + "/flash/HopServevt.swf" ); embed.setAttribute( "type", "application/x-shockwave-flash" ); embed.setAttribute( "name", "__hop_servevt_proxy" ); embed.setAttribute( "swliveconnect", "true" ); embed.setAttribute( "allowScriptAccess", "always" ); embed.setAttribute( "FlashVars", "init=hop_servevt_proxy_flash_init" + "&host=" + host + "&port=" + port + "&key=" + key + "&onevent=hop_trigger_servevt" + "&onclose=hop_servevt_onclose" + "&onerror=hop_servevt_onerror" ); return embed; } var proxy = document.createElement( "div" ); node_style_set( proxy, "position", "fixed" ); node_style_set( proxy, "top", "0" ); node_style_set( proxy, "right", "0" ); node_style_set( proxy, "background", "transparent" ); if( hop_config.flash_markup === "embed" ) { proxy.appendChild( embed_proxy() ); } else { proxy.innerHTML = object_proxy(); } document.body.appendChild( proxy ); document.getElementById( hop_servevt_id ).key = key; return proxy; } function hop_servevt_onerror( msg ) { hop_error( "servevt", new Error( msg ), "internal server event error" ); } function hop_servevt_proxy_flash_init() { hop_flash_minversion_set( 8 ); var pending_events = 0; hop_servevt_proxy = document.getElementById( hop_servevt_id ); var abort = function( id ) { var svc = hop_service_base() + "/server-event/unregister?event=" + id + "&key=" + hop_servevt_proxy.key; hop_servevt_proxy.httpreq = hop_send_request( svc, false, function() {;}, false, false, [] ); } var failure = function( e ) { hop_servevt_onclose(); for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { abort( p ); } } hop_send_request( hop_service_base() + "/server-event/close?key=" + hop_servevt_proxy.key, false, function() {;}, false, false, [] ); } var register = function( id ) { var svc = hop_service_base() + "/server-event/register?event=" + id + "&key=" + hop_servevt_proxy.key + "&flash=true"; var success = function( e ) { if( pending_events > 0 ) { if( pending_events == 1 ) { hop_trigger_serverready_event( new HopServerReadyEvent() ); } pending_events--; } } hop_servevt_proxy.httpreq = hop_send_request( svc, false, success, failure, false, [] ); } hop_servevt_proxy.register = register; hop_servevt_proxy.unregister = function( id ) { abort( id ); } hop_window_onunload_add( failure ); for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { pending_events++; } } if( pending_events > 0 ) { for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { register( p ); } } } else { hop_trigger_serverready_event( new HopServerReadyEvent() ); } } function servevt_flashp( port ) { return port && (hop_config.flash_version >= 8) && (hop_config.flash_external_interface); } function hop_start_servevt_proxy() { hop_servevt_proxy = new Object(); hop_servevt_proxy.register = function( x ) {}; hop_send_request( hop_service_base() + "/server-event/info", false, function( v ) { var host = v[ 0 ]; var port = v[ 1 ]; var key = v[ 2 ]; if( servevt_flashp( port ) ) { try { start_servevt_flash_proxy( key, host, port ); } catch( e ) { hop_error( "hop_start_servevt_proxy", e, "Cannot start flash proxy, port=" + port); } } else { start_servevt_ajax_proxy( key ); } }, function( v ) { throw new Error( "Cannot get server event port number" ); }, true, [] ); } function hop_trigger_servevt( id, text, value, json ) { try { var v = (json ? eval( value, text ) : value); var evt = new HopServerEvent( id, text, v ); var p2 = hop_servevt_table[ id ]; if( sc_isPair( hop_servevt_dlist ) && sc_isPair( hop_servevt_ctable[ id ] ) ) { var p1 = hop_servevt_dlist; while( sc_isPair( p1 ) ) { p1.car( evt ); p1 = p1.cdr; } } evt.isStopped = false; while( sc_isPair( p2 ) ) { try { p2.car( evt ); } catch( exc ) { hop_error( "hop_trigger_servevt [event " + id + "]", exc, p2.car ); } if( evt.isStopped ) break; p2 = p2.cdr; } } catch( exc ) { hop_error( "hop_trigger_servevt [event " + id + "]", exc, value ); } } var hop_serverclose_list = null; var hop_serverclose_triggered = false; function hop_add_serverclose_listener( obj, proc ) { if( obj === document ) { if( hop_serverclose_triggered ) { var evt = new HopServerEvent( "serverclose", false, false ); proc( evt ); } else { hop_serverclose_list = sc_cons( proc, hop_serverclose_list ); } } else { throw new Error( "add-event-listener!: Illegal `serverclose' recipient" + obj ); } } function hop_remove_serverclose_listener( obj, proc ) { if( obj === document ) { hop_serverclose_list = sc_remqBang( proc, hop_serverclose_list ); return true; } else { throw new Error( "remove-event-listener!: Illegal `serverclose' recipient" + obj ); return false; } } function hop_servevt_onclose() { var evt = new HopServerEvent( "serverclose", false, false ); var p = hop_serverclose_list; while( sc_isPair( p ) ) { p.car( evt ); if( evt.isStopped ) break; p = p.cdr; } hop_serverclose_triggered = true; } function hop_add_server_listener( obj, proc, capture ) { if( typeof proc != "function" ) { throw new Error( "Illegal procedure: " + proc ); } if( obj === document ) { hop_servevt_dlist = sc_cons( proc, hop_servevt_dlist ); } else { if( !document.body ) { hop_window_onload_add( function( e ) { hop_add_server_listener( obj, proc, capture ); } ); } else { var o = hop_servevt_table[ obj ]; hop_servevt_table[ obj ] = sc_cons( proc, sc_isPair( o ) ? o : null ); hop_servevt_table[ obj ].hop_servevt = true; if( capture ) { var o = hop_servevt_ctable[ obj ]; hop_servevt_ctable[ obj ] = sc_cons( proc, sc_isPair( o ) ? o : null ); } if( !hop_servevt_proxy ) { hop_start_servevt_proxy(); } else { hop_servevt_proxy.register( obj ); } } } } function hop_remove_server_listener( obj, proc ) { if( obj === document ) { hop_servevt_dlist = sc_remqBang( proc, hop_servevt_dlist ); } else { if( sc_isPair( hop_servevt_table[ obj ] ) ) hop_servevt_table[ obj ] = sc_remqBang( proc, hop_servevt_table[ obj ] ); if( sc_isPair( hop_servevt_ctable[ obj ] ) ) hop_servevt_ctable[ obj ] = sc_remqBang( proc,hop_servevt_ctable[ obj ] ); for( id in hop_servevt_table ) { if( sc_isPair( hop_servevt_table[ obj ] ) ) return; } hop_servevt_proxy.unregister( obj ); } } var hop_serverready_list = null; var hop_serverready_triggered = false; function HopServerReadyEvent() { var o = new Object(); o.isStopped = false; return o; } function hop_trigger_serverready_event( evt ) { while( sc_isPair( hop_serverready_list ) ) { hop_serverready_list.car( evt ); if( evt.isStopped ) break; hop_serverready_list = hop_serverready_list.cdr; } hop_serverready_triggered = true; } function hop_add_serverready_listener( obj, proc ) { if( obj === document ) { if( hop_serverready_triggered ) { proc(); } else { hop_serverready_list = sc_cons( proc, hop_serverready_list ); } } else { throw new Error( "add-event-listener!: Illegal `serverready' recipient" + obj ); } } function hop_remove_serverready_listener( obj, proc ) { if( obj === document ) { hop_serverready_list = sc_remqBang( proc, hop_serverready_list ); return true; } else { throw new Error( "remove-event-listener!: Illegal `serverready' recipient" + obj ); return false; } } var hop_timeout_listeners = null; function hop_add_timeout_listener( obj, proc ) { hop_timeout_listeners = sc_cons( sc_cons( proc, setInterval( proc, obj ) ), hop_timeout_listeners ); } function hop_remove_timeout_listener( proc ) { var p = hop_timeout_listeners; if( sc_isPair( p ) ) { if( p.car.car === proc ) { clearInterval( p.car.cdr ); hop_timeout = p.cdr; } else { while( sc_isPair( p.cdr ) ) { if( p.cdr.car === proc ) { clearInterval( p.cdr.cdr ); p.cdr = p.cdr.cdr; break; } else { p = p.cdr; } } } } } function hop_bigloo_serialize( item ) { var tname = typeof item; if( (item instanceof String) || (tname == "string") ) { if( sc_isSymbol( item ) ) { return "%27" + hop_serialize_string( '%22', sc_symbol2jsstring( item ) ); } else if( sc_isKeyword( item ) ) { return "%3a" + hop_serialize_string( '%22', sc_keyword2jsstring( item ) ); } else { return hop_serialize_string( '%22', item ); } } if( (typeof item) == "number" ) return hop_serialize_number( item ); if( (item instanceof Boolean) || (tname == "boolean") ) return hop_serialize_boolean( item ); if( item instanceof Array ) return hop_serialize_array( item ); if( item === undefined ) return ";"; if( item === null ) return "."; if( item instanceof Date ) return hop_serialize_date( item ); if( (item instanceof Object) && (typeof item.hop_bigloo_serialize == "function") ) return item.hop_bigloo_serialize(); if( (HTMLCollection != undefined) && (item instanceof HTMLCollection) ) return hop_serialize_array( item ); if( (HTMLInputElement != undefined) && (item instanceof HTMLInputElement) ) return hop_bigloo_serialize( item.value ); if( (HTMLTextAreaElement != undefined) && (item instanceof HTMLTextAreaElement) ) return hop_bigloo_serialize( item.value ); if( (HTMLSelectElement != undefined) && (item instanceof HTMLSelectElement) ) return hop_bigloo_serialize( item.value ); if( (item.callee != undefined) && (item.length > -1) ) return hop_serialize_array( item ); if( hop_is_html_element( item ) ) return hop_serialize_html( item ); return hop_bigloo_serialize( "#<" + tname + ">" ); } function hop_size_of_word( word ) { var s = 0; while( word > 0 ) { s++; word >>= 8; } return s; } function hop_serialize_word( word ) { var s = hop_size_of_word( word ); if( s == 0 ) { return "%00"; } else { var i1 = (s >> 4); var i2 = (s & 0xf); var c1 = i1 + ((i1 < 10) ? 48 : 55); var c2 = i2 + ((i2 < 10) ? 48 : 55); var rw = String.fromCharCode( 37, c1, c2 ); s--; while( s >= 0 ) { var c = ((word >> (s << 3)) & 0xff); if( (c < 127) && (c >= 46) ) { rw += String.fromCharCode( c ); } else { var i1 = (c >> 4); var i2 = (c & 0xf); var c1 = i1 + ((i1 < 10) ? 48 : 55); var c2 = i2 + ((i2 < 10) ? 48 : 55); rw += String.fromCharCode( 37, c1, c2 ); } s--; } return rw; } } function ucs2_to_utf8( s ) { var len = s.length; for( var i = 0; i < len; i++ ) { var c = s.charCodeAt( i ); if( c >= 128 ) { var utf = s.substring( 0, i ); for( ; i< len; i++, c = s.charCodeAt( i ) ) { if( c < 128 ) { utf += String.fromCharCode( c ); } else { if( (c > 127) && (c < 2048) ) { utf += String.fromCharCode((c >> 6) | 192); utf += String.fromCharCode((c & 63) | 128); } else { utf += String.fromCharCode((c >> 12) | 224); utf += String.fromCharCode(((c >> 6) & 63) | 128); utf += String.fromCharCode((c & 63) | 128); } } } return utf; } } return s; } function utf_length( s ) { var len = s.length; var res = len; for( var i = 0; i < len; i++ ) { var c = s.charCodeAt( i ); if( c >= 128 ) { if( (c > 127) && (c < 2048) ) { res++; } else { res += 2; } } } return res; } function hop_serialize_string( mark, item ) { return mark + hop_serialize_word( utf_length( item ) ) + encodeURIComponent( item ); } function hop_serialize_number( item ) { var sitem = item + ""; if( sitem.indexOf( "." ) == -1 ) { if( item < 0 ) return '-' + hop_serialize_word( -item ); else return hop_serialize_word( item ); } else { return 'f' + hop_serialize_word( sitem.length ) + sitem; } } function hop_serialize_boolean( item ) { return item ? 'T' : 'F'; } function hop_serialize_array( item ) { var l = item.length; var ra = '[' + hop_serialize_word( l ); var i = 0; for( i = 0; i < l; i++ ) { ra += hop_bigloo_serialize( item[ i ] ); } return ra; } function hop_serialize_date( item ) { var utc = Date.UTC( item.getUTCFullYear(), item.getUTCMonth(), item.getUTCDate(), item.getUTCHours(), item.getUTCMinutes(), item.getUTCSeconds() ) + ""; var ms = utc.substring( 0, utc.length - 3 ); return 'd' + hop_serialize_word( ms.length ) + encodeURIComponent( ms ); } function hop_serialize_html( item ) { if( "outerHTML" in item ) { return hop_serialize_string( '%22', item.outHTML ); } else { if( item.nodeType == 1 ) { var str = "<" + item.tagName + " id='" + item.id + "' " + (item.className ? ("class='" + item.className + "'") : "") + ">" + item.innerHTML + "" + item.tagName + ">"; return hop_serialize_string( '%22', str ); } else { if( item.nodeType == 3 ) { return hop_serialize_string( '%22', item.nodeValue ); } else { return hop_bigloo_serialize( "#<" + tname + ">" ); } } } } function hop_obj_to_string( item ) { return decodeURIComponent( hop_bigloo_serialize( item ) ); } function hop_string_to_obj( s ) { var pointer = 0; var definitions = []; var defining = false; function read_integer( s ) { return read_size( s ); } function read_float( s ) { var szf = read_size( s ); var res = s.substring( pointer, pointer + szf ); pointer += szf; return +res; } function read_char( s ) { new sc_Char(String.fromCharCode(n)); } function read_word( s, sz ) { var acc = 0; for( var iw = 0; iw < sz; iw++ ) { acc = (256 * acc) + s.charCodeAt( pointer++ ); } return acc; } function read_long_word( s, szlw ) { return read_word( szlw ); } function read_size( s ) { var szs = s.charCodeAt( pointer++ ); return read_word( s, szs ); } function read_string( s ) { var sz = read_size( s ); var res = s.substring( pointer, pointer + sz ); if( defining ) { definitions[ defining ] = res; defining = false; } pointer += sz; return res; } function read_definition() { defining = read_item(); return read_item(); } function read_reference() { return definitions[ read_item() ]; } function read_symbol() { return sc_jsstring2symbol( read_item() ); } function read_keyword() { return sc_jsstring2keyword( read_item() ); } function read_cnst() { switch( read_integer( s ) ) { default: alert( "read_cnst: not implemented: " + s ); } } function read_vector( sz ) { var res = sc_makeVector( sz ); if( defining ) { definitions[ defining ] = res; defining = false; } for( var iv = 0; iv < sz; iv++ ) { res[ iv ] = read_item(); } return res; } function read_list( sz ) { var res = sc_cons( null, null ); var hd = res; if( defining ) { definitions[ defining ] = res; defining = false; } for( var i = 0; i < (sz - 2); i++, hd = hd.cdr ) { hd.car = read_item(); hd.cdr = sc_cons( null, null ); } hd.car = read_item(); hd.cdr = read_item(); return res; } function read_extended_list( sz ) { var res = sc_cons( null, null ); var hd = res; if( defining ) { definitions[ defining ] = res; defining = false; } for( var i = 0; i < (sz - 2); i++, hd = hd.cdr ) { hd.car = read_item(); read_item(); hd.cdr = sc_cons( null, null ); } hd.car = read_item(); read_item(); hd.cdr = read_item(); return res; } function read_item() { switch( s.charAt( pointer++ ) ) { case '=': return read_definition(); case '#': return read_reference(); case "'": return read_symbol(); case ":": return read_keyword(); case "a": return read_char( s ); case "F": return false; case "T": return true; case ";": return undefined; case ".": return null; case "<": return read_cnst(); case '"': return read_string( s ) case '(': return read_list( read_size( s ) ); case '^': return read_extended_list( read_size( s ) ); case '[': return read_vector( read_size( s ) ); case "f": return read_float( s ); case "-": return -read_integer( s ); default: pointer--; return read_integer( s ); } } if( s.charAt( pointer ) == 'c' ) { pointer++; definitions = new Array( read_size( s ) ); } return read_item(); } var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; function base64_encode( input ) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt( i++ ); chr2 = input.charCodeAt( i++ ); chr3 = input.charCodeAt( i++ ); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if( isNaN( chr2 ) ) { enc3 = enc4 = 64; } else if( isNaN( chr3 ) ) { enc4 = 64; } output = output + keyStr.charAt( enc1 ) + keyStr.charAt( enc2 ) + keyStr.charAt( enc3 ) + keyStr.charAt( enc4 ); } while( i < input.length ); return output; } function utf8_decode( input ) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < input.length ) { c = input.charCodeAt(i); if( c < 128 ) { string += String.fromCharCode( c ); i++; } else if( (c > 191) && (c < 224) ) { c2 = input.charCodeAt( i + 1 ); string += String.fromCharCode( ((c & 31) << 6) | (c2 & 63) ); i += 2; } else { c2 = input.charCodeAt( i + 1 ); c3 = input.charCodeAt( i + 2 ); string += String.fromCharCode( ((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63) ); i += 3; } } return string; } function base64_decode( input ) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace( /[^A-Za-z0-9\+\/\=]/g, "" ); do { enc1 = keyStr.indexOf( input.charAt( i++ ) ); enc2 = keyStr.indexOf( input.charAt( i++ ) ); enc3 = keyStr.indexOf( input.charAt( i++ ) ); enc4 = keyStr.indexOf( input.charAt( i++ ) ); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode( chr1 ); if( enc3 != 64 ) { output = output + String.fromCharCode( chr2 ); } if( enc4 != 64 ) { output = output + String.fromCharCode( chr3 ); } } while( i < input.length ); return utf8_decode( output ); } var hop_anim_latency = 400; var hop_busy_anim_16_16 = "data:image/gif;base64,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"; function hop_service_url( service, formals, args ) { var len = formals.length; if( len == 0 ) { return service + "?hop-encoding=hop"; } else { var url = service + "?hop-encoding=hop"; var i; if( (args.length == 1) && hop_is_dom_form_element( args[ 0 ] ) ) { var els = args[ 0 ].elements; for( i = 0; i < els.length; i++ ) { if( els[ i ].type == "checkbox" ) { var val = els[ i ].checked ? els[ i ].value : false; url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( val ); } else { if( els[ i ].type == "radio" ) { if( els[ i ].checked ) { url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( els[ i ].value ); } } else { url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( els[ i ].value ); } } } return url; } else { for( i = 0; i < len; i++ ) { url += "&" + formals[ i ] + "=" + hop_bigloo_serialize( args[ i ] ); } return url; } } } function hop_service_url_varargs( service, args ) { var len = (arguments.length - 1); if( len == 0 ) { return service; } else { var url = service + "?hop-encoding=hop"; var i; for( i = 0; i < len; i++ ) { url += "&a" + i + "=" + hop_bigloo_serialize( arguments[ i + 1 ] ); } return url; } } function hop_default_failure( http ) { var t = http.responseText; if( !t ) { alert( "http error " + http.status ); return; } var div = document.getElementById( "hop_default_failure" ); var div2 = document.getElementById( "hop_default_failure_background" ); t = t.replace( /]*>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/head>/g, "" ); t = t.replace( /<(meta|link)[^>]*>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/html>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/body>/g, "" ); t = t.replace( /"/g, "\"" ); if( !div2 ) { div2 = document.createElement( "div" ); div2.id = "hop_default_failure_background"; node_style_set( div2, "position", "fixed" ); node_style_set( div2, "top", "0" ); node_style_set( div2, "bottom", "0" ); node_style_set( div2, "left", "0" ); node_style_set( div2, "right", "0" ); node_style_set( div2, "background", "#000" ); node_style_set( div2, "opacity", "0.5" ); node_style_set( div2, "overflow", "hidden" ); node_style_set( div2, "text-align", "center" ); node_style_set( div2, "z-index", "9999" ); document.body.appendChild( div2 ); } if( !div ) { div = document.createElement( "div" ); div.id = "hop_default_failure"; node_style_set( div, "position", "fixed" ); node_style_set( div, "top", "100px" ); node_style_set( div, "left", "0" ); node_style_set( div, "right", "0" ); node_style_set( div, "text-align", "center" ); node_style_set( div, "border", "0" ); node_style_set( div, "z-index", "10000" ); node_style_set( div, "opacity", "1" ); div.align = "center"; div.innerHTML = t; document.body.appendChild( div ); } else { div.innerHTML = t; } } function hop_anim_16_16( title ) { var vis = document.createElement( "div" ); node_style_set( vis, "position", "fixed" ); node_style_set( vis, "top", "5px" ); node_style_set( vis, "right", "5px" ); node_style_set( vis, "z-index", "100" ); node_style_set( vis, "background", "#eeeeee" ); node_style_set( vis, "border-color", "black" ); node_style_set( vis, "border-style", "outset" ); node_style_set( vis, "border-width", "1px" ); node_style_set( vis, "padding-top", "3px" ); node_style_set( vis, "width", "20px" ); node_style_set( vis, "height", "20px" ); node_style_set( vis, "-moz-border-radius", "0.2em" ); node_style_set( vis, "-moz-opacity", "0.7" ); vis.title = title; vis.align = "center"; var img = document.createElement( "img" ); img.className = "hop-busy-anim"; if( !hop_config.inline_image ) { img.src = hop_share_directory() + "/icons/busy-anim-16.gif"; } else { img.src = hop_busy_anim_16_16; } vis.appendChild( img ); return vis; } var hop_default_anim = hop_anim_16_16; function hop_default_anim_set( anim ) { var old = hop_default_anim; hop_default_anim = anim; return old; } function hop_default_anim_get( ) { return hop_default_anim; } var hop_anim_vis = false; var hop_anim_service = false; var hop_anim_interval; var hop_anim_fun = false; function hop_stop_anim() { if( hop_anim_interval ) { if( hop_has_setInterval ) clearInterval( hop_anim_interval ); hop_anim_interval = false; } } function hop_anim( service, user_anim ) { hop_stop_anim(); if( hop_anim_service == service ) { if( hop_anim_vis && (hop_anim_fun == user_anim) ) { hop_anim_vis.title = service; // node_style_set( hop_anim_vis, "visibility", "visible" ); node_style_set( hop_anim_vis, "display", "block" ); return hop_anim_vis; } else { hop_anim_vis = user_anim( service ); document.body.appendChild( hop_anim_vis ); return hop_anim_vis; } } return false; } function hop_responsetext_error( xhr ) { if( xhr.responseText.length > 80 ) return xhr.responseText.substring( 0, 80 ); else return xhr.responseText; } function hop_send_request( svc, sync, success, failure, anim, henv, auth ) { var xhr = hop_make_xml_http_request(); var hop_err = hop_error; var hop_reperror = hop_responsetext_error; var hop_header_ctype = hop_header_content_type; var err = function( exc, xhr, ctype ) { var txt = hop_reperror( xhr ); var fun = ctype ? ("with-hop [content-type=" + ctype + "]") : "with-hop"; return hop_err( fun, exc, txt, svc ); } function onreadystatechange() { if( xhr.readyState == 4 ) { try { var status = xhr.status; switch( status ) { case 200: try { var ctype = hop_header_ctype( xhr ); var expr; if( ctype === "application/x-javascript" ) { try { expr = eval( xhr.responseText ); } catch( exc ) { err( exc, xhr ); expr = false; } return success( expr, xhr ); } else if( ctype === "text/html" ) { var el = hop_create_element( xhr.responseText ); return success( el, xhr ); } else { return success( xhr.responseText, xhr ); } } catch( exc ) { err( exc, xhr, ctype ); } case 202: return success( hop_unserialize( xhr.responseText ), xhr ); case 204: return false; case 257: return hop_js_eval( xhr ); case 258: if( xhr.responseText != null ) return eval( xhr.responseText ); else return false; case 259: hop_set_cookie( xhr ); return false; case 407: err( "Bad authentication", xhr ); return false; default: if( (typeof status == "number") && (status > 200) && (status < 300) ) { if( success ) { return success( xhr.responseText, xhr ); } } else { if( failure ) { return failure( xhr ); } else { return hop_default_failure( xhr ); } } } } catch( exc ) { if( typeof failure == "function" ) { failure( xhr ); } else { err( exc, xhr ); } } finally { try { if( hop_anim_vis != false ) { node_style_set( hop_anim_vis, "display", "none" ); } hop_anim_service = false; } catch( e ) { } } } return false; } if( !sync ) { xhr.onreadystatechange = onreadystatechange; } xhr.open( "GET", svc, (sync != true) ); xhr.setRequestHeader( 'Connection', 'close' ); xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1' ); if( henv.length > 0 ) { xhr.setRequestHeader( 'Hop-Env', hop_serialize_request_env() ); } if( auth ) { xhr.setRequestHeader( 'Authorization', auth ); } try { if( anim ) hop_anim_service = svc; xhr.send( null ); hop_stop_anim(); if( anim && hop_has_setInterval ) { var a = (anim instanceof Function) ? anim : hop_default_anim; hop_anim_interval = setInterval( function() { hop_anim( svc, a ) }, hop_anim_latency ); } if( sync ) { if( xhr.readyState == 4 ) { onreadystatechange(); } else { hop_error( "with-hop", "synchronous call failed", "readyState: " + xhr.readyState, svc ); } } } catch( e ) { if( hop_anim_vis != false ) { node_style_set( hop_anim_vis, "display", "none" ); } hop_anim_service = false; hop_error( "with-hop", e, "Cannot call server", svc ); } return xhr; } function with_hop( svc, success, failure, sync, anim ) { if( !success ) success = function( h ) { return h }; if( !failure ) failure = hop_default_failure; return hop_send_request( svc, sync, success, failure, true, hop_serialize_request_env(), false ); } /*** META (define-macro (with-hop svc . rest) (let ((success #f) (fail #f) (sync #f) (anim #t) (user #f) (password #f) (authorization #f)) (let loop ((rest rest)) (cond ((null? rest) `(hop_send_request ,svc ,sync ,(or success '(lambda (h) h)) ,(or fail 'hop_default_failure) ,anim (hop_serialize_request_env) ,(cond (authorization authorization) ((and (string? user) (string? password)) (string-append "Basic " (base64-encode (string-append user ":" password))))))) ((eq? (car rest) :anim) (if (null? (cdr rest)) (error 'with-hop "Illegal :anim argument" rest) (set! anim (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :authorization) (if (null? (cdr rest)) (error 'with-hop "Illegal :authorization argument" rest) (set! authorization (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :user) (if (null? (cdr rest)) (error 'with-hop "Illegal :user argument" rest) (set! user (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :password) (if (null? (cdr rest)) (error 'with-hop "Illegal :password argument" rest) (set! password (cadr rest))) (loop (cddr rest))) ((not success) (set! success (car rest)) (loop (cdr rest))) ((not fail) (set! fail (car rest)) (loop (cdr rest))) (else (set! sync (car rest)) (loop (cdr rest))))))) */ function hop( svc, success, failure, sync ) { if( success == true ) { location.href = svc; return true; } if( !success ) success = function( h ) { return h; } if( !failure ) failure = hop_default_failure; return hop_send_request( svc, sync, success, failure, true, hop_serialize_request_env() ); } var hop_request_env = []; var hop_request_env_string = ""; var hop_request_env_invalid = false; function hop_serialize_request_env() { if( hop_request_env_invalid ) { var tmp = null; for( var p in hop_request_env ) { if( (typeof hop_request_env[ p ] != "function") && (hop_request_env[ p ] != undefined) ) { tmp = sc_cons( sc_cons( p, hop_request_env[ p ] ), tmp ); } } hop_request_env_string = hop_bigloo_serialize( tmp ); } return hop_request_env_string; } function hop_request_reset() { hop_request_env_string = ""; hop_request_env_set = false; return null; } function hop_request_set( key, val ) { hop_request_env_invalid = true; hop_request_env[ key ] = val; return val; } /*** META ((export request-get) (peephole: (hole 1 "hop_request[" key"]"))) */ function hop_request_get( key ) { return hop_request[ key ]; } var hop_client_debug = 0; function hop_error( fun, exc, msg, svc ) { var emsg = exc ? exc.toString() : "???"; if( exc ) { if( "message" in exc ) { emsg = exc.message; } else { if( "description" in exc ) { emsg = exc.description; } } if( "line" in exc ) { emsg = emsg + " (line " + exc.line + ")"; } } if( typeof svc === "string" || svc instanceof String ) fun = fun + ", " + svc; alert( "*** ERROR " + fun + ": " + emsg + " -- " + msg ); throw exc; } function hop_debug() { return hop_client_debug; } function hop_debug_set( v ) { if( sc_isNumber( v ) ) hop_client_debug = v; } function hop_trace() { if( hop_client_debug > 0 ) { var svc = hop_service_url( hop_service_base() + "/trace", [ "args" ], new Array( sc_vector2list( arguments ) ) ); hop_send_request( svc, true, function() {}, function() {}, false, [] ); } } function hop_tprint( file, pos, rest ) { var svc = hop_service_url( hop_service_base() + "/trace/tprint", [ "file", "pos", "args" ], [ file, pos, rest ] ); hop_send_request( svc, true, function() {}, function() {}, false, [] ); } /*** META (define-macro (tprint . rest) (if (epair? rest) (match-case (cer rest) ((at ?name ?pos) `(hop_tprint ,(relative-file-name name (pwd)) ,(file-position->line pos name) (list ,@rest))) (else `(hop_tprint #f #f (list ,@rest)))) `(hop_tprint #f #f (list ,@rest)))) */ function hop_replace_inner( el ) { if( el != undefined ) { return function( html ) { if( html ) { hop_innerHTML_set( el, html ); } } } else { alert( "*** Hop Error, Can't find element" ); return function( http ) { }; } } function hop_replace_inner_id( id ) { return hop_replace_inner( document.getElementById( id ) ); } function hop_set_cookie( http ) { try { var cookie = http.getResponseHeader( "set-cookie" ); if( cookie ) document.cookie = cookie; } catch( e ) { ; } } function hop_cookie_remove( name, path, domain ) { if( hop_cookie_get_value( name ) ) { hop_cookie_set_value( name, "", path, domain ); } } function hop_cookie_get_value( name ) { var cookies = document.cookie; var i = cookies.indexOf( name + "=" ); if( i !== -1 ) { var start = i + name.length + 1; var end = cookies.indexOf( ";", start ); if( end == -1 ) end = cookies.length; return unescape( cookies.substring( start, end ) ); } else { return null; } } function hop_cookie_set_value( name, val, path, domain, expires ) { var cookie = name + "=" + val; if( (path instanceof String) || (typeof path == "string") ) { cookie += "; path=" + path; } else { cookie += "; path=/"; } if( (expires instanceof String) || (typeof expires == "string") ) { cookie += "; expires=" + expires; } else { if( expires instanceof Date ) { cookie += "; expires=" + expires.toGMTString(); } } if( (domain instanceof String) || (typeof domain == "string") ) { cookie += "; domain=" + domain; } document.cookie = cookie; } var hop_load_frequency = 100; function HopLoadError( file ) { var e = new Error( "hop-load error" ); e.file = file; return e; } function hop_load( src, timeout ) { var script = document.createElement( "script" ); script.src = src; var loaded = false; var holder = document.getElementsByTagName( "head" ); if( !timeout || (timeout == undefined) ) timeout = -1; if( holder != null ) { if( timeout != 0 ) script.onload = function( e ) { loaded = true; }; holder[ 0 ].appendChild( script ); if( timeout != 0 ) { var it; var p = function() { if( loaded == true ) { clearInterval( it ); } else { if( timeout > 0 ) { timeout -= hop_load_frequency; if( timeout <= 0 ) { clearInterval( it ); throw( new HopLoadError( src ) ); } } } }; it = setInterval( p, hop_load_frequency ); } } else { alert( "*** Hop Error, Can't find HEAD element" ); } } var hop_window_onload_add = function( proc ) { var oldonload = window.onload; if( typeof oldonload != 'function' ) { window.onload = proc; } else { window.onload = function( e ) { oldonload( e ); proc( e ); } } } hop_window_onload_add( function( e ) { hop_window_onload_add = function( proc ) { proc( e ); } } ); function hop_window_onload_cons( proc ) { var oldonload = window.onload; if( typeof oldonload != 'function' ) { window.onload = proc; } else { window.onload = function( e ) { proc( e ); oldonload( e ); } } } function hop_window_onunload_add( proc ) { if( typeof( window.onunload ) != 'function' ) { window.onunload = proc; } else { var oldonunload = window.onunload; window.onunload = function( e ) { oldonunload( e ); proc( e ); } } } function hop_update( node ) { if( node.hop_update != undefined ) { node.hop_update(); } for( var i = 0; i < node.childNodes.length; i++ ) { hop_update( node.childNodes[ i ] ); } } function hop_find_runtime_type( obj ) { if( obj instanceof Object ) { if( obj instanceof Date ) { return "date"; } else { if( obj instanceof RegExp ) { return "regexp"; } else { if( typeof obj.hop_find_runtime_type == "function" ) return obj.hop_find_runtime_type(); else return "object"; } } } else { var tname = typeof obj; if( tname == "string" ) { if( sc_isSymbol( obj ) ) return "symbol"; if( sc_isKeyword( obj ) ) return "keyword"; return tname; } return tname; } } function after( timeout, proc ) { var tm = sc_isNumber( timeout ) ? timeout : 1; var i = setInterval( function() { clearInterval( i ); proc() }, tm ); return true; } function timeout( tm, proc ) { var i = setInterval( function() { if( !proc() ) clearInterval( i )}, tm ); } function url_decode( s ) { try { return decodeURI( s ); } catch( e ) { return s; } } function url_encode( s ) { return encodeURI( s ); } function string_hex_extern( str ) { var res = ""; var l = str.length; for( var i = 0; i < l; i++ ) { res += "0123456789abcdef".charAt( (str.charCodeAt( i ) >> 4) & 15 ) + "0123456789abcdef".charAt( (str.charCodeAt( i ) & 15) ); } return res; } function string_hex_intern( s ) { var res = ""; var l = s.length; var z = '0'.charCodeAt( 0 ); var n = '9'.charCodeAt( 0 ); var a = 'a'.charCodeAt( 0 ); var f = 'f'.charCodeAt( 0 ); var A = 'A'.charCodeAt( 0 ); function hex_to_num( c ) { if( (c >= z) && ( c<= n) ) { return c - z; } if( (c >= a) && ( c<= f) ) { return (c - a) + 10;; } return (c - A) + 10; } for( var i = 0; i < l; i += 2 ) { var d1 = hex_to_num( s.charCodeAt( i ) ); var d2 = hex_to_num( s.charCodeAt( i + 1 ) ); res += String.fromCharCode( (d1 << 4) + d2 ); } return res; } function date_year( d ) { return d.getYear(); } function date_month( d ) { return d.getMonth(); } function date_day( d ) { return d.getDay(); } function date_hour( d ) { return d.getHours(); } function date_minute( d ) { return d.getMinutes(); } function date_second( d ) { return d.getSeconds(); } var hop_current_state_history = undefined; var hop_state_history_handler = {}; function hop_state_history_register_handler( key, reset, proc ) { hop_state_history_handler[ key ] = { reset: reset, proc: proc }; } function _hop_state_entry( op, val ) { this.op = op; this.val = val; this.close = false; } function hop_state_history_to_location( state ) { var loc = undefined; for( p in state ) { if( state[ p ] instanceof _hop_state_entry ) { if( loc == undefined ) { loc = "#" + p + "=" + state[ p ].op + ":" + state[ p ].val; } else { loc += "," + p + "=" + state[ p ].op + ":" + state[ p ].val; } } } return loc; } var hop_hash_history_regexp = /#?([^=]+)=([^:]+):([^,]+)+/; function hop_location_to_state_history( hash ) { var state = {}; var split = hash.split( "," ); for( var i = 0; i < split.length; i++ ) { var el = split[ i ].match( hop_hash_history_regexp ); if( el ) { var id = el[ 1 ]; var op = el[ 2 ]; var val = el [ 3 ]; state[ id ] = new _hop_state_entry( op, val ); } } return state; } function hop_state_history_push( id, op, val ) { if( hop_current_state_history == undefined ) { hop_current_state_history = {}; hop_current_state_history[ id ] = new _hop_state_entry( op, val ); } else { var olde = hop_current_state_history[ id ]; if( olde == undefined ) { hop_current_state_history[ id ] = new _hop_state_entry( op, val ); } else { if( (olde.op != op) || (olde.val != val) ) { olde.op = op; olde.val = val; } } } } function hop_state_history_flush() { var loc = hop_state_history_to_location( hop_current_state_history ); var old = window.location.href; var i = old.indexOf( "#" ); if( i == -1 ) { hop_active_location_set( document, old + loc ); } else { hop_active_location_set( document, old.substring( 0, i ) + loc ); } } var hop_state_history_transaction = 0; function hop_state_history_add( id, op, val ) { hop_state_history_push( id, op, val ); if( hop_state_history_transaction == 0 ) { hop_state_history_flush(); } } function hop_with_history( proc ) { var res; hop_state_history_transaction++; try { res = proc(); } finally { hop_state_history_transaction--; } hop_state_history_flush(); return res; } function hop_state_history_reset() { if( hop_current_state_history != undefined ) { for( p in hop_current_state_history ) { if( hop_current_state_history[ p ] instanceof _hop_state_entry ) { var op = hop_current_state_history[ p ].op; var handler = hop_state_history_handler[ op ]; if( handler != undefined ) { handler.proc( p, handler.reset ); } } } hop_current_state_history = undefined; } } function hop_state_history_update( olds, news ) { var res = 0; if( olds == undefined ) { for( p in news ) { var state = news[ p ]; if( state instanceof _hop_state_entry ) { var op = state.op; var handler = hop_state_history_handler[ op ]; if( (handler != undefined) && !state.close ) { if( handler.proc( p, state.val ) ) { state.close = true; } else { res++; } } } } } else { for( p in olds ) { if( (olds[ p ] instanceof _hop_state_entry) && !(news[ p ] instanceof _hop_state_entry) ) { var op = olds[ p ].op; var handler = hop_state_history_handler[ op ]; if( handler != undefined ) { handler.proc( p, handler.reset ); } } } for( p in news ) { var state = news[ p ]; if( state instanceof _hop_state_entry ) { if( !(olds[ p ] instanceof _hop_state_entry) || (state.op != olds[ p ].op) || (state.val != olds[ p ].val) ) { var op = state.op; var handler = hop_state_history_handler[ op ]; if( (handler != undefined) && !state.close ) { if( handler.proc( p, state.val ) ) { state.close = true; } else { res++; } } } } } } return res; } var hop_hash_history_check_regexp = new RegExp( "^#(?:[^=]+=[^:]+:[^,]+,?)+$" ); function hop_hash_historyp( hash ) { return hop_hash_history_check_regexp.exec( hash ); } var hop_eval_history_interval = false; function hop_retry_eval_history_state( count, old_state, new_state ) { var fun = function() { var c = hop_state_history_update( old_state, new_state ); if( (c == 0) || (c == count) || hop_eval_history_interval.invalid ) { clearInterval( hop_eval_history_interval ); } } hop_eval_history_interval = setInterval( fun, 200 ); hop_eval_history_interval.invalid = false; } function hop_eval_history_state( location ) { var hash = location.hash; if( hop_eval_history_interval ) hop_eval_history_interval.invalid = true; if( hash.length == 0 ) { hop_state_history_reset(); } else { if( hop_hash_historyp( hash ) ) { var new_state = hop_location_to_state_history( hash ); var old_state = hop_current_state_history; var count = hop_state_history_update( old_state, new_state ); if( count == 0 ) { hop_current_state_history = new_state; } else { hop_retry_eval_history_state( count, old_state, new_state ); } } } } function hop_current_history() { var hash = location.hash; if( hash.length == 0 ) { return false; } if( hop_hash_historyp( hash ) ) { return hop_location_to_state_history( hash ); } return false; } function hop_replay_history( hist ) { hop_current_state_history = undefined; var loc = function( v ) { this.hash = v; } hop_eval_history_state( new loc( hop_state_history_to_location( hist ) ) ); } function _hop_history( key ) { this.key = key; } function hop_make_history( key, handler, reset ) { hop_state_history_register_handler( key, reset, handler ); return new _hop_history( key ); } function hop_history_add( history, id, val ) { if( !history instanceof _hop_history ) { alert( "*** ERROR: Illegal history object -- " + history ); return false; } else { return hop_state_history_add( id, history.key, val ); } } if( hop_enable_location_event ) { hop_window_onload_add( function( e ) { hop_add_event_listener( document, "location", hop_eval_history_state ); } ); } function hop_bigloo_serialize_pair( l ) { var res = ""; var len = 0; while (sc_isPair( l ) ) { res += hop_bigloo_serialize( l.car ); l = l.cdr; len++; } if( l == null ) { return hop_serialize_word( len + 1 ) + res + "."; } else { return hop_serialize_word( len + 1 ) + res + hop_bigloo_serialize( l ); } } sc_Pair.prototype.hop_bigloo_serialize = function() { return '(' + hop_bigloo_serialize_pair( this ); }; sc_Pair.prototype.hop_find_runtime_type = function() { return "pair"; }; sc_Vector.prototype.hop_find_runtime_type = function() { return "vector"; }; sc_Struct.prototype.hop_find_runtime_type = function() { return "struct"; }; sc_OutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_StringOutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_GenericOutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_InputPort.prototype.hop_find_runtime_type = function() { return "input-port"; }; Boolean.prototype.hop_find_runtime_type = function() { return "bbool"; }; String.prototype.hop_find_runtime_type = function() { return hop_find_runtime_type(this.toString()); }; sc_Char.prototype.hop_find_runtime_type = function() { return "bchar"; }; ]]> TPAC 08, W3C Technical Plenary 2008 ...Start...Title Preludeapplications demand languageshop HopHOP...The Web...Architecture ApplicationAn applicationA Diffuse Music PlayerHopAudio (architecture) ConclusionConclusionWhy Using Hop?hop.inria.frendHopSlide v1.5.121 October 2008HopSlide Help (v1.5.1)KeyboardToggle this helpalt-hReload slidesalt-rToggle slide selectoralt-sOpen a full screen windowalt-wUpdate sizealt-uToggle big cursoralt-mToggle focusalt-fToggle drawing areaalt-cNext slidePgDn↓alt-nRetEnterSpacePrevious slidePgUp↑alt-pFirst slideHomeLast slideEndClose slideEscMouseReload slidesshift Button1Slides selectorcrtl Button1Focus enlarge/shrinkButton4Button5 image/svg+xmlPress [Space] to start... Hop, an Everyware Development KitManuel SerranoMimosa TeamInria Sophia-Antipolishttp://hop.inria.fr Prelude Applications demand Languages X= 27.3 DATA A, B / 5.0, 12.0. / IF (X) 10, 20, 30 DO 9 J= 1, 10 DO 9 K= 1, 10 9 L= J + K 60 FORMAT ( 9H1GOODBYE. )?module ABRO: input A, B, R; output O; loop [ await A || await B ]; emit O each R end module#include <iostream> class Bird { public: virtual void OutName() { std::cout << "a bird"; } virtual ~Bird() {} }; int main() { Swan mySwan; Bird* myBird = &mySwan; myBird->OutName(); return 0; }
. args) `(hop_dom_create "p" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "param" ,@args)) */ /*** META (define-macro (
. args) `(hop_dom_create "pre" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "q" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "s" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "samp" ,@args)) */ /*** META (define-macro (", start ); if( end == -1 ) end = text.indexOf( "", start ); if( (end > start) ) { res = eval( text.substr( start, end - start ) ); } } return res; } try { if( "getElementsByTagName" in node ) { var scripts = node.getElementsByTagName( "script" ); if( scripts && scripts.length > 0 ) { for ( var j = 0; j < scripts.length; j++ ) { if( false && scripts[ j ].childNodes.length > 0 ) { res = eval( scripts[ j ].childNodes[ 0 ].nodeValue ); } else { res = eval( scripts[ j ].innerHTML ); } } } else { return hop_node_eval_from_text( text ); } } else { return hop_node_eval_from_text( text ); } } catch( e ) { alert( e ); throw e; } return res; } function node_style_get( obj, prop ) { if( (obj instanceof String) || (typeof obj === "string") ) obj = document.getElementById( obj ); if( sc_isKeyword( prop ) ) prop = sc_keyword2jsstring( prop ); return obj.style[ prop ]; } function hop_create_element( html ) { var div = document.createElement( 'div' ); div.innerHTML = "IE7 bug" + html; return div.childNodes[ 1 ]; } function hop_create_encoded_element( html ) { return hop_create_element( decodeURIComponent( html ) ); } function hop_innerHTML_set( nid, html ) { var el; if( (nid instanceof String) || (typeof nid == "string") ) { el = document.getElementById( nid ); if( el == undefined ) { alert( "*** ERROR:innerHTML-set! -- cannot find element \"" + nid + "\""); return; } } else { if( !nid ) { alert( "*** ERROR:innerHTML-set! -- illegal element \"" + nid + "\""); return; } el = nid; } if( (html instanceof String) || (typeof html == "string") ) { el.innerHTML = html; hop_node_eval( el, html ); } else if( hop_is_html_element( html ) || sc_isPair( html ) ) { dom_set_child_node( el, html ); if( hop_innerHTML_need_evalp ) hop_node_eval( el, html ); } else { el.innerHTML = html; } } function hop_style_attribute_set( obj, val ) { var expr; if( (val instanceof String) || (typeof val == "string") ) expr = eval( val ); for( var p in expr ) { node_style_set( obj, p, expr[ p ] ); } } function hop_element_x( obj ) { var res = 0; while( obj != null ) { if( typeof obj.offsetLeft == "number" ) res += obj.offsetLeft; else { break; } obj = obj.offsetParent; } return res; } function hop_element_y( obj ) { var res = 0; while( obj != null ) { if( typeof obj.offsetTop == "number" ) res += obj.offsetTop; else { break; } obj = obj.offsetParent; } return res; } function hop_bounding_box( e, m ) { var n; if( (e instanceof String) || (typeof e == "string") ) { n = document.getElementById( e ); } else { n = e; } if( !m ) m = 0; return [ hop_element_x( n ) - m, hop_element_y( n ) - m, n.offsetWidth + (2*m), n.offsetHeight + (2*m) ]; } function hop_bounding_box_to_list( bbox ) { return sc_vector2list( bbox ); } function hop_bounding_box_x( bbox, loc ) { if( arguments.length == 1 ) return bbox[ 0 ]; if( (loc == "w") || (loc == "nw") || (loc == "sw") ) return bbox[ 0 ]; if( (loc == "n") || (loc == "s")) return bbox[ 0 ] + (bbox[ 2 ]/2); if( (loc == "ne") || (loc == "e") || (loc == "se") ) return bbox[ 0 ] + bbox[ 2 ]; return 0; } function hop_bounding_box_y( bbox, loc ) { if( arguments.length == 1 ) return bbox[ 1 ]; if( (loc == "nw") || (loc == "n") || (loc == "ne") ) return bbox[ 1 ]; if( (loc == "e") || (loc == "w")) return bbox[ 1 ] + (bbox[ 3 ]/2); if( (loc == "se") || (loc == "s") || (loc == "sw") ) return bbox[ 1 ] + bbox[ 3 ]; return 0; } function hop_add_event_listener( obj, event, proc, capture ) { if( event == "location" ) return hop_add_active_location_listener( obj, proc ); if( event == "server" ) return hop_add_server_listener( obj, proc, capture ); if( event == "serverready" ) return hop_add_serverready_listener( obj, proc ); if( event == "serverclose" ) return hop_add_serverclose_listener( obj, proc ); if( event == "timeout" ) return hop_add_timeout_listener( obj, proc ); if( (obj.hop_add_event_listener != undefined) && (obj.hop_add_event_listener != hop_add_event_listener) ) return obj.hop_add_event_listener( event, proc, capture ); return hop_add_native_event_listener( obj, event, proc, capture ); } function hop_remove_event_listener( obj, event, proc, capture ) { if( event == "location" ) return hop_remove_active_location_listener( obj, proc ); if( event == "server" ) return hop_remove_server_listener( obj, proc ); if( event == "serverready" ) return hop_remove_serverready_listener( obj, proc ); if( event == "serverclose" ) return hop_remove_serverclose_listener( obj, proc ); if( event == "timeout" ) return hop_remove_timeout_listener( proc ); if( (obj.hop_remove_event_listener != undefined) && (obj.hop_remove_event_listener != hop_remove_event_listener) ) return obj.hop_remove_event_listener( event, proc, capture ); return hop_remove_native_event_listener( obj, event, proc, capture ); } function hop_add_active_location_listener( obj, proc ) { obj.hop_active_location_proc = proc; var i = window.location.href.indexOf( "#" ); if( i === -1 ) { obj.hop_active_location_href = window.location.href; } else { obj.hop_active_location_href = window.location.href.substring( 0, i-1 ); } if( obj.hop_active_location_interval === undefined ) { var check = function() { if( obj.hop_active_location_href !== window.location.href ) { if( obj.hop_active_location_href != window.location.href ) { obj.hop_active_location_href = window.location.href; obj.hop_active_location_proc( window.location ); } } return true; } obj.hop_active_location_interval = setInterval( check, hop_active_location_timeout ); } return false; } function hop_remove_active_location_listener( obj, proc ) { if( obj.hop_active_location_interval != undefined ) { clearInterval( obj.hop_active_location_interval ); obj.hop_active_location_interval = undefined; } } function hop_active_location_set( obj, href ) { window.location.href = href; obj.hop_active_location_href = window.location.href; } var hop_servevt_id = "__hop_serevt_proxy"; var hop_server_event_count = 0; var re = new RegExp( "<[\/]?event[^>]*>", "g" ); function HopServerEvent( n, text, val ) { this.isStopped = false; this.name = n; this.value = val; this.id = hop_server_event_count++; if( typeof text == "string" ) { this.responseText = text.replace( re, "" ); } else { this.responseText = ""; } } var hop_servevt_proxy = false; var hop_servevt_table = {}; var hop_servevt_ctable = {}; var hop_servevt_dlist = null; function start_servevt_ajax_proxy( key ) { if( !hop_servevt_proxy.httpreq ) { var xhr_error_ttl = 6 * 3; var server_ready = false; var register = function( id ) { var svc = hop_service_base() + "/server-event/register?event=" + id + "&key=" + key; var success = function( val, xhr ) { if( !server_ready ) { server_ready = true; hop_trigger_serverready_event( new HopServerReadyEvent() ); } if( val != null ) { xhr_error_ttl = 6 * 3; register( "" ); while( val != null ) { var v = val.car; var id = v.car; var vals = v.cdr; while( vals != null ) { hop_trigger_servevt( id, vals.car, vals.car, false ); vals = vals.cdr; } val = val.cdr; } } } var failure = function( xhr ) { if( !xhr.status && (xhr_error_ttl > 0) && !xhr.getAllResponseHeaders() ) { xhr_error_ttl--; register( id ); } else { hop_servevt_onclose(); } } hop_servevt_proxy.httpreq = hop_send_request( svc, false, success, failure, false, [] ); } var unregister = function( id ) { hop_servevt_proxy.httpreq.abort(); var svc = hop_service_base() + "/server-event/unregister?event=" + id + "&key=" + hop_servevt_proxy.key; hop_servevt_proxy.httpreq = hop_send_request( svc, false, function() { ; }, false, false, [] ); }; hop_servevt_proxy.register = register; hop_servevt_proxy.unregister = unregister; for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { register( p ); } } } } function start_servevt_flash_proxy( key, host, port ) { var object_proxy = function() { return "" + "" + "" + "" + ""; } var embed_proxy = function() { var embed = document.createElement( "embed" ); embed.id = hop_servevt_id; embed.className = "hop-servevt-proxy"; embed.setAttribute( "width", "1px" ); embed.setAttribute( "height", "1px" ); embed.setAttribute( "src", hop_share_directory() + "/flash/HopServevt.swf" ); embed.setAttribute( "type", "application/x-shockwave-flash" ); embed.setAttribute( "name", "__hop_servevt_proxy" ); embed.setAttribute( "swliveconnect", "true" ); embed.setAttribute( "allowScriptAccess", "always" ); embed.setAttribute( "FlashVars", "init=hop_servevt_proxy_flash_init" + "&host=" + host + "&port=" + port + "&key=" + key + "&onevent=hop_trigger_servevt" + "&onclose=hop_servevt_onclose" + "&onerror=hop_servevt_onerror" ); return embed; } var proxy = document.createElement( "div" ); node_style_set( proxy, "position", "fixed" ); node_style_set( proxy, "top", "0" ); node_style_set( proxy, "right", "0" ); node_style_set( proxy, "background", "transparent" ); if( hop_config.flash_markup === "embed" ) { proxy.appendChild( embed_proxy() ); } else { proxy.innerHTML = object_proxy(); } document.body.appendChild( proxy ); document.getElementById( hop_servevt_id ).key = key; return proxy; } function hop_servevt_onerror( msg ) { hop_error( "servevt", new Error( msg ), "internal server event error" ); } function hop_servevt_proxy_flash_init() { hop_flash_minversion_set( 8 ); var pending_events = 0; hop_servevt_proxy = document.getElementById( hop_servevt_id ); var abort = function( id ) { var svc = hop_service_base() + "/server-event/unregister?event=" + id + "&key=" + hop_servevt_proxy.key; hop_servevt_proxy.httpreq = hop_send_request( svc, false, function() {;}, false, false, [] ); } var failure = function( e ) { hop_servevt_onclose(); for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { abort( p ); } } hop_send_request( hop_service_base() + "/server-event/close?key=" + hop_servevt_proxy.key, false, function() {;}, false, false, [] ); } var register = function( id ) { var svc = hop_service_base() + "/server-event/register?event=" + id + "&key=" + hop_servevt_proxy.key + "&flash=true"; var success = function( e ) { if( pending_events > 0 ) { if( pending_events == 1 ) { hop_trigger_serverready_event( new HopServerReadyEvent() ); } pending_events--; } } hop_servevt_proxy.httpreq = hop_send_request( svc, false, success, failure, false, [] ); } hop_servevt_proxy.register = register; hop_servevt_proxy.unregister = function( id ) { abort( id ); } hop_window_onunload_add( failure ); for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { pending_events++; } } if( pending_events > 0 ) { for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { register( p ); } } } else { hop_trigger_serverready_event( new HopServerReadyEvent() ); } } function servevt_flashp( port ) { return port && (hop_config.flash_version >= 8) && (hop_config.flash_external_interface); } function hop_start_servevt_proxy() { hop_servevt_proxy = new Object(); hop_servevt_proxy.register = function( x ) {}; hop_send_request( hop_service_base() + "/server-event/info", false, function( v ) { var host = v[ 0 ]; var port = v[ 1 ]; var key = v[ 2 ]; if( servevt_flashp( port ) ) { try { start_servevt_flash_proxy( key, host, port ); } catch( e ) { hop_error( "hop_start_servevt_proxy", e, "Cannot start flash proxy, port=" + port); } } else { start_servevt_ajax_proxy( key ); } }, function( v ) { throw new Error( "Cannot get server event port number" ); }, true, [] ); } function hop_trigger_servevt( id, text, value, json ) { try { var v = (json ? eval( value, text ) : value); var evt = new HopServerEvent( id, text, v ); var p2 = hop_servevt_table[ id ]; if( sc_isPair( hop_servevt_dlist ) && sc_isPair( hop_servevt_ctable[ id ] ) ) { var p1 = hop_servevt_dlist; while( sc_isPair( p1 ) ) { p1.car( evt ); p1 = p1.cdr; } } evt.isStopped = false; while( sc_isPair( p2 ) ) { try { p2.car( evt ); } catch( exc ) { hop_error( "hop_trigger_servevt [event " + id + "]", exc, p2.car ); } if( evt.isStopped ) break; p2 = p2.cdr; } } catch( exc ) { hop_error( "hop_trigger_servevt [event " + id + "]", exc, value ); } } var hop_serverclose_list = null; var hop_serverclose_triggered = false; function hop_add_serverclose_listener( obj, proc ) { if( obj === document ) { if( hop_serverclose_triggered ) { var evt = new HopServerEvent( "serverclose", false, false ); proc( evt ); } else { hop_serverclose_list = sc_cons( proc, hop_serverclose_list ); } } else { throw new Error( "add-event-listener!: Illegal `serverclose' recipient" + obj ); } } function hop_remove_serverclose_listener( obj, proc ) { if( obj === document ) { hop_serverclose_list = sc_remqBang( proc, hop_serverclose_list ); return true; } else { throw new Error( "remove-event-listener!: Illegal `serverclose' recipient" + obj ); return false; } } function hop_servevt_onclose() { var evt = new HopServerEvent( "serverclose", false, false ); var p = hop_serverclose_list; while( sc_isPair( p ) ) { p.car( evt ); if( evt.isStopped ) break; p = p.cdr; } hop_serverclose_triggered = true; } function hop_add_server_listener( obj, proc, capture ) { if( typeof proc != "function" ) { throw new Error( "Illegal procedure: " + proc ); } if( obj === document ) { hop_servevt_dlist = sc_cons( proc, hop_servevt_dlist ); } else { if( !document.body ) { hop_window_onload_add( function( e ) { hop_add_server_listener( obj, proc, capture ); } ); } else { var o = hop_servevt_table[ obj ]; hop_servevt_table[ obj ] = sc_cons( proc, sc_isPair( o ) ? o : null ); hop_servevt_table[ obj ].hop_servevt = true; if( capture ) { var o = hop_servevt_ctable[ obj ]; hop_servevt_ctable[ obj ] = sc_cons( proc, sc_isPair( o ) ? o : null ); } if( !hop_servevt_proxy ) { hop_start_servevt_proxy(); } else { hop_servevt_proxy.register( obj ); } } } } function hop_remove_server_listener( obj, proc ) { if( obj === document ) { hop_servevt_dlist = sc_remqBang( proc, hop_servevt_dlist ); } else { if( sc_isPair( hop_servevt_table[ obj ] ) ) hop_servevt_table[ obj ] = sc_remqBang( proc, hop_servevt_table[ obj ] ); if( sc_isPair( hop_servevt_ctable[ obj ] ) ) hop_servevt_ctable[ obj ] = sc_remqBang( proc,hop_servevt_ctable[ obj ] ); for( id in hop_servevt_table ) { if( sc_isPair( hop_servevt_table[ obj ] ) ) return; } hop_servevt_proxy.unregister( obj ); } } var hop_serverready_list = null; var hop_serverready_triggered = false; function HopServerReadyEvent() { var o = new Object(); o.isStopped = false; return o; } function hop_trigger_serverready_event( evt ) { while( sc_isPair( hop_serverready_list ) ) { hop_serverready_list.car( evt ); if( evt.isStopped ) break; hop_serverready_list = hop_serverready_list.cdr; } hop_serverready_triggered = true; } function hop_add_serverready_listener( obj, proc ) { if( obj === document ) { if( hop_serverready_triggered ) { proc(); } else { hop_serverready_list = sc_cons( proc, hop_serverready_list ); } } else { throw new Error( "add-event-listener!: Illegal `serverready' recipient" + obj ); } } function hop_remove_serverready_listener( obj, proc ) { if( obj === document ) { hop_serverready_list = sc_remqBang( proc, hop_serverready_list ); return true; } else { throw new Error( "remove-event-listener!: Illegal `serverready' recipient" + obj ); return false; } } var hop_timeout_listeners = null; function hop_add_timeout_listener( obj, proc ) { hop_timeout_listeners = sc_cons( sc_cons( proc, setInterval( proc, obj ) ), hop_timeout_listeners ); } function hop_remove_timeout_listener( proc ) { var p = hop_timeout_listeners; if( sc_isPair( p ) ) { if( p.car.car === proc ) { clearInterval( p.car.cdr ); hop_timeout = p.cdr; } else { while( sc_isPair( p.cdr ) ) { if( p.cdr.car === proc ) { clearInterval( p.cdr.cdr ); p.cdr = p.cdr.cdr; break; } else { p = p.cdr; } } } } } function hop_bigloo_serialize( item ) { var tname = typeof item; if( (item instanceof String) || (tname == "string") ) { if( sc_isSymbol( item ) ) { return "%27" + hop_serialize_string( '%22', sc_symbol2jsstring( item ) ); } else if( sc_isKeyword( item ) ) { return "%3a" + hop_serialize_string( '%22', sc_keyword2jsstring( item ) ); } else { return hop_serialize_string( '%22', item ); } } if( (typeof item) == "number" ) return hop_serialize_number( item ); if( (item instanceof Boolean) || (tname == "boolean") ) return hop_serialize_boolean( item ); if( item instanceof Array ) return hop_serialize_array( item ); if( item === undefined ) return ";"; if( item === null ) return "."; if( item instanceof Date ) return hop_serialize_date( item ); if( (item instanceof Object) && (typeof item.hop_bigloo_serialize == "function") ) return item.hop_bigloo_serialize(); if( (HTMLCollection != undefined) && (item instanceof HTMLCollection) ) return hop_serialize_array( item ); if( (HTMLInputElement != undefined) && (item instanceof HTMLInputElement) ) return hop_bigloo_serialize( item.value ); if( (HTMLTextAreaElement != undefined) && (item instanceof HTMLTextAreaElement) ) return hop_bigloo_serialize( item.value ); if( (HTMLSelectElement != undefined) && (item instanceof HTMLSelectElement) ) return hop_bigloo_serialize( item.value ); if( (item.callee != undefined) && (item.length > -1) ) return hop_serialize_array( item ); if( hop_is_html_element( item ) ) return hop_serialize_html( item ); return hop_bigloo_serialize( "#<" + tname + ">" ); } function hop_size_of_word( word ) { var s = 0; while( word > 0 ) { s++; word >>= 8; } return s; } function hop_serialize_word( word ) { var s = hop_size_of_word( word ); if( s == 0 ) { return "%00"; } else { var i1 = (s >> 4); var i2 = (s & 0xf); var c1 = i1 + ((i1 < 10) ? 48 : 55); var c2 = i2 + ((i2 < 10) ? 48 : 55); var rw = String.fromCharCode( 37, c1, c2 ); s--; while( s >= 0 ) { var c = ((word >> (s << 3)) & 0xff); if( (c < 127) && (c >= 46) ) { rw += String.fromCharCode( c ); } else { var i1 = (c >> 4); var i2 = (c & 0xf); var c1 = i1 + ((i1 < 10) ? 48 : 55); var c2 = i2 + ((i2 < 10) ? 48 : 55); rw += String.fromCharCode( 37, c1, c2 ); } s--; } return rw; } } function ucs2_to_utf8( s ) { var len = s.length; for( var i = 0; i < len; i++ ) { var c = s.charCodeAt( i ); if( c >= 128 ) { var utf = s.substring( 0, i ); for( ; i< len; i++, c = s.charCodeAt( i ) ) { if( c < 128 ) { utf += String.fromCharCode( c ); } else { if( (c > 127) && (c < 2048) ) { utf += String.fromCharCode((c >> 6) | 192); utf += String.fromCharCode((c & 63) | 128); } else { utf += String.fromCharCode((c >> 12) | 224); utf += String.fromCharCode(((c >> 6) & 63) | 128); utf += String.fromCharCode((c & 63) | 128); } } } return utf; } } return s; } function utf_length( s ) { var len = s.length; var res = len; for( var i = 0; i < len; i++ ) { var c = s.charCodeAt( i ); if( c >= 128 ) { if( (c > 127) && (c < 2048) ) { res++; } else { res += 2; } } } return res; } function hop_serialize_string( mark, item ) { return mark + hop_serialize_word( utf_length( item ) ) + encodeURIComponent( item ); } function hop_serialize_number( item ) { var sitem = item + ""; if( sitem.indexOf( "." ) == -1 ) { if( item < 0 ) return '-' + hop_serialize_word( -item ); else return hop_serialize_word( item ); } else { return 'f' + hop_serialize_word( sitem.length ) + sitem; } } function hop_serialize_boolean( item ) { return item ? 'T' : 'F'; } function hop_serialize_array( item ) { var l = item.length; var ra = '[' + hop_serialize_word( l ); var i = 0; for( i = 0; i < l; i++ ) { ra += hop_bigloo_serialize( item[ i ] ); } return ra; } function hop_serialize_date( item ) { var utc = Date.UTC( item.getUTCFullYear(), item.getUTCMonth(), item.getUTCDate(), item.getUTCHours(), item.getUTCMinutes(), item.getUTCSeconds() ) + ""; var ms = utc.substring( 0, utc.length - 3 ); return 'd' + hop_serialize_word( ms.length ) + encodeURIComponent( ms ); } function hop_serialize_html( item ) { if( "outerHTML" in item ) { return hop_serialize_string( '%22', item.outHTML ); } else { if( item.nodeType == 1 ) { var str = "<" + item.tagName + " id='" + item.id + "' " + (item.className ? ("class='" + item.className + "'") : "") + ">" + item.innerHTML + "" + item.tagName + ">"; return hop_serialize_string( '%22', str ); } else { if( item.nodeType == 3 ) { return hop_serialize_string( '%22', item.nodeValue ); } else { return hop_bigloo_serialize( "#<" + tname + ">" ); } } } } function hop_obj_to_string( item ) { return decodeURIComponent( hop_bigloo_serialize( item ) ); } function hop_string_to_obj( s ) { var pointer = 0; var definitions = []; var defining = false; function read_integer( s ) { return read_size( s ); } function read_float( s ) { var szf = read_size( s ); var res = s.substring( pointer, pointer + szf ); pointer += szf; return +res; } function read_char( s ) { new sc_Char(String.fromCharCode(n)); } function read_word( s, sz ) { var acc = 0; for( var iw = 0; iw < sz; iw++ ) { acc = (256 * acc) + s.charCodeAt( pointer++ ); } return acc; } function read_long_word( s, szlw ) { return read_word( szlw ); } function read_size( s ) { var szs = s.charCodeAt( pointer++ ); return read_word( s, szs ); } function read_string( s ) { var sz = read_size( s ); var res = s.substring( pointer, pointer + sz ); if( defining ) { definitions[ defining ] = res; defining = false; } pointer += sz; return res; } function read_definition() { defining = read_item(); return read_item(); } function read_reference() { return definitions[ read_item() ]; } function read_symbol() { return sc_jsstring2symbol( read_item() ); } function read_keyword() { return sc_jsstring2keyword( read_item() ); } function read_cnst() { switch( read_integer( s ) ) { default: alert( "read_cnst: not implemented: " + s ); } } function read_vector( sz ) { var res = sc_makeVector( sz ); if( defining ) { definitions[ defining ] = res; defining = false; } for( var iv = 0; iv < sz; iv++ ) { res[ iv ] = read_item(); } return res; } function read_list( sz ) { var res = sc_cons( null, null ); var hd = res; if( defining ) { definitions[ defining ] = res; defining = false; } for( var i = 0; i < (sz - 2); i++, hd = hd.cdr ) { hd.car = read_item(); hd.cdr = sc_cons( null, null ); } hd.car = read_item(); hd.cdr = read_item(); return res; } function read_extended_list( sz ) { var res = sc_cons( null, null ); var hd = res; if( defining ) { definitions[ defining ] = res; defining = false; } for( var i = 0; i < (sz - 2); i++, hd = hd.cdr ) { hd.car = read_item(); read_item(); hd.cdr = sc_cons( null, null ); } hd.car = read_item(); read_item(); hd.cdr = read_item(); return res; } function read_item() { switch( s.charAt( pointer++ ) ) { case '=': return read_definition(); case '#': return read_reference(); case "'": return read_symbol(); case ":": return read_keyword(); case "a": return read_char( s ); case "F": return false; case "T": return true; case ";": return undefined; case ".": return null; case "<": return read_cnst(); case '"': return read_string( s ) case '(': return read_list( read_size( s ) ); case '^': return read_extended_list( read_size( s ) ); case '[': return read_vector( read_size( s ) ); case "f": return read_float( s ); case "-": return -read_integer( s ); default: pointer--; return read_integer( s ); } } if( s.charAt( pointer ) == 'c' ) { pointer++; definitions = new Array( read_size( s ) ); } return read_item(); } var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; function base64_encode( input ) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt( i++ ); chr2 = input.charCodeAt( i++ ); chr3 = input.charCodeAt( i++ ); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if( isNaN( chr2 ) ) { enc3 = enc4 = 64; } else if( isNaN( chr3 ) ) { enc4 = 64; } output = output + keyStr.charAt( enc1 ) + keyStr.charAt( enc2 ) + keyStr.charAt( enc3 ) + keyStr.charAt( enc4 ); } while( i < input.length ); return output; } function utf8_decode( input ) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < input.length ) { c = input.charCodeAt(i); if( c < 128 ) { string += String.fromCharCode( c ); i++; } else if( (c > 191) && (c < 224) ) { c2 = input.charCodeAt( i + 1 ); string += String.fromCharCode( ((c & 31) << 6) | (c2 & 63) ); i += 2; } else { c2 = input.charCodeAt( i + 1 ); c3 = input.charCodeAt( i + 2 ); string += String.fromCharCode( ((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63) ); i += 3; } } return string; } function base64_decode( input ) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace( /[^A-Za-z0-9\+\/\=]/g, "" ); do { enc1 = keyStr.indexOf( input.charAt( i++ ) ); enc2 = keyStr.indexOf( input.charAt( i++ ) ); enc3 = keyStr.indexOf( input.charAt( i++ ) ); enc4 = keyStr.indexOf( input.charAt( i++ ) ); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode( chr1 ); if( enc3 != 64 ) { output = output + String.fromCharCode( chr2 ); } if( enc4 != 64 ) { output = output + String.fromCharCode( chr3 ); } } while( i < input.length ); return utf8_decode( output ); } var hop_anim_latency = 400; var hop_busy_anim_16_16 = "data:image/gif;base64,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"; function hop_service_url( service, formals, args ) { var len = formals.length; if( len == 0 ) { return service + "?hop-encoding=hop"; } else { var url = service + "?hop-encoding=hop"; var i; if( (args.length == 1) && hop_is_dom_form_element( args[ 0 ] ) ) { var els = args[ 0 ].elements; for( i = 0; i < els.length; i++ ) { if( els[ i ].type == "checkbox" ) { var val = els[ i ].checked ? els[ i ].value : false; url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( val ); } else { if( els[ i ].type == "radio" ) { if( els[ i ].checked ) { url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( els[ i ].value ); } } else { url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( els[ i ].value ); } } } return url; } else { for( i = 0; i < len; i++ ) { url += "&" + formals[ i ] + "=" + hop_bigloo_serialize( args[ i ] ); } return url; } } } function hop_service_url_varargs( service, args ) { var len = (arguments.length - 1); if( len == 0 ) { return service; } else { var url = service + "?hop-encoding=hop"; var i; for( i = 0; i < len; i++ ) { url += "&a" + i + "=" + hop_bigloo_serialize( arguments[ i + 1 ] ); } return url; } } function hop_default_failure( http ) { var t = http.responseText; if( !t ) { alert( "http error " + http.status ); return; } var div = document.getElementById( "hop_default_failure" ); var div2 = document.getElementById( "hop_default_failure_background" ); t = t.replace( /]*>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/head>/g, "" ); t = t.replace( /<(meta|link)[^>]*>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/html>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/body>/g, "" ); t = t.replace( /"/g, "\"" ); if( !div2 ) { div2 = document.createElement( "div" ); div2.id = "hop_default_failure_background"; node_style_set( div2, "position", "fixed" ); node_style_set( div2, "top", "0" ); node_style_set( div2, "bottom", "0" ); node_style_set( div2, "left", "0" ); node_style_set( div2, "right", "0" ); node_style_set( div2, "background", "#000" ); node_style_set( div2, "opacity", "0.5" ); node_style_set( div2, "overflow", "hidden" ); node_style_set( div2, "text-align", "center" ); node_style_set( div2, "z-index", "9999" ); document.body.appendChild( div2 ); } if( !div ) { div = document.createElement( "div" ); div.id = "hop_default_failure"; node_style_set( div, "position", "fixed" ); node_style_set( div, "top", "100px" ); node_style_set( div, "left", "0" ); node_style_set( div, "right", "0" ); node_style_set( div, "text-align", "center" ); node_style_set( div, "border", "0" ); node_style_set( div, "z-index", "10000" ); node_style_set( div, "opacity", "1" ); div.align = "center"; div.innerHTML = t; document.body.appendChild( div ); } else { div.innerHTML = t; } } function hop_anim_16_16( title ) { var vis = document.createElement( "div" ); node_style_set( vis, "position", "fixed" ); node_style_set( vis, "top", "5px" ); node_style_set( vis, "right", "5px" ); node_style_set( vis, "z-index", "100" ); node_style_set( vis, "background", "#eeeeee" ); node_style_set( vis, "border-color", "black" ); node_style_set( vis, "border-style", "outset" ); node_style_set( vis, "border-width", "1px" ); node_style_set( vis, "padding-top", "3px" ); node_style_set( vis, "width", "20px" ); node_style_set( vis, "height", "20px" ); node_style_set( vis, "-moz-border-radius", "0.2em" ); node_style_set( vis, "-moz-opacity", "0.7" ); vis.title = title; vis.align = "center"; var img = document.createElement( "img" ); img.className = "hop-busy-anim"; if( !hop_config.inline_image ) { img.src = hop_share_directory() + "/icons/busy-anim-16.gif"; } else { img.src = hop_busy_anim_16_16; } vis.appendChild( img ); return vis; } var hop_default_anim = hop_anim_16_16; function hop_default_anim_set( anim ) { var old = hop_default_anim; hop_default_anim = anim; return old; } function hop_default_anim_get( ) { return hop_default_anim; } var hop_anim_vis = false; var hop_anim_service = false; var hop_anim_interval; var hop_anim_fun = false; function hop_stop_anim() { if( hop_anim_interval ) { if( hop_has_setInterval ) clearInterval( hop_anim_interval ); hop_anim_interval = false; } } function hop_anim( service, user_anim ) { hop_stop_anim(); if( hop_anim_service == service ) { if( hop_anim_vis && (hop_anim_fun == user_anim) ) { hop_anim_vis.title = service; // node_style_set( hop_anim_vis, "visibility", "visible" ); node_style_set( hop_anim_vis, "display", "block" ); return hop_anim_vis; } else { hop_anim_vis = user_anim( service ); document.body.appendChild( hop_anim_vis ); return hop_anim_vis; } } return false; } function hop_responsetext_error( xhr ) { if( xhr.responseText.length > 80 ) return xhr.responseText.substring( 0, 80 ); else return xhr.responseText; } function hop_send_request( svc, sync, success, failure, anim, henv, auth ) { var xhr = hop_make_xml_http_request(); var hop_err = hop_error; var hop_reperror = hop_responsetext_error; var hop_header_ctype = hop_header_content_type; var err = function( exc, xhr, ctype ) { var txt = hop_reperror( xhr ); var fun = ctype ? ("with-hop [content-type=" + ctype + "]") : "with-hop"; return hop_err( fun, exc, txt, svc ); } function onreadystatechange() { if( xhr.readyState == 4 ) { try { var status = xhr.status; switch( status ) { case 200: try { var ctype = hop_header_ctype( xhr ); var expr; if( ctype === "application/x-javascript" ) { try { expr = eval( xhr.responseText ); } catch( exc ) { err( exc, xhr ); expr = false; } return success( expr, xhr ); } else if( ctype === "text/html" ) { var el = hop_create_element( xhr.responseText ); return success( el, xhr ); } else { return success( xhr.responseText, xhr ); } } catch( exc ) { err( exc, xhr, ctype ); } case 202: return success( hop_unserialize( xhr.responseText ), xhr ); case 204: return false; case 257: return hop_js_eval( xhr ); case 258: if( xhr.responseText != null ) return eval( xhr.responseText ); else return false; case 259: hop_set_cookie( xhr ); return false; case 407: err( "Bad authentication", xhr ); return false; default: if( (typeof status == "number") && (status > 200) && (status < 300) ) { if( success ) { return success( xhr.responseText, xhr ); } } else { if( failure ) { return failure( xhr ); } else { return hop_default_failure( xhr ); } } } } catch( exc ) { if( typeof failure == "function" ) { failure( xhr ); } else { err( exc, xhr ); } } finally { try { if( hop_anim_vis != false ) { node_style_set( hop_anim_vis, "display", "none" ); } hop_anim_service = false; } catch( e ) { } } } return false; } if( !sync ) { xhr.onreadystatechange = onreadystatechange; } xhr.open( "GET", svc, (sync != true) ); xhr.setRequestHeader( 'Connection', 'close' ); xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1' ); if( henv.length > 0 ) { xhr.setRequestHeader( 'Hop-Env', hop_serialize_request_env() ); } if( auth ) { xhr.setRequestHeader( 'Authorization', auth ); } try { if( anim ) hop_anim_service = svc; xhr.send( null ); hop_stop_anim(); if( anim && hop_has_setInterval ) { var a = (anim instanceof Function) ? anim : hop_default_anim; hop_anim_interval = setInterval( function() { hop_anim( svc, a ) }, hop_anim_latency ); } if( sync ) { if( xhr.readyState == 4 ) { onreadystatechange(); } else { hop_error( "with-hop", "synchronous call failed", "readyState: " + xhr.readyState, svc ); } } } catch( e ) { if( hop_anim_vis != false ) { node_style_set( hop_anim_vis, "display", "none" ); } hop_anim_service = false; hop_error( "with-hop", e, "Cannot call server", svc ); } return xhr; } function with_hop( svc, success, failure, sync, anim ) { if( !success ) success = function( h ) { return h }; if( !failure ) failure = hop_default_failure; return hop_send_request( svc, sync, success, failure, true, hop_serialize_request_env(), false ); } /*** META (define-macro (with-hop svc . rest) (let ((success #f) (fail #f) (sync #f) (anim #t) (user #f) (password #f) (authorization #f)) (let loop ((rest rest)) (cond ((null? rest) `(hop_send_request ,svc ,sync ,(or success '(lambda (h) h)) ,(or fail 'hop_default_failure) ,anim (hop_serialize_request_env) ,(cond (authorization authorization) ((and (string? user) (string? password)) (string-append "Basic " (base64-encode (string-append user ":" password))))))) ((eq? (car rest) :anim) (if (null? (cdr rest)) (error 'with-hop "Illegal :anim argument" rest) (set! anim (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :authorization) (if (null? (cdr rest)) (error 'with-hop "Illegal :authorization argument" rest) (set! authorization (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :user) (if (null? (cdr rest)) (error 'with-hop "Illegal :user argument" rest) (set! user (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :password) (if (null? (cdr rest)) (error 'with-hop "Illegal :password argument" rest) (set! password (cadr rest))) (loop (cddr rest))) ((not success) (set! success (car rest)) (loop (cdr rest))) ((not fail) (set! fail (car rest)) (loop (cdr rest))) (else (set! sync (car rest)) (loop (cdr rest))))))) */ function hop( svc, success, failure, sync ) { if( success == true ) { location.href = svc; return true; } if( !success ) success = function( h ) { return h; } if( !failure ) failure = hop_default_failure; return hop_send_request( svc, sync, success, failure, true, hop_serialize_request_env() ); } var hop_request_env = []; var hop_request_env_string = ""; var hop_request_env_invalid = false; function hop_serialize_request_env() { if( hop_request_env_invalid ) { var tmp = null; for( var p in hop_request_env ) { if( (typeof hop_request_env[ p ] != "function") && (hop_request_env[ p ] != undefined) ) { tmp = sc_cons( sc_cons( p, hop_request_env[ p ] ), tmp ); } } hop_request_env_string = hop_bigloo_serialize( tmp ); } return hop_request_env_string; } function hop_request_reset() { hop_request_env_string = ""; hop_request_env_set = false; return null; } function hop_request_set( key, val ) { hop_request_env_invalid = true; hop_request_env[ key ] = val; return val; } /*** META ((export request-get) (peephole: (hole 1 "hop_request[" key"]"))) */ function hop_request_get( key ) { return hop_request[ key ]; } var hop_client_debug = 0; function hop_error( fun, exc, msg, svc ) { var emsg = exc ? exc.toString() : "???"; if( exc ) { if( "message" in exc ) { emsg = exc.message; } else { if( "description" in exc ) { emsg = exc.description; } } if( "line" in exc ) { emsg = emsg + " (line " + exc.line + ")"; } } if( typeof svc === "string" || svc instanceof String ) fun = fun + ", " + svc; alert( "*** ERROR " + fun + ": " + emsg + " -- " + msg ); throw exc; } function hop_debug() { return hop_client_debug; } function hop_debug_set( v ) { if( sc_isNumber( v ) ) hop_client_debug = v; } function hop_trace() { if( hop_client_debug > 0 ) { var svc = hop_service_url( hop_service_base() + "/trace", [ "args" ], new Array( sc_vector2list( arguments ) ) ); hop_send_request( svc, true, function() {}, function() {}, false, [] ); } } function hop_tprint( file, pos, rest ) { var svc = hop_service_url( hop_service_base() + "/trace/tprint", [ "file", "pos", "args" ], [ file, pos, rest ] ); hop_send_request( svc, true, function() {}, function() {}, false, [] ); } /*** META (define-macro (tprint . rest) (if (epair? rest) (match-case (cer rest) ((at ?name ?pos) `(hop_tprint ,(relative-file-name name (pwd)) ,(file-position->line pos name) (list ,@rest))) (else `(hop_tprint #f #f (list ,@rest)))) `(hop_tprint #f #f (list ,@rest)))) */ function hop_replace_inner( el ) { if( el != undefined ) { return function( html ) { if( html ) { hop_innerHTML_set( el, html ); } } } else { alert( "*** Hop Error, Can't find element" ); return function( http ) { }; } } function hop_replace_inner_id( id ) { return hop_replace_inner( document.getElementById( id ) ); } function hop_set_cookie( http ) { try { var cookie = http.getResponseHeader( "set-cookie" ); if( cookie ) document.cookie = cookie; } catch( e ) { ; } } function hop_cookie_remove( name, path, domain ) { if( hop_cookie_get_value( name ) ) { hop_cookie_set_value( name, "", path, domain ); } } function hop_cookie_get_value( name ) { var cookies = document.cookie; var i = cookies.indexOf( name + "=" ); if( i !== -1 ) { var start = i + name.length + 1; var end = cookies.indexOf( ";", start ); if( end == -1 ) end = cookies.length; return unescape( cookies.substring( start, end ) ); } else { return null; } } function hop_cookie_set_value( name, val, path, domain, expires ) { var cookie = name + "=" + val; if( (path instanceof String) || (typeof path == "string") ) { cookie += "; path=" + path; } else { cookie += "; path=/"; } if( (expires instanceof String) || (typeof expires == "string") ) { cookie += "; expires=" + expires; } else { if( expires instanceof Date ) { cookie += "; expires=" + expires.toGMTString(); } } if( (domain instanceof String) || (typeof domain == "string") ) { cookie += "; domain=" + domain; } document.cookie = cookie; } var hop_load_frequency = 100; function HopLoadError( file ) { var e = new Error( "hop-load error" ); e.file = file; return e; } function hop_load( src, timeout ) { var script = document.createElement( "script" ); script.src = src; var loaded = false; var holder = document.getElementsByTagName( "head" ); if( !timeout || (timeout == undefined) ) timeout = -1; if( holder != null ) { if( timeout != 0 ) script.onload = function( e ) { loaded = true; }; holder[ 0 ].appendChild( script ); if( timeout != 0 ) { var it; var p = function() { if( loaded == true ) { clearInterval( it ); } else { if( timeout > 0 ) { timeout -= hop_load_frequency; if( timeout <= 0 ) { clearInterval( it ); throw( new HopLoadError( src ) ); } } } }; it = setInterval( p, hop_load_frequency ); } } else { alert( "*** Hop Error, Can't find HEAD element" ); } } var hop_window_onload_add = function( proc ) { var oldonload = window.onload; if( typeof oldonload != 'function' ) { window.onload = proc; } else { window.onload = function( e ) { oldonload( e ); proc( e ); } } } hop_window_onload_add( function( e ) { hop_window_onload_add = function( proc ) { proc( e ); } } ); function hop_window_onload_cons( proc ) { var oldonload = window.onload; if( typeof oldonload != 'function' ) { window.onload = proc; } else { window.onload = function( e ) { proc( e ); oldonload( e ); } } } function hop_window_onunload_add( proc ) { if( typeof( window.onunload ) != 'function' ) { window.onunload = proc; } else { var oldonunload = window.onunload; window.onunload = function( e ) { oldonunload( e ); proc( e ); } } } function hop_update( node ) { if( node.hop_update != undefined ) { node.hop_update(); } for( var i = 0; i < node.childNodes.length; i++ ) { hop_update( node.childNodes[ i ] ); } } function hop_find_runtime_type( obj ) { if( obj instanceof Object ) { if( obj instanceof Date ) { return "date"; } else { if( obj instanceof RegExp ) { return "regexp"; } else { if( typeof obj.hop_find_runtime_type == "function" ) return obj.hop_find_runtime_type(); else return "object"; } } } else { var tname = typeof obj; if( tname == "string" ) { if( sc_isSymbol( obj ) ) return "symbol"; if( sc_isKeyword( obj ) ) return "keyword"; return tname; } return tname; } } function after( timeout, proc ) { var tm = sc_isNumber( timeout ) ? timeout : 1; var i = setInterval( function() { clearInterval( i ); proc() }, tm ); return true; } function timeout( tm, proc ) { var i = setInterval( function() { if( !proc() ) clearInterval( i )}, tm ); } function url_decode( s ) { try { return decodeURI( s ); } catch( e ) { return s; } } function url_encode( s ) { return encodeURI( s ); } function string_hex_extern( str ) { var res = ""; var l = str.length; for( var i = 0; i < l; i++ ) { res += "0123456789abcdef".charAt( (str.charCodeAt( i ) >> 4) & 15 ) + "0123456789abcdef".charAt( (str.charCodeAt( i ) & 15) ); } return res; } function string_hex_intern( s ) { var res = ""; var l = s.length; var z = '0'.charCodeAt( 0 ); var n = '9'.charCodeAt( 0 ); var a = 'a'.charCodeAt( 0 ); var f = 'f'.charCodeAt( 0 ); var A = 'A'.charCodeAt( 0 ); function hex_to_num( c ) { if( (c >= z) && ( c<= n) ) { return c - z; } if( (c >= a) && ( c<= f) ) { return (c - a) + 10;; } return (c - A) + 10; } for( var i = 0; i < l; i += 2 ) { var d1 = hex_to_num( s.charCodeAt( i ) ); var d2 = hex_to_num( s.charCodeAt( i + 1 ) ); res += String.fromCharCode( (d1 << 4) + d2 ); } return res; } function date_year( d ) { return d.getYear(); } function date_month( d ) { return d.getMonth(); } function date_day( d ) { return d.getDay(); } function date_hour( d ) { return d.getHours(); } function date_minute( d ) { return d.getMinutes(); } function date_second( d ) { return d.getSeconds(); } var hop_current_state_history = undefined; var hop_state_history_handler = {}; function hop_state_history_register_handler( key, reset, proc ) { hop_state_history_handler[ key ] = { reset: reset, proc: proc }; } function _hop_state_entry( op, val ) { this.op = op; this.val = val; this.close = false; } function hop_state_history_to_location( state ) { var loc = undefined; for( p in state ) { if( state[ p ] instanceof _hop_state_entry ) { if( loc == undefined ) { loc = "#" + p + "=" + state[ p ].op + ":" + state[ p ].val; } else { loc += "," + p + "=" + state[ p ].op + ":" + state[ p ].val; } } } return loc; } var hop_hash_history_regexp = /#?([^=]+)=([^:]+):([^,]+)+/; function hop_location_to_state_history( hash ) { var state = {}; var split = hash.split( "," ); for( var i = 0; i < split.length; i++ ) { var el = split[ i ].match( hop_hash_history_regexp ); if( el ) { var id = el[ 1 ]; var op = el[ 2 ]; var val = el [ 3 ]; state[ id ] = new _hop_state_entry( op, val ); } } return state; } function hop_state_history_push( id, op, val ) { if( hop_current_state_history == undefined ) { hop_current_state_history = {}; hop_current_state_history[ id ] = new _hop_state_entry( op, val ); } else { var olde = hop_current_state_history[ id ]; if( olde == undefined ) { hop_current_state_history[ id ] = new _hop_state_entry( op, val ); } else { if( (olde.op != op) || (olde.val != val) ) { olde.op = op; olde.val = val; } } } } function hop_state_history_flush() { var loc = hop_state_history_to_location( hop_current_state_history ); var old = window.location.href; var i = old.indexOf( "#" ); if( i == -1 ) { hop_active_location_set( document, old + loc ); } else { hop_active_location_set( document, old.substring( 0, i ) + loc ); } } var hop_state_history_transaction = 0; function hop_state_history_add( id, op, val ) { hop_state_history_push( id, op, val ); if( hop_state_history_transaction == 0 ) { hop_state_history_flush(); } } function hop_with_history( proc ) { var res; hop_state_history_transaction++; try { res = proc(); } finally { hop_state_history_transaction--; } hop_state_history_flush(); return res; } function hop_state_history_reset() { if( hop_current_state_history != undefined ) { for( p in hop_current_state_history ) { if( hop_current_state_history[ p ] instanceof _hop_state_entry ) { var op = hop_current_state_history[ p ].op; var handler = hop_state_history_handler[ op ]; if( handler != undefined ) { handler.proc( p, handler.reset ); } } } hop_current_state_history = undefined; } } function hop_state_history_update( olds, news ) { var res = 0; if( olds == undefined ) { for( p in news ) { var state = news[ p ]; if( state instanceof _hop_state_entry ) { var op = state.op; var handler = hop_state_history_handler[ op ]; if( (handler != undefined) && !state.close ) { if( handler.proc( p, state.val ) ) { state.close = true; } else { res++; } } } } } else { for( p in olds ) { if( (olds[ p ] instanceof _hop_state_entry) && !(news[ p ] instanceof _hop_state_entry) ) { var op = olds[ p ].op; var handler = hop_state_history_handler[ op ]; if( handler != undefined ) { handler.proc( p, handler.reset ); } } } for( p in news ) { var state = news[ p ]; if( state instanceof _hop_state_entry ) { if( !(olds[ p ] instanceof _hop_state_entry) || (state.op != olds[ p ].op) || (state.val != olds[ p ].val) ) { var op = state.op; var handler = hop_state_history_handler[ op ]; if( (handler != undefined) && !state.close ) { if( handler.proc( p, state.val ) ) { state.close = true; } else { res++; } } } } } } return res; } var hop_hash_history_check_regexp = new RegExp( "^#(?:[^=]+=[^:]+:[^,]+,?)+$" ); function hop_hash_historyp( hash ) { return hop_hash_history_check_regexp.exec( hash ); } var hop_eval_history_interval = false; function hop_retry_eval_history_state( count, old_state, new_state ) { var fun = function() { var c = hop_state_history_update( old_state, new_state ); if( (c == 0) || (c == count) || hop_eval_history_interval.invalid ) { clearInterval( hop_eval_history_interval ); } } hop_eval_history_interval = setInterval( fun, 200 ); hop_eval_history_interval.invalid = false; } function hop_eval_history_state( location ) { var hash = location.hash; if( hop_eval_history_interval ) hop_eval_history_interval.invalid = true; if( hash.length == 0 ) { hop_state_history_reset(); } else { if( hop_hash_historyp( hash ) ) { var new_state = hop_location_to_state_history( hash ); var old_state = hop_current_state_history; var count = hop_state_history_update( old_state, new_state ); if( count == 0 ) { hop_current_state_history = new_state; } else { hop_retry_eval_history_state( count, old_state, new_state ); } } } } function hop_current_history() { var hash = location.hash; if( hash.length == 0 ) { return false; } if( hop_hash_historyp( hash ) ) { return hop_location_to_state_history( hash ); } return false; } function hop_replay_history( hist ) { hop_current_state_history = undefined; var loc = function( v ) { this.hash = v; } hop_eval_history_state( new loc( hop_state_history_to_location( hist ) ) ); } function _hop_history( key ) { this.key = key; } function hop_make_history( key, handler, reset ) { hop_state_history_register_handler( key, reset, handler ); return new _hop_history( key ); } function hop_history_add( history, id, val ) { if( !history instanceof _hop_history ) { alert( "*** ERROR: Illegal history object -- " + history ); return false; } else { return hop_state_history_add( id, history.key, val ); } } if( hop_enable_location_event ) { hop_window_onload_add( function( e ) { hop_add_event_listener( document, "location", hop_eval_history_state ); } ); } function hop_bigloo_serialize_pair( l ) { var res = ""; var len = 0; while (sc_isPair( l ) ) { res += hop_bigloo_serialize( l.car ); l = l.cdr; len++; } if( l == null ) { return hop_serialize_word( len + 1 ) + res + "."; } else { return hop_serialize_word( len + 1 ) + res + hop_bigloo_serialize( l ); } } sc_Pair.prototype.hop_bigloo_serialize = function() { return '(' + hop_bigloo_serialize_pair( this ); }; sc_Pair.prototype.hop_find_runtime_type = function() { return "pair"; }; sc_Vector.prototype.hop_find_runtime_type = function() { return "vector"; }; sc_Struct.prototype.hop_find_runtime_type = function() { return "struct"; }; sc_OutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_StringOutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_GenericOutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_InputPort.prototype.hop_find_runtime_type = function() { return "input-port"; }; Boolean.prototype.hop_find_runtime_type = function() { return "bbool"; }; String.prototype.hop_find_runtime_type = function() { return hop_find_runtime_type(this.toString()); }; sc_Char.prototype.hop_find_runtime_type = function() { return "bchar"; }; ]]> TPAC 08, W3C Technical Plenary 2008 ...Start...Title Preludeapplications demand languageshop HopHOP...The Web...Architecture ApplicationAn applicationA Diffuse Music PlayerHopAudio (architecture) ConclusionConclusionWhy Using Hop?hop.inria.frendHopSlide v1.5.121 October 2008HopSlide Help (v1.5.1)KeyboardToggle this helpalt-hReload slidesalt-rToggle slide selectoralt-sOpen a full screen windowalt-wUpdate sizealt-uToggle big cursoralt-mToggle focusalt-fToggle drawing areaalt-cNext slidePgDn↓alt-nRetEnterSpacePrevious slidePgUp↑alt-pFirst slideHomeLast slideEndClose slideEscMouseReload slidesshift Button1Slides selectorcrtl Button1Focus enlarge/shrinkButton4Button5 image/svg+xmlPress [Space] to start... Hop, an Everyware Development KitManuel SerranoMimosa TeamInria Sophia-Antipolishttp://hop.inria.fr Prelude Applications demand Languages X= 27.3 DATA A, B / 5.0, 12.0. / IF (X) 10, 20, 30 DO 9 J= 1, 10 DO 9 K= 1, 10 9 L= J + K 60 FORMAT ( 9H1GOODBYE. )?module ABRO: input A, B, R; output O; loop [ await A || await B ]; emit O each R end module#include <iostream> class Bird { public: virtual void OutName() { std::cout << "a bird"; } virtual ~Bird() {} }; int main() { Swan mySwan; Bird* myBird = &mySwan; myBird->OutName(); return 0; }
. args) `(hop_dom_create "q" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "s" ,@args)) */ /*** META (define-macro ( . args) `(hop_dom_create "samp" ,@args)) */ /*** META (define-macro (", start ); if( end == -1 ) end = text.indexOf( "", start ); if( (end > start) ) { res = eval( text.substr( start, end - start ) ); } } return res; } try { if( "getElementsByTagName" in node ) { var scripts = node.getElementsByTagName( "script" ); if( scripts && scripts.length > 0 ) { for ( var j = 0; j < scripts.length; j++ ) { if( false && scripts[ j ].childNodes.length > 0 ) { res = eval( scripts[ j ].childNodes[ 0 ].nodeValue ); } else { res = eval( scripts[ j ].innerHTML ); } } } else { return hop_node_eval_from_text( text ); } } else { return hop_node_eval_from_text( text ); } } catch( e ) { alert( e ); throw e; } return res; } function node_style_get( obj, prop ) { if( (obj instanceof String) || (typeof obj === "string") ) obj = document.getElementById( obj ); if( sc_isKeyword( prop ) ) prop = sc_keyword2jsstring( prop ); return obj.style[ prop ]; } function hop_create_element( html ) { var div = document.createElement( 'div' ); div.innerHTML = "IE7 bug" + html; return div.childNodes[ 1 ]; } function hop_create_encoded_element( html ) { return hop_create_element( decodeURIComponent( html ) ); } function hop_innerHTML_set( nid, html ) { var el; if( (nid instanceof String) || (typeof nid == "string") ) { el = document.getElementById( nid ); if( el == undefined ) { alert( "*** ERROR:innerHTML-set! -- cannot find element \"" + nid + "\""); return; } } else { if( !nid ) { alert( "*** ERROR:innerHTML-set! -- illegal element \"" + nid + "\""); return; } el = nid; } if( (html instanceof String) || (typeof html == "string") ) { el.innerHTML = html; hop_node_eval( el, html ); } else if( hop_is_html_element( html ) || sc_isPair( html ) ) { dom_set_child_node( el, html ); if( hop_innerHTML_need_evalp ) hop_node_eval( el, html ); } else { el.innerHTML = html; } } function hop_style_attribute_set( obj, val ) { var expr; if( (val instanceof String) || (typeof val == "string") ) expr = eval( val ); for( var p in expr ) { node_style_set( obj, p, expr[ p ] ); } } function hop_element_x( obj ) { var res = 0; while( obj != null ) { if( typeof obj.offsetLeft == "number" ) res += obj.offsetLeft; else { break; } obj = obj.offsetParent; } return res; } function hop_element_y( obj ) { var res = 0; while( obj != null ) { if( typeof obj.offsetTop == "number" ) res += obj.offsetTop; else { break; } obj = obj.offsetParent; } return res; } function hop_bounding_box( e, m ) { var n; if( (e instanceof String) || (typeof e == "string") ) { n = document.getElementById( e ); } else { n = e; } if( !m ) m = 0; return [ hop_element_x( n ) - m, hop_element_y( n ) - m, n.offsetWidth + (2*m), n.offsetHeight + (2*m) ]; } function hop_bounding_box_to_list( bbox ) { return sc_vector2list( bbox ); } function hop_bounding_box_x( bbox, loc ) { if( arguments.length == 1 ) return bbox[ 0 ]; if( (loc == "w") || (loc == "nw") || (loc == "sw") ) return bbox[ 0 ]; if( (loc == "n") || (loc == "s")) return bbox[ 0 ] + (bbox[ 2 ]/2); if( (loc == "ne") || (loc == "e") || (loc == "se") ) return bbox[ 0 ] + bbox[ 2 ]; return 0; } function hop_bounding_box_y( bbox, loc ) { if( arguments.length == 1 ) return bbox[ 1 ]; if( (loc == "nw") || (loc == "n") || (loc == "ne") ) return bbox[ 1 ]; if( (loc == "e") || (loc == "w")) return bbox[ 1 ] + (bbox[ 3 ]/2); if( (loc == "se") || (loc == "s") || (loc == "sw") ) return bbox[ 1 ] + bbox[ 3 ]; return 0; } function hop_add_event_listener( obj, event, proc, capture ) { if( event == "location" ) return hop_add_active_location_listener( obj, proc ); if( event == "server" ) return hop_add_server_listener( obj, proc, capture ); if( event == "serverready" ) return hop_add_serverready_listener( obj, proc ); if( event == "serverclose" ) return hop_add_serverclose_listener( obj, proc ); if( event == "timeout" ) return hop_add_timeout_listener( obj, proc ); if( (obj.hop_add_event_listener != undefined) && (obj.hop_add_event_listener != hop_add_event_listener) ) return obj.hop_add_event_listener( event, proc, capture ); return hop_add_native_event_listener( obj, event, proc, capture ); } function hop_remove_event_listener( obj, event, proc, capture ) { if( event == "location" ) return hop_remove_active_location_listener( obj, proc ); if( event == "server" ) return hop_remove_server_listener( obj, proc ); if( event == "serverready" ) return hop_remove_serverready_listener( obj, proc ); if( event == "serverclose" ) return hop_remove_serverclose_listener( obj, proc ); if( event == "timeout" ) return hop_remove_timeout_listener( proc ); if( (obj.hop_remove_event_listener != undefined) && (obj.hop_remove_event_listener != hop_remove_event_listener) ) return obj.hop_remove_event_listener( event, proc, capture ); return hop_remove_native_event_listener( obj, event, proc, capture ); } function hop_add_active_location_listener( obj, proc ) { obj.hop_active_location_proc = proc; var i = window.location.href.indexOf( "#" ); if( i === -1 ) { obj.hop_active_location_href = window.location.href; } else { obj.hop_active_location_href = window.location.href.substring( 0, i-1 ); } if( obj.hop_active_location_interval === undefined ) { var check = function() { if( obj.hop_active_location_href !== window.location.href ) { if( obj.hop_active_location_href != window.location.href ) { obj.hop_active_location_href = window.location.href; obj.hop_active_location_proc( window.location ); } } return true; } obj.hop_active_location_interval = setInterval( check, hop_active_location_timeout ); } return false; } function hop_remove_active_location_listener( obj, proc ) { if( obj.hop_active_location_interval != undefined ) { clearInterval( obj.hop_active_location_interval ); obj.hop_active_location_interval = undefined; } } function hop_active_location_set( obj, href ) { window.location.href = href; obj.hop_active_location_href = window.location.href; } var hop_servevt_id = "__hop_serevt_proxy"; var hop_server_event_count = 0; var re = new RegExp( "<[\/]?event[^>]*>", "g" ); function HopServerEvent( n, text, val ) { this.isStopped = false; this.name = n; this.value = val; this.id = hop_server_event_count++; if( typeof text == "string" ) { this.responseText = text.replace( re, "" ); } else { this.responseText = ""; } } var hop_servevt_proxy = false; var hop_servevt_table = {}; var hop_servevt_ctable = {}; var hop_servevt_dlist = null; function start_servevt_ajax_proxy( key ) { if( !hop_servevt_proxy.httpreq ) { var xhr_error_ttl = 6 * 3; var server_ready = false; var register = function( id ) { var svc = hop_service_base() + "/server-event/register?event=" + id + "&key=" + key; var success = function( val, xhr ) { if( !server_ready ) { server_ready = true; hop_trigger_serverready_event( new HopServerReadyEvent() ); } if( val != null ) { xhr_error_ttl = 6 * 3; register( "" ); while( val != null ) { var v = val.car; var id = v.car; var vals = v.cdr; while( vals != null ) { hop_trigger_servevt( id, vals.car, vals.car, false ); vals = vals.cdr; } val = val.cdr; } } } var failure = function( xhr ) { if( !xhr.status && (xhr_error_ttl > 0) && !xhr.getAllResponseHeaders() ) { xhr_error_ttl--; register( id ); } else { hop_servevt_onclose(); } } hop_servevt_proxy.httpreq = hop_send_request( svc, false, success, failure, false, [] ); } var unregister = function( id ) { hop_servevt_proxy.httpreq.abort(); var svc = hop_service_base() + "/server-event/unregister?event=" + id + "&key=" + hop_servevt_proxy.key; hop_servevt_proxy.httpreq = hop_send_request( svc, false, function() { ; }, false, false, [] ); }; hop_servevt_proxy.register = register; hop_servevt_proxy.unregister = unregister; for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { register( p ); } } } } function start_servevt_flash_proxy( key, host, port ) { var object_proxy = function() { return "" + "" + "" + "" + ""; } var embed_proxy = function() { var embed = document.createElement( "embed" ); embed.id = hop_servevt_id; embed.className = "hop-servevt-proxy"; embed.setAttribute( "width", "1px" ); embed.setAttribute( "height", "1px" ); embed.setAttribute( "src", hop_share_directory() + "/flash/HopServevt.swf" ); embed.setAttribute( "type", "application/x-shockwave-flash" ); embed.setAttribute( "name", "__hop_servevt_proxy" ); embed.setAttribute( "swliveconnect", "true" ); embed.setAttribute( "allowScriptAccess", "always" ); embed.setAttribute( "FlashVars", "init=hop_servevt_proxy_flash_init" + "&host=" + host + "&port=" + port + "&key=" + key + "&onevent=hop_trigger_servevt" + "&onclose=hop_servevt_onclose" + "&onerror=hop_servevt_onerror" ); return embed; } var proxy = document.createElement( "div" ); node_style_set( proxy, "position", "fixed" ); node_style_set( proxy, "top", "0" ); node_style_set( proxy, "right", "0" ); node_style_set( proxy, "background", "transparent" ); if( hop_config.flash_markup === "embed" ) { proxy.appendChild( embed_proxy() ); } else { proxy.innerHTML = object_proxy(); } document.body.appendChild( proxy ); document.getElementById( hop_servevt_id ).key = key; return proxy; } function hop_servevt_onerror( msg ) { hop_error( "servevt", new Error( msg ), "internal server event error" ); } function hop_servevt_proxy_flash_init() { hop_flash_minversion_set( 8 ); var pending_events = 0; hop_servevt_proxy = document.getElementById( hop_servevt_id ); var abort = function( id ) { var svc = hop_service_base() + "/server-event/unregister?event=" + id + "&key=" + hop_servevt_proxy.key; hop_servevt_proxy.httpreq = hop_send_request( svc, false, function() {;}, false, false, [] ); } var failure = function( e ) { hop_servevt_onclose(); for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { abort( p ); } } hop_send_request( hop_service_base() + "/server-event/close?key=" + hop_servevt_proxy.key, false, function() {;}, false, false, [] ); } var register = function( id ) { var svc = hop_service_base() + "/server-event/register?event=" + id + "&key=" + hop_servevt_proxy.key + "&flash=true"; var success = function( e ) { if( pending_events > 0 ) { if( pending_events == 1 ) { hop_trigger_serverready_event( new HopServerReadyEvent() ); } pending_events--; } } hop_servevt_proxy.httpreq = hop_send_request( svc, false, success, failure, false, [] ); } hop_servevt_proxy.register = register; hop_servevt_proxy.unregister = function( id ) { abort( id ); } hop_window_onunload_add( failure ); for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { pending_events++; } } if( pending_events > 0 ) { for( var p in hop_servevt_table ) { if( hop_servevt_table[ p ].hop_servevt ) { register( p ); } } } else { hop_trigger_serverready_event( new HopServerReadyEvent() ); } } function servevt_flashp( port ) { return port && (hop_config.flash_version >= 8) && (hop_config.flash_external_interface); } function hop_start_servevt_proxy() { hop_servevt_proxy = new Object(); hop_servevt_proxy.register = function( x ) {}; hop_send_request( hop_service_base() + "/server-event/info", false, function( v ) { var host = v[ 0 ]; var port = v[ 1 ]; var key = v[ 2 ]; if( servevt_flashp( port ) ) { try { start_servevt_flash_proxy( key, host, port ); } catch( e ) { hop_error( "hop_start_servevt_proxy", e, "Cannot start flash proxy, port=" + port); } } else { start_servevt_ajax_proxy( key ); } }, function( v ) { throw new Error( "Cannot get server event port number" ); }, true, [] ); } function hop_trigger_servevt( id, text, value, json ) { try { var v = (json ? eval( value, text ) : value); var evt = new HopServerEvent( id, text, v ); var p2 = hop_servevt_table[ id ]; if( sc_isPair( hop_servevt_dlist ) && sc_isPair( hop_servevt_ctable[ id ] ) ) { var p1 = hop_servevt_dlist; while( sc_isPair( p1 ) ) { p1.car( evt ); p1 = p1.cdr; } } evt.isStopped = false; while( sc_isPair( p2 ) ) { try { p2.car( evt ); } catch( exc ) { hop_error( "hop_trigger_servevt [event " + id + "]", exc, p2.car ); } if( evt.isStopped ) break; p2 = p2.cdr; } } catch( exc ) { hop_error( "hop_trigger_servevt [event " + id + "]", exc, value ); } } var hop_serverclose_list = null; var hop_serverclose_triggered = false; function hop_add_serverclose_listener( obj, proc ) { if( obj === document ) { if( hop_serverclose_triggered ) { var evt = new HopServerEvent( "serverclose", false, false ); proc( evt ); } else { hop_serverclose_list = sc_cons( proc, hop_serverclose_list ); } } else { throw new Error( "add-event-listener!: Illegal `serverclose' recipient" + obj ); } } function hop_remove_serverclose_listener( obj, proc ) { if( obj === document ) { hop_serverclose_list = sc_remqBang( proc, hop_serverclose_list ); return true; } else { throw new Error( "remove-event-listener!: Illegal `serverclose' recipient" + obj ); return false; } } function hop_servevt_onclose() { var evt = new HopServerEvent( "serverclose", false, false ); var p = hop_serverclose_list; while( sc_isPair( p ) ) { p.car( evt ); if( evt.isStopped ) break; p = p.cdr; } hop_serverclose_triggered = true; } function hop_add_server_listener( obj, proc, capture ) { if( typeof proc != "function" ) { throw new Error( "Illegal procedure: " + proc ); } if( obj === document ) { hop_servevt_dlist = sc_cons( proc, hop_servevt_dlist ); } else { if( !document.body ) { hop_window_onload_add( function( e ) { hop_add_server_listener( obj, proc, capture ); } ); } else { var o = hop_servevt_table[ obj ]; hop_servevt_table[ obj ] = sc_cons( proc, sc_isPair( o ) ? o : null ); hop_servevt_table[ obj ].hop_servevt = true; if( capture ) { var o = hop_servevt_ctable[ obj ]; hop_servevt_ctable[ obj ] = sc_cons( proc, sc_isPair( o ) ? o : null ); } if( !hop_servevt_proxy ) { hop_start_servevt_proxy(); } else { hop_servevt_proxy.register( obj ); } } } } function hop_remove_server_listener( obj, proc ) { if( obj === document ) { hop_servevt_dlist = sc_remqBang( proc, hop_servevt_dlist ); } else { if( sc_isPair( hop_servevt_table[ obj ] ) ) hop_servevt_table[ obj ] = sc_remqBang( proc, hop_servevt_table[ obj ] ); if( sc_isPair( hop_servevt_ctable[ obj ] ) ) hop_servevt_ctable[ obj ] = sc_remqBang( proc,hop_servevt_ctable[ obj ] ); for( id in hop_servevt_table ) { if( sc_isPair( hop_servevt_table[ obj ] ) ) return; } hop_servevt_proxy.unregister( obj ); } } var hop_serverready_list = null; var hop_serverready_triggered = false; function HopServerReadyEvent() { var o = new Object(); o.isStopped = false; return o; } function hop_trigger_serverready_event( evt ) { while( sc_isPair( hop_serverready_list ) ) { hop_serverready_list.car( evt ); if( evt.isStopped ) break; hop_serverready_list = hop_serverready_list.cdr; } hop_serverready_triggered = true; } function hop_add_serverready_listener( obj, proc ) { if( obj === document ) { if( hop_serverready_triggered ) { proc(); } else { hop_serverready_list = sc_cons( proc, hop_serverready_list ); } } else { throw new Error( "add-event-listener!: Illegal `serverready' recipient" + obj ); } } function hop_remove_serverready_listener( obj, proc ) { if( obj === document ) { hop_serverready_list = sc_remqBang( proc, hop_serverready_list ); return true; } else { throw new Error( "remove-event-listener!: Illegal `serverready' recipient" + obj ); return false; } } var hop_timeout_listeners = null; function hop_add_timeout_listener( obj, proc ) { hop_timeout_listeners = sc_cons( sc_cons( proc, setInterval( proc, obj ) ), hop_timeout_listeners ); } function hop_remove_timeout_listener( proc ) { var p = hop_timeout_listeners; if( sc_isPair( p ) ) { if( p.car.car === proc ) { clearInterval( p.car.cdr ); hop_timeout = p.cdr; } else { while( sc_isPair( p.cdr ) ) { if( p.cdr.car === proc ) { clearInterval( p.cdr.cdr ); p.cdr = p.cdr.cdr; break; } else { p = p.cdr; } } } } } function hop_bigloo_serialize( item ) { var tname = typeof item; if( (item instanceof String) || (tname == "string") ) { if( sc_isSymbol( item ) ) { return "%27" + hop_serialize_string( '%22', sc_symbol2jsstring( item ) ); } else if( sc_isKeyword( item ) ) { return "%3a" + hop_serialize_string( '%22', sc_keyword2jsstring( item ) ); } else { return hop_serialize_string( '%22', item ); } } if( (typeof item) == "number" ) return hop_serialize_number( item ); if( (item instanceof Boolean) || (tname == "boolean") ) return hop_serialize_boolean( item ); if( item instanceof Array ) return hop_serialize_array( item ); if( item === undefined ) return ";"; if( item === null ) return "."; if( item instanceof Date ) return hop_serialize_date( item ); if( (item instanceof Object) && (typeof item.hop_bigloo_serialize == "function") ) return item.hop_bigloo_serialize(); if( (HTMLCollection != undefined) && (item instanceof HTMLCollection) ) return hop_serialize_array( item ); if( (HTMLInputElement != undefined) && (item instanceof HTMLInputElement) ) return hop_bigloo_serialize( item.value ); if( (HTMLTextAreaElement != undefined) && (item instanceof HTMLTextAreaElement) ) return hop_bigloo_serialize( item.value ); if( (HTMLSelectElement != undefined) && (item instanceof HTMLSelectElement) ) return hop_bigloo_serialize( item.value ); if( (item.callee != undefined) && (item.length > -1) ) return hop_serialize_array( item ); if( hop_is_html_element( item ) ) return hop_serialize_html( item ); return hop_bigloo_serialize( "#<" + tname + ">" ); } function hop_size_of_word( word ) { var s = 0; while( word > 0 ) { s++; word >>= 8; } return s; } function hop_serialize_word( word ) { var s = hop_size_of_word( word ); if( s == 0 ) { return "%00"; } else { var i1 = (s >> 4); var i2 = (s & 0xf); var c1 = i1 + ((i1 < 10) ? 48 : 55); var c2 = i2 + ((i2 < 10) ? 48 : 55); var rw = String.fromCharCode( 37, c1, c2 ); s--; while( s >= 0 ) { var c = ((word >> (s << 3)) & 0xff); if( (c < 127) && (c >= 46) ) { rw += String.fromCharCode( c ); } else { var i1 = (c >> 4); var i2 = (c & 0xf); var c1 = i1 + ((i1 < 10) ? 48 : 55); var c2 = i2 + ((i2 < 10) ? 48 : 55); rw += String.fromCharCode( 37, c1, c2 ); } s--; } return rw; } } function ucs2_to_utf8( s ) { var len = s.length; for( var i = 0; i < len; i++ ) { var c = s.charCodeAt( i ); if( c >= 128 ) { var utf = s.substring( 0, i ); for( ; i< len; i++, c = s.charCodeAt( i ) ) { if( c < 128 ) { utf += String.fromCharCode( c ); } else { if( (c > 127) && (c < 2048) ) { utf += String.fromCharCode((c >> 6) | 192); utf += String.fromCharCode((c & 63) | 128); } else { utf += String.fromCharCode((c >> 12) | 224); utf += String.fromCharCode(((c >> 6) & 63) | 128); utf += String.fromCharCode((c & 63) | 128); } } } return utf; } } return s; } function utf_length( s ) { var len = s.length; var res = len; for( var i = 0; i < len; i++ ) { var c = s.charCodeAt( i ); if( c >= 128 ) { if( (c > 127) && (c < 2048) ) { res++; } else { res += 2; } } } return res; } function hop_serialize_string( mark, item ) { return mark + hop_serialize_word( utf_length( item ) ) + encodeURIComponent( item ); } function hop_serialize_number( item ) { var sitem = item + ""; if( sitem.indexOf( "." ) == -1 ) { if( item < 0 ) return '-' + hop_serialize_word( -item ); else return hop_serialize_word( item ); } else { return 'f' + hop_serialize_word( sitem.length ) + sitem; } } function hop_serialize_boolean( item ) { return item ? 'T' : 'F'; } function hop_serialize_array( item ) { var l = item.length; var ra = '[' + hop_serialize_word( l ); var i = 0; for( i = 0; i < l; i++ ) { ra += hop_bigloo_serialize( item[ i ] ); } return ra; } function hop_serialize_date( item ) { var utc = Date.UTC( item.getUTCFullYear(), item.getUTCMonth(), item.getUTCDate(), item.getUTCHours(), item.getUTCMinutes(), item.getUTCSeconds() ) + ""; var ms = utc.substring( 0, utc.length - 3 ); return 'd' + hop_serialize_word( ms.length ) + encodeURIComponent( ms ); } function hop_serialize_html( item ) { if( "outerHTML" in item ) { return hop_serialize_string( '%22', item.outHTML ); } else { if( item.nodeType == 1 ) { var str = "<" + item.tagName + " id='" + item.id + "' " + (item.className ? ("class='" + item.className + "'") : "") + ">" + item.innerHTML + "" + item.tagName + ">"; return hop_serialize_string( '%22', str ); } else { if( item.nodeType == 3 ) { return hop_serialize_string( '%22', item.nodeValue ); } else { return hop_bigloo_serialize( "#<" + tname + ">" ); } } } } function hop_obj_to_string( item ) { return decodeURIComponent( hop_bigloo_serialize( item ) ); } function hop_string_to_obj( s ) { var pointer = 0; var definitions = []; var defining = false; function read_integer( s ) { return read_size( s ); } function read_float( s ) { var szf = read_size( s ); var res = s.substring( pointer, pointer + szf ); pointer += szf; return +res; } function read_char( s ) { new sc_Char(String.fromCharCode(n)); } function read_word( s, sz ) { var acc = 0; for( var iw = 0; iw < sz; iw++ ) { acc = (256 * acc) + s.charCodeAt( pointer++ ); } return acc; } function read_long_word( s, szlw ) { return read_word( szlw ); } function read_size( s ) { var szs = s.charCodeAt( pointer++ ); return read_word( s, szs ); } function read_string( s ) { var sz = read_size( s ); var res = s.substring( pointer, pointer + sz ); if( defining ) { definitions[ defining ] = res; defining = false; } pointer += sz; return res; } function read_definition() { defining = read_item(); return read_item(); } function read_reference() { return definitions[ read_item() ]; } function read_symbol() { return sc_jsstring2symbol( read_item() ); } function read_keyword() { return sc_jsstring2keyword( read_item() ); } function read_cnst() { switch( read_integer( s ) ) { default: alert( "read_cnst: not implemented: " + s ); } } function read_vector( sz ) { var res = sc_makeVector( sz ); if( defining ) { definitions[ defining ] = res; defining = false; } for( var iv = 0; iv < sz; iv++ ) { res[ iv ] = read_item(); } return res; } function read_list( sz ) { var res = sc_cons( null, null ); var hd = res; if( defining ) { definitions[ defining ] = res; defining = false; } for( var i = 0; i < (sz - 2); i++, hd = hd.cdr ) { hd.car = read_item(); hd.cdr = sc_cons( null, null ); } hd.car = read_item(); hd.cdr = read_item(); return res; } function read_extended_list( sz ) { var res = sc_cons( null, null ); var hd = res; if( defining ) { definitions[ defining ] = res; defining = false; } for( var i = 0; i < (sz - 2); i++, hd = hd.cdr ) { hd.car = read_item(); read_item(); hd.cdr = sc_cons( null, null ); } hd.car = read_item(); read_item(); hd.cdr = read_item(); return res; } function read_item() { switch( s.charAt( pointer++ ) ) { case '=': return read_definition(); case '#': return read_reference(); case "'": return read_symbol(); case ":": return read_keyword(); case "a": return read_char( s ); case "F": return false; case "T": return true; case ";": return undefined; case ".": return null; case "<": return read_cnst(); case '"': return read_string( s ) case '(': return read_list( read_size( s ) ); case '^': return read_extended_list( read_size( s ) ); case '[': return read_vector( read_size( s ) ); case "f": return read_float( s ); case "-": return -read_integer( s ); default: pointer--; return read_integer( s ); } } if( s.charAt( pointer ) == 'c' ) { pointer++; definitions = new Array( read_size( s ) ); } return read_item(); } var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; function base64_encode( input ) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt( i++ ); chr2 = input.charCodeAt( i++ ); chr3 = input.charCodeAt( i++ ); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if( isNaN( chr2 ) ) { enc3 = enc4 = 64; } else if( isNaN( chr3 ) ) { enc4 = 64; } output = output + keyStr.charAt( enc1 ) + keyStr.charAt( enc2 ) + keyStr.charAt( enc3 ) + keyStr.charAt( enc4 ); } while( i < input.length ); return output; } function utf8_decode( input ) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < input.length ) { c = input.charCodeAt(i); if( c < 128 ) { string += String.fromCharCode( c ); i++; } else if( (c > 191) && (c < 224) ) { c2 = input.charCodeAt( i + 1 ); string += String.fromCharCode( ((c & 31) << 6) | (c2 & 63) ); i += 2; } else { c2 = input.charCodeAt( i + 1 ); c3 = input.charCodeAt( i + 2 ); string += String.fromCharCode( ((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63) ); i += 3; } } return string; } function base64_decode( input ) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace( /[^A-Za-z0-9\+\/\=]/g, "" ); do { enc1 = keyStr.indexOf( input.charAt( i++ ) ); enc2 = keyStr.indexOf( input.charAt( i++ ) ); enc3 = keyStr.indexOf( input.charAt( i++ ) ); enc4 = keyStr.indexOf( input.charAt( i++ ) ); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode( chr1 ); if( enc3 != 64 ) { output = output + String.fromCharCode( chr2 ); } if( enc4 != 64 ) { output = output + String.fromCharCode( chr3 ); } } while( i < input.length ); return utf8_decode( output ); } var hop_anim_latency = 400; var hop_busy_anim_16_16 = "data:image/gif;base64,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"; function hop_service_url( service, formals, args ) { var len = formals.length; if( len == 0 ) { return service + "?hop-encoding=hop"; } else { var url = service + "?hop-encoding=hop"; var i; if( (args.length == 1) && hop_is_dom_form_element( args[ 0 ] ) ) { var els = args[ 0 ].elements; for( i = 0; i < els.length; i++ ) { if( els[ i ].type == "checkbox" ) { var val = els[ i ].checked ? els[ i ].value : false; url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( val ); } else { if( els[ i ].type == "radio" ) { if( els[ i ].checked ) { url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( els[ i ].value ); } } else { url += "&" + els[ i ].name + "=" + hop_bigloo_serialize( els[ i ].value ); } } } return url; } else { for( i = 0; i < len; i++ ) { url += "&" + formals[ i ] + "=" + hop_bigloo_serialize( args[ i ] ); } return url; } } } function hop_service_url_varargs( service, args ) { var len = (arguments.length - 1); if( len == 0 ) { return service; } else { var url = service + "?hop-encoding=hop"; var i; for( i = 0; i < len; i++ ) { url += "&a" + i + "=" + hop_bigloo_serialize( arguments[ i + 1 ] ); } return url; } } function hop_default_failure( http ) { var t = http.responseText; if( !t ) { alert( "http error " + http.status ); return; } var div = document.getElementById( "hop_default_failure" ); var div2 = document.getElementById( "hop_default_failure_background" ); t = t.replace( /]*>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/head>/g, "" ); t = t.replace( /<(meta|link)[^>]*>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/html>/g, "" ); t = t.replace( /]*>/g, "" ); t = t.replace( /<\/body>/g, "" ); t = t.replace( /"/g, "\"" ); if( !div2 ) { div2 = document.createElement( "div" ); div2.id = "hop_default_failure_background"; node_style_set( div2, "position", "fixed" ); node_style_set( div2, "top", "0" ); node_style_set( div2, "bottom", "0" ); node_style_set( div2, "left", "0" ); node_style_set( div2, "right", "0" ); node_style_set( div2, "background", "#000" ); node_style_set( div2, "opacity", "0.5" ); node_style_set( div2, "overflow", "hidden" ); node_style_set( div2, "text-align", "center" ); node_style_set( div2, "z-index", "9999" ); document.body.appendChild( div2 ); } if( !div ) { div = document.createElement( "div" ); div.id = "hop_default_failure"; node_style_set( div, "position", "fixed" ); node_style_set( div, "top", "100px" ); node_style_set( div, "left", "0" ); node_style_set( div, "right", "0" ); node_style_set( div, "text-align", "center" ); node_style_set( div, "border", "0" ); node_style_set( div, "z-index", "10000" ); node_style_set( div, "opacity", "1" ); div.align = "center"; div.innerHTML = t; document.body.appendChild( div ); } else { div.innerHTML = t; } } function hop_anim_16_16( title ) { var vis = document.createElement( "div" ); node_style_set( vis, "position", "fixed" ); node_style_set( vis, "top", "5px" ); node_style_set( vis, "right", "5px" ); node_style_set( vis, "z-index", "100" ); node_style_set( vis, "background", "#eeeeee" ); node_style_set( vis, "border-color", "black" ); node_style_set( vis, "border-style", "outset" ); node_style_set( vis, "border-width", "1px" ); node_style_set( vis, "padding-top", "3px" ); node_style_set( vis, "width", "20px" ); node_style_set( vis, "height", "20px" ); node_style_set( vis, "-moz-border-radius", "0.2em" ); node_style_set( vis, "-moz-opacity", "0.7" ); vis.title = title; vis.align = "center"; var img = document.createElement( "img" ); img.className = "hop-busy-anim"; if( !hop_config.inline_image ) { img.src = hop_share_directory() + "/icons/busy-anim-16.gif"; } else { img.src = hop_busy_anim_16_16; } vis.appendChild( img ); return vis; } var hop_default_anim = hop_anim_16_16; function hop_default_anim_set( anim ) { var old = hop_default_anim; hop_default_anim = anim; return old; } function hop_default_anim_get( ) { return hop_default_anim; } var hop_anim_vis = false; var hop_anim_service = false; var hop_anim_interval; var hop_anim_fun = false; function hop_stop_anim() { if( hop_anim_interval ) { if( hop_has_setInterval ) clearInterval( hop_anim_interval ); hop_anim_interval = false; } } function hop_anim( service, user_anim ) { hop_stop_anim(); if( hop_anim_service == service ) { if( hop_anim_vis && (hop_anim_fun == user_anim) ) { hop_anim_vis.title = service; // node_style_set( hop_anim_vis, "visibility", "visible" ); node_style_set( hop_anim_vis, "display", "block" ); return hop_anim_vis; } else { hop_anim_vis = user_anim( service ); document.body.appendChild( hop_anim_vis ); return hop_anim_vis; } } return false; } function hop_responsetext_error( xhr ) { if( xhr.responseText.length > 80 ) return xhr.responseText.substring( 0, 80 ); else return xhr.responseText; } function hop_send_request( svc, sync, success, failure, anim, henv, auth ) { var xhr = hop_make_xml_http_request(); var hop_err = hop_error; var hop_reperror = hop_responsetext_error; var hop_header_ctype = hop_header_content_type; var err = function( exc, xhr, ctype ) { var txt = hop_reperror( xhr ); var fun = ctype ? ("with-hop [content-type=" + ctype + "]") : "with-hop"; return hop_err( fun, exc, txt, svc ); } function onreadystatechange() { if( xhr.readyState == 4 ) { try { var status = xhr.status; switch( status ) { case 200: try { var ctype = hop_header_ctype( xhr ); var expr; if( ctype === "application/x-javascript" ) { try { expr = eval( xhr.responseText ); } catch( exc ) { err( exc, xhr ); expr = false; } return success( expr, xhr ); } else if( ctype === "text/html" ) { var el = hop_create_element( xhr.responseText ); return success( el, xhr ); } else { return success( xhr.responseText, xhr ); } } catch( exc ) { err( exc, xhr, ctype ); } case 202: return success( hop_unserialize( xhr.responseText ), xhr ); case 204: return false; case 257: return hop_js_eval( xhr ); case 258: if( xhr.responseText != null ) return eval( xhr.responseText ); else return false; case 259: hop_set_cookie( xhr ); return false; case 407: err( "Bad authentication", xhr ); return false; default: if( (typeof status == "number") && (status > 200) && (status < 300) ) { if( success ) { return success( xhr.responseText, xhr ); } } else { if( failure ) { return failure( xhr ); } else { return hop_default_failure( xhr ); } } } } catch( exc ) { if( typeof failure == "function" ) { failure( xhr ); } else { err( exc, xhr ); } } finally { try { if( hop_anim_vis != false ) { node_style_set( hop_anim_vis, "display", "none" ); } hop_anim_service = false; } catch( e ) { } } } return false; } if( !sync ) { xhr.onreadystatechange = onreadystatechange; } xhr.open( "GET", svc, (sync != true) ); xhr.setRequestHeader( 'Connection', 'close' ); xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1' ); if( henv.length > 0 ) { xhr.setRequestHeader( 'Hop-Env', hop_serialize_request_env() ); } if( auth ) { xhr.setRequestHeader( 'Authorization', auth ); } try { if( anim ) hop_anim_service = svc; xhr.send( null ); hop_stop_anim(); if( anim && hop_has_setInterval ) { var a = (anim instanceof Function) ? anim : hop_default_anim; hop_anim_interval = setInterval( function() { hop_anim( svc, a ) }, hop_anim_latency ); } if( sync ) { if( xhr.readyState == 4 ) { onreadystatechange(); } else { hop_error( "with-hop", "synchronous call failed", "readyState: " + xhr.readyState, svc ); } } } catch( e ) { if( hop_anim_vis != false ) { node_style_set( hop_anim_vis, "display", "none" ); } hop_anim_service = false; hop_error( "with-hop", e, "Cannot call server", svc ); } return xhr; } function with_hop( svc, success, failure, sync, anim ) { if( !success ) success = function( h ) { return h }; if( !failure ) failure = hop_default_failure; return hop_send_request( svc, sync, success, failure, true, hop_serialize_request_env(), false ); } /*** META (define-macro (with-hop svc . rest) (let ((success #f) (fail #f) (sync #f) (anim #t) (user #f) (password #f) (authorization #f)) (let loop ((rest rest)) (cond ((null? rest) `(hop_send_request ,svc ,sync ,(or success '(lambda (h) h)) ,(or fail 'hop_default_failure) ,anim (hop_serialize_request_env) ,(cond (authorization authorization) ((and (string? user) (string? password)) (string-append "Basic " (base64-encode (string-append user ":" password))))))) ((eq? (car rest) :anim) (if (null? (cdr rest)) (error 'with-hop "Illegal :anim argument" rest) (set! anim (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :authorization) (if (null? (cdr rest)) (error 'with-hop "Illegal :authorization argument" rest) (set! authorization (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :user) (if (null? (cdr rest)) (error 'with-hop "Illegal :user argument" rest) (set! user (cadr rest))) (loop (cddr rest))) ((eq? (car rest) :password) (if (null? (cdr rest)) (error 'with-hop "Illegal :password argument" rest) (set! password (cadr rest))) (loop (cddr rest))) ((not success) (set! success (car rest)) (loop (cdr rest))) ((not fail) (set! fail (car rest)) (loop (cdr rest))) (else (set! sync (car rest)) (loop (cdr rest))))))) */ function hop( svc, success, failure, sync ) { if( success == true ) { location.href = svc; return true; } if( !success ) success = function( h ) { return h; } if( !failure ) failure = hop_default_failure; return hop_send_request( svc, sync, success, failure, true, hop_serialize_request_env() ); } var hop_request_env = []; var hop_request_env_string = ""; var hop_request_env_invalid = false; function hop_serialize_request_env() { if( hop_request_env_invalid ) { var tmp = null; for( var p in hop_request_env ) { if( (typeof hop_request_env[ p ] != "function") && (hop_request_env[ p ] != undefined) ) { tmp = sc_cons( sc_cons( p, hop_request_env[ p ] ), tmp ); } } hop_request_env_string = hop_bigloo_serialize( tmp ); } return hop_request_env_string; } function hop_request_reset() { hop_request_env_string = ""; hop_request_env_set = false; return null; } function hop_request_set( key, val ) { hop_request_env_invalid = true; hop_request_env[ key ] = val; return val; } /*** META ((export request-get) (peephole: (hole 1 "hop_request[" key"]"))) */ function hop_request_get( key ) { return hop_request[ key ]; } var hop_client_debug = 0; function hop_error( fun, exc, msg, svc ) { var emsg = exc ? exc.toString() : "???"; if( exc ) { if( "message" in exc ) { emsg = exc.message; } else { if( "description" in exc ) { emsg = exc.description; } } if( "line" in exc ) { emsg = emsg + " (line " + exc.line + ")"; } } if( typeof svc === "string" || svc instanceof String ) fun = fun + ", " + svc; alert( "*** ERROR " + fun + ": " + emsg + " -- " + msg ); throw exc; } function hop_debug() { return hop_client_debug; } function hop_debug_set( v ) { if( sc_isNumber( v ) ) hop_client_debug = v; } function hop_trace() { if( hop_client_debug > 0 ) { var svc = hop_service_url( hop_service_base() + "/trace", [ "args" ], new Array( sc_vector2list( arguments ) ) ); hop_send_request( svc, true, function() {}, function() {}, false, [] ); } } function hop_tprint( file, pos, rest ) { var svc = hop_service_url( hop_service_base() + "/trace/tprint", [ "file", "pos", "args" ], [ file, pos, rest ] ); hop_send_request( svc, true, function() {}, function() {}, false, [] ); } /*** META (define-macro (tprint . rest) (if (epair? rest) (match-case (cer rest) ((at ?name ?pos) `(hop_tprint ,(relative-file-name name (pwd)) ,(file-position->line pos name) (list ,@rest))) (else `(hop_tprint #f #f (list ,@rest)))) `(hop_tprint #f #f (list ,@rest)))) */ function hop_replace_inner( el ) { if( el != undefined ) { return function( html ) { if( html ) { hop_innerHTML_set( el, html ); } } } else { alert( "*** Hop Error, Can't find element" ); return function( http ) { }; } } function hop_replace_inner_id( id ) { return hop_replace_inner( document.getElementById( id ) ); } function hop_set_cookie( http ) { try { var cookie = http.getResponseHeader( "set-cookie" ); if( cookie ) document.cookie = cookie; } catch( e ) { ; } } function hop_cookie_remove( name, path, domain ) { if( hop_cookie_get_value( name ) ) { hop_cookie_set_value( name, "", path, domain ); } } function hop_cookie_get_value( name ) { var cookies = document.cookie; var i = cookies.indexOf( name + "=" ); if( i !== -1 ) { var start = i + name.length + 1; var end = cookies.indexOf( ";", start ); if( end == -1 ) end = cookies.length; return unescape( cookies.substring( start, end ) ); } else { return null; } } function hop_cookie_set_value( name, val, path, domain, expires ) { var cookie = name + "=" + val; if( (path instanceof String) || (typeof path == "string") ) { cookie += "; path=" + path; } else { cookie += "; path=/"; } if( (expires instanceof String) || (typeof expires == "string") ) { cookie += "; expires=" + expires; } else { if( expires instanceof Date ) { cookie += "; expires=" + expires.toGMTString(); } } if( (domain instanceof String) || (typeof domain == "string") ) { cookie += "; domain=" + domain; } document.cookie = cookie; } var hop_load_frequency = 100; function HopLoadError( file ) { var e = new Error( "hop-load error" ); e.file = file; return e; } function hop_load( src, timeout ) { var script = document.createElement( "script" ); script.src = src; var loaded = false; var holder = document.getElementsByTagName( "head" ); if( !timeout || (timeout == undefined) ) timeout = -1; if( holder != null ) { if( timeout != 0 ) script.onload = function( e ) { loaded = true; }; holder[ 0 ].appendChild( script ); if( timeout != 0 ) { var it; var p = function() { if( loaded == true ) { clearInterval( it ); } else { if( timeout > 0 ) { timeout -= hop_load_frequency; if( timeout <= 0 ) { clearInterval( it ); throw( new HopLoadError( src ) ); } } } }; it = setInterval( p, hop_load_frequency ); } } else { alert( "*** Hop Error, Can't find HEAD element" ); } } var hop_window_onload_add = function( proc ) { var oldonload = window.onload; if( typeof oldonload != 'function' ) { window.onload = proc; } else { window.onload = function( e ) { oldonload( e ); proc( e ); } } } hop_window_onload_add( function( e ) { hop_window_onload_add = function( proc ) { proc( e ); } } ); function hop_window_onload_cons( proc ) { var oldonload = window.onload; if( typeof oldonload != 'function' ) { window.onload = proc; } else { window.onload = function( e ) { proc( e ); oldonload( e ); } } } function hop_window_onunload_add( proc ) { if( typeof( window.onunload ) != 'function' ) { window.onunload = proc; } else { var oldonunload = window.onunload; window.onunload = function( e ) { oldonunload( e ); proc( e ); } } } function hop_update( node ) { if( node.hop_update != undefined ) { node.hop_update(); } for( var i = 0; i < node.childNodes.length; i++ ) { hop_update( node.childNodes[ i ] ); } } function hop_find_runtime_type( obj ) { if( obj instanceof Object ) { if( obj instanceof Date ) { return "date"; } else { if( obj instanceof RegExp ) { return "regexp"; } else { if( typeof obj.hop_find_runtime_type == "function" ) return obj.hop_find_runtime_type(); else return "object"; } } } else { var tname = typeof obj; if( tname == "string" ) { if( sc_isSymbol( obj ) ) return "symbol"; if( sc_isKeyword( obj ) ) return "keyword"; return tname; } return tname; } } function after( timeout, proc ) { var tm = sc_isNumber( timeout ) ? timeout : 1; var i = setInterval( function() { clearInterval( i ); proc() }, tm ); return true; } function timeout( tm, proc ) { var i = setInterval( function() { if( !proc() ) clearInterval( i )}, tm ); } function url_decode( s ) { try { return decodeURI( s ); } catch( e ) { return s; } } function url_encode( s ) { return encodeURI( s ); } function string_hex_extern( str ) { var res = ""; var l = str.length; for( var i = 0; i < l; i++ ) { res += "0123456789abcdef".charAt( (str.charCodeAt( i ) >> 4) & 15 ) + "0123456789abcdef".charAt( (str.charCodeAt( i ) & 15) ); } return res; } function string_hex_intern( s ) { var res = ""; var l = s.length; var z = '0'.charCodeAt( 0 ); var n = '9'.charCodeAt( 0 ); var a = 'a'.charCodeAt( 0 ); var f = 'f'.charCodeAt( 0 ); var A = 'A'.charCodeAt( 0 ); function hex_to_num( c ) { if( (c >= z) && ( c<= n) ) { return c - z; } if( (c >= a) && ( c<= f) ) { return (c - a) + 10;; } return (c - A) + 10; } for( var i = 0; i < l; i += 2 ) { var d1 = hex_to_num( s.charCodeAt( i ) ); var d2 = hex_to_num( s.charCodeAt( i + 1 ) ); res += String.fromCharCode( (d1 << 4) + d2 ); } return res; } function date_year( d ) { return d.getYear(); } function date_month( d ) { return d.getMonth(); } function date_day( d ) { return d.getDay(); } function date_hour( d ) { return d.getHours(); } function date_minute( d ) { return d.getMinutes(); } function date_second( d ) { return d.getSeconds(); } var hop_current_state_history = undefined; var hop_state_history_handler = {}; function hop_state_history_register_handler( key, reset, proc ) { hop_state_history_handler[ key ] = { reset: reset, proc: proc }; } function _hop_state_entry( op, val ) { this.op = op; this.val = val; this.close = false; } function hop_state_history_to_location( state ) { var loc = undefined; for( p in state ) { if( state[ p ] instanceof _hop_state_entry ) { if( loc == undefined ) { loc = "#" + p + "=" + state[ p ].op + ":" + state[ p ].val; } else { loc += "," + p + "=" + state[ p ].op + ":" + state[ p ].val; } } } return loc; } var hop_hash_history_regexp = /#?([^=]+)=([^:]+):([^,]+)+/; function hop_location_to_state_history( hash ) { var state = {}; var split = hash.split( "," ); for( var i = 0; i < split.length; i++ ) { var el = split[ i ].match( hop_hash_history_regexp ); if( el ) { var id = el[ 1 ]; var op = el[ 2 ]; var val = el [ 3 ]; state[ id ] = new _hop_state_entry( op, val ); } } return state; } function hop_state_history_push( id, op, val ) { if( hop_current_state_history == undefined ) { hop_current_state_history = {}; hop_current_state_history[ id ] = new _hop_state_entry( op, val ); } else { var olde = hop_current_state_history[ id ]; if( olde == undefined ) { hop_current_state_history[ id ] = new _hop_state_entry( op, val ); } else { if( (olde.op != op) || (olde.val != val) ) { olde.op = op; olde.val = val; } } } } function hop_state_history_flush() { var loc = hop_state_history_to_location( hop_current_state_history ); var old = window.location.href; var i = old.indexOf( "#" ); if( i == -1 ) { hop_active_location_set( document, old + loc ); } else { hop_active_location_set( document, old.substring( 0, i ) + loc ); } } var hop_state_history_transaction = 0; function hop_state_history_add( id, op, val ) { hop_state_history_push( id, op, val ); if( hop_state_history_transaction == 0 ) { hop_state_history_flush(); } } function hop_with_history( proc ) { var res; hop_state_history_transaction++; try { res = proc(); } finally { hop_state_history_transaction--; } hop_state_history_flush(); return res; } function hop_state_history_reset() { if( hop_current_state_history != undefined ) { for( p in hop_current_state_history ) { if( hop_current_state_history[ p ] instanceof _hop_state_entry ) { var op = hop_current_state_history[ p ].op; var handler = hop_state_history_handler[ op ]; if( handler != undefined ) { handler.proc( p, handler.reset ); } } } hop_current_state_history = undefined; } } function hop_state_history_update( olds, news ) { var res = 0; if( olds == undefined ) { for( p in news ) { var state = news[ p ]; if( state instanceof _hop_state_entry ) { var op = state.op; var handler = hop_state_history_handler[ op ]; if( (handler != undefined) && !state.close ) { if( handler.proc( p, state.val ) ) { state.close = true; } else { res++; } } } } } else { for( p in olds ) { if( (olds[ p ] instanceof _hop_state_entry) && !(news[ p ] instanceof _hop_state_entry) ) { var op = olds[ p ].op; var handler = hop_state_history_handler[ op ]; if( handler != undefined ) { handler.proc( p, handler.reset ); } } } for( p in news ) { var state = news[ p ]; if( state instanceof _hop_state_entry ) { if( !(olds[ p ] instanceof _hop_state_entry) || (state.op != olds[ p ].op) || (state.val != olds[ p ].val) ) { var op = state.op; var handler = hop_state_history_handler[ op ]; if( (handler != undefined) && !state.close ) { if( handler.proc( p, state.val ) ) { state.close = true; } else { res++; } } } } } } return res; } var hop_hash_history_check_regexp = new RegExp( "^#(?:[^=]+=[^:]+:[^,]+,?)+$" ); function hop_hash_historyp( hash ) { return hop_hash_history_check_regexp.exec( hash ); } var hop_eval_history_interval = false; function hop_retry_eval_history_state( count, old_state, new_state ) { var fun = function() { var c = hop_state_history_update( old_state, new_state ); if( (c == 0) || (c == count) || hop_eval_history_interval.invalid ) { clearInterval( hop_eval_history_interval ); } } hop_eval_history_interval = setInterval( fun, 200 ); hop_eval_history_interval.invalid = false; } function hop_eval_history_state( location ) { var hash = location.hash; if( hop_eval_history_interval ) hop_eval_history_interval.invalid = true; if( hash.length == 0 ) { hop_state_history_reset(); } else { if( hop_hash_historyp( hash ) ) { var new_state = hop_location_to_state_history( hash ); var old_state = hop_current_state_history; var count = hop_state_history_update( old_state, new_state ); if( count == 0 ) { hop_current_state_history = new_state; } else { hop_retry_eval_history_state( count, old_state, new_state ); } } } } function hop_current_history() { var hash = location.hash; if( hash.length == 0 ) { return false; } if( hop_hash_historyp( hash ) ) { return hop_location_to_state_history( hash ); } return false; } function hop_replay_history( hist ) { hop_current_state_history = undefined; var loc = function( v ) { this.hash = v; } hop_eval_history_state( new loc( hop_state_history_to_location( hist ) ) ); } function _hop_history( key ) { this.key = key; } function hop_make_history( key, handler, reset ) { hop_state_history_register_handler( key, reset, handler ); return new _hop_history( key ); } function hop_history_add( history, id, val ) { if( !history instanceof _hop_history ) { alert( "*** ERROR: Illegal history object -- " + history ); return false; } else { return hop_state_history_add( id, history.key, val ); } } if( hop_enable_location_event ) { hop_window_onload_add( function( e ) { hop_add_event_listener( document, "location", hop_eval_history_state ); } ); } function hop_bigloo_serialize_pair( l ) { var res = ""; var len = 0; while (sc_isPair( l ) ) { res += hop_bigloo_serialize( l.car ); l = l.cdr; len++; } if( l == null ) { return hop_serialize_word( len + 1 ) + res + "."; } else { return hop_serialize_word( len + 1 ) + res + hop_bigloo_serialize( l ); } } sc_Pair.prototype.hop_bigloo_serialize = function() { return '(' + hop_bigloo_serialize_pair( this ); }; sc_Pair.prototype.hop_find_runtime_type = function() { return "pair"; }; sc_Vector.prototype.hop_find_runtime_type = function() { return "vector"; }; sc_Struct.prototype.hop_find_runtime_type = function() { return "struct"; }; sc_OutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_StringOutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_GenericOutputPort.prototype.hop_find_runtime_type = function() { return "output-port"; }; sc_InputPort.prototype.hop_find_runtime_type = function() { return "input-port"; }; Boolean.prototype.hop_find_runtime_type = function() { return "bbool"; }; String.prototype.hop_find_runtime_type = function() { return hop_find_runtime_type(this.toString()); }; sc_Char.prototype.hop_find_runtime_type = function() { return "bchar"; }; ]]> TPAC 08, W3C Technical Plenary 2008 ...Start...Title Preludeapplications demand languageshop HopHOP...The Web...Architecture ApplicationAn applicationA Diffuse Music PlayerHopAudio (architecture) ConclusionConclusionWhy Using Hop?hop.inria.frendHopSlide v1.5.121 October 2008HopSlide Help (v1.5.1)KeyboardToggle this helpalt-hReload slidesalt-rToggle slide selectoralt-sOpen a full screen windowalt-wUpdate sizealt-uToggle big cursoralt-mToggle focusalt-fToggle drawing areaalt-cNext slidePgDn↓alt-nRetEnterSpacePrevious slidePgUp↑alt-pFirst slideHomeLast slideEndClose slideEscMouseReload slidesshift Button1Slides selectorcrtl Button1Focus enlarge/shrinkButton4Button5 image/svg+xmlPress [Space] to start... Hop, an Everyware Development KitManuel SerranoMimosa TeamInria Sophia-Antipolishttp://hop.inria.fr Prelude Applications demand Languages X= 27.3 DATA A, B / 5.0, 12.0. / IF (X) 10, 20, 30 DO 9 J= 1, 10 DO 9 K= 1, 10 9 L= J + K 60 FORMAT ( 9H1GOODBYE. )?module ABRO: input A, B, R; output O; loop [ await A || await B ]; emit O each R end module#include <iostream> class Bird { public: virtual void OutName() { std::cout << "a bird"; } virtual ~Bird() {} }; int main() { Swan mySwan; Bird* myBird = &mySwan; myBird->OutName(); return 0; }
X= 27.3 DATA A, B / 5.0, 12.0. / IF (X) 10, 20, 30 DO 9 J= 1, 10 DO 9 K= 1, 10 9 L= J + K 60 FORMAT ( 9H1GOODBYE. )
?
module ABRO: input A, B, R; output O; loop [ await A || await B ]; emit O each R end module
#include <iostream> class Bird { public: virtual void OutName() { std::cout << "a bird"; } virtual ~Bird() {} }; int main() { Swan mySwan; Bird* myBird = &mySwan; myBird->OutName(); return 0; }