PDA

View Full Version : Onclick: Prompt pulling data within an Array



MIODude
01-30-2010, 03:40 AM
Hi.. I should warn, i know almost nothing about javascript. . i've been trying read sample scripts and examples on how to modify this script; but I just don't know enough.

I have a script that pulls data from an array, and copies it directly to the clipboard when a user clicks on it. The problem is this only works in IE, because Firefox doesn't by default allow that to happen. I'm trying to change it so that when it is clicked, instead, it takes what was going to be copied to the clipboard, and puts it in a Prompt box for the user to copy and paste. I had other scripts that do that, but I can't for the life of me figure out how to learn from it!

This is the function in the current script



<script language="javascript" type="text/javascript">
<!--
function selectThis(src) {
document.selection.clear;
txt = eval(src +".innerText");
theObj = document.all(txt);
txtRange = document.body.createTextRange();
txtRange.moveToElementText(eval(src));
txtRange.select();
txtRange.execCommand("RemoveFormat");
txtRange.execCommand("Copy");
alert(txt + " '.$caption[ 'paste' ].'");
}
-->
</script>
';
}


and this is the onclick code



';

foreach ( $ausgabe as $key => $data) {
if ( $key == '' )
continue;
if ( ( $_GET[ 'group' ] != '*' )
&& ( $this->info[ $key ][ 'xx_data' ] != $_GET[ 'group' ] ) )
continue;

$tpack = $this->info[ $key ][ 'pack' ];
$tname = $this->info[ $key ][ 'xx_desc' ];
$jsid= $nick2.'_'.$tpack;

if ( isset( $this->info[ $key ][ 'xx_lock' ] ) ) {
if ( $this->hide_locked > 0 )
continue;
$tname .= ' (gesperrt)';
}
$tname = htmlspecialchars( $tname);
if ( $javascript > 0 ) {
$tname = '<span class="selectable" onclick="javascript:selectThis(\''.
$jsid.'\');">'.
$tname."</span>\n".
'<span id="'.$jsid.'" class="hidden">'.
'/msg '.$this->nick.' xdcc send '.$tpack."</span>\n";
}
if ( isset( $this->info[ $key ][ 'xx_note' ] ) )
$tname .= '<br>'.$this->info[ $key ][ 'xx_note' ];

$label = "Download mit:\n/msg ".$this->nick.' xdcc send '.$tpack."\n";
if ( isset( $this->info[ $key ][ 'xx_md5' ] ) )
$label .= " \nmd5: ".$this->info[ $key ][ 'xx_md5' ];
if ( isset( $this->info[ $key ][ 'xx_crc' ] ) )
$label .= " \ncrc32: ".$this->info[ $key ][ 'xx_crc' ];

echo '
<tr>
<td class="right">#'.$tpack.'</td>
<td class="right">'.$this->info[ $key ][ 'xx_gets' ].'</td>
<td class="right">'.makesize($this->info[ $key ][ 'size' ]).'</td>
<td class="content" title="'.$label.'">'.$tname.'</td>
</tr>
';


I've spent days at trying to customize it.. but.. i'm not a programmer :(

I was able to get it to open a prompt box, and had it populate with ("copy this code", $variable), but cannot figure out how to have it display the proper values that was clicked on. I have no idea though what is considered efficient either in the code.

I hope this isn't considered asking for TOO much help....

Dormilich
01-30-2010, 10:40 AM
what does the "onclick code" looks like in the browser?

PS. your code won’t run in Firefox and Safari.

MIODude
01-30-2010, 07:46 PM
what does the "onclick code" looks like in the browser?

PS. your code wonít run in Firefox and Safari.

right now, it just says that "/msg botname xdcc send 1 has been copied in your clipboard" if you click on pack 1 (botname replaced with the name of the bot). It automatically copies it to the clipboard. Since it doesn't work in Firefox and Safari (which i know).. i want to change it to take what it was copying to the clipboard so that it opens a window up (small window) so that you can copy it yourself to the clipboard using ctl-c.


the botname is a variable as is the pack #. /msg xdcc send is constant.

Dormilich
01-30-2010, 08:29 PM
?????

MIODude
01-30-2010, 09:37 PM
sorry - maybe I'm not understanding what you are asking?

Dormilich
01-30-2010, 10:51 PM
I didnít understand any of your explanation, since it had nothing to do with either PHP or any code you posted (as far as I can tell).

MIODude
01-31-2010, 12:32 AM
Here is a sample website that is using a similar code (its not mine, as mine isn't on the internet yet.. its local)..

http://nipponsei.bahamutsphere.com/xdcc.php

Click on a pack i the list.. Try it in IE, then try in Firefox.. In IE, it copies directly to the clipboard (after first prompting for 'allow access'). In Firefox - nothing happens. Firefox doesn't allow direct clipboard access.

This is a sample of what I'm trying to get to with my script - if you click on a packlist, you'll see it opens a prompt.

http://xdccparser.is-fabulo.us/demo/single/trogador/

See how when you click on the pack list, it prompts. I'm trying to modify my code, so that it prompts, rather than direct access.

Dormilich
01-31-2010, 12:34 AM
unfortunately (well, not that I would miss IE anyhow), there is no IE for darwin.