不会死机的js 格式代码

JSer

/* Global CSS */

* { padding:0px; margin:0px; font-size:13px; font-family: arial 宋体; }

body { overflow:auto; border:0px none black; background-color:buttonface; }

li { margin:0px 0px 0px 40px; padding:2px 4px; }

/* Class CSS */

.quote { color:#999; }
.comments { color: #009090; }
.indent { margin-left:25px; }
.regexp { color:#F000F0; }

/* Identified CSS */

#divTools { height:20px; border-bottom:1px solid #555; padding-left:15px; }

#divTools a { color:navy; text-decoration:none; height:20px; line-height:20px; padding:0px 25px; }

#divTools a:hover { color:white; background-color:navy; text-decoration:none; height:20px; line-height:20px; }

#divJSInput { display:none; width:600px; height:450px; border:2px outset buttonface; position:absolute; background-color:buttonface; z-Index:2; }

#divJSInputTitle { color:white; background-color:navy; height:20px; line-height:20px; padding:0px 10px; cursor:default; }

#txtJSInput { width:598px; height:406px; overflow:auto; padding:4px 8px; background-color:white;}

#divJSInputBar { height:24px; padding:0px 4px; }

#divJSInputBar input { width:110px; height:22px; border:1px solid #555; line-height:20px; }

#divJSOutput { background-color:white; border:1px inset buttonface; width:100%; height:500px; overflow:auto; }

#divWaiting { display:none; width:400px; height:60px; border:1px solid buttonface; position:absolute; background-color:#E0F0F0; z-Index:3; text-align:center; padding-top:10px; }

#divWaiting input { width:140px; height:22px; border:1px solid #555; line-height:20px; cursor:default; margin-top:4px; }

/**********************
Author: Hutia

*********************/

window.onload=init;

//------------------
// Static Variable
//------------------

var KEYWORDS="abstract break byte case catch char class const continue default delete do double else extends false final finally float for function goto if implements import in instanceof int interface long native null package private protected public reset return short static super switch synchronized this throw transient true try var void while with";
var OBJECTS="Anchor Applet Area Arguments Array Boolean Button Checkbox Collection Crypto Date Dictionary Document Drive Drives Element Enumerator Event File FileObject FileSystemObject FileUpload Folder Folders Form Frame Function Global Hidden History HTMLElement Image Infinity Input JavaArray JavaClass JavaObject JavaPackage JSObject Layer Link Math MimeType Navigator Number Object Option Packages Password Plugin PrivilegeManager Random RegExp Screen Select String Submit Text Textarea URL VBArray Window WScript";
var METHODS_PROPERTIES="above abs acos action activeElement alert alinkColor all altKey anchor anchors appCodeName applets apply appName appVersion arguments arity asin assign atan atan2 atob availHeight availLeft availTop availWidth ActiveXObject back background below bgColor big blink blur bold border borderWidths bottom btoa button call callee caller cancelBubble captureEvents ceil charAt charCodeAt charset checked children classes className clear clearInterval clearTimeout click clientInformation clientX clientY close closed colorDepth compile complete concat confirm constructir contains contextual cookie cos crypto ctrlKey current data defaultCharset defaultChecked defaultSelected defaultStatus defaultValue description disableExternalCapture disablePrivilege document domain E Echo element elements embeds enabledPlugin enableExternalCapture enablePrivilege encoding escape eval event exec exp expando FromPoint fgColor fileName find fixed floor focus fontColor fontSize form forms forward frames fromCharCode fromElement getAttribute get getClass getDate getDay getFullYear getHours getMember getMilliseconds getMinutes getMonth getSeconds getSelection getSlot getTime getTimezoneOffset getUTCDate getUTCDay getUTCFullYear getUTCHours getUTCMilliseconds getUTCMinutes getUTCMonth getUTCSeconds getWindow getYear global go HandleEvent Height hash hidden history home host hostName href hspace id ids ignoreCase images index indexOf inner innerHTML innerText innerWidth insertAdjacentHTML insertAdjacentText isFinite isNAN italics java javaEnabled join keyCode Links LN10 LN2 LOG10E LOG2E lang language lastIndex lastIndexOf lastMatch lastModified lastParen layers layerX layerY left leftContext length link linkColor load location locationBar log lowsrc MAX_VALUE MIN_VALUE margins match max menubar method mimeTypes min modifiers moveAbove moveBelow moveBy moveTo moveToAbsolute multiline NaN NEGATIVE_INFINITY name navigate navigator netscape next number offscreenBuffering offset offsetHeight offsetLeft offsetParent offsetTop offsetWidth offsetX offsetY onabort onblur onchange onclick ondblclick ondragdrop onerror onfocus onHelp onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseout onmouseover onmouseup onmove onreset onresize onsubmit onunload open opener options outerHeight outerHTML outerText outerWidth POSITIVE_INFINITY PI paddings pageX pageXOffset pageY pageYOffset parent parentElement parentLayer parentWindow parse parseFloat parseInt pathname personalbar pixelDepth platform plugins pop port pow preference previous print prompt protocol prototype push random readyState reason referrer refresh releaseEvents reload removeAttribute removeMember replace resizeBy resizeTo returnValue reverse right rightcontext round SQRT1_2 SQRT2 screenX screenY scroll scrollbars scrollBy scrollIntoView scrollTo search select selected selectedIndex self setAttribute setDay setFullYear setHotkeys setHours setInterval setMember setMilliseconds setMinutes setMonth setResizable setSeconds setSlot setTime setTimeout setUTCDate setUTCFullYear setUTCHours setUTCMillseconds setUTCMinutes setUTCMonth setUTCSeconds setYear setZOptions shift shiftKey siblingAbove siblingBelow signText sin slice smallsort source sourceIndex splice split sqrt src srcElement srcFilter status statusbar stop strike style sub submit substr substring suffixes sun sup systemLanguage TYPE tagName tags taint taintEnabled tan target test text title toElement toGMTString toLocaleString toLowerCase toolbar top toString toUpperCase toUTCString type typeOf UTC unescape unshift untaint unwatch userAgent userLanguage value valueOf visibility vlinkColor vspace watch which width window write writeln x y zIndex";
var OPS="! $ % & * + - // / : ? [ ] ^ | ~ is new sizeof typeof unchecked";

var regKW=new RegExp("(\\W"+KEYWORDS.replace(/ /g,"$)|(\\W")+"$)","g");
var regObj=new RegExp("(\\W"+OBJECTS.replace(/ /g,"$)|(\\W")+"$)","g");
var regMP=new RegExp("(\\W"+METHODS_PROPERTIES.replace(/ /g,"$)|(\\W")+"$)","g");
//var regOP=new RegExp("(\\W"+OPS.replace(/ /g,"$)|(\\W")+"$)","g");

var colorKW="blue";
var colorObj="red";
var colorMP="#FF8000";
var colorOP="#004000";

//------------------
// Global Variables
//------------------
var divJSInput, txtJSInput, divJSOutput, divWaiting, spnProcess;
var glbStr, glbP, glbRe, curRe, glbTimer;

function init(){
// init global variables
divJSInput=document.getElementById("divJSInput");
txtJSInput=document.getElementById("txtJSInput");
divJSOutput=document.getElementById("divJSOutput");
divWaiting=document.getElementById("divWaiting");
spnProcess=document.getElementById("spnProcess");

// init window state
maximizeWindow();

divJSOutput.style.width=document.body.clientWidth-2;
divJSOutput.style.height=document.body.clientHeight-26;

// init global events
divJSInput.onkeydown=divJSInput_keydown;
}

//------------------
// event scripts
//------------------

function divJSInput_keydown(e){
var e=window.event?window.event:e;
var srcEle=e.srcElement?e.srcElement:e.target;
var sel;
if(e.keyCode==27)hideJSInput();
if(e.keyCode==13&&e.ctrlKey)execJSInput();
if(e.keyCode==9&&srcEle==txtJSInput){
document.selection.createRange().text="\t";return(false); // not support FF
}
}

//------------------
// functional scripts
//------------------

function showJSInput(){
with(divJSInput.style){
display="block";
left=(document.body.clientWidth-divJSInput.offsetWidth)/2;
top=(document.body.clientHeight-divJSInput.offsetHeight)/2;
}

txtJSInput.focus();

return(false);
}

function hideJSInput(){
divJSInput.style.display="none";
}

function execJSInput(){
hideJSInput();

divJSOutput.innerHTML="";

glbStr=txtJSInput.value.replace(/\r\n[ \t]+/gi,"\r\n").replace(/(\r\n)+/gi,"\r\n");
glbP=0;
curRe=glbRe=document.createElement("div");

divJSOutput.appendChild(glbRe);

glbRe.className="codeRoot";

showWait();
core_analysis();
}

function showWait(){
document.body.style.cursor="wait";

with(divWaiting.style){
display="block";
left=(document.body.clientWidth-divWaiting.offsetWidth)/2;
top=(document.body.clientHeight-divWaiting.offsetHeight)/2;
}
spnProcess.innerHTML="0.00% ( 0 / 0 )"
return(false);
}

function stopExec(){
document.body.style.cursor="";
divWaiting.style.display="none";
try{clearTimeout(glbTimer);}catch(e){}

return(false);
}

function core_analysis(){
var str=" ", c="", lastState="", seq, intNextQuote, intTemp, intCount, intWordStart;
spnProcess.innerHTML=parseFloat(glbP/glbStr.length*100).toFixed(2)+"% ( "+glbP+" / "+glbStr.length+" )";
for(var i=glbP;i200){
glbP=i+1;
glbTimer=setTimeout(core_analysis);
return;
}
break;
case "\"":
intNextQuote=i;
while(intNextQuote!=-1&&intNextQuote"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"\"";
i=intNextQuote;
lastState="";
break;
case "\'":
intNextQuote=i;
while(intNextQuote!=-1&&intNextQuote"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"\'";
i=intNextQuote;
lastState="";
break;
case "\/":
if(glbStr.charAt(i+1)=="\/"){
intNextQuote=i;
intNextQuote=glbStr.indexOf("\r\n",intNextQuote+1);
if(intNextQuote==-1)intNextQuote=glbStr.length;
str=str.substring(0,str.length-1);
str+="\/"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"";
i=intNextQuote;
}else if(glbStr.charAt(i+1)=="*"){
intNextQuote=i;
intNextQuote=glbStr.indexOf("*\/",intNextQuote+1);
if(intNextQuote==-1)return;
str=str.substring(0,str.length-1);
str+="\/"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"*\/";
i=intNextQuote+1;
}else if(str.match(/[=(][ \t]*\//)){
intNextQuote=i;
while(intNextQuote!=-1&&intNextQuote"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"\/";
i=intNextQuote;
lastState="";
}
lastState="";
break;
case "{":
outputLn(str);
str=" ";
seq=document.createElement("div");
seq.className="indent";
curRe.appendChild(seq);
curRe=seq;
lastState="\r\n";
if(i-glbP>200){
glbP=i+1;
glbTimer=setTimeout(core_analysis);
return;
}
break;
case "}":
outputLn(str.substring(0,str.length-1));
str="} ";
lastState="";
curRe=curRe.parentNode;
break;
default:
if(c.match(/\w/)&&glbStr.charAt(i-1).match(/\W/)){intWordStart=i;}
if(c.match(/\W/)&&glbStr.charAt(i-1).match(/\w/)){
str=str.substring(0,str.length-htmlEncode(c).length);
str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP)+htmlEncode(c);
}
lastState="";
break;
}
}

if(i==glbStr.length){
if(str!=""){ outputLn(str); str=" "; }
stopExec();
}

}

function outputLn(theStr){
var seq=document.createElement("p");
seq.innerHTML=theStr;
curRe.appendChild(seq);
}

function clKW(str){ return(str.charAt(0)+str.substring(1).fontcolor(colorKW)); }

function clObj(str){ return(str.charAt(0)+str.substring(1).fontcolor(colorObj)); }

function clMP(str){ return(str.charAt(0)+str.substring(1).fontcolor(colorMP)); }

function clOP(str){ return(str.charAt(0)+str.substring(1).fontcolor(colorOP)); }

//------------------
// global scripts
//------------------

function maximizeWindow(){
window.moveTo(0,0);
window.resizeTo(screen.availWidth,screen.availHeight);
}

function htmlEncode(strS){
return(strS.replace(/&/g,"&").replace(//g,">").replace(/ /g," ").replace(/\r\n/g,"
"));
}

Input JS

Please Input the JS:

Processing...

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

(0)

相关推荐

  • 不会死机的js 格式代码

    JSer /* Global CSS */ * { padding:0px; margin:0px; font-size:13px; font-family: arial 宋体; } body { overflow:auto; border:0px none black; background-color:buttonface; } li { margin:0px 0px 0px 40px; padding:2px 4px; } /* Class CSS */ .quote { color:#9

  • 一段几乎可以让你死机的JS代码

    谨慎运行啊,死机了别怪我!这个用来对付那些动不动就喜欢来测测你的程序有没有什么SQL注入洞洞的那种人感觉比较爽哈哈!!以为会了那么一点小本事就不得了!我的IIS日志里成天都能看见这种小朋友做这种事! window.attachEvent("onload",function (){AutoSizeDIV('CODE_7643')})  以下是程序代码: <script>var l="a"for(i=0;i<10;i++){        l=l.re

  • 简单几招让你的电脑不再假死机

    死机,相信是很多朋友习以为常的事.一发现死机,我们通常都会直接热启动或按"Reset",但孰不知,有时电脑并未真正死机,只不过是处于一种假死的状态.按下数字键区的"Num Lock"键,如果指示灯有反应,则说明是假死机.那我们该如何处理真.假死机呢? 一.修改注册表,远离假死机困扰 很多假死机是由于运行的程序没有响应造成的.比如你在同一时间打开或启动的程序过多,导致系统资源消耗严重,就会出现程序停止响应的情况,这时我们可以按下"Ctrl+Alt+Del&q

  • JS SetInterval 代码实现页面轮询

    概念介绍 setInterval 是一个实现定时调用的函数,可按照指定的周期(以毫秒计)来调用函数或计算表达式.setInterval方法会不停地调用函数,直到 clearInterval 被调用或窗口被关闭. 由 setInterval 返回的ID值可用作 clearInterval 方法的参数. 提示: 1000 毫秒= 1 秒. flash用法(来自百度百科) setInterval 动作的作用是在播放动画的时,每隔一定时间就调用函数,方法或对象.可以使用本动作更新来自数据库的变量或更新时

  • js复制内容到剪贴板代码,js复制代码的简单实例

    如下所示: <script type="text/JavaScript"> function jsCopy(){ var e=document.getElementById("contents");//对象是contents e.select(); //选择对象 document.execCommand("Copy"); //执行浏览器复制命令 } </script> <textarea id="conte

  • 导致计算机系统“死机”的原因及其预防方法

    如今的计算机已经接近全面普及的程度了,它给人们在工作和学习上提供了极大的方便,不过,计算机的"死机"对于普通的计算机用户来说,却成为了一个解不开.挣不脱的烦 恼.每当在计算机开机时.或启动操作系统时.或使用一些应用程序时.或正准备退出操作系统时,"死机"这一头"猛兽"随时都有可能迎面扑来.那么,怎么做才能避免计算机"死机"的烦恼呢?下面,笔者就根据导致"死机"的原因和预防的方法分为几点给大家介绍一下,希望下

  • vscode配置setting.json文件实现eslint自动格式代码

    一.ESlint+Vetur 实现ESlint代码规范 二.重点----旧版本(旧版本配置在setting.json 会出现警告) { "eslint.autoFixOnSave": true, "eslint.validate": [ "javascript", { "language": "vue", "autoFix": true }, { "language"

  • angular.js分页代码的实例

    对于大多数web应用来说显示项目列表是一种很常见的任务.通常情况下,我们的数据会比较多,无法很好地显示在单个页面中.在这种情况下,我们需要把数据以页的方式来展示,同时带有转到上一页和下一页的功能.现在在学习angular,使用angularjs 分页,基于 directive 实现,样式使用的 bootstrap,直接在 html代码中加入 标签即可调用. 先来看下效果图 实例代码 app.directive('pagePagination', function(){ return { rest

  • 为输入框加入数字js校验代码分享

    js限制只能数字输入,并且在把输入的"非法字符"清除掉之后将焦点停留在输入非法字符的位置,参考如下: html部分: <input value="" type="text" onkeyup="javascript:RepNumber(this)"> JavaScript部分: function RepNumber(obj) { var reg = /^[\d]+$/g; if (!reg.test(obj.valu

  • Node.js实用代码段之获取Buffer对象字节长度

    我们知道Node.js框架下的Buffer对象能够对二进制数据提供很好的支持,那么获取一个Buffer对象真实的字节长度则是必须要用到的功能了.Node.js框架为开发人员提供了一个Buffer.byteLength()方法,下面我们借助一个官方文档提供的例程向读者演示一下该方法的使用过程. 本例ch04.buffer-byteLength.js主要代码如下: /** * ch04.buffer-byteLength.js */ console.info("------Buffer.byteLe

随机推荐