kopia lustrzana https://github.com/OpenBuilds/OpenBuilds-CONTROL
local
rodzic
00d36ea5a6
commit
4b669dd0af
|
@ -123,3 +123,13 @@ select{
|
|||
.bg-openbuilds {
|
||||
background-color: rgb(74, 78, 81) !important;
|
||||
}
|
||||
|
||||
.keyboardpanel td:nth-child(1){
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.keyboardpanel td:nth-child(2){
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,186 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="svg1901"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)"
|
||||
sodipodi:docname="keyboard.svg"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="53.417px"
|
||||
height="53.99px"
|
||||
viewBox="346.5 473.844 53.417 53.99"
|
||||
enable-background="new 346.5 473.844 53.417 53.99"
|
||||
xml:space="preserve"><metadata
|
||||
id="metadata40"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata>
|
||||
<sodipodi:namedview
|
||||
id="namedview1769"
|
||||
showgrid="false"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
inkscape:cy="23.504242"
|
||||
guidetolerance="10"
|
||||
inkscape:cx="15.478776"
|
||||
gridtolerance="10"
|
||||
inkscape:zoom="5.0346668"
|
||||
objecttolerance="10"
|
||||
borderopacity="1"
|
||||
inkscape:current-layer="layer2"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:snap-grids="true"
|
||||
inkscape:window-height="1018"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid4583" />
|
||||
</sodipodi:namedview>
|
||||
<defs
|
||||
id="defs5">
|
||||
|
||||
|
||||
<inkscape:perspective
|
||||
id="perspective1773"
|
||||
inkscape:persp3d-origin="750 : 250 : 1"
|
||||
inkscape:vp_z="1500 : 375 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_x="0 : 375 : 1"
|
||||
sodipodi:type="inkscape:persp3d">
|
||||
</inkscape:perspective>
|
||||
</defs>
|
||||
<g
|
||||
id="layer2"
|
||||
transform="translate(115.62417,74.248815)">
|
||||
<path
|
||||
id="rect4895"
|
||||
fill="#656565"
|
||||
d="M236.654,400.587h41.954c2.634,0,4.771,1.797,4.771,4.012v44.021 c0,2.216-2.136,4.012-4.771,4.012h-41.954c-2.634,0-4.771-1.796-4.771-4.012v-44.021 C231.883,402.384,234.019,400.587,236.654,400.587z" />
|
||||
<rect
|
||||
id="rect4897"
|
||||
x="272.074"
|
||||
y="404.453"
|
||||
fill="#D6D6D6"
|
||||
width="11.279"
|
||||
height="34.563" />
|
||||
|
||||
<linearGradient
|
||||
id="path4899_1_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="-885.3761"
|
||||
y1="640.0551"
|
||||
x2="-888.4066"
|
||||
y2="652.6821"
|
||||
gradientTransform="matrix(0.2087 0 0 -0.208 461.3392 537.5479)">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#D6D6D6"
|
||||
id="stop9" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#656565"
|
||||
id="stop11" />
|
||||
</linearGradient>
|
||||
<path
|
||||
id="path4899"
|
||||
fill="url(#path4899_1_)"
|
||||
d="M274.235,407.467l9.094-2.972c-0.361-2.856-2.329-3.846-5.069-3.937 c-3.646,0.105-7.203,0.26-9.094,1.337L274.235,407.467z" />
|
||||
<rect
|
||||
id="rect4901"
|
||||
x="240.976"
|
||||
y="439.646"
|
||||
fill="#929292"
|
||||
width="33.469"
|
||||
height="12.975" />
|
||||
|
||||
<linearGradient
|
||||
id="path4903_1_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="2230.7595"
|
||||
y1="454.8979"
|
||||
x2="2250.8057"
|
||||
y2="439.2401"
|
||||
gradientTransform="matrix(-0.2087 0 0 -0.208 744.2323 537.5479)">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#D6D6D6"
|
||||
id="stop16" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#939393"
|
||||
id="stop18" />
|
||||
</linearGradient>
|
||||
<path
|
||||
id="path4903"
|
||||
fill="url(#path4903_1_)"
|
||||
d="M272.535,436.6l10.805,1.155l0.04,10.506c-0.005,2.709-2.167,4.266-4.401,4.359 l-4.81-0.052l-5.324-12.345L272.535,436.6z" />
|
||||
|
||||
<linearGradient
|
||||
id="path4905_1_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="-1084.8995"
|
||||
y1="454.4057"
|
||||
x2="-1061.9962"
|
||||
y2="438.7479"
|
||||
gradientTransform="matrix(0.2087 0 0 -0.208 461.3392 537.5479)">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#656565"
|
||||
id="stop22" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#939393"
|
||||
id="stop24" />
|
||||
</linearGradient>
|
||||
<path
|
||||
id="path4905"
|
||||
fill="url(#path4905_1_)"
|
||||
d="M239.395,436.495l-7.484,1.261l-0.04,10.506c0.005,2.709,2.167,4.266,4.401,4.359 l4.81-0.052l1.687-12.292L239.395,436.495z" />
|
||||
<path
|
||||
id="rect4907"
|
||||
fill="#F1F1F1"
|
||||
d="M243.424,401.246h26.994c2.635,0,4.771,2.128,4.771,4.754v30.736 c0,2.626-2.136,4.755-4.771,4.755h-26.994c-2.635,0-4.771-2.129-4.771-4.755v-30.736 C238.654,403.373,240.789,401.246,243.424,401.246z" />
|
||||
|
||||
<linearGradient
|
||||
id="rect4909_1_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="-1143.3112"
|
||||
y1="401.0522"
|
||||
x2="-1066.7612"
|
||||
y2="401.0522"
|
||||
gradientTransform="matrix(0.2087 0 0 -0.208 488.0692 504.7872)">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#D8D8D8"
|
||||
id="stop29" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#B1B1B1"
|
||||
id="stop31" />
|
||||
</linearGradient>
|
||||
<path
|
||||
id="rect4909"
|
||||
fill="url(#rect4909_1_)"
|
||||
d="M243.424,401.246h25.94c2.635,0,4.771,2.128,4.771,4.754v30.736 c0,2.626-2.136,4.755-4.771,4.755h-25.94c-2.635,0-4.771-2.129-4.771-4.755v-30.736 C238.654,403.373,240.789,401.246,243.424,401.246z" />
|
||||
|
||||
<path
|
||||
id="rect4915"
|
||||
fill="none"
|
||||
stroke="#000000"
|
||||
stroke-width="1.5"
|
||||
d="M236.654,400.587h41.954c2.634,0,4.771,1.797,4.771,4.012 v44.021c0,2.216-2.136,4.012-4.771,4.012h-41.954c-2.634,0-4.771-1.796-4.771-4.012v-44.021 C231.883,402.384,234.019,400.587,236.654,400.587z"
|
||||
style="stroke:#666666;stroke-width:0.9;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
</g>
|
||||
</svg>
|
Po Szerokość: | Wysokość: | Rozmiar: 5.3 KiB |
125
app/index.html
125
app/index.html
|
@ -34,6 +34,7 @@
|
|||
<li><a id="controlTab" href="#section-two" onclick="manualcontrolPanel();"><i class="fas fa-fw fa-play"></i> Control</a></li>
|
||||
<li id="grblSettings" style="display: none;"><a href="#section-grbl" onclick="grblPanel();"><i class="fas fa-fw fa-sliders-h"></i> Grbl Settings</a></li>
|
||||
<li><a href="#section-troubleshooting" onclick="troubleshootingPanel();"><i class="fas fa-fw fa-file-medical-alt"></i> Troubleshooting</a></li>
|
||||
<li id="gamepadTab" style="display: none;"><a href="#section-gamepad" onclick="gamepadPanel();"><i class="fas fa-keyboard"></i> Keyboard <!-- i class="fas fa-gamepad"></i> Gamepad --></a></li>
|
||||
<!-- <li><a href="#section-update" onclick="updatePanel();"><i id="updateIcon" class="fas fa-fw fa-cloud-download-alt"></i> Update <span id="updateAvailable" style="display: none;text-decoration: none !important;">new!</span></a></li> -->
|
||||
</ul>
|
||||
<div class="content-holder">
|
||||
|
@ -307,6 +308,47 @@
|
|||
<span class="title">E-Stop</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" id="section-gamepad">
|
||||
<div class="group" style="width: 100px;">
|
||||
<button class="ribbon-button" onclick="socket.emit('clearAlarm', 2)">
|
||||
<span class="icon">
|
||||
<span class="fa-layers" data-toggle="tooltip" data-placement="bottom" title="Flashes red when machine has entered ALARM state, click Clear Alarm button">
|
||||
<i id="navbellBtn2" class="fas fa-bell fg-red" style="display: none;"></i>
|
||||
<i class="far fa-bell"></i>
|
||||
</span>
|
||||
</span>
|
||||
<span class="caption">Unlock<br>Alarm</span>
|
||||
</button>
|
||||
<button class="ribbon-button" onclick="socket.emit('stop', true)">
|
||||
<span class="icon">
|
||||
<span class="fa-layers fa-fw">
|
||||
<i class="fas fa-circle fg-red" data-fa-transform="grow-8"></i>
|
||||
<i class="fa-inverse far fa-hand-paper" data-fa-transform="grow-1 left-0.5"></i>
|
||||
</span>
|
||||
</span>
|
||||
<span class="caption">Stop<br>Job</span>
|
||||
</button>
|
||||
<span class="title">E-Stop</span>
|
||||
</div>
|
||||
|
||||
<div class="group flex-column" style="width: 320px">
|
||||
<div>
|
||||
<input name="c2" type="checkbox" data-role="switch" data-caption="<i class='fas fa-keyboard'></i> Use Keyboard Controls">
|
||||
</div>
|
||||
<div>
|
||||
<input name="c2" type="checkbox" data-role="switch" data-caption="<i class='fas fa-gamepad'></i> Use Gamepad Controls">
|
||||
</div>
|
||||
<span class="title">Switches</span>
|
||||
</div>
|
||||
|
||||
<!-- <div class="group" style="width: 100px;">
|
||||
<input type="checkbox" data-role="switch" data-caption="Use Keyboard">
|
||||
|
||||
<span class="title">Enable/Disable</span>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
@ -688,6 +730,86 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gamepadPanel" style="display: none;">
|
||||
<!-- <h2 class="text-center">Coming Soon</h2> -->
|
||||
<table class="keyboardpanel">
|
||||
<tr>
|
||||
<th colspan="2">Key</th>
|
||||
<!-- <th></th> -->
|
||||
<th>Function</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span class="fa-layers">
|
||||
<img src="img/keyboard.svg" data-fa-transform="grow-8"/>
|
||||
<i class="fas fa-arrow-left" data-fa-transform="grow-4 down-12 right-10"></i>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="fa-layers">
|
||||
<img src="img/keyboard.svg" data-fa-transform="grow-8"/>
|
||||
<i class="fas fa-arrow-right" data-fa-transform="grow-4 down-12 right-10"></i>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="remark alert m-0">Jog <span class="tally alert">X</span> Axis</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span class="fa-layers">
|
||||
<img src="img/keyboard.svg" data-fa-transform="grow-8"/>
|
||||
<i class="fas fa-arrow-up" data-fa-transform="grow-4 down-12 right-10"></i>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="fa-layers">
|
||||
<img src="img/keyboard.svg" data-fa-transform="grow-8"/>
|
||||
<i class="fas fa-arrow-down" data-fa-transform="grow-4 down-12 right-10"></i>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="remark success m-0">Jog <span class="tally success">Y</span> Axis</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span class="fa-layers">
|
||||
<img src="img/keyboard.svg" data-fa-transform="grow-8"/>
|
||||
<span class="fa-layers-text" data-fa-transform="shrink-3 right-18 down-7" style="font-weight:900">Page</span>
|
||||
<span class="fa-layers-text" data-fa-transform="shrink-3 right-18 down-22" style="font-weight:900">Up</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="fa-layers">
|
||||
<img src="img/keyboard.svg" data-fa-transform="grow-8"/>
|
||||
<span class="fa-layers-text" data-fa-transform="shrink-3 right-18 down-7" style="font-weight:900">Page</span>
|
||||
<span class="fa-layers-text" data-fa-transform="shrink-3 right-17 down-22" style="font-weight:900">Down</span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="remark info m-0"> Jog <span class="tally info">Z</span> Axis</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<span class="fa-layers">
|
||||
<img src="img/keyboard.svg" data-fa-transform="grow-8"/>
|
||||
<span class="fa-layers-text" data-fa-transform="shrink-3 right-17 down-14" style="font-weight:900">Esc</span>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div class="remark m-0">Abort / Stop</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- <div id="updateconsole">Click "Download Updates" above</div> -->
|
||||
</div>
|
||||
|
||||
<!-- Bottom StatusBar -->
|
||||
<div class="fixed-bottom">
|
||||
|
@ -767,5 +889,8 @@
|
|||
<script type="text/javascript" src="js/jog.js"></script>
|
||||
<script type="text/javascript" src="js/calibrate.js"></script>
|
||||
|
||||
<script type="text/javascript" src="lib/gamepad/gamepad.min.js"></script>
|
||||
<script type="text/javascript" src="js/gamepad.js"></script>
|
||||
|
||||
|
||||
</html>
|
|
@ -32,8 +32,8 @@ var grblcalctemplate = `<div>
|
|||
<td style="width: 70%;">
|
||||
<select data-role="select" data-filter="false" id="microstepselect" data-on-change="processpreset();">
|
||||
<option value="32">1/32 Step</option>
|
||||
<option value="16" selected>1/16 Step</option>
|
||||
<option value="8">1/8 Step</option>
|
||||
<option value="16">1/16 Step</option>
|
||||
<option value="8" selected>1/8 Step</option>
|
||||
<option value="4">1/4 Step</option>
|
||||
<option value="1">Full Step</option>
|
||||
</select>
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
var gamepad;
|
||||
var gamepadInterval;
|
||||
|
||||
$(document).ready(function() {
|
||||
// $('#gamepadTab').show();
|
||||
|
||||
gamepad = new Gamepad();
|
||||
|
||||
gamepad.bind(Gamepad.Event.CONNECTED, function(device) {
|
||||
console.log(device)
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.DISCONNECTED, function(device) {
|
||||
// gamepad disconnected
|
||||
console.log(device)
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.UNSUPPORTED, function(device) {
|
||||
// an unsupported gamepad connected (add new mapping)
|
||||
console.log(device)
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.BUTTON_DOWN, function(e) {
|
||||
console.log(e.control, e.gamepad.id);
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.BUTTON_UP, function(e) {
|
||||
// e.control of gamepad e.gamepad released
|
||||
console.log(e.control, e.gamepad.id)
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.AXIS_CHANGED, function(e) {
|
||||
// e.axis changed to value e.value for gamepad e.gamepad
|
||||
console.log(e.axis, e.value, e.gamepad.id)
|
||||
});
|
||||
|
||||
// gamepad.bind(Gamepad.Event.TICK, function(gamepads) {
|
||||
// // gamepads were updated (around 60 times a second)
|
||||
// });
|
||||
|
||||
if (!gamepad.init()) {
|
||||
// Your browser does not support gamepads, get the latest Google Chrome or Firefox
|
||||
}
|
||||
|
||||
gamepadInterval = setInterval(function() {
|
||||
// if (gamepad.gamepads.length > 0) {
|
||||
// $('#gamepadTab').show();
|
||||
// } else {
|
||||
// $('#gamepadTab').hide();
|
||||
// }
|
||||
}, 500)
|
||||
|
||||
});
|
|
@ -31,6 +31,7 @@ function manualcontrolPanel() {
|
|||
$('#grblPanel').hide()
|
||||
$('#updatePanel').hide()
|
||||
$('#troubleshootingPanel').hide()
|
||||
$('#gamepadPanel').hide()
|
||||
}
|
||||
|
||||
function grblPanel() {
|
||||
|
@ -39,6 +40,7 @@ function grblPanel() {
|
|||
$('#grblPanel').show()
|
||||
$('#updatePanel').hide()
|
||||
$('#troubleshootingPanel').hide()
|
||||
$('#gamepadPanel').hide()
|
||||
}
|
||||
|
||||
function updatePanel() {
|
||||
|
@ -46,6 +48,7 @@ function updatePanel() {
|
|||
$('#grblPanel').hide()
|
||||
$('#updatePanel').show()
|
||||
$('#troubleshootingPanel').hide()
|
||||
$('#gamepadPanel').hide()
|
||||
}
|
||||
|
||||
function troubleshootingPanel() {
|
||||
|
@ -53,4 +56,13 @@ function troubleshootingPanel() {
|
|||
$('#grblPanel').hide()
|
||||
$('#updatePanel').hide()
|
||||
$('#troubleshootingPanel').show()
|
||||
$('#gamepadPanel').hide()
|
||||
}
|
||||
|
||||
function gamepadPanel() {
|
||||
$('#manualControlPanel').hide()
|
||||
$('#grblPanel').hide()
|
||||
$('#updatePanel').hide()
|
||||
$('#troubleshootingPanel').hide()
|
||||
$('#gamepadPanel').show()
|
||||
}
|
|
@ -20,7 +20,7 @@ $(document).ready(function() {
|
|||
printLog("<span class='fg-red'>[ update ] </span><span class='fg-green'>You are already running OpenBuilds Machine Driver " + currentVersion + "</span>")
|
||||
}
|
||||
});
|
||||
}, 400)
|
||||
}, 1000)
|
||||
});
|
||||
|
||||
function updateTime() {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/node_modules/
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"indent_size": 1,
|
||||
"indent_char": "\t",
|
||||
"indent_level": 0,
|
||||
"indent_with_tabs": true,
|
||||
"preserve_newlines": true,
|
||||
"max_preserve_newlines": 4,
|
||||
"space_in_paren": false,
|
||||
"jslint_happy": false,
|
||||
"brace_style": "collapse",
|
||||
"keep_array_indentation": false,
|
||||
"keep_function_indentation": false,
|
||||
"eval_code": false,
|
||||
"unescape_strings": false,
|
||||
"break_chained_methods": false,
|
||||
"wrap_line_length": 100
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"evil": true,
|
||||
"forin": true,
|
||||
"jquery": true,
|
||||
"browser": true,
|
||||
"devel": true,
|
||||
"bitwise": true,
|
||||
"camelcase": true,
|
||||
"curly": true,
|
||||
"eqeqeq": false,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"plusplus": false,
|
||||
"quotmark": "single",
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"maxparams": 0,
|
||||
"maxlen": 120,
|
||||
"laxbreak": true,
|
||||
"loopfunc": true,
|
||||
"predef": ["require", "define", "module"]
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
module.exports = function(grunt) {
|
||||
'use strict';
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
jsbeautifier: {
|
||||
files: ['Gruntfile.js', 'gamepad.js', 'test/**/*.js'],
|
||||
options: grunt.file.readJSON('.jsbeautifyrc')
|
||||
},
|
||||
|
||||
// Run JSHint on all sources
|
||||
jshint: {
|
||||
options: {
|
||||
jshintrc: './.jshintrc'
|
||||
},
|
||||
all: ['Gruntfile.js', 'gamepad.js', 'test/**/*.js']
|
||||
},
|
||||
|
||||
// Run js-uglify on the actual library code
|
||||
uglify: {
|
||||
lib: {
|
||||
files: {
|
||||
'gamepad.min.js': ['gamepad.js']
|
||||
},
|
||||
options: {
|
||||
compress: {
|
||||
sequences: false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Run tests using buster
|
||||
buster: {
|
||||
libRaw: {
|
||||
test: {
|
||||
reporter: 'specification',
|
||||
'config-group': 'Library tests raw'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Create YUI documentation
|
||||
yuidoc: {
|
||||
lib: {
|
||||
name: '<%= pkg.name %>',
|
||||
description: '<%= pkg.description %>',
|
||||
version: '<%= pkg.version %>',
|
||||
url: '<%= pkg.homepage %>',
|
||||
options: {
|
||||
paths: ['.'],
|
||||
exclude: '*.min.js',
|
||||
outdir: 'doc/'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-buster');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-yuidoc');
|
||||
grunt.loadNpmTasks('grunt-jsbeautifier');
|
||||
|
||||
grunt.registerTask('format', ['jsbeautifier', 'jshint']);
|
||||
grunt.registerTask('compile', ['uglify']);
|
||||
grunt.registerTask('document', ['yuidoc']);
|
||||
grunt.registerTask('test', ['buster']);
|
||||
grunt.registerTask('default', ['format', 'compile', 'test', 'document']);
|
||||
};
|
|
@ -0,0 +1,80 @@
|
|||
HTML5-JavaScript-Gamepad-Controller-Library
|
||||
===========================================
|
||||
|
||||
**Library for accessing gamepads in modern browsers.**
|
||||
|
||||
* Works with modern browsers and has mappings to many controllers.
|
||||
* Very easy to add mappings to new controllers.
|
||||
* Lightweight.
|
||||
* Includes settings for deadzone and maximization.
|
||||
* Simple event-based system.
|
||||
* Includes state change events.
|
||||
* Minimal working example provided.
|
||||
* Does not depend on any other library.
|
||||
* Includes minimized version.
|
||||
|
||||
|
||||
How to use
|
||||
----------
|
||||
* Include the library.
|
||||
```javascript
|
||||
<script src="gamepad.js"></script>
|
||||
```
|
||||
|
||||
* Create an instance of the Gamepad class.
|
||||
```javascript
|
||||
var gamepad = new Gamepad();
|
||||
```
|
||||
|
||||
* Bind to the events
|
||||
```javascript
|
||||
gamepad.bind(Gamepad.Event.CONNECTED, function(device) {
|
||||
// a new gamepad connected
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.DISCONNECTED, function(device) {
|
||||
// gamepad disconnected
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.UNSUPPORTED, function(device) {
|
||||
// an unsupported gamepad connected (add new mapping)
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.BUTTON_DOWN, function(e) {
|
||||
// e.control of gamepad e.gamepad pressed down
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.BUTTON_UP, function(e) {
|
||||
// e.control of gamepad e.gamepad released
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.AXIS_CHANGED, function(e) {
|
||||
// e.axis changed to value e.value for gamepad e.gamepad
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.TICK, function(gamepads) {
|
||||
// gamepads were updated (around 60 times a second)
|
||||
});
|
||||
```
|
||||
|
||||
* Initilize the gamepads
|
||||
```javascript
|
||||
if (!gamepad.init()) {
|
||||
// Your browser does not support gamepads, get the latest Google Chrome or Firefox
|
||||
}
|
||||
```
|
||||
|
||||
* Try the working example in index.html for more tips
|
||||
|
||||
Development
|
||||
----------
|
||||
|
||||
The library is built using [grunt](http://gruntjs.com/) and [node.js](http://www.nodejs.org/).
|
||||
Have them installed according to their installation guidelines.
|
||||
|
||||
The build sequence consists of the following tasks:
|
||||
* 'format', executing js-beautify (according to .jsbeautifyrc) and jshint (according to .jshintrc)
|
||||
* 'compile', executing UglifyJS2
|
||||
* 'document', using [yuidoc](http://yui.github.io/yuidoc/)
|
||||
|
||||
The default grunt task executes them in the given order.
|
|
@ -0,0 +1,21 @@
|
|||
YUI.add("yuidoc-meta", function(Y) {
|
||||
Y.YUIDoc = { meta: {
|
||||
"classes": [
|
||||
"AnimFrameUpdateStrategy",
|
||||
"FirefoxPlatform",
|
||||
"Gamepad",
|
||||
"ManualUpdateStrategy",
|
||||
"WebKitPlatform"
|
||||
],
|
||||
"modules": [
|
||||
"Gamepad"
|
||||
],
|
||||
"allModules": [
|
||||
{
|
||||
"displayName": "Gamepad",
|
||||
"name": "Gamepad",
|
||||
"description": "This strategy uses a timer function to call an update function.\nThe timer (re)start function can be provided or the strategy reverts to\none of the window.*requestAnimationFrame variants."
|
||||
}
|
||||
]
|
||||
} };
|
||||
});
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 491 B |
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 6.2 KiB |
|
@ -0,0 +1,783 @@
|
|||
/*
|
||||
Font sizes for all selectors other than the body are given in percentages,
|
||||
with 100% equal to 13px. To calculate a font size percentage, multiply the
|
||||
desired size in pixels by 7.6923076923.
|
||||
|
||||
Here's a quick lookup table:
|
||||
|
||||
10px - 76.923%
|
||||
11px - 84.615%
|
||||
12px - 92.308%
|
||||
13px - 100%
|
||||
14px - 107.692%
|
||||
15px - 115.385%
|
||||
16px - 123.077%
|
||||
17px - 130.769%
|
||||
18px - 138.462%
|
||||
19px - 146.154%
|
||||
20px - 153.846%
|
||||
*/
|
||||
|
||||
html {
|
||||
background: #fff;
|
||||
color: #333;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
body {
|
||||
/*font: 13px/1.4 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', 'Bitstream Vera Sans', 'Helvetica', 'Arial', sans-serif;*/
|
||||
font: 13px/1.4 'Helvetica', 'Arial', sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* -- Links ----------------------------------------------------------------- */
|
||||
a {
|
||||
color: #356de4;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
a:hover { text-decoration: underline; }
|
||||
|
||||
/* "Jump to Table of Contents" link is shown to assistive tools, but hidden from
|
||||
sight until it's focused. */
|
||||
.jump {
|
||||
position: absolute;
|
||||
padding: 3px 6px;
|
||||
left: -99999px;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.jump:focus { left: 40%; }
|
||||
|
||||
/* -- Paragraphs ------------------------------------------------------------ */
|
||||
p { margin: 1.3em 0; }
|
||||
dd p, td p { margin-bottom: 0; }
|
||||
dd p:first-child, td p:first-child { margin-top: 0; }
|
||||
|
||||
/* -- Headings -------------------------------------------------------------- */
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: #D98527;/*was #f80*/
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
font-weight: bold;
|
||||
line-height: 1.1;
|
||||
margin: 1.1em 0 0.5em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 184.6%;
|
||||
color: #30418C;
|
||||
margin: 0.75em 0 0.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 153.846%;
|
||||
color: #E48A2B;
|
||||
}
|
||||
|
||||
h3 { font-size: 138.462%; }
|
||||
|
||||
h4 {
|
||||
border-bottom: 1px solid #DBDFEA;
|
||||
color: #E48A2B;
|
||||
font-size: 115.385%;
|
||||
font-weight: normal;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
h5, h6 { font-size: 107.692%; }
|
||||
|
||||
/* -- Code and examples ----------------------------------------------------- */
|
||||
code, kbd, pre, samp {
|
||||
font-family: Menlo, Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;
|
||||
font-size: 92.308%;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
p code, p kbd, p samp, li code {
|
||||
background: #FCFBFA;
|
||||
border: 1px solid #EFEEED;
|
||||
padding: 0 3px;
|
||||
}
|
||||
|
||||
a code, a kbd, a samp,
|
||||
pre code, pre kbd, pre samp,
|
||||
table code, table kbd, table samp,
|
||||
.intro code, .intro kbd, .intro samp,
|
||||
.toc code, .toc kbd, .toc samp {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
pre.code, pre.terminal, pre.cmd {
|
||||
overflow-x: auto;
|
||||
*overflow-x: scroll;
|
||||
padding: 0.3em 0.6em;
|
||||
}
|
||||
|
||||
pre.code {
|
||||
background: #FCFBFA;
|
||||
border: 1px solid #EFEEED;
|
||||
border-left-width: 5px;
|
||||
}
|
||||
|
||||
pre.terminal, pre.cmd {
|
||||
background: #F0EFFC;
|
||||
border: 1px solid #D0CBFB;
|
||||
border-left: 5px solid #D0CBFB;
|
||||
}
|
||||
|
||||
/* Don't reduce the font size of <code>/<kbd>/<samp> elements inside <pre>
|
||||
blocks. */
|
||||
pre code, pre kbd, pre samp { font-size: 100%; }
|
||||
|
||||
/* Used to denote text that shouldn't be selectable, such as line numbers or
|
||||
shell prompts. Guess which browser this doesn't work in. */
|
||||
.noselect {
|
||||
-moz-user-select: -moz-none;
|
||||
-khtml-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* -- Lists ----------------------------------------------------------------- */
|
||||
dd { margin: 0.2em 0 0.7em 1em; }
|
||||
dl { margin: 1em 0; }
|
||||
dt { font-weight: bold; }
|
||||
|
||||
/* -- Tables ---------------------------------------------------------------- */
|
||||
caption, th { text-align: left; }
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td, th {
|
||||
border: 1px solid #fff;
|
||||
padding: 5px 12px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
td { background: #E6E9F5; }
|
||||
td dl { margin: 0; }
|
||||
td dl dl { margin: 1em 0; }
|
||||
td pre:first-child { margin-top: 0; }
|
||||
|
||||
th {
|
||||
background: #D2D7E6;/*#97A0BF*/
|
||||
border-bottom: none;
|
||||
border-top: none;
|
||||
color: #000;/*#FFF1D5*/
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
font-weight: bold;
|
||||
line-height: 1.3;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
|
||||
/* -- Layout and Content ---------------------------------------------------- */
|
||||
#doc {
|
||||
margin: auto;
|
||||
min-width: 1024px;
|
||||
}
|
||||
|
||||
.content { padding: 0 20px 0 25px; }
|
||||
|
||||
.sidebar {
|
||||
padding: 0 15px 0 10px;
|
||||
}
|
||||
#bd {
|
||||
padding: 7px 0 130px;
|
||||
position: relative;
|
||||
width: 99%;
|
||||
}
|
||||
|
||||
/* -- Table of Contents ----------------------------------------------------- */
|
||||
|
||||
/* The #toc id refers to the single global table of contents, while the .toc
|
||||
class refers to generic TOC lists that could be used throughout the page. */
|
||||
|
||||
.toc code, .toc kbd, .toc samp { font-size: 100%; }
|
||||
.toc li { font-weight: bold; }
|
||||
.toc li li { font-weight: normal; }
|
||||
|
||||
/* -- Intro and Example Boxes ----------------------------------------------- */
|
||||
/*
|
||||
.intro, .example { margin-bottom: 2em; }
|
||||
.example {
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
-moz-box-shadow: 0 0 5px #bfbfbf;
|
||||
-webkit-box-shadow: 0 0 5px #bfbfbf;
|
||||
box-shadow: 0 0 5px #bfbfbf;
|
||||
padding: 1em;
|
||||
}
|
||||
.intro {
|
||||
background: none repeat scroll 0 0 #F0F1F8; border: 1px solid #D4D8EB; padding: 0 1em;
|
||||
}
|
||||
*/
|
||||
|
||||
/* -- Other Styles ---------------------------------------------------------- */
|
||||
|
||||
/* These are probably YUI-specific, and should be moved out of Selleck's default
|
||||
theme. */
|
||||
|
||||
.button {
|
||||
border: 1px solid #dadada;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
color: #444;
|
||||
display: inline-block;
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
font-size: 92.308%;
|
||||
font-weight: bold;
|
||||
padding: 4px 13px 3px;
|
||||
-moz-text-shadow: 1px 1px 0 #fff;
|
||||
-webkit-text-shadow: 1px 1px 0 #fff;
|
||||
text-shadow: 1px 1px 0 #fff;
|
||||
white-space: nowrap;
|
||||
|
||||
background: #EFEFEF; /* old browsers */
|
||||
background: -moz-linear-gradient(top, #f5f5f5 0%, #efefef 50%, #e5e5e5 51%, #dfdfdf 100%); /* firefox */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(50%,#efefef), color-stop(51%,#e5e5e5), color-stop(100%,#dfdfdf)); /* webkit */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#dfdfdf',GradientType=0 ); /* ie */
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
border-color: #466899;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
-moz-text-shadow: 1px 1px 0 #222;
|
||||
-webkit-text-shadow: 1px 1px 0 #222;
|
||||
text-shadow: 1px 1px 0 #222;
|
||||
|
||||
background: #6396D8; /* old browsers */
|
||||
background: -moz-linear-gradient(top, #6396D8 0%, #5A83BC 50%, #547AB7 51%, #466899 100%); /* firefox */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6396D8), color-stop(50%,#5A83BC), color-stop(51%,#547AB7), color-stop(100%,#466899)); /* webkit */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6396D8', endColorstr='#466899',GradientType=0 ); /* ie */
|
||||
}
|
||||
|
||||
.newwindow { text-align: center; }
|
||||
|
||||
.header .version em {
|
||||
display: block;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
#classdocs .item {
|
||||
border-bottom: 1px solid #466899;
|
||||
margin: 1em 0;
|
||||
padding: 1.5em;
|
||||
}
|
||||
|
||||
#classdocs .item .params p,
|
||||
#classdocs .item .returns p,{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#classdocs .item em code, #classdocs .item em.comment {
|
||||
color: green;
|
||||
}
|
||||
|
||||
#classdocs .item em.comment a {
|
||||
color: green;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#classdocs .foundat {
|
||||
font-size: 11px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.attrs .emits {
|
||||
margin-left: 2em;
|
||||
padding: .5em;
|
||||
border-left: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
abbr {
|
||||
border-bottom: 1px dashed #ccc;
|
||||
font-size: 80%;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.prettyprint li.L0,
|
||||
.prettyprint li.L1,
|
||||
.prettyprint li.L2,
|
||||
.prettyprint li.L3,
|
||||
.prettyprint li.L5,
|
||||
.prettyprint li.L6,
|
||||
.prettyprint li.L7,
|
||||
.prettyprint li.L8 {
|
||||
list-style: decimal;
|
||||
}
|
||||
|
||||
ul li p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.method .name {
|
||||
font-size: 110%;
|
||||
}
|
||||
|
||||
.apidocs .methods .extends .method,
|
||||
.apidocs .properties .extends .property,
|
||||
.apidocs .attrs .extends .attr,
|
||||
.apidocs .events .extends .event {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.apidocs .methods .extends .inherited,
|
||||
.apidocs .properties .extends .inherited,
|
||||
.apidocs .attrs .extends .inherited,
|
||||
.apidocs .events .extends .inherited {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#hd {
|
||||
background: whiteSmoke;
|
||||
background: -moz-linear-gradient(top,#DCDBD9 0,#F6F5F3 100%);
|
||||
background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#DCDBD9),color-stop(100%,#F6F5F3));
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dcdbd9',endColorstr='#F6F5F3',GradientType=0);
|
||||
border-bottom: 1px solid #DFDFDF;
|
||||
padding: 0 15px 1px 20px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
#hd img {
|
||||
margin-right: 10px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
/* -- API Docs CSS ---------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
This file is organized so that more generic styles are nearer the top, and more
|
||||
specific styles are nearer the bottom of the file. This allows us to take full
|
||||
advantage of the cascade to avoid redundant style rules. Please respect this
|
||||
convention when making changes.
|
||||
*/
|
||||
|
||||
/* -- Generic TabView styles ------------------------------------------------ */
|
||||
|
||||
/*
|
||||
These styles apply to all API doc tabviews. To change styles only for a
|
||||
specific tabview, see the other sections below.
|
||||
*/
|
||||
|
||||
.yui3-js-enabled .apidocs .tabview {
|
||||
visibility: hidden; /* Hide until the TabView finishes rendering. */
|
||||
_visibility: visible;
|
||||
}
|
||||
|
||||
.apidocs .tabview.yui3-tabview-content { visibility: visible; }
|
||||
.apidocs .tabview .yui3-tabview-panel { background: #fff; }
|
||||
|
||||
/* -- Generic Content Styles ------------------------------------------------ */
|
||||
|
||||
/* Headings */
|
||||
h2, h3, h4, h5, h6 {
|
||||
border: none;
|
||||
color: #30418C;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.link-docs {
|
||||
float: right;
|
||||
font-size: 15px;
|
||||
margin: 4px 4px 6px;
|
||||
padding: 6px 30px 5px;
|
||||
}
|
||||
|
||||
.apidocs { zoom: 1; }
|
||||
|
||||
/* Generic box styles. */
|
||||
.apidocs .box {
|
||||
border: 1px solid;
|
||||
border-radius: 3px;
|
||||
margin: 1em 0;
|
||||
padding: 0 1em;
|
||||
}
|
||||
|
||||
/* A flag is a compact, capsule-like indicator of some kind. It's used to
|
||||
indicate private and protected items, item return types, etc. in an
|
||||
attractive and unobtrusive way. */
|
||||
.apidocs .flag {
|
||||
background: #bababa;
|
||||
border-radius: 3px;
|
||||
color: #fff;
|
||||
font-size: 11px;
|
||||
margin: 0 0.5em;
|
||||
padding: 2px 4px 1px;
|
||||
}
|
||||
|
||||
/* Class/module metadata such as "Uses", "Extends", "Defined in", etc. */
|
||||
.apidocs .meta {
|
||||
background: #f9f9f9;
|
||||
border-color: #efefef;
|
||||
color: #555;
|
||||
font-size: 11px;
|
||||
padding: 3px 6px;
|
||||
}
|
||||
|
||||
.apidocs .meta p { margin: 0; }
|
||||
|
||||
/* Deprecation warning. */
|
||||
.apidocs .box.deprecated,
|
||||
.apidocs .flag.deprecated {
|
||||
background: #fdac9f;
|
||||
border: 1px solid #fd7775;
|
||||
}
|
||||
|
||||
.apidocs .box.deprecated p { margin: 0.5em 0; }
|
||||
.apidocs .flag.deprecated { color: #333; }
|
||||
|
||||
/* Module/Class intro description. */
|
||||
.apidocs .intro {
|
||||
background: #f0f1f8;
|
||||
border-color: #d4d8eb;
|
||||
}
|
||||
|
||||
/* Loading spinners. */
|
||||
#bd.loading .apidocs,
|
||||
#api-list.loading .yui3-tabview-panel {
|
||||
background: #fff url(../img/spinner.gif) no-repeat center 70px;
|
||||
min-height: 150px;
|
||||
}
|
||||
|
||||
#bd.loading .apidocs .content,
|
||||
#api-list.loading .yui3-tabview-panel .apis {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.apidocs .no-visible-items { color: #666; }
|
||||
|
||||
/* Generic inline list. */
|
||||
.apidocs ul.inline {
|
||||
display: inline;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.apidocs ul.inline li { display: inline; }
|
||||
|
||||
/* Comma-separated list. */
|
||||
.apidocs ul.commas li:after { content: ','; }
|
||||
.apidocs ul.commas li:last-child:after { content: ''; }
|
||||
|
||||
/* Keyboard shortcuts. */
|
||||
kbd .cmd { font-family: Monaco, Helvetica; }
|
||||
|
||||
/* -- Generic Access Level styles ------------------------------------------- */
|
||||
.apidocs .item.protected,
|
||||
.apidocs .item.private,
|
||||
.apidocs .index-item.protected,
|
||||
.apidocs .index-item.deprecated,
|
||||
.apidocs .index-item.private {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.show-deprecated .item.deprecated,
|
||||
.show-deprecated .index-item.deprecated,
|
||||
.show-protected .item.protected,
|
||||
.show-protected .index-item.protected,
|
||||
.show-private .item.private,
|
||||
.show-private .index-item.private {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.hide-inherited .item.inherited,
|
||||
.hide-inherited .index-item.inherited {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* -- Generic Item Index styles --------------------------------------------- */
|
||||
.apidocs .index { margin: 1.5em 0 3em; }
|
||||
|
||||
.apidocs .index h3 {
|
||||
border-bottom: 1px solid #efefef;
|
||||
color: #333;
|
||||
font-size: 13px;
|
||||
margin: 2em 0 0.6em;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.apidocs .index .no-visible-items { margin-top: 2em; }
|
||||
|
||||
.apidocs .index-list {
|
||||
border-color: #efefef;
|
||||
font-size: 12px;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
-moz-column-count: 4;
|
||||
-moz-column-gap: 10px;
|
||||
-moz-column-width: 170px;
|
||||
-ms-column-count: 4;
|
||||
-ms-column-gap: 10px;
|
||||
-ms-column-width: 170px;
|
||||
-o-column-count: 4;
|
||||
-o-column-gap: 10px;
|
||||
-o-column-width: 170px;
|
||||
-webkit-column-count: 4;
|
||||
-webkit-column-gap: 10px;
|
||||
-webkit-column-width: 170px;
|
||||
column-count: 4;
|
||||
column-gap: 10px;
|
||||
column-width: 170px;
|
||||
}
|
||||
|
||||
.apidocs .no-columns .index-list {
|
||||
-moz-column-count: 1;
|
||||
-ms-column-count: 1;
|
||||
-o-column-count: 1;
|
||||
-webkit-column-count: 1;
|
||||
column-count: 1;
|
||||
}
|
||||
|
||||
.apidocs .index-item { white-space: nowrap; }
|
||||
|
||||
.apidocs .index-item .flag {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #afafaf;
|
||||
display: inline;
|
||||
margin: 0 0 0 0.2em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* -- Generic API item styles ----------------------------------------------- */
|
||||
.apidocs .args {
|
||||
display: inline;
|
||||
margin: 0 0.5em;
|
||||
}
|
||||
|
||||
.apidocs .flag.chainable { background: #46ca3b; }
|
||||
.apidocs .flag.protected { background: #9b86fc; }
|
||||
.apidocs .flag.private { background: #fd6b1b; }
|
||||
.apidocs .flag.async { background: #356de4; }
|
||||
.apidocs .flag.required { background: #e60923; }
|
||||
|
||||
.apidocs .item {
|
||||
border-bottom: 1px solid #efefef;
|
||||
margin: 1.5em 0 2em;
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
.apidocs .item h4,
|
||||
.apidocs .item h5,
|
||||
.apidocs .item h6 {
|
||||
color: #333;
|
||||
font-family: inherit;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.apidocs .item .description p,
|
||||
.apidocs .item pre.code {
|
||||
margin: 1em 0 0;
|
||||
}
|
||||
|
||||
.apidocs .item .meta {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.apidocs .item .name {
|
||||
display: inline;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.apidocs .item .type,
|
||||
.apidocs .item .type a,
|
||||
.apidocs .returns-inline {
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.apidocs .item .type,
|
||||
.apidocs .returns-inline {
|
||||
font-size: 11px;
|
||||
margin: 0 0 0 0;
|
||||
}
|
||||
|
||||
.apidocs .item .type a { border-bottom: 1px dotted #afafaf; }
|
||||
.apidocs .item .type a:hover { border: none; }
|
||||
|
||||
/* -- Item Parameter List --------------------------------------------------- */
|
||||
.apidocs .params-list {
|
||||
list-style: square;
|
||||
margin: 1em 0 0 2em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.apidocs .param { margin-bottom: 1em; }
|
||||
|
||||
.apidocs .param .type,
|
||||
.apidocs .param .type a {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.apidocs .param .type {
|
||||
margin: 0 0 0 0.5em;
|
||||
*margin-left: 0.5em;
|
||||
}
|
||||
|
||||
.apidocs .param-name { font-weight: bold; }
|
||||
|
||||
/* -- Item "Emits" block ---------------------------------------------------- */
|
||||
.apidocs .item .emits {
|
||||
background: #f9f9f9;
|
||||
border-color: #eaeaea;
|
||||
}
|
||||
|
||||
/* -- Item "Returns" block -------------------------------------------------- */
|
||||
.apidocs .item .returns .type,
|
||||
.apidocs .item .returns .type a {
|
||||
font-size: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* -- Class Constructor block ----------------------------------------------- */
|
||||
.apidocs .constructor .item {
|
||||
border: none;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
/* -- File Source View ------------------------------------------------------ */
|
||||
.apidocs .file pre.code,
|
||||
#doc .apidocs .file pre.prettyprint {
|
||||
background: inherit;
|
||||
border: none;
|
||||
overflow: visible;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.apidocs .L0,
|
||||
.apidocs .L1,
|
||||
.apidocs .L2,
|
||||
.apidocs .L3,
|
||||
.apidocs .L4,
|
||||
.apidocs .L5,
|
||||
.apidocs .L6,
|
||||
.apidocs .L7,
|
||||
.apidocs .L8,
|
||||
.apidocs .L9 {
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
/* -- Submodule List -------------------------------------------------------- */
|
||||
.apidocs .module-submodule-description {
|
||||
font-size: 12px;
|
||||
margin: 0.3em 0 1em;
|
||||
}
|
||||
|
||||
.apidocs .module-submodule-description p:first-child { margin-top: 0; }
|
||||
|
||||
/* -- Sidebar TabView ------------------------------------------------------- */
|
||||
#api-tabview { margin-top: 0.6em; }
|
||||
|
||||
#api-tabview-filter,
|
||||
#api-tabview-panel {
|
||||
border: 1px solid #dfdfdf;
|
||||
}
|
||||
|
||||
#api-tabview-filter {
|
||||
border-bottom: none;
|
||||
border-top: none;
|
||||
padding: 0.6em 10px 0 10px;
|
||||
}
|
||||
|
||||
#api-tabview-panel { border-top: none; }
|
||||
#api-filter { width: 97%; }
|
||||
|
||||
/* -- Content TabView ------------------------------------------------------- */
|
||||
#classdocs .yui3-tabview-panel { border: none; }
|
||||
|
||||
/* -- Source File Contents -------------------------------------------------- */
|
||||
.prettyprint li.L0,
|
||||
.prettyprint li.L1,
|
||||
.prettyprint li.L2,
|
||||
.prettyprint li.L3,
|
||||
.prettyprint li.L5,
|
||||
.prettyprint li.L6,
|
||||
.prettyprint li.L7,
|
||||
.prettyprint li.L8 {
|
||||
list-style: decimal;
|
||||
}
|
||||
|
||||
/* -- API options ----------------------------------------------------------- */
|
||||
#api-options {
|
||||
font-size: 11px;
|
||||
margin-top: 2.2em;
|
||||
position: absolute;
|
||||
right: 1.5em;
|
||||
}
|
||||
|
||||
/*#api-options label { margin-right: 0.6em; }*/
|
||||
|
||||
/* -- API list -------------------------------------------------------------- */
|
||||
#api-list {
|
||||
margin-top: 1.5em;
|
||||
*zoom: 1;
|
||||
}
|
||||
|
||||
.apis {
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0.5em 0 0.5em 0.4em;
|
||||
}
|
||||
|
||||
.apis a {
|
||||
border: 1px solid transparent;
|
||||
display: block;
|
||||
margin: 0 0 0 -4px;
|
||||
padding: 1px 4px 0;
|
||||
text-decoration: none;
|
||||
_border: none;
|
||||
_display: inline;
|
||||
}
|
||||
|
||||
.apis a:hover,
|
||||
.apis a:focus {
|
||||
background: #E8EDFC;
|
||||
background: -moz-linear-gradient(top, #e8edfc 0%, #becef7 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#E8EDFC), color-stop(100%,#BECEF7));
|
||||
border-color: #AAC0FA;
|
||||
border-radius: 3px;
|
||||
color: #333;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.api-list-item a:hover,
|
||||
.api-list-item a:focus {
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px #fff;
|
||||
}
|
||||
|
||||
.apis .message { color: #888; }
|
||||
.apis .result a { padding: 3px 5px 2px; }
|
||||
|
||||
.apis .result .type {
|
||||
right: 4px;
|
||||
top: 7px;
|
||||
}
|
||||
|
||||
.api-list-item .yui3-highlight {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 740 B |
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 2.6 KiB |
|
@ -0,0 +1,10 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Redirector</title>
|
||||
<meta http-equiv="refresh" content="0;url=../">
|
||||
</head>
|
||||
<body>
|
||||
<a href="../">Click here to redirect</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,52 @@
|
|||
YUI.add('api-filter', function (Y) {
|
||||
|
||||
Y.APIFilter = Y.Base.create('apiFilter', Y.Base, [Y.AutoCompleteBase], {
|
||||
// -- Initializer ----------------------------------------------------------
|
||||
initializer: function () {
|
||||
this._bindUIACBase();
|
||||
this._syncUIACBase();
|
||||
},
|
||||
getDisplayName: function(name) {
|
||||
|
||||
Y.each(Y.YUIDoc.meta.allModules, function(i) {
|
||||
if (i.name === name && i.displayName) {
|
||||
name = i.displayName;
|
||||
}
|
||||
});
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}, {
|
||||
// -- Attributes -----------------------------------------------------------
|
||||
ATTRS: {
|
||||
resultHighlighter: {
|
||||
value: 'phraseMatch'
|
||||
},
|
||||
|
||||
// May be set to "classes" or "modules".
|
||||
queryType: {
|
||||
value: 'classes'
|
||||
},
|
||||
|
||||
source: {
|
||||
valueFn: function() {
|
||||
var self = this;
|
||||
return function(q) {
|
||||
var data = Y.YUIDoc.meta[self.get('queryType')],
|
||||
out = [];
|
||||
Y.each(data, function(v) {
|
||||
if (v.toLowerCase().indexOf(q.toLowerCase()) > -1) {
|
||||
out.push(v);
|
||||
}
|
||||
});
|
||||
return out;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}, '3.4.0', {requires: [
|
||||
'autocomplete-base', 'autocomplete-highlighters', 'autocomplete-sources'
|
||||
]});
|
|
@ -0,0 +1,251 @@
|
|||
YUI.add('api-list', function (Y) {
|
||||
|
||||
var Lang = Y.Lang,
|
||||
YArray = Y.Array,
|
||||
|
||||
APIList = Y.namespace('APIList'),
|
||||
|
||||
classesNode = Y.one('#api-classes'),
|
||||
inputNode = Y.one('#api-filter'),
|
||||
modulesNode = Y.one('#api-modules'),
|
||||
tabviewNode = Y.one('#api-tabview'),
|
||||
|
||||
tabs = APIList.tabs = {},
|
||||
|
||||
filter = APIList.filter = new Y.APIFilter({
|
||||
inputNode : inputNode,
|
||||
maxResults: 1000,
|
||||
|
||||
on: {
|
||||
results: onFilterResults
|
||||
}
|
||||
}),
|
||||
|
||||
search = APIList.search = new Y.APISearch({
|
||||
inputNode : inputNode,
|
||||
maxResults: 100,
|
||||
|
||||
on: {
|
||||
clear : onSearchClear,
|
||||
results: onSearchResults
|
||||
}
|
||||
}),
|
||||
|
||||
tabview = APIList.tabview = new Y.TabView({
|
||||
srcNode : tabviewNode,
|
||||
panelNode: '#api-tabview-panel',
|
||||
render : true,
|
||||
|
||||
on: {
|
||||
selectionChange: onTabSelectionChange
|
||||
}
|
||||
}),
|
||||
|
||||
focusManager = APIList.focusManager = tabviewNode.plug(Y.Plugin.NodeFocusManager, {
|
||||
circular : true,
|
||||
descendants: '#api-filter, .yui3-tab-panel-selected .api-list-item a, .yui3-tab-panel-selected .result a',
|
||||
keys : {next: 'down:40', previous: 'down:38'}
|
||||
}).focusManager,
|
||||
|
||||
LIST_ITEM_TEMPLATE =
|
||||
'<li class="api-list-item {typeSingular}">' +
|
||||
'<a href="{rootPath}{typePlural}/{name}.html">{displayName}</a>' +
|
||||
'</li>';
|
||||
|
||||
// -- Init ---------------------------------------------------------------------
|
||||
|
||||
// Duckpunch FocusManager's key event handling to prevent it from handling key
|
||||
// events when a modifier is pressed.
|
||||
Y.before(function (e, activeDescendant) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
|
||||
return new Y.Do.Prevent();
|
||||
}
|
||||
}, focusManager, '_focusPrevious', focusManager);
|
||||
|
||||
Y.before(function (e, activeDescendant) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
|
||||
return new Y.Do.Prevent();
|
||||
}
|
||||
}, focusManager, '_focusNext', focusManager);
|
||||
|
||||
// Create a mapping of tabs in the tabview so we can refer to them easily later.
|
||||
tabview.each(function (tab, index) {
|
||||
var name = tab.get('label').toLowerCase();
|
||||
|
||||
tabs[name] = {
|
||||
index: index,
|
||||
name : name,
|
||||
tab : tab
|
||||
};
|
||||
});
|
||||
|
||||
// Switch tabs on Ctrl/Cmd-Left/Right arrows.
|
||||
tabviewNode.on('key', onTabSwitchKey, 'down:37,39');
|
||||
|
||||
// Focus the filter input when the `/` key is pressed.
|
||||
Y.one(Y.config.doc).on('key', onSearchKey, 'down:83');
|
||||
|
||||
// Keep the Focus Manager up to date.
|
||||
inputNode.on('focus', function () {
|
||||
focusManager.set('activeDescendant', inputNode);
|
||||
});
|
||||
|
||||
// Update all tabview links to resolved URLs.
|
||||
tabview.get('panelNode').all('a').each(function (link) {
|
||||
link.setAttribute('href', link.get('href'));
|
||||
});
|
||||
|
||||
// -- Private Functions --------------------------------------------------------
|
||||
function getFilterResultNode() {
|
||||
return filter.get('queryType') === 'classes' ? classesNode : modulesNode;
|
||||
}
|
||||
|
||||
// -- Event Handlers -----------------------------------------------------------
|
||||
function onFilterResults(e) {
|
||||
var frag = Y.one(Y.config.doc.createDocumentFragment()),
|
||||
resultNode = getFilterResultNode(),
|
||||
typePlural = filter.get('queryType'),
|
||||
typeSingular = typePlural === 'classes' ? 'class' : 'module';
|
||||
|
||||
if (e.results.length) {
|
||||
YArray.each(e.results, function (result) {
|
||||
frag.append(Lang.sub(LIST_ITEM_TEMPLATE, {
|
||||
rootPath : APIList.rootPath,
|
||||
displayName : filter.getDisplayName(result.highlighted),
|
||||
name : result.text,
|
||||
typePlural : typePlural,
|
||||
typeSingular: typeSingular
|
||||
}));
|
||||
});
|
||||
} else {
|
||||
frag.append(
|
||||
'<li class="message">' +
|
||||
'No ' + typePlural + ' found.' +
|
||||
'</li>'
|
||||
);
|
||||
}
|
||||
|
||||
resultNode.empty(true);
|
||||
resultNode.append(frag);
|
||||
|
||||
focusManager.refresh();
|
||||
}
|
||||
|
||||
function onSearchClear(e) {
|
||||
|
||||
focusManager.refresh();
|
||||
}
|
||||
|
||||
function onSearchKey(e) {
|
||||
var target = e.target;
|
||||
|
||||
if (target.test('input,select,textarea')
|
||||
|| target.get('isContentEditable')) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
inputNode.focus();
|
||||
focusManager.refresh();
|
||||
}
|
||||
|
||||
function onSearchResults(e) {
|
||||
var frag = Y.one(Y.config.doc.createDocumentFragment());
|
||||
|
||||
if (e.results.length) {
|
||||
YArray.each(e.results, function (result) {
|
||||
frag.append(result.display);
|
||||
});
|
||||
} else {
|
||||
frag.append(
|
||||
'<li class="message">' +
|
||||
'No results found. Maybe you\'ll have better luck with a ' +
|
||||
'different query?' +
|
||||
'</li>'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
focusManager.refresh();
|
||||
}
|
||||
|
||||
function onTabSelectionChange(e) {
|
||||
var tab = e.newVal,
|
||||
name = tab.get('label').toLowerCase();
|
||||
|
||||
tabs.selected = {
|
||||
index: tab.get('index'),
|
||||
name : name,
|
||||
tab : tab
|
||||
};
|
||||
|
||||
switch (name) {
|
||||
case 'classes': // fallthru
|
||||
case 'modules':
|
||||
filter.setAttrs({
|
||||
minQueryLength: 0,
|
||||
queryType : name
|
||||
});
|
||||
|
||||
search.set('minQueryLength', -1);
|
||||
|
||||
// Only send a request if this isn't the initially-selected tab.
|
||||
if (e.prevVal) {
|
||||
filter.sendRequest(filter.get('value'));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'everything':
|
||||
filter.set('minQueryLength', -1);
|
||||
search.set('minQueryLength', 1);
|
||||
|
||||
if (search.get('value')) {
|
||||
search.sendRequest(search.get('value'));
|
||||
} else {
|
||||
inputNode.focus();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// WTF? We shouldn't be here!
|
||||
filter.set('minQueryLength', -1);
|
||||
search.set('minQueryLength', -1);
|
||||
}
|
||||
|
||||
if (focusManager) {
|
||||
setTimeout(function () {
|
||||
focusManager.refresh();
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function onTabSwitchKey(e) {
|
||||
var currentTabIndex = tabs.selected.index;
|
||||
|
||||
if (!(e.ctrlKey || e.metaKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
switch (e.keyCode) {
|
||||
case 37: // left arrow
|
||||
if (currentTabIndex > 0) {
|
||||
tabview.selectChild(currentTabIndex - 1);
|
||||
inputNode.focus();
|
||||
}
|
||||
break;
|
||||
|
||||
case 39: // right arrow
|
||||
if (currentTabIndex < (Y.Object.size(tabs) - 2)) {
|
||||
tabview.selectChild(currentTabIndex + 1);
|
||||
inputNode.focus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}, '3.4.0', {requires: [
|
||||
'api-filter', 'api-search', 'event-key', 'node-focusmanager', 'tabview'
|
||||
]});
|
|
@ -0,0 +1,98 @@
|
|||
YUI.add('api-search', function (Y) {
|
||||
|
||||
var Lang = Y.Lang,
|
||||
Node = Y.Node,
|
||||
YArray = Y.Array;
|
||||
|
||||
Y.APISearch = Y.Base.create('apiSearch', Y.Base, [Y.AutoCompleteBase], {
|
||||
// -- Public Properties ----------------------------------------------------
|
||||
RESULT_TEMPLATE:
|
||||
'<li class="result {resultType}">' +
|
||||
'<a href="{url}">' +
|
||||
'<h3 class="title">{name}</h3>' +
|
||||
'<span class="type">{resultType}</span>' +
|
||||
'<div class="description">{description}</div>' +
|
||||
'<span class="className">{class}</span>' +
|
||||
'</a>' +
|
||||
'</li>',
|
||||
|
||||
// -- Initializer ----------------------------------------------------------
|
||||
initializer: function () {
|
||||
this._bindUIACBase();
|
||||
this._syncUIACBase();
|
||||
},
|
||||
|
||||
// -- Protected Methods ----------------------------------------------------
|
||||
_apiResultFilter: function (query, results) {
|
||||
// Filter components out of the results.
|
||||
return YArray.filter(results, function (result) {
|
||||
return result.raw.resultType === 'component' ? false : result;
|
||||
});
|
||||
},
|
||||
|
||||
_apiResultFormatter: function (query, results) {
|
||||
return YArray.map(results, function (result) {
|
||||
var raw = Y.merge(result.raw), // create a copy
|
||||
desc = raw.description || '';
|
||||
|
||||
// Convert description to text and truncate it if necessary.
|
||||
desc = Node.create('<div>' + desc + '</div>').get('text');
|
||||
|
||||
if (desc.length > 65) {
|
||||
desc = Y.Escape.html(desc.substr(0, 65)) + ' …';
|
||||
} else {
|
||||
desc = Y.Escape.html(desc);
|
||||
}
|
||||
|
||||
raw['class'] || (raw['class'] = '');
|
||||
raw.description = desc;
|
||||
|
||||
// Use the highlighted result name.
|
||||
raw.name = result.highlighted;
|
||||
|
||||
return Lang.sub(this.RESULT_TEMPLATE, raw);
|
||||
}, this);
|
||||
},
|
||||
|
||||
_apiTextLocator: function (result) {
|
||||
return result.displayName || result.name;
|
||||
}
|
||||
}, {
|
||||
// -- Attributes -----------------------------------------------------------
|
||||
ATTRS: {
|
||||
resultFormatter: {
|
||||
valueFn: function () {
|
||||
return this._apiResultFormatter;
|
||||
}
|
||||
},
|
||||
|
||||
resultFilters: {
|
||||
valueFn: function () {
|
||||
return this._apiResultFilter;
|
||||
}
|
||||
},
|
||||
|
||||
resultHighlighter: {
|
||||
value: 'phraseMatch'
|
||||
},
|
||||
|
||||
resultListLocator: {
|
||||
value: 'data.results'
|
||||
},
|
||||
|
||||
resultTextLocator: {
|
||||
valueFn: function () {
|
||||
return this._apiTextLocator;
|
||||
}
|
||||
},
|
||||
|
||||
source: {
|
||||
value: '/api/v1/search?q={query}&count={maxResults}'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}, '3.4.0', {requires: [
|
||||
'autocomplete-base', 'autocomplete-highlighters', 'autocomplete-sources',
|
||||
'escape'
|
||||
]});
|
|
@ -0,0 +1,370 @@
|
|||
YUI().use(
|
||||
'yuidoc-meta',
|
||||
'api-list', 'history-hash', 'node-screen', 'node-style', 'pjax',
|
||||
function (Y) {
|
||||
|
||||
var win = Y.config.win,
|
||||
localStorage = win.localStorage,
|
||||
|
||||
bdNode = Y.one('#bd'),
|
||||
|
||||
pjax,
|
||||
defaultRoute,
|
||||
|
||||
classTabView,
|
||||
selectedTab;
|
||||
|
||||
// Kill pjax functionality unless serving over HTTP.
|
||||
if (!Y.getLocation().protocol.match(/^https?\:/)) {
|
||||
Y.Router.html5 = false;
|
||||
}
|
||||
|
||||
// Create the default route with middleware which enables syntax highlighting
|
||||
// on the loaded content.
|
||||
defaultRoute = Y.Pjax.defaultRoute.concat(function (req, res, next) {
|
||||
prettyPrint();
|
||||
bdNode.removeClass('loading');
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
pjax = new Y.Pjax({
|
||||
container : '#docs-main',
|
||||
contentSelector: '#docs-main > .content',
|
||||
linkSelector : '#bd a',
|
||||
titleSelector : '#xhr-title',
|
||||
|
||||
navigateOnHash: true,
|
||||
root : '/',
|
||||
routes : [
|
||||
// -- / ----------------------------------------------------------------
|
||||
{
|
||||
path : '/(index.html)?',
|
||||
callbacks: defaultRoute
|
||||
},
|
||||
|
||||
// -- /classes/* -------------------------------------------------------
|
||||
{
|
||||
path : '/classes/:class.html*',
|
||||
callbacks: [defaultRoute, 'handleClasses']
|
||||
},
|
||||
|
||||
// -- /files/* ---------------------------------------------------------
|
||||
{
|
||||
path : '/files/*file',
|
||||
callbacks: [defaultRoute, 'handleFiles']
|
||||
},
|
||||
|
||||
// -- /modules/* -------------------------------------------------------
|
||||
{
|
||||
path : '/modules/:module.html*',
|
||||
callbacks: defaultRoute
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// -- Utility Functions --------------------------------------------------------
|
||||
|
||||
pjax.checkVisibility = function (tab) {
|
||||
tab || (tab = selectedTab);
|
||||
|
||||
if (!tab) { return; }
|
||||
|
||||
var panelNode = tab.get('panelNode'),
|
||||
visibleItems;
|
||||
|
||||
// If no items are visible in the tab panel due to the current visibility
|
||||
// settings, display a message to that effect.
|
||||
visibleItems = panelNode.all('.item,.index-item').some(function (itemNode) {
|
||||
if (itemNode.getComputedStyle('display') !== 'none') {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
panelNode.all('.no-visible-items').remove();
|
||||
|
||||
if (!visibleItems) {
|
||||
if (Y.one('#index .index-item')) {
|
||||
panelNode.append(
|
||||
'<div class="no-visible-items">' +
|
||||
'<p>' +
|
||||
'Some items are not shown due to the current visibility ' +
|
||||
'settings. Use the checkboxes at the upper right of this ' +
|
||||
'page to change the visibility settings.' +
|
||||
'</p>' +
|
||||
'</div>'
|
||||
);
|
||||
} else {
|
||||
panelNode.append(
|
||||
'<div class="no-visible-items">' +
|
||||
'<p>' +
|
||||
'This class doesn\'t provide any methods, properties, ' +
|
||||
'attributes, or events.' +
|
||||
'</p>' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Hide index sections without any visible items.
|
||||
Y.all('.index-section').each(function (section) {
|
||||
var items = 0,
|
||||
visibleItems = 0;
|
||||
|
||||
section.all('.index-item').each(function (itemNode) {
|
||||
items += 1;
|
||||
|
||||
if (itemNode.getComputedStyle('display') !== 'none') {
|
||||
visibleItems += 1;
|
||||
}
|
||||
});
|
||||
|
||||
section.toggleClass('hidden', !visibleItems);
|
||||
section.toggleClass('no-columns', visibleItems < 4);
|
||||
});
|
||||
};
|
||||
|
||||
pjax.initClassTabView = function () {
|
||||
if (!Y.all('#classdocs .api-class-tab').size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (classTabView) {
|
||||
classTabView.destroy();
|
||||
selectedTab = null;
|
||||
}
|
||||
|
||||
classTabView = new Y.TabView({
|
||||
srcNode: '#classdocs',
|
||||
|
||||
on: {
|
||||
selectionChange: pjax.onTabSelectionChange
|
||||
}
|
||||
});
|
||||
|
||||
pjax.updateTabState();
|
||||
classTabView.render();
|
||||
};
|
||||
|
||||
pjax.initLineNumbers = function () {
|
||||
var hash = win.location.hash.substring(1),
|
||||
container = pjax.get('container'),
|
||||
hasLines, node;
|
||||
|
||||
// Add ids for each line number in the file source view.
|
||||
container.all('.linenums>li').each(function (lineNode, index) {
|
||||
lineNode.set('id', 'l' + (index + 1));
|
||||
lineNode.addClass('file-line');
|
||||
hasLines = true;
|
||||
});
|
||||
|
||||
// Scroll to the desired line.
|
||||
if (hasLines && /^l\d+$/.test(hash)) {
|
||||
if ((node = container.getById(hash))) {
|
||||
win.scroll(0, node.getY());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pjax.initRoot = function () {
|
||||
var terminators = /^(?:classes|files|modules)$/,
|
||||
parts = pjax._getPathRoot().split('/'),
|
||||
root = [],
|
||||
i, len, part;
|
||||
|
||||
for (i = 0, len = parts.length; i < len; i += 1) {
|
||||
part = parts[i];
|
||||
|
||||
if (part.match(terminators)) {
|
||||
// Makes sure the path will end with a "/".
|
||||
root.push('');
|
||||
break;
|
||||
}
|
||||
|
||||
root.push(part);
|
||||
}
|
||||
|
||||
pjax.set('root', root.join('/'));
|
||||
};
|
||||
|
||||
pjax.updateTabState = function (src) {
|
||||
var hash = win.location.hash.substring(1),
|
||||
defaultTab, node, tab, tabPanel;
|
||||
|
||||
function scrollToNode() {
|
||||
if (node.hasClass('protected')) {
|
||||
Y.one('#api-show-protected').set('checked', true);
|
||||
pjax.updateVisibility();
|
||||
}
|
||||
|
||||
if (node.hasClass('private')) {
|
||||
Y.one('#api-show-private').set('checked', true);
|
||||
pjax.updateVisibility();
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
// For some reason, unless we re-get the node instance here,
|
||||
// getY() always returns 0.
|
||||
var node = Y.one('#classdocs').getById(hash);
|
||||
win.scrollTo(0, node.getY() - 70);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
if (!classTabView) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (src === 'hashchange' && !hash) {
|
||||
defaultTab = 'index';
|
||||
} else {
|
||||
if (localStorage) {
|
||||
defaultTab = localStorage.getItem('tab_' + pjax.getPath()) ||
|
||||
'index';
|
||||
} else {
|
||||
defaultTab = 'index';
|
||||
}
|
||||
}
|
||||
|
||||
if (hash && (node = Y.one('#classdocs').getById(hash))) {
|
||||
if ((tabPanel = node.ancestor('.api-class-tabpanel', true))) {
|
||||
if ((tab = Y.one('#classdocs .api-class-tab.' + tabPanel.get('id')))) {
|
||||
if (classTabView.get('rendered')) {
|
||||
Y.Widget.getByNode(tab).set('selected', 1);
|
||||
} else {
|
||||
tab.addClass('yui3-tab-selected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll to the desired element if this is a hash URL.
|
||||
if (node) {
|
||||
if (classTabView.get('rendered')) {
|
||||
scrollToNode();
|
||||
} else {
|
||||
classTabView.once('renderedChange', scrollToNode);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tab = Y.one('#classdocs .api-class-tab.' + defaultTab);
|
||||
|
||||
// When the `defaultTab` node isn't found, `localStorage` is stale.
|
||||
if (!tab && defaultTab !== 'index') {
|
||||
tab = Y.one('#classdocs .api-class-tab.index');
|
||||
}
|
||||
|
||||
if (classTabView.get('rendered')) {
|
||||
Y.Widget.getByNode(tab).set('selected', 1);
|
||||
} else {
|
||||
tab.addClass('yui3-tab-selected');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pjax.updateVisibility = function () {
|
||||
var container = pjax.get('container');
|
||||
|
||||
container.toggleClass('hide-inherited',
|
||||
!Y.one('#api-show-inherited').get('checked'));
|
||||
|
||||
container.toggleClass('show-deprecated',
|
||||
Y.one('#api-show-deprecated').get('checked'));
|
||||
|
||||
container.toggleClass('show-protected',
|
||||
Y.one('#api-show-protected').get('checked'));
|
||||
|
||||
container.toggleClass('show-private',
|
||||
Y.one('#api-show-private').get('checked'));
|
||||
|
||||
pjax.checkVisibility();
|
||||
};
|
||||
|
||||
// -- Route Handlers -----------------------------------------------------------
|
||||
|
||||
pjax.handleClasses = function (req, res, next) {
|
||||
var status = res.ioResponse.status;
|
||||
|
||||
// Handles success and local filesystem XHRs.
|
||||
if (res.ioResponse.readyState === 4 && (!status || (status >= 200 && status < 300))) {
|
||||
pjax.initClassTabView();
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
pjax.handleFiles = function (req, res, next) {
|
||||
var status = res.ioResponse.status;
|
||||
|
||||
// Handles success and local filesystem XHRs.
|
||||
if (res.ioResponse.readyState === 4 && (!status || (status >= 200 && status < 300))) {
|
||||
pjax.initLineNumbers();
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
// -- Event Handlers -----------------------------------------------------------
|
||||
|
||||
pjax.onNavigate = function (e) {
|
||||
var hash = e.hash,
|
||||
originTarget = e.originEvent && e.originEvent.target,
|
||||
tab;
|
||||
|
||||
if (hash) {
|
||||
tab = originTarget && originTarget.ancestor('.yui3-tab', true);
|
||||
|
||||
if (hash === win.location.hash) {
|
||||
pjax.updateTabState('hashchange');
|
||||
} else if (!tab) {
|
||||
win.location.hash = hash;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Only scroll to the top of the page when the URL doesn't have a hash.
|
||||
this.set('scrollToTop', !e.url.match(/#.+$/));
|
||||
|
||||
bdNode.addClass('loading');
|
||||
};
|
||||
|
||||
pjax.onOptionClick = function (e) {
|
||||
pjax.updateVisibility();
|
||||
};
|
||||
|
||||
pjax.onTabSelectionChange = function (e) {
|
||||
var tab = e.newVal,
|
||||
tabId = tab.get('contentBox').getAttribute('href').substring(1);
|
||||
|
||||
selectedTab = tab;
|
||||
|
||||
// If switching from a previous tab (i.e., this is not the default tab),
|
||||
// replace the history entry with a hash URL that will cause this tab to
|
||||
// be selected if the user navigates away and then returns using the back
|
||||
// or forward buttons.
|
||||
if (e.prevVal && localStorage) {
|
||||
localStorage.setItem('tab_' + pjax.getPath(), tabId);
|
||||
}
|
||||
|
||||
pjax.checkVisibility(tab);
|
||||
};
|
||||
|
||||
// -- Init ---------------------------------------------------------------------
|
||||
|
||||
pjax.on('navigate', pjax.onNavigate);
|
||||
|
||||
pjax.initRoot();
|
||||
pjax.upgrade();
|
||||
pjax.initClassTabView();
|
||||
pjax.initLineNumbers();
|
||||
pjax.updateVisibility();
|
||||
|
||||
Y.APIList.rootPath = pjax.get('root');
|
||||
|
||||
Y.one('#api-options').delegate('click', pjax.onOptionClick, 'input');
|
||||
|
||||
Y.on('hashchange', function (e) {
|
||||
pjax.updateTabState('hashchange');
|
||||
}, win);
|
||||
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
YUI().use('node', function(Y) {
|
||||
var code = Y.all('.prettyprint.linenums');
|
||||
if (code.size()) {
|
||||
code.each(function(c) {
|
||||
var lis = c.all('ol li'),
|
||||
l = 1;
|
||||
lis.each(function(n) {
|
||||
n.prepend('<a name="LINENUM_' + l + '"></a>');
|
||||
l++;
|
||||
});
|
||||
});
|
||||
var h = location.hash;
|
||||
location.hash = '';
|
||||
h = h.replace('LINE_', 'LINENUM_');
|
||||
location.hash = h;
|
||||
}
|
||||
});
|
|
@ -0,0 +1,130 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Change Log</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
<a style="float:right" href="README.html">README</a>
|
||||
|
||||
<h1>Known Issues</h1>
|
||||
<ul>
|
||||
<li>Perl formatting is really crappy. Partly because the author is lazy and
|
||||
partly because Perl is
|
||||
<a href="http://www.perlmonks.org/?node_id=663393">hard</a> to parse.
|
||||
<li>On some browsers, <code><code></code> elements with newlines in the text
|
||||
which use CSS to specify <code>white-space:pre</code> will have the newlines
|
||||
improperly stripped if the element is not attached to the document at the time
|
||||
the stripping is done. Also, on IE 6, all newlines will be stripped from
|
||||
<code><code></code> elements because of the way IE6 produces
|
||||
<code>innerHTML</code>. Workaround: use <code><pre></code> for code with
|
||||
newlines.
|
||||
</ul>
|
||||
|
||||
<h1>Change Log</h1>
|
||||
<h2>29 March 2007</h2>
|
||||
<ul>
|
||||
<li>Added <a href="tests/prettify_test.html#PHP">tests</a> for PHP support
|
||||
to address
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=3"
|
||||
>issue 3</a>.
|
||||
<li>Fixed
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=6"
|
||||
>bug</a>: <code>prettyPrintOne</code> was not halting. This was not
|
||||
reachable through the normal entry point.
|
||||
<li>Fixed
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=4"
|
||||
>bug</a>: recursing into a script block or PHP tag that was not properly
|
||||
closed would not silently drop the content.
|
||||
(<a href="tests/prettify_test.html#issue4">test</a>)
|
||||
<li>Fixed
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=8"
|
||||
>bug</a>: was eating tabs
|
||||
(<a href="tests/prettify_test.html#issue8">test</a>)
|
||||
<li>Fixed entity handling so that the caveat
|
||||
<blockquote>
|
||||
<p>Caveats: please properly escape less-thans. <tt>x&lt;y</tt>
|
||||
instead of <tt>x<y</tt>, and use <tt>"</tt> instead of
|
||||
<tt>&quot;</tt> for string delimiters.</p>
|
||||
</blockquote>
|
||||
is no longer applicable.
|
||||
<li>Added noisefree's C#
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=4"
|
||||
>patch</a>
|
||||
<li>Added a <a href="http://google-code-prettify.googlecode.com/files/prettify-small.zip">distribution</a> that has comments and
|
||||
whitespace removed to reduce download size from 45.5kB to 12.8kB.
|
||||
</ul>
|
||||
<h2>4 Jul 2008</h2>
|
||||
<ul>
|
||||
<li>Added <a href="http://code.google.com/p/google-code-prettify/issues/detail?id=17">language specific formatters</a> that are triggered by the presence
|
||||
of a <code>lang-<language-file-extension></code></li>
|
||||
<li>Fixed <a href="http://code.google.com/p/google-code-prettify/issues/detail?id=29">bug</a>: python handling of <code>'''string'''</code>
|
||||
<li>Fixed bug: <code>/</code> in regex <code>[charsets] should not end regex</code>
|
||||
</ul>
|
||||
<h2>5 Jul 2008</h2>
|
||||
<ul>
|
||||
<li>Defined language extensions for Lisp and Lua</code>
|
||||
</ul>
|
||||
<h2>14 Jul 2008</h2>
|
||||
<ul>
|
||||
<li>Language handlers for F#, OCAML, SQL</code>
|
||||
<li>Support for <code>nocode</code> spans to allow embedding of line
|
||||
numbers and code annotations which should not be styled or otherwise
|
||||
affect the tokenization of prettified code.
|
||||
See the issue 22
|
||||
<a href="tests/prettify_test.html#issue22">testcase</a>.</code>
|
||||
</ul>
|
||||
<h2>6 Jan 2009</h2>
|
||||
<ul>
|
||||
<li>Language handlers for Visual Basic, Haskell, CSS, and WikiText</li>
|
||||
<li>Added <tt>.mxml</tt> extension to the markup style handler for
|
||||
Flex <a href="http://en.wikipedia.org/wiki/MXML">MXML files</a>. See
|
||||
<a
|
||||
href="http://code.google.com/p/google-code-prettify/issues/detail?id=37"
|
||||
>issue 37</a>.
|
||||
<li>Added <tt>.m</tt> extension to the C style handler so that Objective
|
||||
C source files properly highlight. See
|
||||
<a
|
||||
href="http://code.google.com/p/google-code-prettify/issues/detail?id=58"
|
||||
>issue 58</a>.
|
||||
<li>Changed HTML lexer to use the same embedded source mechanism as the
|
||||
wiki language handler, and changed to use the registered
|
||||
CSS handler for STYLE element content.
|
||||
</ul>
|
||||
<h2>21 May 2009</h2>
|
||||
<ul>
|
||||
<li>Rewrote to improve performance on large files.
|
||||
See <a href="http://mikesamuel.blogspot.com/2009/05/efficient-parsing-in-javascript.html">benchmarks</a>.</li>
|
||||
<li>Fixed bugs with highlighting of Haskell line comments, Lisp
|
||||
number literals, Lua strings, C preprocessor directives,
|
||||
newlines in Wiki code on Windows, and newlines in IE6.</li>
|
||||
</ul>
|
||||
<h2>14 August 2009</h2>
|
||||
<ul>
|
||||
<li>Fixed prettifying of <code><code></code> blocks with embedded newlines.
|
||||
</ul>
|
||||
<h2>3 October 2009</h2>
|
||||
<ul>
|
||||
<li>Fixed prettifying of XML/HTML tags that contain uppercase letters.
|
||||
</ul>
|
||||
<h2>19 July 2010</h2>
|
||||
<ul>
|
||||
<li>Added support for line numbers. Bug
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=22"
|
||||
>22</a></li>
|
||||
<li>Added YAML support. Bug
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=123"
|
||||
>123</a></li>
|
||||
<li>Added VHDL support courtesy Le Poussin.</li>
|
||||
<li>IE performance improvements. Bug
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=102"
|
||||
>102</a> courtesy jacobly.</li>
|
||||
<li>A variety of markup formatting fixes courtesy smain and thezbyg.</li>
|
||||
<li>Fixed copy and paste in IE[678].
|
||||
<li>Changed output to use <code>&#160;</code> instead of
|
||||
<code>&nbsp;</code> so that the output works when embedded in XML.
|
||||
Bug
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=108"
|
||||
>108</a>.</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed 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.
|
|
@ -0,0 +1,203 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Javascript code prettifier</title>
|
||||
|
||||
<link href="src/prettify.css" type="text/css" rel="stylesheet" />
|
||||
|
||||
<script src="src/prettify.js" type="text/javascript"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body { margin-left: .5in }
|
||||
h1, h2, h3, h4, .footer { margin-left: -.4in; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body onload="prettyPrint()" bgcolor="white">
|
||||
<small style="float: right">Languages : <a href="README-zh-Hans.html">CH</a></small>
|
||||
<h1>Javascript code prettifier</h1>
|
||||
|
||||
<h2>Setup</h2>
|
||||
<ol>
|
||||
<li><a href="http://code.google.com/p/google-code-prettify/downloads/list">Download</a> a distribution
|
||||
<li>Include the script and stylesheets in your document
|
||||
(you will need to make sure the css and js file are on your server, and
|
||||
adjust the paths in the <tt>script</tt> and <tt>link</tt> tag)
|
||||
<pre class="prettyprint">
|
||||
<link href="prettify.css" type="text/css" rel="stylesheet" />
|
||||
<script type="text/javascript" src="prettify.js"></script></pre>
|
||||
<li>Add <code class="prettyprint lang-html">onload="prettyPrint()"</code> to your
|
||||
document's body tag.
|
||||
<li>Modify the stylesheet to get the coloring you prefer</li>
|
||||
</ol>
|
||||
|
||||
<h2>Usage</h2>
|
||||
<p>Put code snippets in
|
||||
<tt><pre class="prettyprint">...</pre></tt>
|
||||
or <tt><code class="prettyprint">...</code></tt>
|
||||
and it will automatically be pretty printed.
|
||||
|
||||
<table summary="code examples">
|
||||
<tr>
|
||||
<th>The original
|
||||
<th>Prettier
|
||||
<tr>
|
||||
<td><pre style="border: 1px solid #888;padding: 2px"
|
||||
><a name="voila1"></a>class Voila {
|
||||
public:
|
||||
// Voila
|
||||
static const string VOILA = "Voila";
|
||||
|
||||
// will not interfere with embedded <a href="#voila1">tags</a>.
|
||||
}</pre>
|
||||
|
||||
<td><pre class="prettyprint"><a name="voila2"></a>class Voila {
|
||||
public:
|
||||
// Voila
|
||||
static const string VOILA = "Voila";
|
||||
|
||||
// will not interfere with embedded <a href="#voila2">tags</a>.
|
||||
}</pre>
|
||||
</table>
|
||||
|
||||
<h2>FAQ</h2>
|
||||
<h3 id="langs">Which languages does it work for?</h3>
|
||||
<p>The comments in <tt>prettify.js</tt> are authoritative but the lexer
|
||||
should work on a number of languages including C and friends,
|
||||
Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles.
|
||||
It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl
|
||||
and Ruby, but, because of commenting conventions, doesn't work on
|
||||
Smalltalk, or CAML-like languages.</p>
|
||||
|
||||
<p>LISPy languages are supported via an extension:
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-lisp.js"
|
||||
><code>lang-lisp.js</code></a>.</p>
|
||||
<p>And similarly for
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-css.js"
|
||||
><code>CSS</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-hs.js"
|
||||
><code>Haskell</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-lua.js"
|
||||
><code>Lua</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-ml.js"
|
||||
><code>OCAML, SML, F#</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-vb.js"
|
||||
><code>Visual Basic</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-sql.js"
|
||||
><code>SQL</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-proto.js"
|
||||
><code>Protocol Buffers</code></a>, and
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-wiki.js"
|
||||
><code>WikiText</code></a>..
|
||||
|
||||
<p>If you'd like to add an extension for your favorite language, please
|
||||
look at <tt>src/lang-lisp.js</tt> and file an
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/list"
|
||||
>issue</a> including your language extension, and a testcase.</p>
|
||||
|
||||
<h3>How do I specify which language my code is in?</h3>
|
||||
<p>You don't need to specify the language since <code>prettyprint()</code>
|
||||
will guess. You can specify a language by specifying the language extension
|
||||
along with the <code>prettyprint</code> class like so:</p>
|
||||
<pre class="prettyprint lang-html"
|
||||
><pre class="prettyprint <b>lang-html</b>">
|
||||
The lang-* class specifies the language file extensions.
|
||||
File extensions supported by default include
|
||||
"bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html",
|
||||
"java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh",
|
||||
"xhtml", "xml", "xsl".
|
||||
</pre></pre>
|
||||
|
||||
<h3>It doesn't work on <tt><obfuscated code sample></tt>?</h3>
|
||||
<p>Yes. Prettifying obfuscated code is like putting lipstick on a pig
|
||||
— i.e. outside the scope of this tool.</p>
|
||||
|
||||
<h3>Which browsers does it work with?</h3>
|
||||
<p>It's been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4.
|
||||
Look at <a href="tests/prettify_test.html">the test page</a> to see if it
|
||||
works in your browser.</p>
|
||||
|
||||
<h3>What's changed?</h3>
|
||||
<p>See the <a href="CHANGES.html">change log</a></p>
|
||||
|
||||
<h3>Why doesn't Prettyprinting of strings work on WordPress?</h3>
|
||||
<p>Apparently wordpress does "smart quoting" which changes close quotes.
|
||||
This causes end quotes to not match up with open quotes.
|
||||
<p>This breaks prettifying as well as copying and pasting of code samples.
|
||||
See
|
||||
<a href="http://wordpress.org/support/topic/125038"
|
||||
>WordPress's help center</a> for info on how to stop smart quoting of code
|
||||
snippets.</p>
|
||||
|
||||
<h3 id="linenums">How do I put line numbers in my code?</h3>
|
||||
<p>You can use the <code>linenums</code> class to turn on line
|
||||
numbering. If your code doesn't start at line number 1, you can
|
||||
add a colon and a line number to the end of that class as in
|
||||
<code>linenums:52</code>.
|
||||
|
||||
<p>For example
|
||||
<pre class="prettyprint"><pre class="prettyprint linenums:<b>4</b>"
|
||||
>// This is line 4.
|
||||
foo();
|
||||
bar();
|
||||
baz();
|
||||
boo();
|
||||
far();
|
||||
faz();
|
||||
<pre></pre>
|
||||
produces
|
||||
<pre class="prettyprint linenums:4"
|
||||
>// This is line 4.
|
||||
foo();
|
||||
bar();
|
||||
baz();
|
||||
boo();
|
||||
far();
|
||||
faz();
|
||||
</pre>
|
||||
|
||||
<h3>How do I prevent a portion of markup from being marked as code?</h3>
|
||||
<p>You can use the <code>nocode</code> class to identify a span of markup
|
||||
that is not code.
|
||||
<pre class="prettyprint"><pre class=prettyprint>
|
||||
int x = foo(); /* This is a comment <span class="nocode">This is not code</span>
|
||||
Continuation of comment */
|
||||
int y = bar();
|
||||
</pre></pre>
|
||||
produces
|
||||
<pre class="prettyprint">
|
||||
int x = foo(); /* This is a comment <span class="nocode">This is not code</span>
|
||||
Continuation of comment */
|
||||
int y = bar();
|
||||
</pre>
|
||||
|
||||
<p>For a more complete example see the issue22
|
||||
<a href="tests/prettify_test.html#issue22">testcase</a>.</p>
|
||||
|
||||
<h3>I get an error message "a is not a function" or "opt_whenDone is not a function"</h3>
|
||||
<p>If you are calling <code>prettyPrint</code> via an event handler, wrap it in a function.
|
||||
Instead of doing
|
||||
<blockquote>
|
||||
<code class="prettyprint lang-js"
|
||||
>addEventListener('load', prettyPrint, false);</code>
|
||||
</blockquote>
|
||||
wrap it in a closure like
|
||||
<blockquote>
|
||||
<code class="prettyprint lang-js"
|
||||
>addEventListener('load', function (event) { prettyPrint() }, false);</code>
|
||||
</blockquote>
|
||||
so that the browser does not pass an event object to <code>prettyPrint</code> which
|
||||
will confuse it.
|
||||
|
||||
<br><br><br>
|
||||
|
||||
<div class="footer">
|
||||
<!-- Created: Tue Oct 3 17:51:56 PDT 2006 -->
|
||||
<!-- hhmts start -->
|
||||
Last modified: Wed Jul 19 13:56:00 PST 2010
|
||||
<!-- hhmts end -->
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,503 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>AnimFrameUpdateStrategy - HTML5-JavaScript-Gamepad-Controller-Library</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="../assets/css/logo.png" title="HTML5-JavaScript-Gamepad-Controller-Library"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 0.0.1</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AnimFrameUpdateStrategy.html">AnimFrameUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/FirefoxPlatform.html">FirefoxPlatform</a></li>
|
||||
|
||||
<li><a href="../classes/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
<li><a href="../classes/ManualUpdateStrategy.html">ManualUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/WebKitPlatform.html">WebKitPlatform</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1>AnimFrameUpdateStrategy Class</h1>
|
||||
<div class="box meta">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="foundat">
|
||||
Defined in: <a href="../files/gamepad.js.html#l45"><code>gamepad.js:45</code></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
Module: <a href="../modules/Gamepad.html">Gamepad</a>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="box intro">
|
||||
<p>This strategy uses a timer function to call an update function.
|
||||
The timer (re)start function can be provided or the strategy reverts to
|
||||
one of the window.*requestAnimationFrame variants.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="constructor">
|
||||
<h2>Constructor</h2>
|
||||
<div id="method_AnimFrameUpdateStrategy" class="method item">
|
||||
<h3 class="name"><code>AnimFrameUpdateStrategy</code></h3>
|
||||
|
||||
|
||||
<div class="args">
|
||||
<span class="paren">(</span><ul class="args-list inline commas">
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code class="optional">[requestAnimationFrame]</code>
|
||||
|
||||
</li>
|
||||
|
||||
</ul><span class="paren">)</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l45"><code>gamepad.js:45</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="params">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<ul class="params-list">
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name optional">[requestAnimationFrame]</code>
|
||||
<span class="type">Function</span>
|
||||
<span class="flag optional" title="This parameter is optional.">optional</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>function to use for timer creation</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="classdocs" class="tabview">
|
||||
<ul class="api-class-tabs">
|
||||
<li class="api-class-tab index"><a href="#index">Index</a></li>
|
||||
|
||||
|
||||
<li class="api-class-tab methods"><a href="#methods">Methods</a></li>
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<div id="index" class="api-class-tabpanel index">
|
||||
<h2 class="off-left">Item Index</h2>
|
||||
|
||||
|
||||
<div class="index-section methods">
|
||||
<h3>Methods</h3>
|
||||
|
||||
<ul class="index-list methods">
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_start">start</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_startTicker">startTicker</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_tickFunction">tickFunction</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="methods" class="api-class-tabpanel">
|
||||
<h2 class="off-left">Methods</h2>
|
||||
|
||||
|
||||
<div id="method_start" class="method item">
|
||||
<h3 class="name"><code>start</code></h3>
|
||||
|
||||
|
||||
<div class="args">
|
||||
<span class="paren">(</span><ul class="args-list inline commas">
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code>updateFunction</code>
|
||||
|
||||
</li>
|
||||
|
||||
</ul><span class="paren">)</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l82"><code>gamepad.js:82</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<p>Starts the update strategy using the given function</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="params">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<ul class="params-list">
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name">updateFunction</code>
|
||||
<span class="type">Function</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>the function to call at each update</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_startTicker" class="method item">
|
||||
<h3 class="name"><code>startTicker</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l73"><code>gamepad.js:73</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<p>(Re)Starts the ticker</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_tickFunction" class="method item">
|
||||
<h3 class="name"><code>tickFunction</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l64"><code>gamepad.js:64</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<p>This method calls the (user) update and restarts itself</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,668 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>FirefoxPlatform - HTML5-JavaScript-Gamepad-Controller-Library</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="../assets/css/logo.png" title="HTML5-JavaScript-Gamepad-Controller-Library"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 0.0.1</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AnimFrameUpdateStrategy.html">AnimFrameUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/FirefoxPlatform.html">FirefoxPlatform</a></li>
|
||||
|
||||
<li><a href="../classes/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
<li><a href="../classes/ManualUpdateStrategy.html">ManualUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/WebKitPlatform.html">WebKitPlatform</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1>FirefoxPlatform Class</h1>
|
||||
<div class="box meta">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="foundat">
|
||||
Defined in: <a href="../files/gamepad.js.html#l221"><code>gamepad.js:221</code></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
Module: <a href="../modules/Gamepad.html">Gamepad</a>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="box intro">
|
||||
<p>This platform is for mozilla based environments that provide gamepad
|
||||
updates via events.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="constructor">
|
||||
<h2>Constructor</h2>
|
||||
<div id="method_FirefoxPlatform" class="method item">
|
||||
<h3 class="name"><code>FirefoxPlatform</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l221"><code>gamepad.js:221</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="classdocs" class="tabview">
|
||||
<ul class="api-class-tabs">
|
||||
<li class="api-class-tab index"><a href="#index">Index</a></li>
|
||||
|
||||
|
||||
<li class="api-class-tab methods"><a href="#methods">Methods</a></li>
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<div id="index" class="api-class-tabpanel index">
|
||||
<h2 class="off-left">Item Index</h2>
|
||||
|
||||
|
||||
<div class="index-section methods">
|
||||
<h3>Methods</h3>
|
||||
|
||||
<ul class="index-list methods">
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_factory">factory</a>
|
||||
|
||||
|
||||
<span class="flag static">static</span>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_getType()">getType()</a>
|
||||
|
||||
|
||||
<span class="flag static">static</span>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_getType()">getType()</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_isSupported">isSupported</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_update">update</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="methods" class="api-class-tabpanel">
|
||||
<h2 class="off-left">Methods</h2>
|
||||
|
||||
|
||||
<div id="method_factory" class="method item">
|
||||
<h3 class="name"><code>factory</code></h3>
|
||||
|
||||
|
||||
<div class="args">
|
||||
<span class="paren">(</span><ul class="args-list inline commas">
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code>listener</code>
|
||||
|
||||
</li>
|
||||
|
||||
</ul><span class="paren">)</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<span class="returns-inline">
|
||||
<span class="type">Object</span>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span class="flag static">static</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l240"><code>gamepad.js:240</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<p>Provides a platform object that returns true for isSupported() if valid.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="params">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<ul class="params-list">
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name">listener</code>
|
||||
<span class="type">Object</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>the listener to use</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="returns">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<div class="returns-description">
|
||||
|
||||
|
||||
<span class="type">Object</span>:
|
||||
|
||||
<p>a platform object</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_getType()" class="method item">
|
||||
<h3 class="name"><code>getType()</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
<span class="returns-inline">
|
||||
<span class="type">String</span>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span class="flag static">static</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l257"><code>gamepad.js:257</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="returns">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<div class="returns-description">
|
||||
|
||||
|
||||
<span class="type">String</span>:
|
||||
|
||||
<p>'Firefox'</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_getType()" class="method item">
|
||||
<h3 class="name"><code>getType()</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
<span class="returns-inline">
|
||||
<span class="type">String</span>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l266"><code>gamepad.js:266</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="returns">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<div class="returns-description">
|
||||
|
||||
|
||||
<span class="type">String</span>:
|
||||
|
||||
<p>'Firefox'</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_isSupported" class="method item">
|
||||
<h3 class="name"><code>isSupported</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
<span class="returns-inline">
|
||||
<span class="type">Boolean</span>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l274"><code>gamepad.js:274</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="returns">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<div class="returns-description">
|
||||
|
||||
|
||||
<span class="type">Boolean</span>:
|
||||
|
||||
<p>true</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_update" class="method item">
|
||||
<h3 class="name"><code>update</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l283"><code>gamepad.js:283</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<p>Does nothing on the Firefox platform</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,407 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ManualUpdateStrategy - HTML5-JavaScript-Gamepad-Controller-Library</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="../assets/css/logo.png" title="HTML5-JavaScript-Gamepad-Controller-Library"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 0.0.1</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AnimFrameUpdateStrategy.html">AnimFrameUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/FirefoxPlatform.html">FirefoxPlatform</a></li>
|
||||
|
||||
<li><a href="../classes/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
<li><a href="../classes/ManualUpdateStrategy.html">ManualUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/WebKitPlatform.html">WebKitPlatform</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1>ManualUpdateStrategy Class</h1>
|
||||
<div class="box meta">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="foundat">
|
||||
Defined in: <a href="../files/gamepad.js.html#l93"><code>gamepad.js:93</code></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
Module: <a href="../modules/Gamepad.html">Gamepad</a>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="box intro">
|
||||
<p>This strategy gives the user the ability to call the library internal
|
||||
update function on request. Use this strategy if you already have a
|
||||
timer function running by requestAnimationFrame and you need fine control
|
||||
over when the gamepads are updated.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="constructor">
|
||||
<h2>Constructor</h2>
|
||||
<div id="method_ManualUpdateStrategy" class="method item">
|
||||
<h3 class="name"><code>ManualUpdateStrategy</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l93"><code>gamepad.js:93</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="classdocs" class="tabview">
|
||||
<ul class="api-class-tabs">
|
||||
<li class="api-class-tab index"><a href="#index">Index</a></li>
|
||||
|
||||
|
||||
<li class="api-class-tab methods"><a href="#methods">Methods</a></li>
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<div id="index" class="api-class-tabpanel index">
|
||||
<h2 class="off-left">Item Index</h2>
|
||||
|
||||
|
||||
<div class="index-section methods">
|
||||
<h3>Methods</h3>
|
||||
|
||||
<ul class="index-list methods">
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_start">start</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_update">update</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="methods" class="api-class-tabpanel">
|
||||
<h2 class="off-left">Methods</h2>
|
||||
|
||||
|
||||
<div id="method_start" class="method item">
|
||||
<h3 class="name"><code>start</code></h3>
|
||||
|
||||
|
||||
<div class="args">
|
||||
<span class="paren">(</span><ul class="args-list inline commas">
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code>updateFunction</code>
|
||||
|
||||
</li>
|
||||
|
||||
</ul><span class="paren">)</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l113"><code>gamepad.js:113</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<p>Starts the update strategy using the given function</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="params">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<ul class="params-list">
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name">updateFunction</code>
|
||||
<span class="type">Function</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>the function to call at each update</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_update" class="method item">
|
||||
<h3 class="name"><code>update</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l107"><code>gamepad.js:107</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<p>Calls the update function in the started state. Does nothing otherwise.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,724 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebKitPlatform - HTML5-JavaScript-Gamepad-Controller-Library</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="../assets/css/logo.png" title="HTML5-JavaScript-Gamepad-Controller-Library"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 0.0.1</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AnimFrameUpdateStrategy.html">AnimFrameUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/FirefoxPlatform.html">FirefoxPlatform</a></li>
|
||||
|
||||
<li><a href="../classes/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
<li><a href="../classes/ManualUpdateStrategy.html">ManualUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/WebKitPlatform.html">WebKitPlatform</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1>WebKitPlatform Class</h1>
|
||||
<div class="box meta">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="foundat">
|
||||
Defined in: <a href="../files/gamepad.js.html#l123"><code>gamepad.js:123</code></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
Module: <a href="../modules/Gamepad.html">Gamepad</a>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="box intro">
|
||||
<p>This platform is for webkit based environments that need to be polled
|
||||
for updates.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="constructor">
|
||||
<h2>Constructor</h2>
|
||||
<div id="method_WebKitPlatform" class="method item">
|
||||
<h3 class="name"><code>WebKitPlatform</code></h3>
|
||||
|
||||
|
||||
<div class="args">
|
||||
<span class="paren">(</span><ul class="args-list inline commas">
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code>listener</code>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code>gamepadGetter</code>
|
||||
|
||||
</li>
|
||||
|
||||
</ul><span class="paren">)</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l123"><code>gamepad.js:123</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="params">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<ul class="params-list">
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name">listener</code>
|
||||
<span class="type">Object</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>the listener to provide _connect and _disconnect callbacks</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name">gamepadGetter</code>
|
||||
<span class="type">Function</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>the poll function to return an array of connected gamepads</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="classdocs" class="tabview">
|
||||
<ul class="api-class-tabs">
|
||||
<li class="api-class-tab index"><a href="#index">Index</a></li>
|
||||
|
||||
|
||||
<li class="api-class-tab methods"><a href="#methods">Methods</a></li>
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<div id="index" class="api-class-tabpanel index">
|
||||
<h2 class="off-left">Item Index</h2>
|
||||
|
||||
|
||||
<div class="index-section methods">
|
||||
<h3>Methods</h3>
|
||||
|
||||
<ul class="index-list methods">
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_factory">factory</a>
|
||||
|
||||
|
||||
<span class="flag static">static</span>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_getType()">getType()</a>
|
||||
|
||||
|
||||
<span class="flag static">static</span>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_getType()">getType()</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_isSupported">isSupported</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_update">update</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="methods" class="api-class-tabpanel">
|
||||
<h2 class="off-left">Methods</h2>
|
||||
|
||||
|
||||
<div id="method_factory" class="method item">
|
||||
<h3 class="name"><code>factory</code></h3>
|
||||
|
||||
|
||||
<div class="args">
|
||||
<span class="paren">(</span><ul class="args-list inline commas">
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code>listener</code>
|
||||
|
||||
</li>
|
||||
|
||||
</ul><span class="paren">)</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<span class="returns-inline">
|
||||
<span class="type">Object</span>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span class="flag static">static</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l139"><code>gamepad.js:139</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<p>Provides a platform object that returns true for isSupported() if valid.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="params">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<ul class="params-list">
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name">listener</code>
|
||||
<span class="type">Object</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>the listener to use</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="returns">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<div class="returns-description">
|
||||
|
||||
|
||||
<span class="type">Object</span>:
|
||||
|
||||
<p>a platform object</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_getType()" class="method item">
|
||||
<h3 class="name"><code>getType()</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
<span class="returns-inline">
|
||||
<span class="type">String</span>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span class="flag static">static</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l169"><code>gamepad.js:169</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="returns">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<div class="returns-description">
|
||||
|
||||
|
||||
<span class="type">String</span>:
|
||||
|
||||
<p>'WebKit'</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_getType()" class="method item">
|
||||
<h3 class="name"><code>getType()</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
<span class="returns-inline">
|
||||
<span class="type">String</span>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l178"><code>gamepad.js:178</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="returns">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<div class="returns-description">
|
||||
|
||||
|
||||
<span class="type">String</span>:
|
||||
|
||||
<p>'WebKit'</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_isSupported" class="method item">
|
||||
<h3 class="name"><code>isSupported</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
<span class="returns-inline">
|
||||
<span class="type">Boolean</span>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l186"><code>gamepad.js:186</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="returns">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<div class="returns-description">
|
||||
|
||||
|
||||
<span class="type">Boolean</span>:
|
||||
|
||||
<p>true</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="method_update" class="method item">
|
||||
<h3 class="name"><code>update</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/gamepad.js.html#l194"><code>gamepad.js:194</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<p>Queries the currently connected gamepads and reports any changes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Redirector</title>
|
||||
<meta http-equiv="refresh" content="0;url=../">
|
||||
</head>
|
||||
<body>
|
||||
<a href="../">Click here to redirect</a>
|
||||
</body>
|
||||
</html>
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,10 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Redirector</title>
|
||||
<meta http-equiv="refresh" content="0;url=../">
|
||||
</head>
|
||||
<body>
|
||||
<a href="../">Click here to redirect</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,132 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML5-JavaScript-Gamepad-Controller-Library</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="./assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="./assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="./assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="./assets/css/logo.png" title="HTML5-JavaScript-Gamepad-Controller-Library"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 0.0.1</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="./classes/AnimFrameUpdateStrategy.html">AnimFrameUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="./classes/FirefoxPlatform.html">FirefoxPlatform</a></li>
|
||||
|
||||
<li><a href="./classes/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
<li><a href="./classes/ManualUpdateStrategy.html">ManualUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="./classes/WebKitPlatform.html">WebKitPlatform</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="./modules/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<div class="apidocs">
|
||||
<div id="docs-main" class="content">
|
||||
<p>
|
||||
Browse to a module or class using the sidebar to view its API documentation.
|
||||
</p>
|
||||
|
||||
<h2>Keyboard Shortcuts</h2>
|
||||
|
||||
<ul>
|
||||
<li><p>Press <kbd>s</kbd> to focus the API search box.</p></li>
|
||||
|
||||
<li><p>Use <kbd>Up</kbd> and <kbd>Down</kbd> to select classes, modules, and search results.</p></li>
|
||||
|
||||
<li class="mac-only"><p>With the API search box or sidebar focused, use <kbd><span class="cmd">⌘</span>-Left</kbd> or <kbd><span class="cmd">⌘</span>-Right</kbd> to switch sidebar tabs.</p></li>
|
||||
|
||||
<li class="pc-only"><p>With the API search box or sidebar focused, use <kbd>Ctrl+Left</kbd> and <kbd>Ctrl+Right</kbd> to switch sidebar tabs.</p></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="./assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="./assets/js/yui-prettify.js"></script>
|
||||
<script src="./assets/../api.js"></script>
|
||||
<script src="./assets/js/api-filter.js"></script>
|
||||
<script src="./assets/js/api-list.js"></script>
|
||||
<script src="./assets/js/api-search.js"></script>
|
||||
<script src="./assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,182 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Gamepad - HTML5-JavaScript-Gamepad-Controller-Library</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="../assets/css/logo.png" title="HTML5-JavaScript-Gamepad-Controller-Library"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 0.0.1</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AnimFrameUpdateStrategy.html">AnimFrameUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/FirefoxPlatform.html">FirefoxPlatform</a></li>
|
||||
|
||||
<li><a href="../classes/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
<li><a href="../classes/ManualUpdateStrategy.html">ManualUpdateStrategy</a></li>
|
||||
|
||||
<li><a href="../classes/WebKitPlatform.html">WebKitPlatform</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/Gamepad.html">Gamepad</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1>Gamepad Module</h1>
|
||||
<div class="box clearfix meta">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="foundat">
|
||||
Defined in: <a href="../files/gamepad.js.html#l289"><code>gamepad.js:289</code></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="box intro">
|
||||
<p>This strategy uses a timer function to call an update function.
|
||||
The timer (re)start function can be provided or the strategy reverts to
|
||||
one of the window.*requestAnimationFrame variants.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="yui3-g">
|
||||
<div class="yui3-u-1-2">
|
||||
|
||||
<p>This module provides the following classes:</p>
|
||||
|
||||
<ul class="module-classes">
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/AnimFrameUpdateStrategy.html">
|
||||
AnimFrameUpdateStrategy
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/FirefoxPlatform.html">
|
||||
FirefoxPlatform
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/Gamepad.html">
|
||||
Gamepad
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/ManualUpdateStrategy.html">
|
||||
ManualUpdateStrategy
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/WebKitPlatform.html">
|
||||
WebKitPlatform
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="yui3-u-1-2">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Redirector</title>
|
||||
<meta http-equiv="refresh" content="0;url=../">
|
||||
</head>
|
||||
<body>
|
||||
<a href="../">Click here to redirect</a>
|
||||
</body>
|
||||
</html>
|
Plik diff jest za duży
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,114 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>GamePad Library Demo</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
|
||||
<script src="gamepad.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<ul id="gamepads"></ul>
|
||||
<p id="connect-notice">Connect your controller and press any button.</p>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
// Attach it to the window so it can be inspected at the console.
|
||||
window.gamepad = new Gamepad();
|
||||
|
||||
gamepad.bind(Gamepad.Event.CONNECTED, function(device) {
|
||||
console.log('Connected', device);
|
||||
|
||||
$('#gamepads').append('<li id="gamepad-' + device.index + '"><h1>Gamepad #' + device.index + ': "' + device.id + '"</h1></li>');
|
||||
|
||||
var mainWrap = $('#gamepad-' + device.index),
|
||||
statesWrap,
|
||||
logWrap,
|
||||
control,
|
||||
value,
|
||||
i;
|
||||
|
||||
mainWrap.append('<strong>State</strong><ul id="states-' + device.index + '"></ul>');
|
||||
mainWrap.append('<strong>Events</strong><ul id="log-' + device.index + '"></ul>');
|
||||
|
||||
statesWrap = $('#states-' + device.index)
|
||||
logWrap = $('#log-' + device.index)
|
||||
|
||||
for (control in device.state) {
|
||||
value = device.state[control];
|
||||
|
||||
statesWrap.append('<li>' + control + ': <span id="state-' + device.index + '-' + control + '">' + value + '</span></li>');
|
||||
}
|
||||
for (i = 0; i < device.buttons.length; i++) {
|
||||
value = device.buttons[i];
|
||||
statesWrap.append('<li>Raw Button ' + i + ': <span id="button-' + device.index + '-' + i + '">' + value + '</span></li>');
|
||||
}
|
||||
for (i = 0; i < device.axes.length; i++) {
|
||||
value = device.axes[i];
|
||||
statesWrap.append('<li>Raw Axis ' + i + ': <span id="axis-' + device.index + '-' + i + '">' + value + '</span></li>');
|
||||
}
|
||||
|
||||
$('#connect-notice').hide();
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.DISCONNECTED, function(device) {
|
||||
console.log('Disconnected', device);
|
||||
|
||||
$('#gamepad-' + device.index).remove();
|
||||
|
||||
if (gamepad.count() == 0) {
|
||||
$('#connect-notice').show();
|
||||
}
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.TICK, function(gamepads) {
|
||||
var gamepad,
|
||||
wrap,
|
||||
control,
|
||||
value,
|
||||
i,
|
||||
j;
|
||||
|
||||
for (i = 0; i < gamepads.length; i++) {
|
||||
gamepad = gamepads[i];
|
||||
wrap = $('#gamepad-' + i);
|
||||
|
||||
if (gamepad) {
|
||||
for (control in gamepad.state) {
|
||||
value = gamepad.state[control];
|
||||
|
||||
$('#state-' + gamepad.index + '-' + control + '').html(value);
|
||||
}
|
||||
for (j = 0; j < gamepad.buttons.length; j++) {
|
||||
value = gamepad.buttons[j];
|
||||
|
||||
$('#button-' + gamepad.index + '-' + j + '').html(value);
|
||||
}
|
||||
for (j = 0; j < gamepad.axes.length; j++) {
|
||||
value = gamepad.axes[j];
|
||||
|
||||
$('#axis-' + gamepad.index + '-' + j + '').html(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.BUTTON_DOWN, function(e) {
|
||||
$('#log-' + e.gamepad.index).append('<li>' + e.control + ' down</li>');
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.BUTTON_UP, function(e) {
|
||||
$('#log-' + e.gamepad.index).append('<li>' + e.control + ' up</li>');
|
||||
});
|
||||
|
||||
gamepad.bind(Gamepad.Event.AXIS_CHANGED, function(e) {
|
||||
$('#log-' + e.gamepad.index).append('<li>' + e.axis + ' changed to ' + e.value + '</li>');
|
||||
});
|
||||
|
||||
if (!gamepad.init()) {
|
||||
alert('Your browser does not support gamepads, get the latest Google Chrome or Firefox.');
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "HTML5-JavaScript-Gamepad-Controller-Library",
|
||||
"version": "0.0.1",
|
||||
"description": "Library for accessing gamepads in modern browsers.",
|
||||
"homepage": "https://github.com/kallaspriit/HTML5-JavaScript-Gamepad-Controller-Library",
|
||||
"bugs": "https://github.com/kallaspriit/HTML5-JavaScript-Gamepad-Controller-Library/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/kallaspriit/HTML5-JavaScript-Gamepad-Controller-Library.git"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"buster": "~0.6.12",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-buster": "git://github.com/busterjs/grunt-buster.git",
|
||||
"grunt-contrib-jshint": "~0.4.3",
|
||||
"grunt-contrib-yuidoc": "~0.4.0",
|
||||
"grunt-jsbeautifier": "~0.1.9",
|
||||
"grunt-contrib-uglify": "~0.2.2"
|
||||
},
|
||||
"scripts": {
|
||||
"grunt": "node -e \"require('grunt').tasks();\""
|
||||
}
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var buster = require('buster');
|
||||
var assert = buster.assert;
|
||||
|
||||
buster.testCase('ButtonGetter', {
|
||||
setUp: function() {
|
||||
this.Gamepad = require('../gamepad.js').Gamepad;
|
||||
|
||||
this.updater = new this.Gamepad.UpdateStrategies.ManualUpdateStrategy();
|
||||
this.obj = new this.Gamepad(this.updater);
|
||||
},
|
||||
|
||||
|
||||
'value by button': {
|
||||
setUp: function() {
|
||||
var buttons = {
|
||||
byButton: [0]
|
||||
};
|
||||
|
||||
this.gamepad = {
|
||||
buttons: ['uninitialized']
|
||||
};
|
||||
|
||||
|
||||
this.getter = this.obj._createButtonGetter(this.gamepad, buttons, 0);
|
||||
},
|
||||
|
||||
'should be 0 if the raw value is 0': function() {
|
||||
this.gamepad.buttons[0] = 0;
|
||||
|
||||
var result = this.getter();
|
||||
|
||||
assert.equals(result, 0);
|
||||
},
|
||||
|
||||
'should be 1 if the raw value is 1': function() {
|
||||
this.gamepad.buttons[0] = 1;
|
||||
|
||||
var result = this.getter();
|
||||
|
||||
assert.equals(result, 1);
|
||||
},
|
||||
|
||||
'should be 0.25 if the raw value is 0.25': function() {
|
||||
this.gamepad.buttons[0] = 0.25;
|
||||
|
||||
var result = this.getter();
|
||||
|
||||
assert.equals(result, 0.25);
|
||||
},
|
||||
|
||||
'should read GamepadButton objects if available': function() {
|
||||
function GamepadButton(value) {
|
||||
this.value = value;
|
||||
}
|
||||
this.gamepad.buttons[0] = new GamepadButton(1);
|
||||
|
||||
var result = this.getter();
|
||||
|
||||
assert.equals(result, 1);
|
||||
}
|
||||
},
|
||||
|
||||
'value by axis': {
|
||||
setUp: function() {
|
||||
this.buttons = {
|
||||
byButton: [-1],
|
||||
byAxis: ['uninitialized']
|
||||
};
|
||||
|
||||
this.gamepad = {
|
||||
axes: ['uninitialized']
|
||||
};
|
||||
},
|
||||
|
||||
'should be 0 for range 0..1 with raw value 0': function() {
|
||||
this.buttons.byAxis[0] = [0, 0, 1];
|
||||
var getter = this.obj._createButtonGetter(this.gamepad, this.buttons, 0);
|
||||
|
||||
this.gamepad.axes[0] = 0;
|
||||
|
||||
var result = getter();
|
||||
|
||||
assert.equals(result, 0);
|
||||
},
|
||||
|
||||
'should be 1 for range 0..1 with raw value 1': function() {
|
||||
this.buttons.byAxis[0] = [0, 0, 1];
|
||||
var getter = this.obj._createButtonGetter(this.gamepad, this.buttons, 0);
|
||||
|
||||
this.gamepad.axes[0] = 1;
|
||||
|
||||
var result = getter();
|
||||
|
||||
assert.equals(result, 1);
|
||||
},
|
||||
|
||||
'should be 0.25 for range 0..1 with raw value 0.25': function() {
|
||||
this.buttons.byAxis[0] = [0, 0, 1];
|
||||
var getter = this.obj._createButtonGetter(this.gamepad, this.buttons, 0);
|
||||
|
||||
this.gamepad.axes[0] = 0.25;
|
||||
|
||||
var result = getter();
|
||||
|
||||
assert.equals(result, 0.25);
|
||||
},
|
||||
|
||||
'should be 0 for range 0..-1 with raw value 0': function() {
|
||||
this.buttons.byAxis[0] = [0, 0, -1];
|
||||
var getter = this.obj._createButtonGetter(this.gamepad, this.buttons, 0);
|
||||
|
||||
this.gamepad.axes[0] = 0;
|
||||
|
||||
var result = getter();
|
||||
|
||||
assert.equals(result, 0);
|
||||
},
|
||||
|
||||
'should be 1 for range 0..-1 with raw value -1': function() {
|
||||
this.buttons.byAxis[0] = [0, 0, -1];
|
||||
var getter = this.obj._createButtonGetter(this.gamepad, this.buttons, 0);
|
||||
|
||||
this.gamepad.axes[0] = -1;
|
||||
|
||||
var result = getter();
|
||||
|
||||
assert.equals(result, 1);
|
||||
},
|
||||
|
||||
'should be 0 for range 0..1 with raw value -0.25': function() {
|
||||
this.buttons.byAxis[0] = [0, 0, 1];
|
||||
var getter = this.obj._createButtonGetter(this.gamepad, this.buttons, 0);
|
||||
|
||||
this.gamepad.axes[0] = -0.25;
|
||||
|
||||
var result = getter();
|
||||
|
||||
assert.equals(result, 0);
|
||||
},
|
||||
|
||||
'should be 0 for range 0..-1 with raw value 0.25': function() {
|
||||
this.buttons.byAxis[0] = [0, 0, -1];
|
||||
var getter = this.obj._createButtonGetter(this.gamepad, this.buttons, 0);
|
||||
|
||||
this.gamepad.axes[0] = 0.25;
|
||||
|
||||
var result = getter();
|
||||
|
||||
assert.equals(result, 0);
|
||||
},
|
||||
|
||||
// seen with PS3 buttons (extra buttons)
|
||||
'should be 0 for range -1..1 with raw value -1': function() {
|
||||
this.buttons.byAxis[0] = [0, -1, 1];
|
||||
var getter = this.obj._createButtonGetter(this.gamepad, this.buttons, 0);
|
||||
|
||||
this.gamepad.axes[0] = -1;
|
||||
|
||||
var result = getter();
|
||||
|
||||
assert.equals(result, 0);
|
||||
},
|
||||
|
||||
// seen with PS3 buttons (extra buttons)
|
||||
'should be 0.75 for range -1..1 with raw value 0.5': function() {
|
||||
this.buttons.byAxis[0] = [0, -1, 1];
|
||||
var getter = this.obj._createButtonGetter(this.gamepad, this.buttons, 0);
|
||||
|
||||
this.gamepad.axes[0] = 0.5;
|
||||
|
||||
var result = getter();
|
||||
|
||||
assert.equals(result, 0.75);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
})();
|
|
@ -0,0 +1,43 @@
|
|||
/* global global */
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var buster = require('buster');
|
||||
var assert = buster.assert;
|
||||
|
||||
var GamepadSimulator = require('./GamepadSimulator.js');
|
||||
|
||||
buster.testCase('Firefox', {
|
||||
setUp: function() {
|
||||
var simulator = new GamepadSimulator();
|
||||
var nullFunction = function() {};
|
||||
|
||||
this.simulator = simulator;
|
||||
global.window = {
|
||||
addEventListener: nullFunction,
|
||||
navigator: {
|
||||
userAgent: 'Firefox'
|
||||
}
|
||||
};
|
||||
|
||||
this.listener = {
|
||||
_connect: nullFunction,
|
||||
_disconnect: nullFunction
|
||||
};
|
||||
|
||||
this.Gamepad = require('../gamepad.js').Gamepad;
|
||||
this.platform = this.Gamepad.resolvePlatform(this.listener);
|
||||
},
|
||||
|
||||
'should be supported': function() {
|
||||
assert(this.platform.isSupported());
|
||||
},
|
||||
|
||||
'should have type "Firefox"': function() {
|
||||
var result = this.platform.getType();
|
||||
|
||||
assert.equals(result, 'Firefox');
|
||||
}
|
||||
|
||||
});
|
||||
})();
|
|
@ -0,0 +1,255 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var buster = require('buster');
|
||||
var assert = buster.assert;
|
||||
|
||||
var GamepadSimulator = require('./GamepadSimulator.js');
|
||||
var PlatformSimulator = require('./PlatformSimulator.js');
|
||||
var GamepadUser = require('./GamepadUser.js');
|
||||
|
||||
/*
|
||||
* Probes all controls;
|
||||
* First all buttons (setting their value to 1.0, then reset to 0.0),
|
||||
* then all axes (first 1.0, then -1.0, then reset to 0.0)
|
||||
*/
|
||||
|
||||
function probeControls(test) {
|
||||
var i;
|
||||
var buttons = test.gamepad.buttons;
|
||||
var axes = test.gamepad.axes;
|
||||
|
||||
for (i = 0; i < buttons.length; i++) {
|
||||
buttons[i] = 1.0;
|
||||
test.updater.update();
|
||||
buttons[i] = 0.0;
|
||||
}
|
||||
for (i = 0; i < axes.length; i++) {
|
||||
axes[i] = 1.0;
|
||||
test.updater.update();
|
||||
axes[i] = -1.0;
|
||||
test.updater.update();
|
||||
axes[i] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests the report of BUTTON_DOWN with control names for buttons.
|
||||
* The method first iterates from 0..N of all gamepad buttons and fires them,
|
||||
* then does the same for all axes.
|
||||
*
|
||||
* @param {Object} test the buster test to run in
|
||||
* @param {Array} expected the expected list of buttons to be reported
|
||||
*/
|
||||
|
||||
function buttonsTest(test, expected) {
|
||||
var result = [];
|
||||
|
||||
test.user.onButtonDown = function(data) {
|
||||
result.push(data.control);
|
||||
};
|
||||
probeControls(test);
|
||||
|
||||
assert.equals(result, expected);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests the report of AXIS_CHANGED with control names for axes.
|
||||
* The method first iterates from 0..N of all gamepad buttons and fires them,
|
||||
* then does the same for all axes.
|
||||
*
|
||||
* @param {Object} test the buster test to run in
|
||||
* @param {Array} expected the expected list of axes to be reported
|
||||
*/
|
||||
|
||||
function axesTest(test, expected) {
|
||||
var result = [];
|
||||
|
||||
test.user.onAxisChanged = function(data) {
|
||||
if ((data.value > 0.0) && (result[result.length - 1] !== data.axis)) {
|
||||
result.push(data.axis);
|
||||
}
|
||||
};
|
||||
probeControls(test);
|
||||
|
||||
assert.equals(result, expected);
|
||||
}
|
||||
|
||||
buster.testCase('Gamepad Mapping', {
|
||||
setUp: function() {
|
||||
var gamepadSimulator = new GamepadSimulator();
|
||||
var that = this;
|
||||
|
||||
this.gamepadSimulator = gamepadSimulator;
|
||||
|
||||
this.Gamepad = require('../gamepad.js').Gamepad;
|
||||
|
||||
this.PlatformFactories = this.Gamepad.PlatformFactories;
|
||||
this.Gamepad.PlatformFactories = [
|
||||
function(listener) {
|
||||
var platform = that.platform = new PlatformSimulator(listener);
|
||||
|
||||
return platform;
|
||||
}
|
||||
];
|
||||
|
||||
this.updater = new this.Gamepad.UpdateStrategies.ManualUpdateStrategy();
|
||||
|
||||
this.obj = new this.Gamepad(this.updater);
|
||||
this.user = new GamepadUser(this.Gamepad.Event, this.obj);
|
||||
this.obj.init();
|
||||
|
||||
},
|
||||
|
||||
tearDown: function() {
|
||||
this.Gamepad.PlatformFactories = this.PlatformFactories;
|
||||
},
|
||||
|
||||
'XBOX controller': {
|
||||
|
||||
setUp: function() {
|
||||
this.gamepad = this.gamepadSimulator.addGamepad(0, 'xbox gamepad', 17);
|
||||
this.platform.listener._connect(this.gamepad);
|
||||
},
|
||||
|
||||
'should have all buttons mapped': function() {
|
||||
buttonsTest(this, ['FACE_1', 'FACE_2', 'FACE_3', 'FACE_4', 'LEFT_TOP_SHOULDER',
|
||||
'RIGHT_TOP_SHOULDER',
|
||||
'LEFT_BOTTOM_SHOULDER', 'RIGHT_BOTTOM_SHOULDER',
|
||||
'SELECT_BACK', 'START_FORWARD', 'LEFT_STICK', 'RIGHT_STICK',
|
||||
'DPAD_UP', 'DPAD_DOWN', 'DPAD_LEFT', 'DPAD_RIGHT',
|
||||
'HOME'
|
||||
]);
|
||||
},
|
||||
|
||||
'should have all axes mapped': function() {
|
||||
axesTest(this, ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y']);
|
||||
}
|
||||
},
|
||||
|
||||
'Logitech controller on WebKit': {
|
||||
setUp: function() {
|
||||
this.gamepad = this.gamepadSimulator.addGamepad(0, 'logitech gamepad');
|
||||
this.platform.type = 'WebKit';
|
||||
this.platform.listener._connect(this.gamepad);
|
||||
},
|
||||
|
||||
'should have all buttons mapped': function() {
|
||||
buttonsTest(this, ['FACE_3', 'FACE_1', 'FACE_2', 'FACE_4',
|
||||
'LEFT_TOP_SHOULDER', 'RIGHT_TOP_SHOULDER', 'LEFT_BOTTOM_SHOULDER', 'RIGHT_BOTTOM_SHOULDER',
|
||||
'SELECT_BACK', 'START_FORWARD', 'LEFT_STICK', 'HOME', 'RIGHT_STICK',
|
||||
'DPAD_UP', 'DPAD_DOWN', 'DPAD_LEFT', 'DPAD_RIGHT'
|
||||
]);
|
||||
},
|
||||
|
||||
'should have all axes mapped': function() {
|
||||
axesTest(this, ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y']);
|
||||
}
|
||||
},
|
||||
|
||||
'Logitech controller on Firefox': {
|
||||
setUp: function() {
|
||||
this.gamepad = this.gamepadSimulator.addGamepad(0, 'logitech gamepad', 15, 5);
|
||||
this.platform.type = 'Firefox';
|
||||
this.platform.listener._connect(this.gamepad);
|
||||
},
|
||||
|
||||
'should have all buttons mapped': function() {
|
||||
buttonsTest(this, ['FACE_1', 'FACE_2', 'FACE_3', 'FACE_4',
|
||||
'LEFT_TOP_SHOULDER', 'RIGHT_TOP_SHOULDER',
|
||||
'SELECT_BACK', 'START_FORWARD', 'LEFT_STICK', 'RIGHT_STICK', 'HOME',
|
||||
'DPAD_UP', 'DPAD_DOWN', 'DPAD_LEFT', 'DPAD_RIGHT',
|
||||
'LEFT_BOTTOM_SHOULDER', 'RIGHT_BOTTOM_SHOULDER'
|
||||
]);
|
||||
},
|
||||
|
||||
'should have all axes mapped': function() {
|
||||
axesTest(this, ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y']);
|
||||
}
|
||||
},
|
||||
|
||||
'Playstation controller on WebKit': {
|
||||
setUp: function() {
|
||||
this.gamepad = this.gamepadSimulator.addGamepad(0, 'playstation gamepad', 17);
|
||||
this.platform.type = 'WebKit';
|
||||
this.platform.listener._connect(this.gamepad);
|
||||
},
|
||||
|
||||
'should have all buttons mapped': function() {
|
||||
buttonsTest(this, ['FACE_1', 'FACE_2', 'FACE_3', 'FACE_4', 'LEFT_TOP_SHOULDER',
|
||||
'RIGHT_TOP_SHOULDER',
|
||||
'LEFT_BOTTOM_SHOULDER', 'RIGHT_BOTTOM_SHOULDER',
|
||||
'SELECT_BACK', 'START_FORWARD', 'LEFT_STICK', 'RIGHT_STICK',
|
||||
'DPAD_UP', 'DPAD_DOWN', 'DPAD_LEFT', 'DPAD_RIGHT',
|
||||
'HOME'
|
||||
]);
|
||||
},
|
||||
|
||||
'should have all axes mapped': function() {
|
||||
axesTest(this, ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y']);
|
||||
}
|
||||
},
|
||||
|
||||
'Playstation controller on Firefox': {
|
||||
setUp: function() {
|
||||
this.gamepad = this.gamepadSimulator.addGamepad(0, 'playstation gamepad');
|
||||
this.platform.type = 'Firefox';
|
||||
this.platform.listener._connect(this.gamepad);
|
||||
},
|
||||
|
||||
'should have all buttons mapped': function() {
|
||||
buttonsTest(this, ['SELECT_BACK', 'LEFT_STICK', 'RIGHT_STICK', 'START_FORWARD',
|
||||
'DPAD_UP', 'DPAD_RIGHT', 'DPAD_DOWN', 'DPAD_LEFT',
|
||||
'LEFT_BOTTOM_SHOULDER', 'RIGHT_BOTTOM_SHOULDER', 'LEFT_TOP_SHOULDER', 'RIGHT_TOP_SHOULDER',
|
||||
'FACE_4', 'FACE_2', 'FACE_1', 'FACE_3'
|
||||
]);
|
||||
},
|
||||
|
||||
'should have all axes mapped': function() {
|
||||
axesTest(this, ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y']);
|
||||
}
|
||||
},
|
||||
|
||||
'Retrolink N64 controller on Firefox': {
|
||||
setUp: function() {
|
||||
this.gamepad = this.gamepadSimulator.addGamepad(0,
|
||||
'79-6-Generic USB Joystick ');
|
||||
this.platform.type = 'Firefox';
|
||||
this.platform.listener._connect(this.gamepad);
|
||||
},
|
||||
|
||||
'should have all buttons mapped': function() {
|
||||
buttonsTest(this, ['FACE_4', 'FACE_2', 'FACE_1', 'FACE_3',
|
||||
'LEFT_TOP_SHOULDER', 'RIGHT_TOP_SHOULDER', 'SELECT_BACK',
|
||||
'START_FORWARD', 'DPAD_UP', 'DPAD_DOWN', 'DPAD_LEFT',
|
||||
'DPAD_RIGHT'
|
||||
]);
|
||||
},
|
||||
|
||||
'should have all axes mapped': function() {
|
||||
axesTest(this, ['LEFT_STICK_X', 'LEFT_STICK_Y']);
|
||||
}
|
||||
},
|
||||
|
||||
'Retrolink N64 controller on WebKit': {
|
||||
setUp: function() {
|
||||
this.gamepad = this.gamepadSimulator.addGamepad(0,
|
||||
'Generic USB Joystick (STANDARD GAMEPAD Vendor: 0079 Product: 0006)');
|
||||
this.platform.type = 'WebKit';
|
||||
this.platform.listener._connect(this.gamepad);
|
||||
},
|
||||
|
||||
'should have all buttons mapped': function() {
|
||||
buttonsTest(this, ['FACE_4', 'FACE_2', 'FACE_1', 'FACE_3',
|
||||
'LEFT_TOP_SHOULDER', 'RIGHT_TOP_SHOULDER', 'SELECT_BACK',
|
||||
'START_FORWARD', 'DPAD_UP', 'DPAD_DOWN', 'DPAD_LEFT',
|
||||
'DPAD_RIGHT'
|
||||
]);
|
||||
},
|
||||
|
||||
'should have all axes mapped': function() {
|
||||
axesTest(this, ['LEFT_STICK_X', 'LEFT_STICK_Y']);
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
|
@ -0,0 +1,42 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var Gamepad = function(index, id, buttonCount, axisCount) {
|
||||
this.index = index;
|
||||
this.id = id;
|
||||
|
||||
this.buttons = [];
|
||||
while (this.buttons.length < (buttonCount || 16)) {
|
||||
this.buttons.push(0.0);
|
||||
}
|
||||
this.axes = [];
|
||||
while (this.axes.length < (axisCount || 4)) {
|
||||
this.axes.push(0.0);
|
||||
}
|
||||
};
|
||||
|
||||
var GamepadSimulator = function() {
|
||||
this.gamepads = [];
|
||||
};
|
||||
|
||||
GamepadSimulator.prototype.getGamepads = function() {
|
||||
return this.gamepads;
|
||||
};
|
||||
|
||||
GamepadSimulator.prototype.addGamepad = function(index, id, buttonCount, axisCount) {
|
||||
var gamepad = new Gamepad(index, id, buttonCount, axisCount);
|
||||
|
||||
while (index >= this.gamepads.length) {
|
||||
this.gamepads.push(null);
|
||||
}
|
||||
this.gamepads[index] = gamepad;
|
||||
|
||||
return gamepad;
|
||||
};
|
||||
|
||||
GamepadSimulator.prototype.removeGamepad = function(index) {
|
||||
this.gamepads[index] = null;
|
||||
};
|
||||
|
||||
module.exports = GamepadSimulator;
|
||||
})();
|
|
@ -0,0 +1,59 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var buster = require('buster');
|
||||
var assert = buster.assert;
|
||||
|
||||
var GamepadSimulator = require('./GamepadSimulator.js');
|
||||
var PlatformSimulator = require('./PlatformSimulator.js');
|
||||
var GamepadUser = require('./GamepadUser.js');
|
||||
|
||||
buster.testCase('Gamepad', {
|
||||
setUp: function() {
|
||||
var gamepadSimulator = new GamepadSimulator();
|
||||
var that = this;
|
||||
|
||||
this.gamepadSimulator = gamepadSimulator;
|
||||
|
||||
this.Gamepad = require('../gamepad.js').Gamepad;
|
||||
this.PlatformFactories = this.Gamepad.PlatformFactories;
|
||||
|
||||
this.Gamepad.PlatformFactories = [
|
||||
function(listener) {
|
||||
var platform = that.platform = new PlatformSimulator(listener);
|
||||
|
||||
return platform;
|
||||
}
|
||||
];
|
||||
|
||||
this.updater = new this.Gamepad.UpdateStrategies.ManualUpdateStrategy();
|
||||
|
||||
this.obj = new this.Gamepad(this.updater);
|
||||
this.user = new GamepadUser(this.Gamepad.Event, this.obj);
|
||||
this.obj.init();
|
||||
},
|
||||
|
||||
tearDown: function() {
|
||||
this.Gamepad.PlatformFactories = this.PlatformFactories;
|
||||
},
|
||||
|
||||
'should cause CONNECTED event when XBOX type added': function() {
|
||||
var spy = this.spy(this.user, 'onConnected');
|
||||
var gamepad = this.gamepadSimulator.addGamepad(0, 'xbox gamepad identificaiton');
|
||||
|
||||
this.platform.listener._connect(gamepad);
|
||||
|
||||
assert.calledWith(spy, gamepad);
|
||||
},
|
||||
|
||||
'should cause CONNECTED event when platform resolves mapping': function() {
|
||||
var spy = this.spy(this.user, 'onConnected');
|
||||
var gamepad = this.gamepadSimulator.addGamepad(0, 'playstation thingie');
|
||||
|
||||
this.platform.mapping = {};
|
||||
this.platform.listener._connect(gamepad);
|
||||
|
||||
assert.calledWith(spy, gamepad);
|
||||
}
|
||||
});
|
||||
})();
|
|
@ -0,0 +1,30 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var nullFunction = function() {};
|
||||
|
||||
var GamepadUser = function(events, api) {
|
||||
var that = this;
|
||||
|
||||
function binder(event, handlerName) {
|
||||
api.bind(event, function() {
|
||||
that[handlerName].apply(that, arguments);
|
||||
});
|
||||
}
|
||||
|
||||
binder(events.CONNECTED, 'onConnected');
|
||||
binder(events.DISCONNECTED, 'onDisconnected');
|
||||
binder(events.BUTTON_DOWN, 'onButtonDown');
|
||||
binder(events.BUTTON_UP, 'onButtonUp');
|
||||
binder(events.AXIS_CHANGED, 'onAxisChanged');
|
||||
};
|
||||
|
||||
GamepadUser.prototype.onConnected = nullFunction;
|
||||
GamepadUser.prototype.onDisconnected = nullFunction;
|
||||
GamepadUser.prototype.onButtonDown = nullFunction;
|
||||
GamepadUser.prototype.onButtonUp = nullFunction;
|
||||
GamepadUser.prototype.onAxisChanged = nullFunction;
|
||||
|
||||
|
||||
module.exports = GamepadUser;
|
||||
})();
|
|
@ -0,0 +1,38 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var buster = require('buster');
|
||||
var assert = buster.assert;
|
||||
|
||||
buster.testCase('Gamepad Interface', {
|
||||
setUp: function() {
|
||||
this.Gamepad = require('../gamepad.js').Gamepad;
|
||||
},
|
||||
|
||||
'object': {
|
||||
setUp: function() {
|
||||
this.obj = new this.Gamepad(new this.Gamepad.UpdateStrategies.ManualUpdateStrategy());
|
||||
},
|
||||
|
||||
'should be instantiable': function() {
|
||||
assert.isObject(this.obj);
|
||||
},
|
||||
|
||||
'should provide init method': function() {
|
||||
assert.isFunction(this.obj.init);
|
||||
},
|
||||
|
||||
'should provide bind method': function() {
|
||||
assert.isFunction(this.obj.bind);
|
||||
},
|
||||
|
||||
'should provide unbind method': function() {
|
||||
assert.isFunction(this.obj.unbind);
|
||||
},
|
||||
|
||||
'should provide count method': function() {
|
||||
assert.isFunction(this.obj.count);
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
|
@ -0,0 +1,23 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var PlatformSimulator = function(listener) {
|
||||
this.listener = listener;
|
||||
this.type = 'Simulator';
|
||||
this.mapping = null;
|
||||
};
|
||||
|
||||
PlatformSimulator.prototype.getType = function() {
|
||||
return this.type;
|
||||
};
|
||||
|
||||
PlatformSimulator.prototype.isSupported = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
PlatformSimulator.prototype.update = function() {
|
||||
|
||||
};
|
||||
|
||||
module.exports = PlatformSimulator;
|
||||
})();
|
|
@ -0,0 +1,143 @@
|
|||
/* global global */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var buster = require('buster');
|
||||
var assert = buster.assert;
|
||||
var refute = buster.refute;
|
||||
|
||||
buster.testCase('Platform', {
|
||||
setUp: function() {
|
||||
this.Gamepad = require('../gamepad.js').Gamepad;
|
||||
this.obj = new this.Gamepad(new this.Gamepad.UpdateStrategies.ManualUpdateStrategy());
|
||||
},
|
||||
|
||||
'unsupported should cause init() to return false': function() {
|
||||
global.window = {
|
||||
navigator: {}
|
||||
};
|
||||
var result = this.obj.init();
|
||||
|
||||
refute(result);
|
||||
},
|
||||
|
||||
'Gamepad.getNullPlatform()': {
|
||||
setUp: function() {
|
||||
this.platform = this.Gamepad.getNullPlatform();
|
||||
},
|
||||
|
||||
'should return an object': function() {
|
||||
assert.isObject(this.platform);
|
||||
},
|
||||
|
||||
'should return false for isSupported()': function() {
|
||||
refute(this.platform.isSupported());
|
||||
},
|
||||
|
||||
'should provide update method': function() {
|
||||
assert.isFunction(this.platform.update);
|
||||
},
|
||||
|
||||
'should provide an immutable object': function() {
|
||||
this.platform.isSupported = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
var newObject = this.Gamepad.getNullPlatform();
|
||||
|
||||
refute.same(newObject, this.platform);
|
||||
}
|
||||
},
|
||||
|
||||
'Gamepad.resolvePlatform()': {
|
||||
setUp: function() {
|
||||
this.PlatformFactories = this.Gamepad.PlatformFactories;
|
||||
},
|
||||
|
||||
tearDown: function() {
|
||||
this.Gamepad.PlatformFactories = this.PlatformFactories;
|
||||
delete global.window;
|
||||
},
|
||||
|
||||
'should provide unsupported platform when no factories available': function() {
|
||||
this.Gamepad.PlatformFactories = [];
|
||||
|
||||
var platform = this.Gamepad.resolvePlatform();
|
||||
|
||||
refute(platform.isSupported());
|
||||
},
|
||||
|
||||
'should provide platform for polling window.navigator.webkitGamepads array': function() {
|
||||
global.window = {
|
||||
navigator: {
|
||||
webkitGamepads: [1, 2, 3]
|
||||
}
|
||||
};
|
||||
|
||||
var platform = this.Gamepad.resolvePlatform();
|
||||
|
||||
assert(platform.isSupported());
|
||||
},
|
||||
|
||||
'should provide platform for polling window.navigator.getGamepads() function': function() {
|
||||
global.window = {
|
||||
navigator: {
|
||||
getGamepads: function() {
|
||||
return ['game1'];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var platform = this.Gamepad.resolvePlatform();
|
||||
|
||||
assert(platform.isSupported());
|
||||
assert(platform.gamepadGetter()[0] === 'game1');
|
||||
},
|
||||
|
||||
'should provide platform for polling window.navigator.webkitGamepads() function': function() {
|
||||
global.window = {
|
||||
navigator: {
|
||||
webkitGamepads: function() {
|
||||
return ['game1'];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var platform = this.Gamepad.resolvePlatform();
|
||||
|
||||
assert(platform.isSupported());
|
||||
assert(platform.gamepadGetter()[0] === 'game1');
|
||||
},
|
||||
|
||||
'should provide platform for polling window.navigator.webkitGetGamepads() function': function() {
|
||||
global.window = {
|
||||
navigator: {
|
||||
webkitGetGamepads: function() {
|
||||
return ['game1'];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var platform = this.Gamepad.resolvePlatform();
|
||||
|
||||
assert(platform.isSupported());
|
||||
assert(platform.gamepadGetter()[0] === 'game1');
|
||||
},
|
||||
|
||||
'should provide platform for Firefox': function() {
|
||||
global.window = {
|
||||
addEventListener: function() {},
|
||||
navigator: {
|
||||
userAgent: 'Firefox'
|
||||
}
|
||||
};
|
||||
|
||||
var platform = this.Gamepad.resolvePlatform();
|
||||
|
||||
assert(platform.isSupported());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
})();
|
|
@ -0,0 +1,163 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var buster = require('buster');
|
||||
var assert = buster.assert;
|
||||
var refute = buster.refute;
|
||||
|
||||
var GamepadSimulator = require('./GamepadSimulator.js');
|
||||
var PlatformSimulator = require('./PlatformSimulator.js');
|
||||
var GamepadUser = require('./GamepadUser.js');
|
||||
|
||||
buster.testCase('Resolve Mapping', {
|
||||
'envMatchesFilter()': {
|
||||
setUp: function() {
|
||||
this.Gamepad = require('../gamepad.js').Gamepad;
|
||||
|
||||
},
|
||||
|
||||
'should return true for empty filter': function() {
|
||||
var filter = {};
|
||||
var env = {
|
||||
type: 'someType'
|
||||
};
|
||||
var result = this.Gamepad.envMatchesFilter(filter, env);
|
||||
|
||||
assert(result);
|
||||
},
|
||||
|
||||
'should return false for a filter property not found in env': function() {
|
||||
var filter = {
|
||||
type: 'logitech'
|
||||
};
|
||||
var env = {};
|
||||
var result = this.Gamepad.envMatchesFilter(filter, env);
|
||||
|
||||
refute(result);
|
||||
},
|
||||
|
||||
'should return false for a non matching filter property': function() {
|
||||
var filter = {
|
||||
type: 'logitech'
|
||||
};
|
||||
var env = {
|
||||
type: 'playstation'
|
||||
};
|
||||
var result = this.Gamepad.envMatchesFilter(filter, env);
|
||||
|
||||
refute(result);
|
||||
},
|
||||
|
||||
'should return false for partially not matching type': function() {
|
||||
var filter = {
|
||||
platform: 'WebKit',
|
||||
type: 'logitech'
|
||||
};
|
||||
var env = {
|
||||
platform: 'WebKit',
|
||||
type: 'playstation'
|
||||
};
|
||||
var result = this.Gamepad.envMatchesFilter(filter, env);
|
||||
|
||||
refute(result);
|
||||
},
|
||||
|
||||
'should return false for partially not matching platform': function() {
|
||||
var filter = {
|
||||
platform: 'Firefox',
|
||||
type: 'playstation'
|
||||
};
|
||||
var env = {
|
||||
platform: 'WebKit',
|
||||
type: 'playstation'
|
||||
};
|
||||
var result = this.Gamepad.envMatchesFilter(filter, env);
|
||||
|
||||
refute(result);
|
||||
},
|
||||
|
||||
'should return true for matching both': function() {
|
||||
var filter = {
|
||||
platform: 'Firefox',
|
||||
type: 'playstation'
|
||||
};
|
||||
var env = {
|
||||
platform: 'Firefox',
|
||||
type: 'playstation'
|
||||
};
|
||||
var result = this.Gamepad.envMatchesFilter(filter, env);
|
||||
|
||||
assert(result);
|
||||
}
|
||||
},
|
||||
'method ': {
|
||||
setUp: function() {
|
||||
var gamepadSimulator = new GamepadSimulator();
|
||||
var that = this;
|
||||
|
||||
this.gamepadSimulator = gamepadSimulator;
|
||||
|
||||
this.Gamepad = require('../gamepad.js').Gamepad;
|
||||
|
||||
this.Mappings = this.Gamepad.Mappings;
|
||||
this.PlatformFactories = this.Gamepad.PlatformFactories;
|
||||
this.Gamepad.PlatformFactories = [
|
||||
function(listener) {
|
||||
var platform = that.platform = new PlatformSimulator(listener);
|
||||
|
||||
return platform;
|
||||
}
|
||||
];
|
||||
|
||||
this.updater = new this.Gamepad.UpdateStrategies.ManualUpdateStrategy();
|
||||
|
||||
this.obj = new this.Gamepad(this.updater);
|
||||
this.user = new GamepadUser(this.Gamepad.Event, this.obj);
|
||||
this.obj.init();
|
||||
},
|
||||
|
||||
tearDown: function() {
|
||||
this.Gamepad.PlatformFactories = this.PlatformFactories;
|
||||
this.Gamepad.Mappings = this.Mappings;
|
||||
},
|
||||
|
||||
'should return standard mapping if specials empty ': function() {
|
||||
var gamepad = this.gamepadSimulator.addGamepad(0, 'Logitech stuff ');
|
||||
this.Gamepad.Mappings = [];
|
||||
|
||||
var result = this.obj._resolveMapping(gamepad);
|
||||
|
||||
assert.equals(result, this.Gamepad.StandardMapping);
|
||||
},
|
||||
|
||||
// found under Windows with an old Logitech gamepad
|
||||
'should return standard mapping if id empty ': function() {
|
||||
var gamepad = this.gamepadSimulator.addGamepad(0, '');
|
||||
this.Gamepad.Mappings = [{
|
||||
env: {
|
||||
type: this.Gamepad.Type.LOGITECH
|
||||
}
|
||||
}];
|
||||
|
||||
var result = this.obj._resolveMapping(gamepad);
|
||||
|
||||
assert.equals(result, this.Gamepad.StandardMapping);
|
||||
},
|
||||
|
||||
'should return mapping for type if matching': function() {
|
||||
var gamepad = this.gamepadSimulator.addGamepad(0, 'Playstation stuff');
|
||||
var logitechMapping = {
|
||||
env: {
|
||||
type: this.Gamepad.Type.PLAYSTATION
|
||||
}
|
||||
};
|
||||
this.Gamepad.Mappings = [logitechMapping];
|
||||
|
||||
var result = this.obj._resolveMapping(gamepad);
|
||||
|
||||
assert.equals(result, logitechMapping);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
|
@ -0,0 +1,105 @@
|
|||
/* global global */
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var buster = require('buster');
|
||||
var assert = buster.assert;
|
||||
var refute = buster.refute;
|
||||
|
||||
var GamepadSimulator = require('./GamepadSimulator.js');
|
||||
|
||||
buster.testCase('WebKit', {
|
||||
setUp: function() {
|
||||
var simulator = new GamepadSimulator();
|
||||
var nullFunction = function() {};
|
||||
|
||||
this.simulator = simulator;
|
||||
global.window = {
|
||||
navigator: {
|
||||
webkitGetGamepads: function() {
|
||||
return simulator.getGamepads();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.listener = {
|
||||
_connect: nullFunction,
|
||||
_disconnect: nullFunction
|
||||
};
|
||||
|
||||
this.Gamepad = require('../gamepad.js').Gamepad;
|
||||
this.platform = this.Gamepad.resolvePlatform(this.listener);
|
||||
},
|
||||
|
||||
'should be supported by polling webkitGetGamepads()': function() {
|
||||
assert(this.platform.isSupported());
|
||||
},
|
||||
|
||||
'should call nothing if list of gamepads stays empty': function() {
|
||||
var spy = this.spy(this.listener, '_connect');
|
||||
|
||||
this.platform.update();
|
||||
this.platform.update();
|
||||
|
||||
refute.called(spy);
|
||||
},
|
||||
|
||||
'should report a connected gamepad if added': function() {
|
||||
var spy = this.spy(this.listener, '_connect');
|
||||
var gamepad = this.simulator.addGamepad(0, 'Testpad1');
|
||||
|
||||
this.platform.update();
|
||||
|
||||
assert.calledWith(spy, gamepad);
|
||||
},
|
||||
|
||||
'should call nothing if list of gamepads remains same': function() {
|
||||
var spy = this.spy(this.listener, '_connect');
|
||||
this.simulator.addGamepad(0, 'Testpad1');
|
||||
|
||||
this.platform.update();
|
||||
this.platform.update();
|
||||
|
||||
assert.calledOnce(spy);
|
||||
},
|
||||
|
||||
'should report a disconnected gamepad if removed': function() {
|
||||
var spy = this.spy(this.listener, '_disconnect');
|
||||
var gamepad = this.simulator.addGamepad(0, 'Testpad1');
|
||||
this.platform.update();
|
||||
|
||||
this.simulator.removeGamepad(0);
|
||||
this.platform.update();
|
||||
|
||||
assert.calledWith(spy, gamepad);
|
||||
},
|
||||
|
||||
'should report a second connected gamepad if added': function() {
|
||||
var spy = this.spy(this.listener, '_connect');
|
||||
var gamepad = this.simulator.addGamepad(1, 'Testpad2');
|
||||
|
||||
this.platform.update();
|
||||
|
||||
assert.calledWith(spy, gamepad);
|
||||
},
|
||||
|
||||
'should handle connection of second gamepad in same slot': function() {
|
||||
var spy = this.spy(this.listener, '_connect');
|
||||
|
||||
this.simulator.addGamepad(0, 'Testpad1');
|
||||
this.platform.update();
|
||||
|
||||
this.simulator.addGamepad(0, 'Testpad2');
|
||||
this.platform.update();
|
||||
|
||||
assert.calledTwice(spy);
|
||||
},
|
||||
|
||||
'should have type "WebKit"': function() {
|
||||
var result = this.platform.getType();
|
||||
|
||||
assert.equals(result, 'WebKit');
|
||||
}
|
||||
|
||||
});
|
||||
})();
|
|
@ -0,0 +1,7 @@
|
|||
var config = module.exports;
|
||||
|
||||
config['Library tests raw'] = {
|
||||
rootPath: '../',
|
||||
environment: 'node',
|
||||
tests: ['test/**/*Test.js']
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "OpenBuildsMachineDriver",
|
||||
"version": "1.0.74",
|
||||
"version": "1.0.75",
|
||||
"license": "AGPL-3.0",
|
||||
"description": "Machine Interface Driver for OpenBuilds",
|
||||
"author": "github.com/openbuilds <webmaster@openbuilds.com>",
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Make download page
|
||||
Keyboard/Gamepad/HID
|
Ładowanie…
Reference in New Issue