Skip to content

Instantly share code, notes, and snippets.

@hokein
Created Jul 17, 2015
Embed
What would you like to do?
Steam-overlay-bug
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello Greenworks</title>
<script src="main.js"></script>
</head>
<body>
<h1>Greenworks Test</h1>
NW.js version: <i><script>document.write(process.versions['node-webkit'])</script></i>.</br>
io.js version: <i><script>document.write(process.version)</script></i>.</br>
<div id="logs" style="width: 70%; border: 1px dashed #ccc; padding: 3px; margin-top:10px;"></div>
<canvas id="forceRefreshCanvas" width="1" height="1"></canvas>
</body>
</body>
var message = '';
var greenworks = require('./greenworks');
if (!greenworks.initAPI()) {
log('Greenworks inits error');
}
function log(msg) {
message = message + msg + '<br>';
document.getElementById('logs').innerHTML = message;
}
function testSteamAPI() {
greenworks.saveTextToFile('test_file.txt', 'test_content',
function() { log('Save text to file successfully'); },
function(err) { log('Failed on saving text to file'); });
greenworks.readTextFromFile('test_file.txt', function(message) {
log('Read text from file successfully.'); }, function(err) {
log('Failed on reading text from file'); });
greenworks.getCloudQuota(
function() { log('Getting cloud quota successfully.') },
function(err) { log('Failed on getting cloud quota.') });
greenworks.activateAchievement('achievement',
function() { log('Activating achievement successfully'); },
function(err) { log('Failed on activating achievement.'); });
log('Cloud Enabled: ' + greenworks.isCloudEnabled());
log('isGameOverlayEnabled: ' + greenworks.isGameOverlayEnabled());
}
function forceRefresh() {
var canvas = document.getElementById("forceRefreshCanvas");
var ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
window.requestAnimationFrame(forceRefresh);
}
document.addEventListener('DOMContentLoaded', function() {
testSteamAPI();
forceRefresh();
});
{
"name": "greenworks-nw-demo",
"main": "index.html"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment