神奇的读心术

APM60- 2010-09-20 02:17:00
神奇的读心术。之前在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>
...全文
294 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwfgu00ing 2010-09-21
  • 打赏
  • 举报
回复
我知道了
myhope88 2010-09-21
  • 打赏
  • 举报
回复
以前我看过用flash做的,跟这个差不多,不过具体原理也不是很懂
zhaobocheng 2010-09-21
  • 打赏
  • 举报
回复
呵呵,但是没有明白什么意思。
zc00603 2010-09-21
  • 打赏
  • 举报
回复
JS写得不错
yuyejiewu 2010-09-21
  • 打赏
  • 举报
回复
87} 67y 47x 27k 7w
86n 66{ 46n 26t 6v
85~ 65w 45k 25} 5}
84q 64k 44p 24x 4z
83l 63k 43o 23y 3m
82z 62q 42q 22n 2z
wang15072732418 2010-09-21
  • 打赏
  • 举报
回复
呵呵,js写的好
lchy110 2010-09-21
  • 打赏
  • 举报
回复
我知道了。。。
lchy110 2010-09-21
  • 打赏
  • 举报
回复
我知道了。。。
sunqiusong 2010-09-21
  • 打赏
  • 举报
回复
接分。。。。。
slysmart 2010-09-21
  • 打赏
  • 举报
回复
我是来接分,祝中秋快乐!
RHINO_WU 2010-09-21
  • 打赏
  • 举报
回复
明明就是数学的花样
amani11 2010-09-20
  • 打赏
  • 举报
回复
呵呵,不错
真哥哥 2010-09-20
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 hookee 的回复:]
~~~~~~~~jF
[/Quote]
那么多还J
HSBOY86 2010-09-20
  • 打赏
  • 举报
回复
有分接我不会坏你好事的
zoujp_xyz 2010-09-20
  • 打赏
  • 举报
回复
JF~~~~~~~~~~~~~~~~~~~
hookee 2010-09-20
  • 打赏
  • 举报
回复
~~~~~~~~jF
24K純帥 2010-09-20
  • 打赏
  • 举报
回复
我真的真的是知道了
MrSLin 2010-09-20
  • 打赏
  • 举报
回复
mark,我是第一次见...
jnhcd 2010-09-20
  • 打赏
  • 举报
回复
我是来接分的
修石 2010-09-20
  • 打赏
  • 举报
回复
一点都不准
加载更多回复(6)

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧