从这个index.js文件中,当用户完成游戏时,输出显示在innerhtml,我不知道如何检索存储在此文件中的级别,点击和效率变量并显示在另一个php页面上这样我可以存储在mysql数据库中吗?
index.php文件
var MemoryGame = function (evt) {
"use strict";
var lvlNum = 0,
info = document.getElementById('game-info'),
lvlCtrls = document.getElementById('levels'),
lvls = [
{'rows': 3, 'cols': 4, 'matches': 2},
{'rows': 4, 'cols': 4, 'matches': 2},
{'rows': 4, 'cols': 5, 'matches': 2},
{'rows': 3, 'cols': 4, 'matches': 3},
{'rows': 3, 'cols': 5, 'matches': 3},
{'rows': 3, 'cols': 6, 'matches': 3},
{'rows': 4, 'cols': 4, 'matches': 4},
{'rows': 4, 'cols': 5, 'matches': 4},
{'rows': 4, 'cols': 6, 'matches': 4},
{'rows': 5, 'cols': 6, 'matches': 5}
],
lastBtn = lvlCtrls.childNodes[1],
btn = null,
lvl = lvls[lvlNum],
currentLvl = null,
start = function () {
currentLvl = new Level(evt, lvl.rows, lvl.cols, lvl.matches);
currentLvl.onwin = function (clicks, prc) {
info.innerHTML = 'You\'ve found all matches in <strong>' + clicks + '</strong> clicks with <strong>' + prc + '%</strong> efficiency';
};
info.innerHTML = 'Click the cards to reveal <strong>' + lvl.matches + '</strong> matches';
//Retrieve game points
alert('a');
$('#score').click(function() {
alert('b');
$('#postscore').val(clicks);
$('#postscoreform').submit();
});
};
start();
evt.attach('mousedown', lvlCtrls, function (e, src) {
if (src.tagName === 'A') {
btn = src.parentNode;
lastBtn.className = '';
btn.className = 'selected';
lastBtn = btn;
lvlNum = src.getAttribute('level');
lvl = lvls[lvlNum];
start();
}
});
};
index.js文件
config.assets.cache_limit = 50.megabytes
config.assets.configure do |env|
env.cache = Sprockets::Cache::FileStore.new(
File.join(ENV['RAILS_TMP'], 'cache/assets'),
config.assets.cache_limit,
env.logger
)
end
有人请帮助我!!