2010-March-8 presentation notes

* learning from stupid mistakes

* LOTS of mistakes = LOTS of time wasted.

* also LOTS of learning

* wasn’t taking JavaScript seriously

* I need to do more high-level design

source code, base_set.js:


/*
* base_set.js
*This is to represent a base set for Diamond faceted search.
*It represents a set of solar events that can be described by a HEK API URL.
*coded by Ian Ruotsala
*
*I use Yahoo's YUI library to parse the JSON into JavaScript Object.
*copyright info for YUI here: http://developer.yahoo.com/yui/license.html
*tl;dr: it's a BSD copyleft sorta thing
*--Ian Ruotsala, Mar. 8, 2010
*/

/*should be able to:
* report various details about the set it reps,
* e.g. count of various events. BUT, what if
* base_set doesn't do much besides hold info,
* and the root set, or super set or whatever
* does most of the work??? Yeah, I think that's
* a better idea, will put that burden on super
* sets and root sets
*--ICR, Feb. 15, 2010
*/

/*well, damn, that means base_set is actually
* very nearly done, just need to check if >200
* events returned
* --ICR, Feb. 15, 2010
*/

/*
* base_set.js finally working like I want it,
* --ICR, Mar. 5, 2010
*/

function base_set(url){

//should I also have an assemble_url???
//no, I'd save that for the root_set --ICR, Feb. 15, 2010

//what if url described over 200 events???
/*probably should just make super set by
* dividing set into two, then ANDing
* them into super set
* --ICR, Feb. 15, 2010
*/
this.url = url;
//I also need to store the JSON
var jsonDoc;

this.update_set = update_set;
this.set_url = set_url;
}

function update_set(){
//send present url to query, update the stored JSON
var httpQuery = new XMLHttpRequest();
httpQuery.open("GET",this.url,false);
httpQuery.send(null);
var returnString = httpQuery.responseText;
document.write(typeof(returnString));

var returnObj = YAHOO.lang.JSON.parse(returnString);

document.write(typeof(returnObj));

this.jsonDoc = returnObj;

//return true if >= 200 events returned
if (returnObj.result.length >= 200){
return true;
}

return false;
}

function set_url(url_string){
this.url = url_string;
}

function test(){

/*
*outputs: "foo test_urlbarhekbazstringobjectfoo1objectobject97bar1"
*/

test_bs = new base_set("test_url");
document.write("foo\n");
document.write(test_bs.url);
document.write("bar");
test_bs.set_url("hek");
document.write(test_bs.url);
document.write("baz");
test_bs.update_set();
document.write("foo1");

//test to see how many events are gotten
//i.e. how many items in jsonDoc.result?
document.write(typeof(test_bs.jsonDoc));
document.write(typeof(test_bs.jsonDoc.result));
document.write(test_bs.jsonDoc.result.length);

document.write("bar1");
}

About ruoian27

Computer science student, taking Student Originated Software presently
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to 2010-March-8 presentation notes

  1. nelkar02 says:

    Good one.

Leave a Reply

Your email address will not be published. Required fields are marked *