You still haven't made it all that clear how/where you (or anyone?) will see the code generated by your paste operation. I am assuming that since there is a copy, there must be a paste before anything can be seen as a result of the copy. Questions:
- Is there a paste?
- If so, who sees the paste - just you, or all/some users as well?
- If there is a paste, where does it go?
If there is a paste, and you want that paste formated in a certain way, it would be at the time of the paste, not at the time of the copy where line breaks could most effectively be inserted. From what you are saying, this would most likely take the form of a regular expression replace on the comma and the end of the string:
Code:
string_value.replace(/,/g, ',\n').replace(/( };)$/, '\n$1')
For example, if you had:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<script type="text/javascript">
var string_value="var cfg = {\
height:'334',\
width:'470',\
file:'\" + s + \"',\
backcolor:'000000',\
frontcolor:'FFFFFF',\
lightcolor:'FF0000',\
screencolor:'330000',\
logo:'http://www.microtronix-tech.com/tbionline/logo.png',\
showstop:'true',\
autostart:'true'\
};"
document.write(string_value.replace(/,/g, ',\n').replace(/( };)$/, '\n$1'));
</script>
</body>
</html>
This would be the generated source code of that page:
Code:
<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body>
<script type="text/javascript">
var string_value="var cfg = {\
height:'334',\
width:'470',\
file:'\" + s + \"',\
backcolor:'000000',\
frontcolor:'FFFFFF',\
lightcolor:'FF0000',\
screencolor:'330000',\
logo:'http://www.microtronix-tech.com/tbionline/logo.png',\
showstop:'true',\
autostart:'true'\
};"
document.write(string_value.replace(/,/g, ',\n').replace(/( };)$/, '\n$1'));
</script>var cfg = { height:'334',
width:'470',
file:'" + s + "',
backcolor:'000000',
frontcolor:'FFFFFF',
lightcolor:'FF0000',
screencolor:'330000',
logo:'http://www.microtronix-tech.com/tbionline/logo.png',
showstop:'true',
autostart:'true'
};
</body></html>
Bookmarks