Ted, that's a really nice exhibit. Since you volunteered :), let me put
in my 2 cents on what would be nice to have.
Your idea, of having the order of a certain set of items specified
"schematically" as part of the data file, is on that I have suggested in
the past. I think it is a good one. I can imagine two approaches. One
is to specifically order the items as part of the schema definition:
types: {sourceType: {order: ["US Legal", "Foreign", ... etc]}}
(I think it would be a useful discipline to say that you can't order any
old strings but must specifically order items of a given type). Another
approach would be to add an annotation on the type that says it should
be ordered in the same order as it is defined in the data file, e.g.
types: {sourceType: {ordered: true}}}.
A different approach would be to pose this as a presentation problem
rather than a data problem. Let the author specify what should go on as
part of the presentation, not the data. There could be language for
defining a "group lens" that specifies how each group should look.
Using the same approach (of assigning a numeric order field to each
source type) one could say, e.g.
<div ex:role="view" ex:orders=".sourceType.order">
<div ex:role="groupLens">
<H3><span ex:content="!order"></span></H3>
<span ex:content="items"></span>
...
here, the grouplens applies to each group of items, and the "starting
point" for expressions in the groupLens is the value on which the group
was created---ie, in this case a particular .sourceType.order value. So
when I express "!order", it takes me from that value back to the
sourceType whose order has that value, and makes that the header for the
group. The ex:content="items" span says where to put the list of
items. It could be wrapped inside an <ul> or other list tag to control
how the individual items are laid out. Or even more general, one could
put a lens for items inside the "list items here" span So, for example,
if I wanted a tabular view of each group:
< div ex:role="groupLens">
<table>
<span ex:content="!order"></span>
<tr>
<td><span ex:content=".label"></span> <td> <span ex:content=".type">
</tr>
</span>
</table>
This is simple but powerful, as it lets the author do anything they want
with the groups---style and lay each one out however they like, and
possibly even compute and display aggregate information about the group
that way exhibit currently computes counts.
Ted wrote:
> Thanks David. Changing the code you pointed out allowed me to
> generate the sort order I wanted.
>
> Here it is:
> http://libdev.law.columbia.edu/neweres/sorted.html
>
> A nice feature would be if you could specify a sort order in an
> external file, like with plural label terms, and then read that in to
> this function for customized sorting. I would be willing to work on
> this, but I'm not sure where to begin.
>
> Thanks again.
>
>
> var processNonNumericLevel = function(items, index, values, valueType)
> {
> var keys = [];
> var compareKeys;
> var retrieveItems;
> var order = orders[index];
>
> if (valueType == "item") {
> values.visit(function(itemID) {
> var label = database.getObject(itemID, "label");
> label = label != null ? label : itemID;
> keys.push({ itemID: itemID, display: label });
> });
>
> compareKeys = function(key1, key2) {
> var c = key1.display.localeCompare(key2.display);
> return c != 0 ? c : key1.itemID.localeCompare
> (key2.itemID);
> };
>
> retrieveItems = order.forward ? function(key) {
> return database.getSubjects(key.itemID,
> order.property, null, items);
> } : function(key) {
> return database.getObjects(key.itemID, order.property,
> null, items);
> };
> }else if (order.property == "type" && order.forward) {
> var map = {
> "US Legal Databases" : 0,
> "Periodical and Treatise Indexes" : 1,
> "Foreign Law Databases": 2,
> "International Law Databases": 3,
> //... add everything here ...
> };
> values.visit(function(typeID) {
> keys.push({ display: typeID, index: typeID in map ? map
> [typeID] : -1 });
> });
> compareKeys = function(key1, key2) {
> var c = key1.index - key2.index;
> return c != 0 ? c : key1.display.localeCompare
> (key2.display);
> };
> retrieveItems = function(key) {
> return database.getSubjects(key.display, "type", null,
> items);
> };
> }else { //text
> values.visit(function(value) {
> keys.push({ display: value });
> });
>
> compareKeys = function(key1, key2) {
> return key1.display.localeCompare(key2.display);
> };
> retrieveItems = order.forward ? function(key) {
> return database.getSubjects(key.display,
> order.property, null, items);
> } : function(key) {
> return database.getObjects(key.display,
> order.property, null, items);
> };
> }
>
> keys.sort(function(key1, key2) {
> return (order.ascending ? 1 : -1) * compareKeys(key1,
> key2);
> });
>
> for (var k = 0; k < keys.length; k++) {
> var key = keys[k];
> key.items = retrieveItems(key);
> if (!settings.showDuplicates) {
> items.removeSet(key.items);
> }
> }
>
> return keys;
> };
>
> HTML
> <div ex:role="view"
>
> ex:showAll="true"
> ex:orders=".type, .name"
> ex:showToolbox="false"
> class="exhibit-body" >
> </div>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SIMILE Widgets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/simile-widgets?hl=en
-~----------~----~----~----~------~----~------~--~---