function saveHTML52score(score, gamename) {
let pathArray = window.location.pathname.split('/');
let newpath = '';
if (pathArray[1] && pathArray[1] != 'arcade' && pathArray[1] != 'games') {
newpath = '/' + pathArray[1];
}
scorepost(window.location.protocol + '//' + window.location.hostname + newpath + '/index.php?act=Arcade&do=newscore', {
gname : gamename,
gscore: score
});
}
function scorepost(href, inputs) {
var gform = document.createElement('form');
gform.method = 'post';
gform.action = href;
gform.target = '_parent';
for (var k in inputs) {
var input = document.createElement('input');
input.setAttribute('name', k);
input.setAttribute('value', inputs[k]);
gform.appendChild(input);
}
document.body.appendChild(gform);
gform.submit();
document.body.removeChild(gform);
}
An example of usage:
var score = parseInt(localStorage.getItem("energizerScore")), gamename = 'energizerCZ';
saveHTML52score(score, gamename);
This code is inserted in index.html
<script type="text/javascript">
function scorepost(href, inputs) {
var gform = document.createElement('form');
gform.method = 'post';
gform.action = href;
gform.target = '_parent';
for (var k in inputs) {
var input = document.createElement('input');
input.setAttribute('name', k);
input.setAttribute('value', inputs[k]);
gform.appendChild(input);
}
document.body.appendChild(gform);
gform.submit();
document.body.removeChild(gform);
}
</script>
and this is the score code
let pathArray = window.location.pathname.split('/');
let newpath = '';
if (pathArray[1] && pathArray[1] != 'arcade') {
newpath = '/' + pathArray[1];
}
scorepost('https://' + window.location.hostname + '/index.php?act=Arcade&do=newscore', {
gname : '1010Hex_Origon',
gscore: score
});
This is the way the code should be used, it's a score code developed at origon-games.dk
But you haven't used this code origon for a long time.
For those of you having issues with Origon's save code from older circulating games, you just need to find the file within the game dubbed "ThirdParty.js" & edit the submit_score function near the end of the file. What he posted in the second code block from his previous post is what goes in there except you just need to change the name to match the internal name (not the game name).
Example:
Change "MyInternalGameName_Origon" to the internal game name.
// Called when user is ready to submit a score.
submitScore: function(score = null)
{
let internalName = 'MyInternalGameName_Origon', newpath = '', pathArray = window.location.pathname.split('/');
if (!["arcade", "games"].includes(pathArray[1]))
newpath = '/' + pathArray[1];
if (score != null) {
scorepost(window.location.protocol + '//' + window.location.hostname + newpath + '/index.php?act=Arcade&do=newscore', {
gname : internalName,
gscore: score
});
}
}