November 9th, 2011

Illuminati

Interesting Links for 9-11-2011

Illuminati

Three things make a poll.

The UK should join the Schengen Area

Yes
52(76.5%)
No
16(23.5%)

Pringles

GOOD
48(63.2%)
BAD
28(36.8%)

Sour Cream & Onion Pringles, with in Onion and Garlic dip

GOOD
28(38.4%)
BAD
45(61.6%)

Damn, it's getting really dark in the evenings

GOOD
23(29.5%)
BAD
50(64.1%)
Hah! I'm not in the same hemisphere as you!
5(6.4%)
livejournal blackout

Learning to loathe Javascript

I'm adding the templating function to my link poster, so that different people can have different looking posts.

And I figure that if I'm doing that then I should have a "reset to default" button, to set it back to an unfucked state.

Should be simple enough - all I need is a button that you click, and a function that sets some text in the textarea holding the template. How hard can it be?

The first thing that got me was that my button was called "ResetTemplate" and my function was called "ResetTemplate" and when I called "ResetTemplate()" from the onClick of the button, guess what happened?

Did you guess "Nothing at all"? Because that's exactly what happened. Which left me completely baffled for about 45 minutes until I created a "test" function, which worked, and then slowly tweaked it until it contained exactly the same text as the ResetTemplate function, at which point the only possible explanation was the name of the function. Which wasn't my idea of fun.

And then, having got that far, I reasoned that as I had a document, containing a form, containing a fieldset, containing a textarea, I should have something like:
document.DeliciousPoster.TemplateFields.PostTemplate.value = "Replacement Text";

But no, that doesn't work either. Because, it transpires, the PostTemplate textarea isn't part of the TemplateFields fieldset. It's directly part of the form. Which makes no sense to me at all, but there you go, apparently that's how it works.

So if anyone would like to point me in the direction of a good book, or tutorial, or somesuch, that would help me avoid constantly falling into these pitfalls, then I would appreciate it.

(I'm also constantly frustrated by the lack of autocomplete. Having to actually remember the names of functions/methods/properties feels hopelessly old-fashioned. But I don't think there's much I can do about that...)



Original post on Dreamwidth - there are comment count unavailable comments there.
Made of Love

Link Feed Templates

After much faffing around with Javascript and the like, the templating is now in.

It's not for people that don't understand code at all, but I can't see much of a way to make it simpler.

The current default template looks like this:
<ul class="links">
#foreach($link in $links)
<li class="link"><A href="$link.URL">$link.Title</A>
#if($link.Description)<BR><span class="link-description">$link.Description</span>#end
<BR><span class="link-tags">(tags:#foreach($tag in $link.Tags) <A href="$tag.TagURL">$tag.Tag</A>#end )</span>
</li>
<BR><BR>
#end
</ul>

which basically says:
  • Start a list
  • For each link in the collection of links:
    • Create a new list item and put the link title in it, and make that title a hyperlink to the URL of the link.
    • If the link has a description, then put it in, on a new line.
    • Add a new line, and then put in each tag, turning it into a hyperlink back to the site that the links came from (i.e. delicious or pinboard)
    • end the list item
  • end the list


If you're going to play around with it then use the "Test" input and output settings, so that you're not constantly scraping the source links/posting to your journal. If you completely mess it up then hit the "Reset Templates" button to restore the original template.

Next up - a template for the subject line/title.
Original post on Dreamwidth - there are comment count unavailable comments there.