Rowstyler Script

53 views
Skip to first unread message

Roger Cutler

unread,
Sep 7, 2024, 6:23:50 PM9/7/24
to SIMILE Widgets
I had to move from api.simile-widgets.org/exhibit/3.0.0rc1/exhibit-api.js to https://api.simile-widgets.org/exhibit/STABLE/exhibit-api.js because Simile/Babel has disappeared and I don't know how else to turn my Excel spreadsheet into Jason -- and the former version does not appear to accept txt/tsv that I can get from Excel.  So now I'm using STABLE so I can use txt files, and the following code, which worked in the earlier version, does not work any more.  Can someone tell me how to update this to work in the STABLE version?  Frankly I don't know how I got this to work in the first place, and I don't really understand it now at all -- and I can't find whatever docs I had to figure this code out in the first place.  So I'm afraid I'm pretty ignorant. 

<script type="text/javascript">
    var rowStyler = function (item, database, tr) {
        var TimesPerf = database.getObject(item, "TimesPerf");
        var BackColor = "white";
        var ForeColor = "black";
        switch (TimesPerf) {
            case 0: BackColor = "#CCCCCC"; ForeColor = "white"; break;
        }
        tr.style.background = BackColor;
        tr.style.color = ForeColor;
    };
    </script>

Also, is there any way I can honor special characters like in "Dvořák" and "Fauré"? This worked in Babel/Jason but not in DOS txt from Excel.  I can output unicode txt from Excel, but Exhibit STABLE doesn't seem to handle that very well.

David Karger

unread,
Sep 8, 2024, 12:00:08 AM9/8/24
to simile-...@googlegroups.com

Hi Roget.   Per the previous post on this mailing list, Babel had to be shut down due to a server migration   I had no idea that anyone was still using it for anything.  tsv should work fine with the newer exhibit; i'll try to look into what's wrong.   Do you need to generate your json data on the fly or do you just make a new static json file every few months?  There are plenty of online tools supporting the latter kind of manual conversion, such as https://codebeautify.org/excel-to-json

--
You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simile-widget...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simile-widgets/b0320c5f-bfe2-4eed-9a34-e82f0cb14b00n%40googlegroups.com.

Roger Cutler

unread,
Sep 8, 2024, 6:01:23 PM9/8/24
to SIMILE Widgets
Thank you for the excel-to-json application link. It did convert my Excel spreadsheet to something that looks somewhat like the Jason Babel used to give me,  Unfortunately, however, Exhibit will not display this data.

If I knew how to replace the following script in STABLE it would help a lot.

<script type="text/javascript">
    var rowStyler = function (item, database, tr) {
        var TimesPerf = database.getObject(item, "TimesPerf");
        var BackColor = "white";
        var ForeColor = "black";
        switch (TimesPerf) {
            case 0: BackColor = "#CCCCCC"; ForeColor = "white"; break;
        }
        tr.style.background = BackColor;
        tr.style.color = ForeColor;
    };
    </script>


Luis Miguel Morillas

unread,
Sep 9, 2024, 2:04:21 AM9/9/24
to simile-...@googlegroups.com
What's the error the console raises? Have you got your example online?

Here you have an example with rowStyle function:
https://simile-widgets.org/exhibit3/examples/senate/senate.html &
https://github.com/simile-widgets/exhibit/blob/6bf824e8b99136d5f46f97c3f55bc71a0e176596/scripted/demos/senate/html5.html#L16

Best,

-- luismiguel (@lmorillas)
> To view this discussion on the web visit https://groups.google.com/d/msgid/simile-widgets/36fef05a-0b24-429a-9652-f6f428a1412en%40googlegroups.com.

David Karger

unread,
Sep 9, 2024, 8:25:32 AM9/9/24
to simile-...@googlegroups.com

Roger, I'll try to look at the script issue but in the meantime you probably just need to make a small change to what is coming out of the json converter.   I downloaded the example xls and loaded it into the converter, and it produced json that starts like this:

{
  "Spies": [
    {

probably because the filename was Spies.xls .   Change the word "Spies" to "items" and see what happens.

Roger Cutler

unread,
Sep 9, 2024, 1:30:10 PM9/9/24
to SIMILE Widgets
I tried changing it to "Items" -- Exhibit still choked.

Luis Miguel Morillas

unread,
Sep 9, 2024, 1:33:14 PM9/9/24
to simile-...@googlegroups.com

Could you show the sources of your code?

Luismi


Roger Cutler

unread,
Sep 9, 2024, 1:46:49 PM9/9/24
to SIMILE Widgets
An operating version using a txt file is at http://rtcutler.com/HSCArchive/HSCHistoryRTC.htm. You can pick up the various files from that Web site.


On Monday, September 9, 2024 at 7:25:32 AM UTC-5 kar...@csail.mit.edu wrote:

Luis Miguel Morillas

unread,
Sep 10, 2024, 4:14:06 AM9/10/24
to simile-...@googlegroups.com
I I worked a bit on your example [1]. I hope it helps. I converted the
Excel spreadsheet to CSV (I use LibreOffice) in Unicode, I made syntax
changes to exhibit 3, and a correction in the JavaScript function.

[1] https://lmorillas.github.io/exhibit_tests/hschistory

Saludos,

-- luismiguel (@lmorillas)

El lun, 9 sept 2024 a las 19:46, Roger Cutler
(<roger...@gmail.com>) escribió:
>
> To view this discussion on the web visit https://groups.google.com/d/msgid/simile-widgets/f237f10e-2f37-4aec-be34-31dadd2dac7dn%40googlegroups.com.

Roger Cutler

unread,
Sep 10, 2024, 1:58:14 PM9/10/24
to SIMILE Widgets
Hey, you're really good.  Thank you very much. It appears that Excel does not have a Unicode CSV option, but it does have UTF-8 and that was good enough to render "Dvořák", "Fauré", and "Bekümmernis" correctly, which is what I care about. Again, thanks for taking the time to help me.
Reply all
Reply to author
Forward
0 new messages