Where do I put the [img[item(Url)]] in this javascript code?

2 views
Skip to first unread message

Måns

unread,
Mar 7, 2010, 6:08:49 PM3/7/10
to TiddlyWiki
Hi TwWizards

I have this wonderfull script from Eric:
<script>
var out="";
var txt=store.getTiddlerText("CoverList","Get Urls from the
Coverlist");
var items=txt.split("\n----\n");
if (!items[1]) items=txt.split("\n");
for (var i=0; i<items.length; i++) {
if (i>0 && i/5==Math.floor(i/5)) out += "|\n"; // start a new row
out += "|"+items[i];// add item to row
}

out += "|\n"; // end last row
return out;
</script>

I have tried all sorts of combinations to get the image markup to
surround items(Urls) fetched from the CoverList.
I did: out += "|[img["+items[i];// add item to row
and: out += "]]|\n";
But it only worked with one item, as soon as I added items to the
CoverList the table was broken..

regards Måns Mårtensson

Måns

unread,
Mar 7, 2010, 6:29:48 PM3/7/10
to TiddlyWiki
This breaks the table - but shows images for the Urls:
<script>
var out="";
var txt=store.getTiddlerText("CoverList","Get urls from the

Coverlist");
var items=txt.split("\n----\n");
if (!items[1]) items=txt.split("\n");
for (var i=0; i<items.length; i++) {
if (i>0 && i/2==Math.floor(i/2)) out += "]]|[img[\n"; // start a new
row
out += "]]|[img["+items[i];// add item to row
}

out += "]]|[img[\n"; // end last row
return out;
</script>
I'd like the images to link to the images as well:
[img[Url][Url]]
Is this possible?

regards Måns Mårtensson

Mark S.

unread,
Mar 7, 2010, 10:22:20 PM3/7/10
to TiddlyWiki
This seemed to work
Mark
-- - - - - - - - -- - - -

<script>
var out="|";
var txt=store.getTiddlerText("CoverList","Get urls from the
Coverlist");
var items=txt.split("\n----\n");
if (!items[1]) items=txt.split("\n");

var i = 0;
for (i=0; i<items.length; i++) {
if (i>0 && (i%2)==0 ) out += "\n| "; // start a new row
out += " [img["+items[i]+"]["+items[i]+"]] |" ; // add item to row
}
if ((i%2)!=0) out += "|"; // start a new row

return out;
</script>

Måns

unread,
Mar 9, 2010, 2:17:34 AM3/9/10
to TiddlyWiki
Hi Mark
> This seemed to work

Indeed it did :-)

Thanks a lot!!
I've even managed to make it spit out iframes!
See it working here:
http://maans.bplaced.net/TiddlyHome/kartotek/#Covers
and with iframes:
http://maans.bplaced.net/TiddlyHome/kartotek/#Medier

Thanks for helping me out again Mark. I apreciate it very much!

Regards Måns Mårtensson

Måns

unread,
Mar 10, 2010, 2:05:42 AM3/10/10
to TiddlyWiki
Hmm
I've broken the table when I changed my use of the hr-seperated list,
to make it "fit the standards" of Eric's ListBoxPlugin.
http://www.tiddlytools.com/#ListboxPlugin.

Now a listitem consists of a title(to be shown in a select from
dropdown list) (equals)= fieldvalue newline: tooltip......
Ex:
Avatar=http://image.png
this is an image I found at flickr.com

I need the script only to fetch the data on the first line just after
the equalsign....
However this is out of my reach...

I've tried to look at the ListBoxPlugin code to see if there is some
code which might help me - and I believe some of this is what I need
to implement in the script Mark made for me:
{ // param is item value or 'label=value'
var parts=p.split("=");
var label=parts[0]; var v=parts[1]?parts[1]:parts[0];
items.push(label+"="+v);
}

or sth with this line: listtxt=this.getWikifiedData(listtxt);
if (listtxt.length)
var items=listtxt.split(listtxt.indexOf('\n----\n')!=-1?'\n----
\n':'\n');

If there is a simple solution for my problem - please give me a
hint :-)

Regards Måns Mårtensson

Måns

unread,
Mar 10, 2010, 2:35:54 AM3/10/10
to TiddlyWiki
I tried this - but it's not working - maybe you can tweak it to work?
<script>
var out="|";
var txt=store.getTiddlerText("CoverListe","Get links from the

Coverlist");
var items=txt.split("\n----\n");
if (txt.length)
items=items.concat(txt.split(txt.indexOf('\n----\n')!=-1?'\n----
\n':'\n'));

if (!items[1]) items=txt.split("\n");
var i = 0;
for (i=0; i<items.length; i++) {
if (i>0 && (i%5)==0 ) out += "\n| "; // start a new row

out += " [img["+items[i]+"]["+items[i]+"]] |" ; // add item to row
}

if ((i%5)!=0) out += "|"; // start a new row
return out;
</script>

Regards Måns Mårtensson


On 10 Mar., 08:05, Måns <humam...@gmail.com> wrote:
> Hmm
> I've broken the table when I changed my use of the hr-seperated list,

> to make it "fit the standards" of Eric's ListBoxPlugin.http://www.tiddlytools.com/#ListboxPlugin.

Reply all
Reply to author
Forward
0 new messages