|
Posted by Steve on 04/18/07 14:13
"Vince Morgan" <vinhar@REMOVEoptusnet.com.au> wrote in message
news:462618c8$0$22073$afc38c87@news.optusnet.com.au...
| An application I'd build would upload the stripped alternate file onto the
| server, but when it was viewed would in fact show the one that has the
| formatting etc transparently.
| Sorry for the verbosity, it's getting late here and my brain is dying ;)
| Vince
no problem. initially i didn't like the description of 'how' you were going
to do it since it isn't os independent.
i'd pull in the source code for a script into a browser (much like doing
..phps). i'd then detect double/right clicks using js. i'd have calculated
line numbers for the source when outputting to the browser. js would get the
line number via the src element - since any attribute you put into an html
tag, you can set the line number, function/variable name, etc. and use that
to post back to php when commenting is saved. anyway, the mouse clicking
would open a floating div with a textarea into which you put your
comment(s). the comments and lines numbers are stored in js. when a 'save'
operation is performed, i'd dynamically create a form thusly:
//javascript
var html = '<form name="comments">';
loop here for all comments
{
html += '<textarea name="line[" + line + "]>' + comment + '</textarea>';
}
html += '<form>';
someDivOrSpan.innerHTML = html;
comments.submit();
//javascript
php would simply store the php script name, line, comment for each of the
comments in the lines array sent in via the browser. now when you retrieve
the file, you are essentially repopulating the js lines information with
comments...js handles mouseover/click events to show/hide comments from that
info. php also creates a tag similar to strtoupper(md5(mt_rand(uniquid(),
true))) and stores it in the db as well...when it creates the html, it
supplies the comments in whatever pleasant fashion you see fit, puts the tag
at the line number, puts toggleDisplay type of show/hide functionality with
the tag. the tag would look like this in the html output:
<div onclick="toggleDisplay(document.getElementById(<?= $tag ?>)">
<img src='question.mark.jpg'>
<div id="<?= $tag ?>" style="display:none;"><span><?= $comment
?></span></div>
</div>
and toggleDisplay?
//javascript
function toggleDisplay(el)
{
el.style.display = el.style.display == 'none' ? '' : 'none';
el.style.postion = 'absolute';
}
//javascript
anyway...that's off the top of my head. it's easy to implement and is os
independent.
cheers.
Navigation:
[Reply to this message]
|