Prevent code duplication

Source: Internet
Author: User

Insert in Document.body.oncopy event events
or the "Oncopy" property of <body>
function Copycode ()
{
Try
{
var range = Document.selection.createRange ();
if (Document.selection.type!= "None")
{
var parent = range.parentelement ();
var parentname = Parent.tagname;
if (parentname!= null)
{
if (parentname.tolowercase () = = "Pre")
{
Replace superfluous <br> tags in a <pre> blocks.
var re =/<br>/gi;
var code = Range.htmlText.replace (Re, "\ r \ n");

Replace non-breaking spaces.
Re =//gi;
Code = Code.replace (Re, "");

Replace & characters.
Re =/&/gi;
Code = Code.replace (Re, "&");

Replace < characters.
Re =/</gi;
Code = Code.replace (Re, "<");

Replace > characters.
Re =/>/gi;
Code = Code.replace (Re, ">");

Cjm:remove colorization
Re =/<\/?span ([^>]) *>/gi;
Code = Code.replace (Re, "");

if (Code!= NULL)
{
Window.event.returnValue = false;
Window.clipboardData.setData ("Text", code);
}
}
}
}
}
catch (e) {}
}

<HTML>
<HEAD>
<TITLE> Anti-duplication </TITLE>
<script language=javascript src= "/blog/js/oncopy.js" >
</SCRIPT>

<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content= "Feiyun" >
<meta name= "Keywords" content= "Nocopy" >
<meta name= "Description" content= "no copy" >
</HEAD>
<body oncopy= "return Copycode ();" >
<font color= "#FF0000" > Anti-code copy, do not believe you try (only to prevent code duplication, others can be replicated) </FONT><BR>
<TABLE>
<TR>
<TD>aa</TD>
<TD>bb</TD>
<TD>cc</TD>
</TR>
<TR>
<TD>dd</TD>
<TD>ee</TD>
<TD>ff</TD>
</TR>
</TABLE>

<pre lang=vbscript><%
<span class=vb-statement>option</span> <span class=vb-statement>explicit</span>
<span class=vb-statement>dim</span> FSO
<span class=vb-statement>set</span> fso = CreateObject (<span class=vb-string> " Scripting.FileSystemObject "</SPAN>)
<span class=vb-statement>dim</span> asplines, Jslines, Aspbytes, Jsbytes, aspwords
Iterate (Server.MapPath (<span class=vb-string> "/web_api" </SPAN>))
Response.Write <span class=vb-string> "ASP:
Total Lines coded: "</SPAN> & asplines & <span class=vb-string>"
Total Bytes: "</SPAN> & aspbytes & <span class=vb-string>"
Total individual Elements (words) Typed: "</SPAN> & Aspwords
Response.Write <span Class=vb-string> "
Jscript:
Total Lines coded: "</SPAN> & jslines & <span class=vb-string>"
"</SPAN> & <span class=vb-string>" Total Bytes: "</SPAN> & Jsbytes
<span class=vb-statement>function</span> Iterate (path)
<span class=vb-statement>dim</span> folder, folders, files, file, ts, txt, arr, f
<span class=vb-statement>set</span> folder = Fso.getfolder (path)
<span class=vb-statement>set</span> files = folder.files
<span class=vb-statement>dim</span> Rx, c
<span class=vb-statement>set</span> rx = <span class=vb-keyword>new</span> regexp
Rx.ignorecase = <span class=vb-keyword>true</span>
Rx.global = <span class=vb-keyword>true</span>
Rx.pattern = <span class=vb-string> "+" </SPAN>
<span class=vb-statement>for</span> <span class=vb-statement>each</span> file in Files
<span class=vb-statement>if</span> Right (File.name,<span class=vb-literal>4</span>) =< SPAN class=vb-string> ". asp" </SPAN> <span class=vb-keyword>or</span> Right (file.name,<span class=vb-literal>3</span>) =<span class=vb-string> ". js" </SPAN> <span class=vb-statement >then</SPAN>
<span class=vb-statement>set</span> ts = file.openastextstream
<span class=vb-statement>if</span> Ts.atendofstream <span class=vb-statement>then</span> txt = <span class=vb-string> "" </SPAN> <span class=vb-statement>else</span> txt = ts.readall
Ts.close
txt = rx.replace (txt,<span class=vb-string> "" </SPAN>)
TXT = replace (TXT,VBCRLF&AMP;VBCRLF,VBCRLF)
arr = Split (replace (Txt,vbcrlf,<span class=vb-string> "</SPAN>), <span class=vb-string>" "</ span>)
Aspwords = aspwords + UBound (arr)
arr = Split (TXT,VBCRLF)
<span class=vb-statement>if</span> Right (File.name,<span class=vb-literal>4</span>) =< SPAN class=vb-string> ". asp" </SPAN> <span class=vb-statement>then</span>
Asplines = Asplines + UBound (arr)
Aspbytes = aspbytes + len (TXT)
<span class=vb-statement>else</span>
Jslines = Jslines + UBound (arr)
Jsbytes = jsbytes + len (TXT)
<span class=vb-statement>end</span> <span class=vb-statement>if</span>
<span class=vb-statement>end</span> <span class=vb-statement>if</span>
<span class=vb-statement>next</span>
<span class=vb-statement>set</span> folders = folder.subfolders
<span class=vb-statement>for</span> <span class=vb-statement>each</span> F in folders
Iterate F.path
<span class=vb-statement>next</span>
<span class=vb-statement>end</span> <span class=vb-statement>function</span>
%></pre>

</BODY>
</HTML>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.