Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active August 29, 2015 14:02
Show Gist options
  • Save kenwebb/81786af30c8ac62e4753 to your computer and use it in GitHub Desktop.
Save kenwebb/81786af30c8ac62e4753 to your computer and use it in GitHub Desktop.
The Love Letter - Jake - no postMessage()
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Sun Jun 01 2014 11:11:34 GMT-0400 (EDT)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: The Love Letter - Jake - no postMessage()
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: b82b688d02e6b9f06fef 81786af30c8ac62e4753
Keywords:
My Notes
--------
This version of the Helen and Jake multi-app uses Xholon messaging, with no HTML postMessage().
This is possible because both the Helen window and the Jake window have the same domain, protocol and port.
The Helen window is the top window on the page, while the Jake window is an iframe or optionally on a separate page.
In science fiction writer Jack Finney's short story `The Love Letter`,
Jake Belknap and Helen Elizabeth Worley correspond while living in 1959 and 1882 respectively.
This Xholon workbook is Jake's world.
References
----------
(1) http://www.primordion.com/Xholon/gwt/wb/editwb.html?app=9460309abdef48f184cf&src=gist
Helen's world
(2) http://en.wikipedia.org/wiki/Jack_Finney
(3) http://richters-time.blogspot.ca/2007/09/love-letter-by-jack-finney.html
(4) http://en.wikipedia.org/wiki/The_Love_Letter_%281998_film%29
(5)
]]></Notes>
<_-.XholonClass>
<NoBoundariesSystem/>
<Jake/>
<Letter superClass="Attribute_String"/>
<Letters/>
</_-.XholonClass>
<xholonClassDetails>
<Jake xhType="XhtypePureActiveObject">
<port index="0" connector="../Letters/Letter"/>
</Jake>
</xholonClassDetails>
<NoBoundariesSystem>
<Jake/>
<Letters>
<Letter><![CDATA[
Helen: I have just read the letter in the secret drawer of your desk, and I wish I knew how I could possibly help you. I can't tell what you might think of me if there were a way I could reach you.But you are someone I am certain I would like to know. I hope you are beautiful, but you needn't be; you're a girl I could like, and maybe ardently, and if I did I promise you I'd be true and loving.Do the best you can, Helen Elizabeth Worley, in the time and place you are;I can't reach you or help you. But I'll think of you. And maybe I'll dream of you, too.
Yours,
JAKE BELKNAP
]]></Letter>
<Letter><![CDATA[
Helen, my dear: I don't know how to say this so it will seem even comprehensible to you. But I do exist, here in Brooklyn,less than three blocks from where you now read this — in the year 1959. We are separated not by space, but by the years which lie between us. Now I own the desk which you once had, and at which you wrote the note I found in it. Helen, all I can tell you is that I answered that note, mailed it late at night at the old Wister station, and that somehow it reached you, as I hope this will too. This is no hoax! Can you imagine anyone playing a joke that cruel? I live in a Brooklyn, within sight of your house, that you cannot imagine. It is a city whose streets are now crowded with wheeled vehicles propelled by engines. And it is a city extending far beyond the limits you know, with a population of millions, so crowded there is hardly room any longer for trees.From my window as I write I can see — across Brooklyn Bridge, which is hardly changed from the way you, too, can see it now — Manhattan Island,and rising from it are the lighted silhouettes of stone-and-steel buildings more than one thousand feet high.
You must believe me. I live, I exist, seventy-seven years after you read this; and with the feeling that I have fallen in love with you.
Helen: there are three secret drawers in our desk. Into the first you put only the letter I found. You cannot now add something to that drawer and hope that it will reach me. For I have already opened that drawer and found only the letter you put there. Nothing else can now come down through the years to me in that drawer, for you cannot now alter what you have already done.
Into the second drawer, in 1882, you put the note which lies before me, which I found when I opened that drawer a few minutes ago. You put nothing else into it. and now that, too, cannot be changed. But I haven't opened the third drawer, Helen. Not yet! It is the last way you can still reach me, and the last time. I will mail this as I did before,then wait. In a week I will open the last drawer.
JAKE BELKNAP
]]></Letter>
</Letters>
</NoBoundariesSystem>
<NoBoundariesSystembehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var sys;
var beh = {
postConfigure: function() {
sys = this.cnode.parent();
$wnd.xh.param("TimeStep", "19590001");
$wnd.xh.param("TimeStepInterval", "1000");
$wnd.xh.param("InformationFile","http://en.wikipedia.org/wiki/The_Love_Letter_%281998_film%29");
}
}
]]></NoBoundariesSystembehavior>
<Jakebehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var jake, helen, letter;
var beh = {
postConfigure: function() {
jake = this.cnode.parent();
letter = jake.port(0);
var helenWindow = null;
if ($wnd.self == $wnd.top) {
// Jake is in a separately opened window
helenWindow = $wnd.opener;
}
else {
// Jake is in an iframe
helenWindow = $wnd.top;
}
helen = helenWindow.xh.root().first().first();
// let the Helen window/app know that the Jake window/app is ready
helen.msg(201, null, jake);
},
act: function() {
//jake.println("Jake");
},
processReceivedMessage: function(msg) {
jake.println("\n\nJake has received a message (signal:" + msg.signal + ") from "
+ msg.sender.xhc().name() + ":\n" + msg.data);
if (letter) {
helen.msg(102, letter.text(), jake);
letter = letter.next();
}
}
}
]]></Jakebehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Jake</title>
<rect id="NoBoundariesSystem/Jake" fill="#98FB98" height="50" width="50" x="25" y="0"/>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment