Skip to content
This repository was archived by the owner on Feb 14, 2018. It is now read-only.

Hi! I cleaned up your code for you! #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Logs and databases #
######################
*.log

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
14 changes: 7 additions & 7 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ for further updates.
## License

<pre>
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2006 Alex Brem <alex@0xab.cd>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
</pre>
Expand Down
46 changes: 23 additions & 23 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@

// install the event handler for #debug #output
$('input[@type="text"], textarea').keyup(update).mousedown(update).mousemove(update).mouseup(update);

// assign the field1 paste event
$('.replace').click(function(e){
$('#field1').replaceSelection($(this).title());
e.preventDefault();
});

});

/*
this function handles #debug #output
*/

function update(e) {

// here we fetch our text range object
var range = $(this).getSelection();

Expand All @@ -43,27 +43,27 @@
((typeof range['col'] != 'undefined') ? "caret col: " + range.col + "\n" : '') +
"selected text:\n<span class=\"txt\">" + (($('#ws').get(0).checked) ? range.text.whitespace() : range.text) + "</span>\n\n"
);

}

/*
this code block is not needed for jQuery fieldSelection
this is just to visualize white space in #debug #output
*/

String.prototype.whitespace = (function() {
if (!RegExp.escape) {

if (!RegExp.escape) {
RegExp.escape = (function() { // RegExp.escape by Simon Wilson & Mark Wubben
var specials = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\' ];
var sRE = new RegExp( '(\\' + specials.join('|\\') + ')', 'g' );
return function(text) { return text.replace(sRE, '\\$1') }
})();

}

var ws = { "\r\n": "¶", "\n": "¶", "\r": "¶", "\t": "&raquo;", " ": "&middot;" };

return ($.browser.msie) ? function() {
// &#8203; to break up our whitespaces doesn't work in IE (it prints a block)
// but nevertheless he doesn't need it, because he has "word-wrap:break-word;"
Expand All @@ -76,7 +76,7 @@
$.each(ws, function(i){ s = s.replace(new RegExp(RegExp.escape(i), 'g'), this + "\u200b") });
return s;
}

})();

function hexdump(txt, hi_f, hi_t) {
Expand Down Expand Up @@ -111,34 +111,34 @@
return hex;

}

//--><!]]>

</script>
<style type="text/css">
body {
background:#cc9;
color:#653;
font:1em Georgia, "Courier New", serif;
}

h1 { color:#430 }

h1 .nuf {
background-color:HighlightText;
color:Highlight;
}

h1 .fun {
background-color:Highlight;
color:HighlightText;
}

a:link { color:#993 }
a:visited { color:#660 }

#content { position:relative }

#debug {
position:absolute;
top:5%;
Expand All @@ -150,7 +150,7 @@
background:#ee9;
border:1px solid #996;
}

#output .txt {
background:#f99;
display:inline;
Expand All @@ -161,29 +161,29 @@
background:#cc9;
color:#630;
}

pre {
white-space:pre-wrap;
white-space:-moz-pre-wrap;
white-space:-pre-wrap;
white-space:-o-pre-wrap;
word-wrap:break-word;
}

label {
color:#663;
font-size:80%;
}

input[type='text'], textarea {
display:block;
width:300px;
margin-bottom:8px;
}

/* bastard. */
/* bastard. */
* html input, * html textarea { display:block; }

</style>
</head>
<body>
Expand Down