神奇的读心术

APM60- APM60- 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
神奇的读心术。之前在MFC版上看到的。
做个web版的给大家娱乐一下。
祝大家中秋节快乐!

请知道底细的童鞋不要说出来,给神奇的大魔法师slowhand留点面子。
(回复“我知道了”就可以)



玩法:心中默想任意一个两位数,例如:23。然后个数与十位相加:2+3=5。
用这个两位数23减相加的和5,得到23-5=18在页面中找到18对应的图标,记在心中。
然后点击占卜按钮,见证奇迹的时刻到了。

代码:

<html>
<body>
<style type="text/css">
.table_back{width:320px;height:480px;border:0px}
.floor{border:0px solid gray;font-size:12px;line-height:24px;}
</style>

<div id="NT">神奇的占卜</div>

<script type="text/javascript">
/*
标题:神奇的占卜
设计:宁涛
日期:2010年9月20日
*/

function Prediction(options) {
var self = this;
for (var p in options) this[p] = options[p];
this.parent = this.parent || document.body;
this.rowCount = this.rowCount || 20;
this.colCount = this.colCount || 5;
this.picMax = this.picMax || 20;

this.table_back = document.createElement("table");
this.table_back.className = "table_back";
this.table_back.cellPadding = "0px";
this.table_back.cellSpacing = "0px";
this.floors = {};
for (var i = 0; i < this.rowCount; i++) {
var tr = this.table_back.insertRow(-1);
for (var j = 0; j < this.colCount; j++) {
var td = tr.insertCell(-1);
td.className = "floor";
this.floors[[i, j]] = {td: td};
td.innerHTML = " ";
}
}
this.parent.appendChild(this.table_back);

this.div_Intro = document.createElement("div");
this.div_Intro.innerHTML =
"玩法:心中默想任意一个两位数,例如:23。<br>"+
"然后个数与十位相加:2+3=5。<br>"+
"用这个两位数23减相加的和5,得到23-5=18。<br>"+
"在页面中找到18对应的图标,记在心中。<br>"+
"然后点击占卜按钮,见证奇迹的时刻到了。<br>";
this.parent.appendChild(this.div_Intro);

this.button_Predict = document.createElement("input");
this.button_Predict.type = "button";
this.button_Predict.value = "占卜";
this.button_Predict.onclick = function() {
self.Predict();
};
this.parent.appendChild(this.button_Predict);

this.font_Result = document.createElement("font");
this.font_Result.face = "webdings";
this.font_Result.size = "5px";
this.font_Result.style.width = "50px";
var TmpClr = Math.floor(0xFFFFFF / (this.picMax+1)).toString(16);
this.font_Result.color = "000000".substr(TmpClr.length) + TmpClr;
this.font_Result.innerHTML = " ";
this.parent.appendChild(this.font_Result);

this.button_Replay = document.createElement("input");
this.button_Replay.type = "button";
this.button_Replay.value = "刷新";
this.button_Replay.onclick = function() {
self.replay();
};
this.parent.appendChild(this.button_Replay);

this.replay();
}

Prediction.prototype = {
replay: function(){
this.picOffSet = 40 + Math.floor( (120-this.picMax) * Math.random() );
for(var i = 0; i < this.rowCount; i++) {
for(var j = 0; j < this.colCount; j++) {
this.floors[[i, j]].td.innerHTML = this.NewCell((this.rowCount-i-1)+(this.colCount-j-1)*this.rowCount);
}
}
this.font_Result.innerHTML = " ";
},

NewCell: function(cell_index) {
var RandNum = Math.floor(this.picMax * Math.random());
if((0==(cell_index%9)) && (cell_index<90)) RandNum=0;
var TmpClr = Math.floor(0xFFFFFF * (RandNum+1) / (this.picMax+1)).toString(16);
TmpClr = "000000".substr(TmpClr.length) + TmpClr;
var TmpStr = cell_index;
TmpStr += "<font face=\"webdings\" size=\"5px\" color=\"#";
TmpStr += TmpClr
TmpStr += "\">";
TmpStr += String.fromCharCode(this.picOffSet+RandNum);
TmpStr += "<\/font>";
return TmpStr;
},

Predict: function() {
this.font_Result.innerHTML = String.fromCharCode(this.picOffSet);
}
}

function $(id) { return document.getElementById(id); }

new Prediction({parent: $("NT")});

</script>
</body>
</html>
...全文

相关推荐

评论 29
收藏 已收藏
分享
返回顶部
APM60-
JavaScript 87,984 成员 224,680 内容