Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Math

is it possible to use math do do things like this:

{sum {$.season$}+2}

where the season variable is a number, of course.

(I update the season variable approx every three months, now I have a workaround using many more variables - but this would be useful)

I guess it's not implemented, but maybe it's something for the whishlist for version 3? :)

Fredrik Jacobsson
Saturday, July 19, 2003

You can do that sort of thing by inserting a citydesk variable in a block of Javascript.

For your case

<script>
document.write {$.season$}+2;
</script>

would probably do the trick.

Matthew Lock
Sunday, July 20, 2003

Ahh thanks. I'll give it a try.

(dont know anything about javascript,so I really appreciate it)

Fredrik Jacobsson
Sunday, July 20, 2003

Worked fine. Had to add () to the math.

A Q regarding the above...when I switch to HTML-mode and back this is there:

<script type="text/javascript">
//<![CDATA[
document.write ({$.season$}+7);<SPAN id=fogstart><\/SPAN><SPAN id=fogend><\/SPAN>//]]>
</script>

What good does it do? I understand it's a new beta thingey, but why was that addition needed? To preserve what?

Fredrik Jacobsson
Sunday, July 20, 2003

Short story:

//<![CDATA[
and the
//]]>

are legit, and required to make your website valid XHTML.

The

<SPAN id=fogstart><\/SPAN><SPAN id=fogend><\/SPAN>

is a CityDesk beta bug and you should be delete it.

Long story:

Scripts can include characters like < and > and & which would confuse an XML parser. XHTML is required to be XML. If you want to get < and > and & through your XML parsers, you have to surround it by <![CDATA[ and ]]>. However this is not valid JavaScript and would confuse the JavaScript compiler, therefore we make them JavaScript comments using // resulting in all scripts being surrounded by //<![CDATA[  and //]]>.

Part two, the span stuff. CityDesk attempts to maintain your cursor position as you switch between HTML View and Normal View. It does this by inserting these spans on one side at the current cursor position, then searching for them and removing them on the other side and moving the cursor to where the spans were. What you're seeing here seems to be that you had your cursor inside some JavaScript when you switched to Normal View.

Joel Spolsky
Sunday, July 20, 2003

Thanks Joel.

Fredrik Jacobsson
Monday, July 21, 2003

*  Recent Topics

*  Fog Creek Home