View Full Version : Developing the CFC map (HTML, JavaScript, PERL)


stormbind
Jun 11, 2004, 07:09 AM
Where are you all? Over 100 people signed the map... and now it's dead quiet.

Edit: Original post was deleted

So, you want to join huh? :thumbsup:

Don't be put off by scarey looking PERL code or whatever may be foreign to you.

The (prospective) developer must already have registered and confirmed their user account. I cannot create a user account on the SourceForge.net site. I can only add an existing user account to this project.

Step 1: Grap yourself a free account from http://sourceforge.net/ and then let me know who you are. There's something for everyone: from planners, to artists, to coders... :cool:

By allowing a developer to join your team, you are giving them security clearance to access the resources offered by SourceForge.net to your project team ... By adding a developer to your team, you are stating that you trust them to act on your behalf in the development of your project.

Step 2: Realise that the project is to be distributed under the GNU Public License, and expressly state your intentions so that you can be given the optimal permissions.

stormbind
Jun 11, 2004, 01:15 PM
Oki, peeps, sourceforge has donated an account! :D

http://sourceforge.net/projects/guestaphics/ (project portal)
http://guestaphics.sourceforge.net (home page)

I need some help. Here's some things...

1. It still doesn't have national flags :cry:
2. A project icon would be cool (must scale to 16x16 pixels)
3. Project design... ideal for someone with lots of ideas! :D
4. If you can program in any language then please join!!
5. Anything I missed?

Plexus
Jun 11, 2004, 01:29 PM
I can program rudimentary HTML and I'm pretty handy with the Photoshop and Illustrator. Consider me joined.

LordKestrel
Jun 11, 2004, 01:39 PM
What are you trying to accomplish here? A piece of software that can generate a map based upon coordinates you enter? I'm sure that there is software out there that will do that already.

stormbind
Jun 11, 2004, 01:43 PM
Cool :thumbsup:

Are you a member of sourceforce.net? (it's free)

I'll try to get a working version on the free webspace they have given us, so you can see what's missing.. this might take me a while :rolleyes:

stormbind
Jun 11, 2004, 01:48 PM
No, it's a map that CFC members can stick labeled pins in to show where they are...

There was already an attempt but the providers kept deleting pins (see OT for a thread on this).

By making our own, we won't have that problem :)

I have done a rudimentary version in JavaScript/PERL.

LordKestrel
Jun 11, 2004, 02:22 PM
I saw the thread in OT earlier, but I didn't know if you were just trying to make a map here, or write an entire application to make the map.

How fancy of a UI do you want? You can make it really simple by just using an image map and then have a backend piece update the image based on the coordinates you click on. Fairly simple, and allows easy abuse. However, it would work for a first rough draft.

stormbind
Jun 11, 2004, 03:09 PM
Well this is what I have at the moment...

You click on the map (script gets the coords), you fill in your details/post and send it to a CGI script.

CGI script opens a HTML flatfile and adds a new table with your details. It then sends you back to the map.

The map downloads the HTML flatfile (all tables), extracts the coords/names/posts and displays them as pins.

I'm a bit tired so making a few mistakes. I'm trying to get it stable enough to upload a demo, so you can try it out, and see what needs improving.

There's some BBS tricks that may come in handy for security.

---

For members who don't like programming, there's a lot of other stuff like images/html/text/documentation... :p

Btw, it's GNU public license. I had to pick one when setting up the sourceforge account and it seemed like a safe option - there were too many licenses to consider :blush:

Black Fluffy Lion
Jun 11, 2004, 03:20 PM
Why are you using perl for this? wouldn't something like PHP + database (or flat file) be more suitable?

stormbind
Jun 11, 2004, 03:27 PM
Maybe I have used PERL before :p

If you want to write a PHP+mySQL alternative for the backend then that's cool. Not everyone has mySQL though so best to keep it as an alternative and not a requirement.

LordKestrel
Jun 11, 2004, 03:48 PM
Well this is what I have at the moment...

You click on the map (script gets the coords), you fill in your details/post and send it to a CGI script.

CGI script opens a HTML flatfile and adds a new table with your details. It then sends you back to the map.

The map downloads the HTML flatfile (all tables), extracts the coords/names/posts and displays them as pins.

I'm a bit tired so making a few mistakes. I'm trying to get it stable enough to upload a demo, so you can try it out, and see what needs improving.

There's some BBS tricks that may come in handy for security.

---

For members who don't like programming, there's a lot of other stuff like images/html/text/documentation... :p

Btw, it's GNU public license. I had to pick one when setting up the sourceforge account and it seemed like a safe option - there were too many licenses to consider :blush:


Sounds like you're well on your way.

As for licensing, the GPL is always a decent choice. Another one that I like, is the BSD license. Allows effectively the same "do anything with it" that the GPL gives, with the added feature that someone can use it (or part of it) in a commercial app without providing the source. Makes it a little less restrictive, but if you don't like the idea of someone profiting off of what you're working on, then the GPL works. (You can use GPL in a commercial product, but you're obligated to provide the source for it, which is why it's usually not used for that).

I'm sure the difference between the license types is more than what I said, but that's the main point that I remember.

And if you want a little help, I might have some time to do some backend database work for you. I was an Oracle DBA for years, although it has been several since I played with it.

Black Fluffy Lion
Jun 11, 2004, 03:49 PM
Maybe I have used PERL before :p

If you want to write a PHP+mySQL alternative for the backend then that's cool. Not everyone has mySQL though so best to keep it as an alternative and not a requirement.

OK, fair enough :) I may do so if I have the time in future

stormbind
Jun 11, 2004, 04:51 PM
Sounds like you're well on your way.

Hard to tell. There's always something to be added, plus it's not had any input from others yet which may completely change the strategy.

And if you want a little help, I might have some time to do some backend database work for you. I was an Oracle DBA for years, although it has been several since I played with it.

Oh yeah, that would cool! Databases are my weakest point by far. I really don't have clue :blush:

I normally do client-side scripts which work best with HTML or XML data. This means my databases are generally in those formats, but this is not ideal for server-side sorting. I know most PHP/PERL developers raise an eyebrow when they see my flatfiles :lol:

Take a look at my pathetic CGI script and see, it's actually storing the data as HTML (native to JavaScript/DOM, and PERL can use it's XML module)

Judging my BFL's response (and personal experience) there will be at least two competiting backend solutions :blush:

#!/usr/bin/perl

$home = "http://guestaphics.sourceforge.net/demo/read.html";
$profile = "http://forums.civfanatics.com/member.php?u=";

# ^^
# You may need to edit the above lines
# Copyright 2004, stormbind777@sourceforge.net
################################################## ####################

&error('Essential data was not recieved') unless $ENV{'CONTENT_LENGTH'};
$output = "$ENV{'DOCUMENT_ROOT'}/book.lib";

# Input

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/<([^>]|\n)*>//g;
$INPUT{$name} = $value;
}

# Check

&error('There were no coordinates') unless $INPUT{'x'} && $INPUT{'y'};
&error('Too many fields were left blank') unless $INPUT{'name'} && $INPUT{'message'};

# Output

open (FILE,"$output") || die "Can't open $output: $!\n";
@lines = <FILE>;
close(FILE);

open (POST,">$output") || die "Can't open $output: $!\n";

foreach $line (@lines) {
if ($line =~ /<!--store-->/) {
print POST ( "<!--store-->\n"
. "<table><tr>"
. "<td id=\"coord\">$INPUT{'x'}\;$INPUT{'y'}</td>"
. "<td id=\"flag\"><img src=\"flags/$INPUT{'flag'}.png\"></td>"
. "<td id=\"name\"><a href=\"$profile$INPUT{'uid'}\">$INPUT{'name'}</a></td>"
. "<td id=\"message\">$INPUT{'message'}</td>"
. "</tr></table>\n");
}
} else { print POST ("$line");}
}

close (POST);

# Success

print ("Content-Type: text/html\n\n"
. "<html><head><title>Success</title></head>\n"
. "<body><h1>Thank you for pinning</h1>\n"
. "Your are now represented in our community map.\n"
. "<a href=\"$home\">Continue..</a>\n");

exit;

# Errors

sub error($){
$error = shift;

print ("Content-Type: text/html\n\n"
. "<html><head><title>Error</title></head>\n"
. "<body><h1>An error occurred</h1>\n"
. "$error, and your submission has been discarded.\n"
. "<a href=\"$home\">Continue..</a>\n");

exit;
}

stormbind
Jun 12, 2004, 06:24 AM
There is a XML::Parser (http://search.cpan.org/~msergeant/XML-Parser-2.34/Parser.pm) module in PERL, and that would probably handle any server-side sorting of HTML elements - if needed. I don't see a need for it atm though.

stormbind
Jun 12, 2004, 01:05 PM
I can't upload anything. I have been trying all day :cry:

They use SSH instead of FTP, so that basically means using FileZilla. It seems like good software but I don't know what I'm doing... every login attempt results in a timeout, even though I can login to the shell account :(

KaeptnOvi
Jun 12, 2004, 04:15 PM
you might want to use WinSCP (http://winscp.sourceforge.net/eng/) it's great if you have to transfer files through SSH

stormbind
Jun 13, 2004, 03:43 AM
Woot! That worked :)

Feels just like Windows now :p

Plexus
Jun 13, 2004, 04:03 AM
How bouts an icon?

http://www.civfanatics.net/uploads7/comdem64.pnghttp://www.civfanatics.net/uploads7/comdem.png http://www.civfanatics.net/uploads7/comdem16.png

DOWNLOAD ZEM NOW!! (http://www.civfanatics.net/uploads7/comdemicon1.zip)

BTW: My Sourceforge username is Plexust or Plexus (login/public).

damunzy
Jun 13, 2004, 08:48 AM
Sounds like you're well on your way.

As for licensing, the GPL is always a decent choice. Another one that I like, is the BSD license. Allows effectively the same "do anything with it" that the GPL gives, with the added feature that someone can use it (or part of it) in a commercial app without providing the source. Makes it a little less restrictive, but if you don't like the idea of someone profiting off of what you're working on, then the GPL works. (You can use GPL in a commercial product, but you're obligated to provide the source for it, which is why it's usually not used for that).
I'm sure the difference between the license types is more than what I said, but that's the main point that I remember.The whole point of Open Source Software (OSS), at least from the creators' point of view, is that people be able to see the code that they are using so that they can modify it if need be. With the BSD licensing you can take that open code, modify it, and close it back up again. Meaning that the people that use the modified code are stuck with you for tech support if something goes wrong (since you, nor anyone lese, can see the source code to fix the problem). Something to think about. Someone could take your hard work, with BSD licensing, change it a bit, and then close it up - not very friendly. :)


I wish I could help but I have no real value to add to the project. But good luck!

stormbind
Jun 13, 2004, 09:03 AM
That's really nice Plexus! :)

Can the pin head be moved or enlarged to make use of the space in the top-right corner? I uploaded your 16x16 version (as favicon.ico, favicon.png and favicon.gif) but FireFox ignored it; did I do something wrong? :undecide:

Black Fluffy Lion
Jun 13, 2004, 09:13 AM
You need to add a link tag to <head>:

<link rel="shortcut icon" href="favicon.ico" />

stormbind
Jun 13, 2004, 10:22 AM
Oop..! I blaim the hot weather :mischief:

Seperate issue: For ages the CGI script kept spitting out "missing data" and it took me several hours to realise I had forgotten to add method="POST" to the form :lol:

:wallbash:

Pre-release demo now uploaded, but don't expect anything special. It's rather weak, messy, buggy (i.e. resize the map in mozilla) ... but it works and is easy to insult, which is where the project hopefully begins :D

Contributions now welcome! :thumbsup:

There are lots of image/html/css imperfections *hint* ;)

Plexus
Jun 13, 2004, 12:31 PM
I'm getting a runtime error here in Firefox and IE:

Line: 69
Error: 'parent.dat.document.forms.0x' is null or not an object.

stormbind
Jun 13, 2004, 04:07 PM
That's non-critical. Hit the post button top-left and parent.dat.document.forms.0x will then exist.

Fixed it anyway :thumbsup:

Plexus
Jun 13, 2004, 06:15 PM
I changed the map a bit, added Socotra and changed some colors.

http://www.civfanatics.net/uploads7/comdemworld.png

Gogf
Jun 13, 2004, 06:55 PM
Sorry to sound to newbyish, but what exaactly is this?

stormbind
Jun 14, 2004, 04:29 AM
It's a guestbook, but you post stickies to the world map.

Nice map Plexus, but I like uniformity. Does the map come with a theme? :D :mischief:

stormbind
Jun 14, 2004, 10:18 AM
Updated. It's now pretty much how I wanted the tech-demonstration to be.

Who remembers their project development module? There's supposed to be lots of planning, questions and ideas.

How far is this going to go? Which technologies are to be used etc..

The argument against using client-side JS is that you cannot know which browsers are being used, or which features disabled... but I don't see a way of getting the coordinates without JS. Am I right or have I overlooked something?

Should people be able to move their pins or edit the entry? Does it need need to come with hacks that plug it into various BBS? Should it have it's own BBS? How much support should their be for old browsers... really, anything & everything that pops into your head! What are your thoughts? :cool:

stormbind
Jun 14, 2004, 10:46 AM
Oh, and we need a new pin because I borrowed the current one :lol:

LordKestrel
Jun 14, 2004, 02:15 PM
Doing it without javascript is preferable. Some people (like me ;)) keep it disabled, because of the inherent security risk present with javascript implementations.

The only way I can think of doing it without javascript, would be a map comprised of 1x1 pixels, with each pixel having an href pointing to a form that you fill in. A serious pain in the butt though, so using javascript would be far easier.

stormbind
Jun 14, 2004, 03:43 PM
Would form fields for lattitude & longtitude work? How many people actually know their position? I certainly don't... I'm not even sure how it would be worked out :undecide:

It makes a big difference because if JS is used for the (essential) map, it might as well be used everywhere. But if there is an escape from JS for the map, then all the functions/subroutines get moved server side for maximum compatibility.

I don't mind, because (1) I am very experienced with JS programs - think HTA etc., and (2) I enjoy excuses to practice PERL - I haven't very much experience :(

Re: 1x1 pixel idea. We can generate lots of styled A tags (with a loop in PERL) and overlay them on an image of the world. How might that work with zooming? It would be a big download even to cover a small map.

stormbind
Jun 14, 2004, 04:45 PM
This is the closest I could come to 1x1 pixel A tags. It's interlaced in MSIE, and OK in Mozilla.

<style>
A {
width:1px;
height:1px;
background-color:red;
font-size:0px;
padding:0px;
margin:0px;
border:none;

}

IMG {height:1px;width:1px;border:none;}

BODY {font-size:0px;}
</style>

<body>
<script>
for (var i=0;i<999;i++) document.write('<a href="?"><img></a>');
</script>


</body>

stormbind
Jun 14, 2004, 05:34 PM
Map with Latitude and Longitude

http://www.nationalgeographic.com/xpeditions/atlas/world/world-dwl.gif

http://cse.ssl.berkeley.edu/segwayEd/lessons/search_ice_snow/worldmapL.gif

---

Who is BFL? :p

crystal
Jun 14, 2004, 06:06 PM
I can code HTML/Javascript/Perl/whatever. ;) Is my help needed in this project? Also I'm not sure if I understood how you plan to implement this population map... how you identify the users, for example, and will this service be hosted on a good enough server with Perl support? :p

stormbind
Jun 15, 2004, 05:11 AM
I can code HTML/Javascript/Perl/whatever.
Yay! :thumbsup:

will this service be hosted on a good enough server with Perl support?
I was planning to let BBS admins download it and install it on their own servers.

But, for ourselves, we have a sourceforge.net account with shell access and PERL/PHP/SSI/mySQL/Python etc.. and I have uploaded a working prototype (mostly JavaScript).

how you identify the users
If it's a stand alone product then we don't need to: just like a guestbook, but if it's intergrated with any community then we can take their BBS userID and use that.

With a tiny modification to almost any BBS (i.e. vBulletin), the map can recieve the userID either in the QUERY_STRING or POST_DATA. If vBulletin generated the link <a href="/map/showmap?user=43786">Sign Population Map</a> then we have the userID and can link back to their profile. Ok, it's not secure but it's a start :p

Even if modifications to the backend are not possible (i.e. EZBoard), the same can be done with JavaScript.
var userID = document.getElementById('link_to_profile').innerHT ML.split('?')[1];
document.write('<a href="/map/showmap?user='+userID+'">');

There are probably better ways. What are your thoughts?

crystal
Jun 15, 2004, 07:06 AM
At least I don't want any Javascript crap to be integrated on that site. ;)

Since I don't know too well how vBulletin works, I'll assume here that the population map will be a stand-alone program. One thing is for sure: we have to generate the map image dynamically (in other words: the pins have to be integrated on the image.) At least in my browser the prototype image doesn't display correctly.

There should be separate pages for viewing the map and registering to it. On the registration page user should be able to click on his location on the map and after that enter his name, user id, additional comments etc. Then in the main page should be a list of registered users along with some additional info (their country etc.) On the other hand, I have no idea how to program the server-side script to recognize which country you clicked on the registration page. :confused: (Actually, knowing how programs like Paint Shop Pro work would help in this project.)

stormbind
Jun 15, 2004, 07:23 AM
At least I don't want any Javascript crap to be integrated on that site. ;)

I understand that, but there are a number of JS functions that have to be solved without JS before it can be discounted.

1. How to get new coordinates without JS?
2. How to display name & comment over the pin without JS?
3. How to generate the image without DOM?

At least in my browser the prototype image doesn't display correctly.
Without seeing it, you don't know what it's trying to show :(

There are buttons (top-left) for navigating the prototype.

Which browser is that? I used DOM (standards compliant) and tested in Mozilla/MSIE (with JS enabled).

On the registration page user should be able to click on his location on the map and after that enter his name, user id, additional comments etc.Can that be solved without JS?

I looked at millions of <a href=""> tags, but the filesize would be huge and it doesn't work in IE. For some reason it interlaces each line

Actually, knowing how programs like Paint Shop Pro work would help in this project.
PaintShop Pro runs client side, like JavaScript ;)

PERL is completely server-side; it will never interact with elements in the browser.

stormbind
Jun 15, 2004, 07:43 AM
This is the prototype in MSIE.

1. Buttons at the top
2. Map in the middle
3. Guestbook at the bottom

How it works...

1. Downloads guestbook
2. Extracts values (name, comment, coordinates)
3. Floats pins (position:absolute;top:__px;left:__px;) over the map
4. Onmouseover event makes a comment_box appear with the message as shown

How PERL might do it...

1. Extract values (name:comment, coordinates)
2. Generate HTML for floating pins (position:absolute;top:__px;left:__px;)
3. Use title="" to display name: comment

Plexus
Jun 15, 2004, 07:51 AM
New Thumbtackhttp://www.civfanatics.net/uploads7/comdemthumbtack.png

Edit:
And menu background- http://www.civfanatics.net/uploads7/comdemmenubg.png

stormbind
Jun 15, 2004, 07:53 AM
Crystal, can you explain something to me about PERL. On page 1 I posted a simple PERL script for recording data.

I have changed it (untested) and have some questions...

1. Is it OK to merge the @lines = <FILE>; because in the page 1 post it's seperate.
2. Is flock needed?
3. Is a test to see if flock worked also needed?

Here is my latest file...


#!/usr/bin/perl

$profile = "http://forums.civfanatics.com/member.php?u=";
$output = "/home/groups/g/gu/guestaphics/htdocs/demo/read.html";
$home = "http://guestaphics.sourceforge.net/demo/read.html";

# ^^
# You may need to edit the above lines
################################################## ####################

&error('Essential data was not received') unless $ENV{'CONTENT_LENGTH'};

# Input

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/<([^>]|\n)*>//g;
$INPUT{$name} = $value;
}

# Check

&error('There were no coordinates') unless $INPUT{'x'} && $INPUT{'y'};
&error('Too many fields were left blank') unless $INPUT{'name'} && $INPUT{'message'};

# Output

open (DB,">$output") || &error('The server couldn\'t open a database');
flock (DB, 2);
@lines = <DB>;
foreach $line (@lines) {
if ($line =~ /<!--store-->/) {
print DB ( "<!--store-->\n"
. "<table><tr>"
. "<td id=\"coord\">$INPUT{'x'}\;$INPUT{'y'}</td>"
. "<td id=\"flag\"><img src=\"flags/$INPUT{'flag'}.png\"></td>"
. "<td id=\"name\"><a href=\"$profile$INPUT{'uid'}\">$INPUT{'name'}</a></td>"
. "<td id=\"message\">$INPUT{'message'}</td>"
. "</tr></table>\n");
} else { print DB ("$line");}
}
flock (DB, 8);
close (DB);

# Success

print ("Content-Type: text/html\n\n"
. "<html><head><title>Success</title></head>\n"
. "<body><h1>Thank you for pinning</h1>\n"
. "Your are now represented in our community map.\n"
. "<a href=\"$home\">Continue..</a></body></html>\n");

exit;

# Errors

sub error($){
$error = shift;

print ("Content-Type: text/html\n\n"
. "<html><head><title>Error</title></head>\n"
. "<body><h1>An error occurred</h1>\n"
. "$error, and your submission has been discarded.\n"
. "<a href=\"$home\">Continue..</a></body></html>\n");

exit;
}

stormbind
Jun 15, 2004, 08:00 AM
New Thumbtackhttp://www.civfanatics.net/uploads7/comdemthumbtack.png

Edit:
And menu background- http://www.civfanatics.net/uploads7/comdemmenubg.png
Looks good but I can't use it. IE won't display png transparency (without being told which colour is supposed to be transparent), and my editor made a mess of opening it so I couldn't convert the file to gif or find out what the transparent colour is :undecide:

Plexus
Jun 15, 2004, 08:06 AM
It's not alpha-blended. It shouldn't be a problem, stormbind.

stormbind
Jun 15, 2004, 09:37 AM
Oh, ok :p

This message is too short...

crystal
Jun 15, 2004, 11:50 AM
I understand that, but there are a number of JS functions that have to be solved without JS before it can be discounted.

1. How to get new coordinates without JS?
2. How to display name & comment over the pin without JS?
3. How to generate the image without DOM?

1. Should be possible with server-side image maps.
2. Maybe it should be implemented like an "optional" feature on the site (so that map works without JS too)?
3. Umm, learn how to write gif images? :p

http://www.hk8.org/old_web/linux/cgi/ch13_01.htm
http://search.cpan.org/~addi/Imager-0.41/Imager.pm


Without seeing it, you don't know what it's trying to show :(

There are buttons (top-left) for navigating the prototype.

Which browser is that? I used DOM (standards compliant) and tested in Mozilla/MSIE (with JS enabled).

Can that be solved without JS?

I use Opera (and ad filtering software too, sometimes it messes up pages :blush: )

Also I know very little about DOM, don't ask me. ;)

I looked at millions of <a href=""> tags, but the filesize would be huge and it doesn't work in IE. For some reason it interlaces each line


PaintShop Pro runs client side, like JavaScript ;)

PERL is completely server-side; it will never interact with elements in the browser.
:rolleyes: :rolleyes: :rolleyes:

I know that. I was just wondering how to generate images on the fly.

crystal
Jun 15, 2004, 12:06 PM
Crystal, can you explain something to me about PERL. On page 1 I posted a simple PERL script for recording data.

I have changed it (untested) and have some questions...

1. Is it OK to merge the @lines = <FILE>; because in the page 1 post it's seperate.
2. Is flock needed?
3. Is a test to see if flock worked also needed?

Here is my latest file...
1. Umm... what is this FILE again?
2. I never use flock in my programs... and is the file opened only for reading? If yes, I think flock is a little useless. :p

stormbind
Jun 15, 2004, 12:49 PM
No, the file is opened for writing. PERL isn't being used for reading: There is nothing for it to read (in the prototype)!

I read that flock should be used incase there are two attempts to edit the file at the same time.

stormbind
Jun 15, 2004, 12:58 PM
1. Should be possible with server-side image maps.
It's a lot of data. There are millions of points on the map.
3. Umm, learn how to write gif images? :p
Few hosts have that feature :(

I use Opera
Error messages? I used DOM which Opera should fully support.

I know that. I was just wondering how to generate images on the fly.
I was talking about getting the coords. If JS is used for one critical task, there is really no point in trying to avoid it's use elsewhere.

How are you going to get the coordinates without JS? I still think manually entering the lattitude/longtitude is the only way.

crystal
Jun 15, 2004, 01:28 PM
Error messages? I used DOM which Opera should fully support.
There was no error messages. The pins were just in wrong places.

I was talking about getting the coords. If JS is used for one critical task, there is really no point in trying to avoid it's use elsewhere.

How are you going to get the coordinates without JS? I still think manually entering the lattitude/longtitude is the only way.
Well, don't think so.
http://www.htmlhelp.com/reference/html40/forms/input.html


The image input type specifies a graphical submit button. The SRC attribute must be included to specify the URI of the image. The ALT attribute should be used to give replacement text for those not loading images. ALT is a new addition in HTML 4.0; many browsers rely on either the NAME or VALUE attribute as alternate text, so authors should use all three attributes for the same purpose where possible. The topic of graphical submit buttons for text users is discussed in detail in the article INPUT TYPE=IMAGE for text users?.

When the graphical submit button is clicked, the coordinates of the click are sent with the form submission as name.x=x-value and name.y=y-value where name is the value of the NAME attribute, x-value is the click's pixels from the left of the image, and y-value is the click's pixels from the top of the image. The USEMAP attribute combined with TYPE=image defines a client-side image map that can be used with client-side scripting, but this method is poorly supported. The USEMAP attribute gives the URI of the defining MAP.
After that just process the input with Perl in some way, or something...

stormbind
Jun 15, 2004, 01:37 PM
Crystal, I don't see how that is related.

I think you need to see the prototype before we will be talking about the same thing.

crystal
Jun 15, 2004, 01:46 PM
Crystal, I don't see how that is related.

I think you need to see the prototype before we will be talking about the same thing.
Hmm, I thought you meant how the posting of new coordinates should be implemented.

Anyway, I looked at the prototype and I think the small windows popping up when you move your mouse over a pin are a non-critical feature and it doesn't matter too much if they are on the page or not...

stormbind
Jun 15, 2004, 01:53 PM
When you post [which I just broke - oops :blush:], how will the <form></form> get the coordinates from the map?

At the moment, it's using JavaScript's event.clientX and event.clientY to get an exact position of the click.

Image maps are normally used over large areas (i.e. countries) so you know in which region someone clicked - but how will it know the difference in New York and LA? :confused:

crystal
Jun 15, 2004, 03:19 PM
When you post [which I just broke - oops :blush:], how will the <form></form> get the coordinates from the map?
Wasn't it explained in the page I posted? ;)

Here (http://ist.uwaterloo.ca/cs/Perl.htm) is also a tutorial on how to process forms in servers.

At the moment, it's using JavaScript's event.clientX and event.clientY to get an exact position of the click.

Image maps are normally used over large areas (i.e. countries) so you know in which region someone clicked - but how will it know the difference in New York and LA? :confused:
Well, that's quite difficult to implement. Most likely you would need a long list of major cities and their coordinates on the map image.

stormbind
Jun 15, 2004, 03:33 PM
Wasn't it explained in the page I posted? ;)

Here (http://ist.uwaterloo.ca/cs/Perl.htm) is also a tutorial on how to process forms in servers.

I know how to use forms! :dubious:

I think we have had more than one breakdown in communications ;)

Well, that's quite difficult to implement. Most likely you would need a long list of major cities and their coordinates on the map image.
A long list of cities for every nation in the world, and what about the villages? I think this solution is going nowhere fast.

How about, after entering the coordinated manually, there is a "test" button that submits them to the server and it adds the test pin to the map... before you submit the comment, so you can tweak the position.. ?

crystal
Jun 16, 2004, 05:40 AM
Blah, I'll just shut up if my advices are so useless. :p

stormbind
Jun 16, 2004, 06:52 AM
Blah, I'll just shut up if my advices are so useless. :p
No, not useless. We have different opinions, but all exploration is good.

---

There's something that bugs me about parsing every line in a file..

@lines = <DB>;
foreach $line (@lines) { if ($line =~ /<!--store-->/) { ... } }

Does it have to parse every line? It strikes me as being very wasteful of processor time.

What happens to the later lines if the loop is broken when the match is found?

crystal
Jun 16, 2004, 09:48 AM
No, not useless. We have different opinions, but all exploration is good.
Just ask basic Perl questions and we should have no communication problems. ;)

There's something that bugs me about parsing every line in a file..

@lines = <DB>;
foreach $line (@lines) { if ($line =~ /<!--store-->/) { ... } }

Does it have to parse every line? It strikes me as being very wasteful of processor time.
If don't know the exact array indexes, you most likely have to iterate through the whole array. But Perl should be fast in this kind of work.

What happens to the later lines if the loop is broken when the match is found?
How you mean it's broken? foreach iterates through every index unless you end the loop with "last;". Btw, you can replace "foreach" with "for" here, they should do the same thing.