Skip to content

Commit de9974d

Browse files
committed
PSR2 examples
Updated bracketing style and also changed all vars to lets.
1 parent 5def58d commit de9974d

File tree

9 files changed

+87
-162
lines changed

9 files changed

+87
-162
lines changed

examples/basic_code_wheel/index.html

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ <h1>Winwheel.js example wheel - basic code wheel</h1>
7474
</div>
7575
<script>
7676
// Create new wheel object specifying the parameters at creation time.
77-
var theWheel = new Winwheel({
77+
let theWheel = new Winwheel({
7878
'numSegments' : 8, // Specify number of segments.
7979
'outerRadius' : 212, // Set outer radius so wheel fits inside the background.
8080
'textFontSize' : 28, // Set font size as desired.
@@ -99,35 +99,31 @@ <h1>Winwheel.js example wheel - basic code wheel</h1>
9999
});
100100

101101
// Vars used by the code in this page to do power controls.
102-
var wheelPower = 0;
103-
var wheelSpinning = false;
102+
let wheelPower = 0;
103+
let wheelSpinning = false;
104104

105105
// -------------------------------------------------------
106106
// Function to handle the onClick on the power buttons.
107107
// -------------------------------------------------------
108108
function powerSelected(powerLevel)
109109
{
110110
// Ensure that power can't be changed while wheel is spinning.
111-
if (wheelSpinning == false)
112-
{
111+
if (wheelSpinning == false) {
113112
// Reset all to grey incase this is not the first time the user has selected the power.
114113
document.getElementById('pw1').className = "";
115114
document.getElementById('pw2').className = "";
116115
document.getElementById('pw3').className = "";
117116

118117
// Now light up all cells below-and-including the one selected by changing the class.
119-
if (powerLevel >= 1)
120-
{
118+
if (powerLevel >= 1) {
121119
document.getElementById('pw1').className = "pw1";
122120
}
123121

124-
if (powerLevel >= 2)
125-
{
122+
if (powerLevel >= 2) {
126123
document.getElementById('pw2').className = "pw2";
127124
}
128125

129-
if (powerLevel >= 3)
130-
{
126+
if (powerLevel >= 3) {
131127
document.getElementById('pw3').className = "pw3";
132128
}
133129

@@ -146,20 +142,14 @@ <h1>Winwheel.js example wheel - basic code wheel</h1>
146142
function startSpin()
147143
{
148144
// Ensure that spinning can't be clicked again while already running.
149-
if (wheelSpinning == false)
150-
{
145+
if (wheelSpinning == false) {
151146
// Based on the power level selected adjust the number of spins for the wheel, the more times is has
152147
// to rotate with the duration of the animation the quicker the wheel spins.
153-
if (wheelPower == 1)
154-
{
148+
if (wheelPower == 1) {
155149
theWheel.animation.spins = 3;
156-
}
157-
else if (wheelPower == 2)
158-
{
150+
} else if (wheelPower == 2) {
159151
theWheel.animation.spins = 8;
160-
}
161-
else if (wheelPower == 3)
162-
{
152+
} else if (wheelPower == 3) {
163153
theWheel.animation.spins = 15;
164154
}
165155

examples/basic_image_wheel/index.html

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ <h1>Winwheel.js example wheel - basic image wheel</h1>
7474
</div>
7575
<script>
7676
// Create new wheel object specifying the parameters at creation time.
77-
var theWheel = new Winwheel({
77+
let theWheel = new Winwheel({
7878
'numSegments' : 4, // Specify number of segments.
7979
'outerRadius' : 150, // Set outer radius so wheel fits inside the background.
8080
'drawMode' : 'image', // drawMode must be set to image.
@@ -105,7 +105,7 @@ <h1>Winwheel.js example wheel - basic image wheel</h1>
105105
});
106106

107107
// Create new image object in memory.
108-
var loadedImg = new Image();
108+
let loadedImg = new Image();
109109

110110
// Create callback to execute once the image has finished loading.
111111
loadedImg.onload = function()
@@ -120,35 +120,31 @@ <h1>Winwheel.js example wheel - basic image wheel</h1>
120120

121121

122122
// Vars used by the code in this page to do power controls.
123-
var wheelPower = 0;
124-
var wheelSpinning = false;
123+
let wheelPower = 0;
124+
let wheelSpinning = false;
125125

126126
// -------------------------------------------------------
127127
// Function to handle the onClick on the power buttons.
128128
// -------------------------------------------------------
129129
function powerSelected(powerLevel)
130130
{
131131
// Ensure that power can't be changed while wheel is spinning.
132-
if (wheelSpinning == false)
133-
{
132+
if (wheelSpinning == false) {
134133
// Reset all to grey incase this is not the first time the user has selected the power.
135134
document.getElementById('pw1').className = "";
136135
document.getElementById('pw2').className = "";
137136
document.getElementById('pw3').className = "";
138137

139138
// Now light up all cells below-and-including the one selected by changing the class.
140-
if (powerLevel >= 1)
141-
{
139+
if (powerLevel >= 1) {
142140
document.getElementById('pw1').className = "pw1";
143141
}
144142

145-
if (powerLevel >= 2)
146-
{
143+
if (powerLevel >= 2) {
147144
document.getElementById('pw2').className = "pw2";
148145
}
149146

150-
if (powerLevel >= 3)
151-
{
147+
if (powerLevel >= 3) {
152148
document.getElementById('pw3').className = "pw3";
153149
}
154150

@@ -167,20 +163,14 @@ <h1>Winwheel.js example wheel - basic image wheel</h1>
167163
function startSpin()
168164
{
169165
// Ensure that spinning can't be clicked again while already running.
170-
if (wheelSpinning == false)
171-
{
166+
if (wheelSpinning == false) {
172167
// Based on the power level selected adjust the number of spins for the wheel, the more times is has
173168
// to rotate with the duration of the animation the quicker the wheel spins.
174-
if (wheelPower == 1)
175-
{
169+
if (wheelPower == 1) {
176170
theWheel.animation.spins = 2;
177-
}
178-
else if (wheelPower == 2)
179-
{
171+
} else if (wheelPower == 2) {
180172
theWheel.animation.spins = 5;
181-
}
182-
else if (wheelPower == 3)
183-
{
173+
} else if (wheelPower == 3) {
184174
theWheel.animation.spins = 8;
185175
}
186176

examples/continuous_spining_wheel/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h1>Winwheel.js example wheel - ongoing spin wheel</h1>
4242
</div>
4343
<script>
4444
// Create new wheel object specifying the parameters at creation time.
45-
var theWheel = new Winwheel({
45+
let theWheel = new Winwheel({
4646
'numSegments' : 8, // Specify number of segments.
4747
'outerRadius' : 212, // Set outer radius so wheel fits inside the background.
4848
'textFontSize' : 28, // Set font size as desired.
-19.7 KB
Binary file not shown.

examples/hollow_wheel/index.html

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ <h1>Winwheel.js example wheel - hollow wheel</h1>
7979
</div>
8080
<script>
8181
// Create new wheel object specifying the parameters at creation time.
82-
var theWheel = new Winwheel({
82+
let theWheel = new Winwheel({
8383
'numSegments' : 16, // Specify number of segments.
8484
'outerRadius' : 212, // Set radius to so wheel fits the background.
8585
'innerRadius' : 120, // Set inner radius to make wheel hollow.
@@ -114,35 +114,31 @@ <h1>Winwheel.js example wheel - hollow wheel</h1>
114114
});
115115

116116
// Vars used by the code in this page to do power controls.
117-
var wheelPower = 0;
118-
var wheelSpinning = false;
117+
let wheelPower = 0;
118+
let wheelSpinning = false;
119119

120120
// -------------------------------------------------------
121121
// Function to handle the onClick on the power buttons.
122122
// -------------------------------------------------------
123123
function powerSelected(powerLevel)
124124
{
125125
// Ensure that power can't be changed while wheel is spinning.
126-
if (wheelSpinning == false)
127-
{
126+
if (wheelSpinning == false) {
128127
// Reset all to grey incase this is not the first time the user has selected the power.
129128
document.getElementById('pw1').className = "";
130129
document.getElementById('pw2').className = "";
131130
document.getElementById('pw3').className = "";
132131

133132
// Now light up all cells below-and-including the one selected by changing the class.
134-
if (powerLevel >= 1)
135-
{
133+
if (powerLevel >= 1) {
136134
document.getElementById('pw1').className = "pw1";
137135
}
138136

139-
if (powerLevel >= 2)
140-
{
137+
if (powerLevel >= 2) {
141138
document.getElementById('pw2').className = "pw2";
142139
}
143140

144-
if (powerLevel >= 3)
145-
{
141+
if (powerLevel >= 3) {
146142
document.getElementById('pw3').className = "pw3";
147143
}
148144

@@ -161,20 +157,14 @@ <h1>Winwheel.js example wheel - hollow wheel</h1>
161157
function startSpin()
162158
{
163159
// Ensure that spinning can't be clicked again while already running.
164-
if (wheelSpinning == false)
165-
{
160+
if (wheelSpinning == false) {
166161
// Based on the power level selected adjust the number of spins for the wheel, the more times is has
167162
// to rotate with the duration of the animation the quicker the wheel spins.
168-
if (wheelPower == 1)
169-
{
163+
if (wheelPower == 1) {
170164
theWheel.animation.spins = 3;
171-
}
172-
else if (wheelPower == 2)
173-
{
165+
} else if (wheelPower == 2) {
174166
theWheel.animation.spins = 8;
175-
}
176-
else if (wheelPower == 3)
177-
{
167+
} else if (wheelPower == 3) {
178168
theWheel.animation.spins = 15;
179169
}
180170

examples/one_image_per_segment/index.html

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ <h1>Winwheel.js example wheel - one image per segment</h1>
7575
</div>
7676
<script>
7777
// Create new wheel object specifying the parameters at creation time.
78-
var theWheel = new Winwheel({
78+
let theWheel = new Winwheel({
7979
'numSegments' : 8, // Specify number of segments.
8080
'outerRadius' : 200, // Set outer radius so wheel fits inside the background.
8181
'drawText' : true, // Code drawn text can be used with segment images.
@@ -109,35 +109,31 @@ <h1>Winwheel.js example wheel - one image per segment</h1>
109109
});
110110

111111
// Vars used by the code in this page to do power controls.
112-
var wheelPower = 0;
113-
var wheelSpinning = false;
112+
let wheelPower = 0;
113+
let wheelSpinning = false;
114114

115115
// -------------------------------------------------------
116116
// Function to handle the onClick on the power buttons.
117117
// -------------------------------------------------------
118118
function powerSelected(powerLevel)
119119
{
120120
// Ensure that power can't be changed while wheel is spinning.
121-
if (wheelSpinning == false)
122-
{
121+
if (wheelSpinning == false) {
123122
// Reset all to grey incase this is not the first time the user has selected the power.
124123
document.getElementById('pw1').className = "";
125124
document.getElementById('pw2').className = "";
126125
document.getElementById('pw3').className = "";
127126

128127
// Now light up all cells below-and-including the one selected by changing the class.
129-
if (powerLevel >= 1)
130-
{
128+
if (powerLevel >= 1) {
131129
document.getElementById('pw1').className = "pw1";
132130
}
133131

134-
if (powerLevel >= 2)
135-
{
132+
if (powerLevel >= 2) {
136133
document.getElementById('pw2').className = "pw2";
137134
}
138135

139-
if (powerLevel >= 3)
140-
{
136+
if (powerLevel >= 3) {
141137
document.getElementById('pw3').className = "pw3";
142138
}
143139

@@ -156,20 +152,14 @@ <h1>Winwheel.js example wheel - one image per segment</h1>
156152
function startSpin()
157153
{
158154
// Ensure that spinning can't be clicked again while already running.
159-
if (wheelSpinning == false)
160-
{
155+
if (wheelSpinning == false) {
161156
// Based on the power level selected adjust the number of spins for the wheel, the more times is has
162157
// to rotate with the duration of the animation the quicker the wheel spins.
163-
if (wheelPower == 1)
164-
{
158+
if (wheelPower == 1) {
165159
theWheel.animation.spins = 3;
166-
}
167-
else if (wheelPower == 2)
168-
{
160+
} else if (wheelPower == 2) {
169161
theWheel.animation.spins = 8;
170-
}
171-
else if (wheelPower == 3)
172-
{
162+
} else if (wheelPower == 3) {
173163
theWheel.animation.spins = 15;
174164
}
175165

0 commit comments

Comments
 (0)