UNPKG

cordova-plugin-gamecenter

Version:

This plugin allows interaction with iOS Game Center.

348 lines (299 loc) 11.3 kB
<!DOCTYPE html> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <html> <head> <meta charset="utf-8" /> <meta name="format-detection" content="telephone=no" /> <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 --> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> <title>Hello World</title> <style> /********************************************* * GLOBAL STYLES *********************************************/ * { -webkit-touch-callout: none; -webkit-tap-highlight-color: rgba(0,0,0,0); -webkit-text-size-adjust: none; -webkit-user-drag: none; } html, body { margin: 0; min-height: 100%; } body { background: #393939; color: #000; font-family: Arial, sans-serif; font-size: medium; line-height: 22px; } .spacer { margin-top: 20px; } .floatRight { float: right; } #container { width: 320px; margin: 0 auto; } /********************************************* * HEADERS *********************************************/ h1 { color: #42679C; font-size: xx-large; margin: 24px 0; } h2 { color: #42679C; font-size: x-large; margin: 32px 0 18px; } h3 { color: #42679C; font-size: large; margin: 30px 0 16px; } h4, h5, h6 { color: #000; font-size: 16px; margin: 20px 0 14px; } /********************************************* * LINKS *********************************************/ a { color: #42679C; } /********************************************* * BUTTONS *********************************************/ .controls { display: block; padding: 15px 0; } button { border: 1px solid #cfcfcf; background: #eee; display: inline-block; line-height: 22px; padding: 5px 20px; color: #333; font-size: large; } button:disabled { opacity: 0.5; } button:not(:disabled):hover { background: #fff; color: #ef4327; } button.small { color: #43679B; font-weight: bold; background: none; line-height: inherit; padding: 2px 5px; } /********************************************* * RADIO BUTTON, INPUT BOXES, CHECK BOXES *********************************************/ input[type="checkbox"], input[type="radio"] { display: none; } label + br + input[type="text"] { display: inline-block; margin: 0 2px 2px 0; padding: 2px 4px; border: 1px solid #cfcfcf; color: #000; background: #eee; font-size: larger; border-radius: 0; } label + br + input[type="password"] { display: inline-block; margin: 0 2px 2px 0; padding: 2px 4px; border: 1px solid #cfcfcf; color: #000; background: #eee; font-size: larger; border-radius: 0; } input[type="checkbox"] + label, input[type="radio"] + label { display: inline-block; margin: 0 2px 2px 0; padding: 2px 4px; border: 1px solid #cfcfcf; color: #000; background: #eee; font-size: larger; } input[type="checkbox"] + label:hover, input[type="radio"] + label:hover, input[type="text"] + label:hover { background: #fff; border-color: #ef4327; color: #ef4327; } input[type="checkbox"]:checked + label, input[type="radio"]:checked + label, input[type="text"]:checked + label { background: #ef4327; color: #fff; border-color: #ef4327; } input[type="radio"] + label:before { content: '○'; font-size: 16px; margin-right: 3px; } input[type="radio"]:checked + label:before { content: '●'; } input[type="checkbox"] + label:before { content: '□'; font-size: 15px; margin-right: 4px; } input[type="checkbox"]:checked + label:before { content: '■'; } /********************************************* * CODE & SYNTAX *********************************************/ code, samp { display: block; background: #393939; color: #fff; padding: 12px; border: 1px solid #000; font-family: 'Lucida Console', Monaco, monospace; font-size: larger; white-space: pre-wrap; position: relative; } code:hover:before, samp:hover:before { display: inline-block; white-space: nowrap; position: absolute; top: -20px; right: -10px; background: #FFD; color: #330; content: 'Click to copy'; padding: 2px 4px; font-family: sans-serif; font-size: larger; opacity: 0.9; font-weight: bold; } /********************************************* * SECTION DIVIDERS *********************************************/ section { margin-bottom: 20px; } /********************************************* * DIALOGS *********************************************/ section.dialog { border: 1px solid #999; background: #fff; padding: 12px; margin: 0; position: relative; } section.dialog h1 { display: block; margin: -12px -12px 12px -12px; padding: 10px 4px; background: #eee; text-align: center; font-size: 13px; font-weight: normal; color: #000; } section.dialog section { padding: 20px; margin: 20px -12px; border-top: 1px solid #999; border-bottom: 1px solid #999; border-left: 10px solid #999; border-right: 10px solid #999; } section.dialog section h1 { text-align: center; padding: 0; background: none; color: #42679C; font-size: 13px; margin: 0 0 10px 0; } </style> </head> <body> <div id="container"> <h1>Game Center Plugin</h1> <section class="dialog"> <p>Experiment by pressing the buttons to test the APIs.</p> <p>Authenticate with Game Center.</p> <button onclick="authenticate();">Authenticate</button> <p>Show the game leaderboard.</p> <button onclick="showLeaderboard();">Show</button> <p>Show current user achievements.</p> <button onclick="showAchievements();">Show</button> <p>Report a score.</p> <button onclick="reportScore();">Report score</button> <p>Report and achievement gain.</p> <button onclick="reportAchievement();">Report achievement</button> </section> </div> <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript"> function authenticate() { gameCenter.authenticate(successCallback, failCallback); } function showLeaderboard() { var category = prompt("What's the category?", "CATEGORY"); gameCenter.showLeaderboard(category, successCallback, failCallback); } function showAchievements() { gameCenter.showAchievements(successCallback, failCallback); } function reportScore(category, score) { var score = parseInt(prompt("What's the score?", "100")); gameCenter.reportScore(category, score, successCallback, failCallback); } function reportAchievement() { var category = prompt("What's the category?", "FLAME_SWORD"); gameCenter.reportAchievement(category, successCallback, failCallback); } function successCallback(result) { setTimeout(function () { alert("Success " + JSON.stringify(result)); }, 0); } function failCallback(err) { setTimeout(function () { alert("Error: " + err); }, 0); } </script> </body> </html>