//url-escaped, ready for use:
javascript:function%20userSel()%7Bif%20(window.getSelection)%7Btxt%20=%20window.getSelection();%7Delse%20if%20(document.getSelection)%20%20%20%20%7Btxt%20=%20document.getSelection();%7Delse%20if%20(document.selection)%7Btxt%20=%20document.selection.createRange().text;%7Delse%20return;%20%20return%20txt;%7Dfunction%20add(h)%7Bb.appendChild(h);%7Dfunction%20makeTag(t)%7Breturn%20document.createElement(t);%7Dfunction%20makeText(tag,text)%7Bt=makeTag(tag);%20t.appendChild(document.createTextNode(text));%20return%20t;%7Dp=document.location;%20q=document.title.replace(/%5C[[%5E%5C]]*%5C](.*)%20-%20JAG%20JIRA/,%20'$1');%20d=window.open().document;%20d.open();%20d.close();%20b=d.body;%20d.title%20=%20q%20+%20'%20:%20summary%20:%20JIRA';%20u=p+'%5Cn'+q+'%5Cn'+userSel();%20add(makeText('style',%20'textarea%7Bwidth:100%;height:100%;%7D'));%20add(makeText('textarea',%20u));%20void%200
//unescaped, with line breaks
javascript: function userSel() {
if (window.getSelection) {
txt = window.getSelection();
} else if (document.getSelection) {
txt = document.getSelection();
} else if (document.selection) {
txt = document.selection.createRange().text;
} else return;
return txt;
}
function add(h) {
b.appendChild(h);
}
function makeTag(t) {
return document.createElement(t);
}
function makeText(tag, text) {
t = makeTag(tag);
t.appendChild(document.createTextNode(text));
return t;
}
p = document.location;
q = document.title.replace(/[[^]]*](.*) - JAG JIRA/, '$1');
d = window.open().document;
d.open();
d.close();
b = d.body;
d.title = q + ' : summary : JIRA';
u = p + '
' + q + '
' + userSel();
add(makeText('style', 'textarea{width:100%;height:100%;}'));
add(makeText('textarea', u));
void 0;
Tag Archive for copy
Summarize Web page bookmarklet
Category: Uncategorized |
Tags: bookmarking, bookmarklets, clipboard, copy, javascript, javascript-pseudo-protocol, paste, text
copy selected text
function getSelectedText(){
if (window.getSelection){
txt = window.getSelection();
}
else if (document.getSelection) {
txt = document.getSelection();
}
else if (document.selection){
txt = document.selection.createRange().text;
}
else return;
return txt;
}
Duplicate file
# so we can work with relative paths
cd "$TM_DIRECTORY"
# construct a default name for the duplicate
def_name=`perl -pe <<<"$TM_FILENAME" 's/^(.*?)(.[^.]*)?$/$1 copy$2/'`
# prompt user for a name
CocoaDialog inputbox --text "$def_name" --button1 "Duplicate" --button2 "Cancel"|{
# if user selected 'Duplicate' and file doesn't exist
read res; read new_name;
if [[ "$res" == "1" && ! -e "$new_name" ]]; then
# do the actual duplication
cp -p "$TM_FILENAME" "$new_name"
# force TM to refresh project drawer and open duplicate
{ osascript -e 'tell application "SystemEvents" to activate'
-e 'tell application "TextMate" to activate'
# open -a TextMate "$new_name";
} &>/dev/null &
fi
}
DOS copy directories with subdirectories
xcopy _adodb c:WAMPApache2.2_adodb /S
Copy File
//importjava.net commons
FileTools.copyFile("foo.txt", "bar.txt");
//antbuilder (no import needed!)
( new AntBuilder ( ) ).copy ( file : 'blah' , tofile : 'fobar' )
wsh_setClipboard
function setClip( txt )
{
var ie = new ActiveXObject( "InternetExplorer.Application" );
ie.Navigate( "about:blank" );
while( ie.Busy ) WScript.Sleep( 50 );
ie.Document.parentWindow.clipboardData.setData( "text", txt );
ie.Quit( );
}
Copiar un arbol de carpetas y archivos sin limite de niveles
function copiarArbol($source, $dest){
$folder = opendir($source);
while($file = readdir($folder)){
if ($file == '.' || $file == '..') continue;
if(is_dir($source.'/'.$file)){
if( !is_dir($dest.'/'.$file)) mkdir($dest.'/'.$file, 0666);
copiarArbol($source.'/'.$file , $dest.'/'.$file);
}else{
if(strrchr($file,'.') != '.db'){
copy($source.'/'.$file , $dest.'/'.$file );
chmod($dest.'/'.$file , 0666);
}
}
}
closedir($folder);
return 1;
}