Skip to content
This repository has been archived by the owner on Jun 24, 2018. It is now read-only.

Commit

Permalink
login removes focus
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.osteele.com/home/osteele/svn/projects/cloud@42 e7b8d44c-8308-0410-acfb-b763ae30a170
  • Loading branch information
osteele committed Jan 7, 2006
1 parent a01dbe9 commit db24d7f
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -4,12 +4,12 @@ require 'openlaszlo_tasks'

SERVER_URL = 'osteele@osteele.com:expialidocio.us'
UPLOADS = %w{expialidocious.swf index.html proxy.php favicon.ico javascript about}
PUBLIC_SOURCES=%w{expialidocious.png analyzer.js expialidocious.lzx histogram.lzx colors.js login.lzx thumb.lzx}
PUBLIC_SOURCES=%w{expialidocious.png analyzer.js expialidocious.lzx histogram.lzx colors.js login.lzx thumb.lzx cloud.lzx}
ABOUT_HTML = FileList.new 'about/*.html'
ABOUT_MASTER = 'about/about.html'

task :default => :deploy
CLEAN.include 'cloud.swf'
CLEAN.include 'expialidocious.swf'

file 'expialidocious.swf' => FileList.new('*.lzx') + FileList.new('*.js')

Expand Down
2 changes: 1 addition & 1 deletion about/about.html
Expand Up @@ -8,7 +8,7 @@

<div style="float: right; width: 250; margin-left: 5px; padding: 5px; font-size: 90%; border: 1px solid black; color: #444">
<strong>News</strong>
<p>Saturday January 7 &mdash; Sped up tag processing and interaction.</p>
<p>Saturday January 7 &mdash; Sped up; cleaned up code some.</p>
<p>Thursday January 5 &mdash; My son made me a new logo for the application.</p>
<p>Thursday January 5 &mdash; Jon Udell <a href="http://weblog.infoworld.com/udell/2006/01/05.html#a1364">posted</a> about this application. Shamed by his posting, I went ahead and added links to the <a href="../src">sources</a> (rough as they are).</p>
<p>Wednesday January 4 &mdash; first blogged about this on the <a href="http://weblog.openlaszlo.org">OpenLaszlo project blog</a>.</p>
Expand Down
5 changes: 5 additions & 0 deletions expialidocious.lzx
Expand Up @@ -22,6 +22,11 @@ coupling between the different views.
<include href="histogram.lzx"/>
<splash/>

<script>
// The ondata handler for postData sets this.
var TagData = null;
</script>

<dataset name="postData" src="http:data.xml"
ondata="canvas.processPostDataset()"/>

Expand Down
20 changes: 14 additions & 6 deletions login.lzx
@@ -1,21 +1,29 @@
<!--
Copryight 2005-2006 Oliver steele. Some rights reserved.
$LastChangedDate$

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License:
http://creativecommons.org/licenses/by-nc-sa/2.5/.
-->

<library>
<vbox id="loginView" align="center"
y="${credits.y+credits.height+20}"
width="250" spacing="2"
visible="${appstate.state=='login' || appstate.state=='retrieving'}"
fontsize="14">
<method name="updateButtons">
submitButton.setAttribute('enable', this.userText != '' &amp;&amp; this.passwordText != nil);
</method>

<method name="submit"><![CDATA[
var username = userField.getText();
// sometimes the password has an initial newline?
// Sometimes the password has an initial newline. This gets rid of
// it.
var split = passwordField.getText().split();
var password = '';
for (var i = 0; i < split.length; i++) password += split[i];
Debug.write('username="'+username+'"');
Debug.write('password="'+password+'"');
//Debug.write('username="'+username+'"');
//Debug.write('password="'+password+'"');
if (username=='' || password=='') return;
LzFocus.clearFocus();
appstate.signin(username, password)
]]></method>

Expand Down
216 changes: 216 additions & 0 deletions main.lzx
@@ -0,0 +1,216 @@
<!--
Copryight 2005-2006 Oliver steele. Some rights reserved.
$LastChangedDate: 2006-01-07 08:16:19 -0500 (Sat, 07 Jan 2006) $

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License:
http://creativecommons.org/licenses/by-nc-sa/2.5/.
-->
<canvas proxied="false" title="expialidocio.us" height="100%">
<include href="incubator/roundrectbutton.lzx"/>
<include href="incubator/ulink.lzx"/>
<include href="thumb.lzx"/>
<script src="analyzer.js"/>
<script src="colors.js"/>
<splash/>

<dataset name="postData" src="http:data.xml" ondata="canvas.processPostDataset()"/>

<script><![CDATA[
var ServerURLs = {
localhost: 'http://localhost/proxy.php',
server: 'http://expialidocio.us/proxy.php'
}
function isRemoteRequest(sourceKey) {
return ServerURLs[sourceKey];
}
function requestPosts(sourceKey, username, password) {
var url = ServerURLs[sourceKey];
if (url) {
postData.setQueryType('POST');
postData.setQueryParams({user: username, password: password})
} else {
url = 'http:tests/' + source + '.xml';
}
Debug.write(url);
postData.setSrc(url);
appstate.setAttribute('state', 'retrieving');
postData.doRequest();
}
]]></script>

<!-- Process the post data, once it has returned. The dataset's ondata
handler invokes this. -->
<method name="processPostDataset"><![CDATA[
var root = postData.data;
if (root.nodeName=='error') {
var message =
root.attributes['code'] == '401' ?
"Del.icio.us didn't accept your username and password. Please try again.<br/><font size='10' color='#000'>If the problem persists, del.icio.us may be refusing requests from the expialidocio.us server. If you're certain you got your name and password right, please try again tomorrow.</font>" :
LzBrowser.urlUnescape(postData.attributes['message']);
loginView.errorMessage.setAttribute('text', message);
return appstate.setAttribute('state', 'login');
}
if (!(root.childNodes||[]).length)
return appstate.setAttribute('state', 'empty');
appstate.setAttribute('username', root.attributes['user']);
appstate.setAttribute('state', 'running');

TagData = new DataFrame;
//var t0 = (new Date).getTime();
fillTagFrame(TagData, root.childNodes);
//Debug.write('fill', (new Date).getTime-t0);

SortedTags = [].concat(TagData.rowNames);
SortedTags.sort();
TagSortInverse = computeArrayinversion(SortedTags, TagData.rowNames);

histogram.drawGraph();
allStart.setText(TagData.columnNames[0]);
allEnd.setText(TagData.columnNames[TagData.columnNames.length - 1]);
var cn = Math.floor(TagData.columns.length/3);
histogram.selector.setRange(cn, TagData.columns.length-cn);
myview.animate('opacity', 1.0, 1000);
credits.animate('y', myview.y+myview.height+40, 0);
]]></method>

<node id="appstate">
<attribute name="username" type="string" value=""/>
<attribute name="state" type="string" value="login"/>
<method name="signin" args="username, password"><![CDATA[
loginView.errorMessage.setAttribute('text', '');
appstate.setAttribute('username', username);
requestPosts(source, username, password);
]]></method>
<method name="signout">
appstate.setAttribute('state', 'login');
credits.setAttribute('y', 0)
</method>
</node>

<!-- The dates at the bottom of the tag cloud and the histogram. -->
<class name="dateLabel" extends="text" resize="true"
fontsize="24" fgcolor="#60ff60"/>

<!-- The "logged in" box at the upper right -->
<hbox id="loggedIn" align="right" visible="${appstate.state == 'running'}" fontsize="14" y="5">
<text>username:</text>
<text resize="true" fontstyle="bold" text="${appstate.username}"/>
<view width="2"/>
<roundrectbutton width="$once{null}" height="15" y="4" onclick="appstate.signout()">Logout</roundrectbutton>
<view width="10" height="25"/>
</hbox>

<!-- The tag cloud. This is just a container for a text field that
knows how to set its text. -->
<view id="myview" width="100%" layout="axis: y" opacity="0.1"
visible="${appstate.state=='running'}" y="${loggedIn.height}">
<view id="cloud" width="${parent.width-20}" x="10" height="200" bgcolor="#f0f0ff">
<attribute name="rangeMin" value="null"/>
<attribute name="rangeMax" value="null"/>
<method name="setRange" args="a,b"><![CDATA[
if (arguments.length < 1) a = 0;
if (arguments.length < 2) b = TagData.columns.length;
if (a == rangeMin && b == rangeMax) return;
currentStart.setText(TagData.columnNames[a]);
currentEnd.setText(TagData.columnNames[b-1]);
this.rangeMin = a;
this.rangeMax = b;
var tagCounts = TagData.columnRangeSum(a, b);

var max = 0;
var min = 100;
for (var i = 0; i < tagCounts.length; i++) {
var c = tagCounts[i];
if (c > max) max = c;
if (c < min) min = c;
}

str = '';
for (var i = 0; i < tagCounts.length; i++) {
var tagname = SortedTags[i];
var count = tagCounts[TagSortInverse[i]];
if (!count) continue;
var s = (count - min) / (max - min);
var c = Math.floor(255*(1-1.0*s));
var fontsize = 10+12*s;
// TODO: change this to cloud.fgcolor
var color = long2css(interpolateColors(cloud.bgcolor, 0x0000FF, 0.25+0.75*s));
var label = '<font size=\"' + fontsize + '" color="' + color + '">' + tagname + ' </font>'
var url = 'http://del.icio.us/' + appstate.username + '/' + tagname
str += '<a href=\"' + url + '\" target="_blank">' + label + '</a>'
}
tags.setText(str);
]]></method>
<text name="tags" multiline="true" width="100%" height="100%"/>
</view>

<!-- The funnel from the histogram to the cloud. -->>
<drawview id="funnel" x="${cloud.x}" width="${cloud.width}" height="50">
<dateLabel id="currentStart" align="left" valign="bottom"/>
<dateLabel id="currentEnd" align="right" valign="bottom"/>
<method name="update" event="onx" reference="histogram.selector">
var h = this.height;
var r = 20; // rounding radius
var x0 = cloud.getAttributeRelative('x', this)-10;
var x1 = histogram.selector.getAttributeRelative('x', this)-10;
var x2 = x1+histogram.selector.getAttributeRelative('width', this);
var x3 = x0+cloud.getAttributeRelative('width', this);
clear();
beginPath();
moveTo(x0, 0);
quadraticCurveTo(x0, r, x0+r, r)
lineTo(x1-r, h-r);
quadraticCurveTo(x1, h-r, x1, h);
lineTo(x2, h);
quadraticCurveTo(x2, h-r, x2+r, h-r);
lineTo(x3-r, r);
quadraticCurveTo(x3, r, x3, 0);
this.fillStyle = cloud.bgcolor;
var g = this.createLinearGradient(0, 0, 0, h);
g.addColorStop(0, cloud.bgcolor);
g.addColorStop(1, histogram.bgcolor);
this.fillStyle = g;
fill();
</method>
<method event="onwidth" reference="histogram.selector">
update();
</method>
</drawview>

<!-- The date*postings histogram... -->
<include href="histogram.lzx"/>

<!-- and its labels. -->
<view x="${histogram.x}" width="${histogram.width}">
<dateLabel id="allStart" fontsize="18" align="left"/>
<dateLabel id="allEnd" fontsize="18" align="right"/>
</view>
</view>

<!-- FIXME: ${credits.height} is too high -->
<view x="25%" width="50%" y="150" fontsize="24">
<text visible="${appstate.state=='empty'}" width="100%" align="center" valign="middle" multiline="true"><a href="http://del.icio.us"><u><font color="#0000ff">de.licio.us</font></u></a> doesn't show any posts tagged with your account. This could be because you haven't tagged any pages, in which case you should tag some and then come back here. Or it could be because the del.icio.us server is responding null.</text>
</view>

<view id="credits" layout="axis: y">
<view id="logo" resource="expialidocious.png"/>
<text visible="${appstate.state=='running'}" multiline="true" width="${logo.width}" fgcolor="#444">The bar chart displays the number of posts you've tagged, for each day that you've tagged any posts at all. The tag cloud contains tags for the selected range of dates. Drag the red slider to move the date range; drag the side handles to extend it. Click on a tag name to visit your de.licio.us page for that tag.</text>
<text fgcolor="#222"><i>Copyright 2005 by <a href="http://osteele.com"><u><font color="#0000ff">Oliver Steele</font></u></a>. <a href="http://creativecommons.org/licenses/by-nc-sa/2.5/">Some rights reserved.</a></i></text>
<hbox>
<ulink href="about/about.html">About</ulink>
<text>|</text>
<ulink href="mailto:steele@osteele.com">Contact</ulink>
<text>|</text>
<ulink href="about/privacy.html">Privacy</ulink>
</hbox>
</view>

<include href="login.lzx"/>

<debug/>

<script>
if (_root['source'] == undefined) source = 'posts';
if (!isRemoteRequest(source)) requestPosts(source);
</script>
</canvas>

0 comments on commit db24d7f

Please sign in to comment.