Skip to content

Commit bf519d1

Browse files
committed
added firebase and local storage to docs
1 parent 69f4553 commit bf519d1

File tree

4 files changed

+141
-44
lines changed

4 files changed

+141
-44
lines changed

dist/woof.js

+28-4
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,9 @@ function Woof() {
663663
});
664664
};
665665
document.body.addEventListener("keyup", thisContext._onKeyUpHandler);
666-
}
666+
});
667667
// The following methods is where we keep track of user's events
668-
);thisContext._onMouseMoves = [];
668+
thisContext._onMouseMoves = [];
669669
thisContext.onMouseMove = function (func) {
670670
if (typeof func != "function") {
671671
throw new TypeError("onMouseMove(function) requires one function input.");
@@ -1132,9 +1132,9 @@ Woof.prototype.Sprite = function () {
11321132
var data = _this.collisionContext.getImageData(canvasLeft, canvasTop, right - left, top - bottom).data;
11331133
} catch (e) {
11341134
if (e instanceof DOMException) {
1135-
console.warn("You have an image at an untrusted URL. Consider uploading to Imgur and using https."
1135+
console.warn("You have an image at an untrusted URL. Consider uploading to Imgur and using https.");
11361136
// bounds are overlapping and we can't get canvas data, so return true
1137-
);return true;
1137+
return true;
11381138
}
11391139
}
11401140

@@ -2164,6 +2164,30 @@ Woof.prototype.pow = function (a, b) {
21642164
return Math.pow(a, b);
21652165
};
21662166

2167+
//IN THE MIDDLE OF ADDING CURRENCY FUNCTIONS
2168+
// const getData = (url, callback) => {
2169+
// fetch(url,{mode:'cors',header:{'Access-Control-Allow-Origin':'*'}}).then(result => {
2170+
// result.json().then(data => {
2171+
// callback(data)
2172+
// })
2173+
// })
2174+
// }
2175+
2176+
// function func(data){
2177+
// return data.rates;
2178+
// }
2179+
2180+
// Woof.prototype.currencyConversionRate = function(from, to) {
2181+
// // httpGetAsync("http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b1b15e88fa797225412429c1c50c122a1", "");
2182+
// var rate = undefined;
2183+
// var url = "http://api.fixer.io/latest?base=" + from;
2184+
// getData(url, data => {
2185+
// rate = data;
2186+
// console.log(rate);
2187+
// })
2188+
// return rate;
2189+
// };
2190+
21672191
// find the woof.js script tag in the page
21682192
var currentScript = document.currentScript || Array.prototype.slice.call(document.getElementsByTagName('script')).find(function (s) {
21692193
return s.src.includes('woof.js');

docs/docs.css

+23
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,29 @@ h4 {
393393
border-radius: 10px;
394394
}
395395

396+
#Firebase {
397+
background-color: #ffca27;
398+
width:90% !important;
399+
}
400+
#Local{
401+
background-color: #0BCC9E;
402+
width:90% !important;
403+
}
404+
405+
/*CURRENCY FUNCTIONS STILL IN THE WORKS*/
406+
/*#Currency{
407+
background-color: #00DA1F;
408+
width:90% !important;
409+
}*/
410+
411+
/*#Currency,*/
412+
#Local,
413+
#Firebase {
414+
height: 8%;
415+
width: 33%;
416+
border-radius: 10px;
417+
}
418+
396419
#postimage {
397420
background-color: #7775D3;
398421
height: 10%;

docs/index.html

+66-40
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<input id="searchbar" type="search" class="form-control" placeholder="Search blocks..." v-model="search"></input>
2121
</div>
2222
<div :style="menuItem" v-for="(blocks, menu) in searched(menus)">
23-
<template v-if="menu != 'Sprites & Backgrounds'">
23+
<template v-if="menu != 'Sprites & Backgrounds' && menu != 'Integrations' ">
2424
<button v-show="open == undefined || open == menu || search" :class="{highlight: !search}" class="all" :id="menu.split(' ')[0]" @click="toggle(menu)">{{ menu }}</button>
2525
<div v-show="open == menu || search" class="list" v-for="block in blocks">
2626
<vue-block :block="block"></vue-block>
@@ -47,6 +47,7 @@
4747
<script src="./docs.js"></script>
4848
<script id="block-template" type="text/x-template">
4949
<div class="block">
50+
<div v-if="block.integrationDescription" class="alert" :class='block.integrationDescriptionClass' role='alert'>{{ block.integrationDescription }}</div>
5051
<img v-if="block.url" ondragstart="event.dataTransfer.setData('text/plain', event.target.alt)" :alt="block.code" :src="block.url">
5152
<div v-if="block.description">{{ block.description }}</div>
5253
<div v-if="block.html" v-html="block.html"></div>
@@ -78,40 +79,69 @@
7879
search: "",
7980
open: undefined,
8081
menus: {
81-
"Keyboard Shortcuts": [{
82-
description: "Save",
83-
code: "Ctl-S"
84-
}, {
85-
description: "Undo",
86-
code: "Ctl-Z"
87-
}, {
88-
description: "Redo",
89-
code: "Ctl-Shift-Z"
90-
}, {
91-
description: "Copy",
92-
code: "Ctl-C"
93-
}, {
94-
description: "Cut",
95-
code: "Ctl-X"
96-
}, {
97-
description: "Paste",
98-
code: "Ctl-V"
99-
}, {
100-
description: "Find",
101-
code: "Ctl-F"
102-
}, {
103-
description: "Select All",
104-
code: "Ctl-A"
105-
}, {
106-
description: "Comment or uncomment code",
107-
code: "Ctl-/"
108-
}, {
109-
description: "Select next occurance of word",
110-
code: "Ctl-D"
111-
}, {
112-
description: "Beautify the selected code with proper indentation",
113-
code: "Ctl-B"
114-
}, ],
82+
"Integrations": {
83+
Firebase: [
84+
{
85+
integrationDescription:"Firebase is Google's mobile platform that helps you with cloud storage.",
86+
integrationDescriptionClass:"alert-info"
87+
},
88+
{html:"<hr style=\"height:7px;border:none;color:#e0e0e0;background-color:#e0e0e0;\"/>"},
89+
{
90+
description: "Import JavaScript code from an external URL. The second input happens after the code is imported.",
91+
code: "importCodeURL('https://www.gstatic.com/firebasejs/3.4.0/firebase.js', () => {\n firebase.initializeApp({\/* credentials here */})\n})",
92+
tags: "import code url require firebase library module"
93+
},
94+
{html:"<hr style=\"height:7px;border:none;color:#e0e0e0;background-color:#e0e0e0;\"/>"},
95+
{
96+
integrationDescription:"Here is a quick run through of how to use Firebase to store a high score:",
97+
integrationDescriptionClass:"alert-info",
98+
html:"<iframe src='http://coding.space/woof/high_score.html' width='100%' height='500px'></iframe>",
99+
tags:"firebase cloud storage high score"
100+
},
101+
],
102+
"Local Storage": [
103+
{
104+
integrationDescription:"Use Local Storage to keep data for a specific user on a specific device. Local Stroage can help you to keep track of a specific user's high score.",
105+
integrationDescriptionClass:"alert-info"
106+
},
107+
{html:"<hr style=\"height:7px;border:none;color:#e0e0e0;background-color:#e0e0e0;\"/>"},
108+
{
109+
description:"First, you want to check if local storage for a specific variable exists. If it doesn't, then create it.",
110+
code:'if (!localStorage.highscore) {\n localStorage.setItem("highscore", 0)\n}',
111+
tags:"local storage high score"
112+
},
113+
{
114+
description:"Retrieve your local storage.",
115+
code:'localStorage.highscore',
116+
tags:"local storage high score"
117+
},
118+
{
119+
description:"Set your local storage.",
120+
code:'//At the end of the game\nlocalStorage.highscore = 50',
121+
tags:"local storage high score"
122+
},
123+
{
124+
description:"Display your local storage.",
125+
code:'var textSprite = new Text({\n text: () => localStorage.highscore, \n size: 12, \n color: "rgb(100, 50, 240)", \n fontFamily: "arial", \n textAlign: "left"\n})',
126+
tags:"local storage high score"
127+
}
128+
],
129+
//CURRENCY FUNCTIONS STILL IN THE WORKS
130+
// "Currency Conversion":[
131+
// {
132+
// integrationDescription:"Use the corrency conversion functions to convert with current conversion rates.",
133+
// html:"<a href='https://www.easymarkets.com/int/learn-centre/discover-trading/currency-acronyms-and-abbreviations/'>Click here for a list of currency abbreviations</a>",
134+
// integrationDescriptionClass:"alert-info"
135+
// },
136+
// {html:"<hr style=\"height:7px;border:none;color:#e0e0e0;background-color:#e0e0e0;\"/>"},
137+
// {
138+
// description:"Get the current conversion rate.",
139+
// code:'//From USD to EUR\ncurrencyConversionRate("USD","EUR")\n//From GBP to USD\ncurrencyConversionRate("GBP","USD")',
140+
// tags:"currency conversion"
141+
// }
142+
// ]
143+
144+
},
115145
"Sprites & Backgrounds": {
116146
Background: [
117147
{
@@ -1481,10 +1511,6 @@
14811511
description: "But you can also create a function without a name, which is called an anonymous function:",
14821512
code: "forever(() => {\n sprite.x++\n})",
14831513
tags: "anonymous function"
1484-
}, {
1485-
description: "Import JavaScript code from an external URL. The second input happens after the code is imported.",
1486-
code: "importCodeURL('https://www.gstatic.com/firebasejs/3.4.0/firebase.js', () => {\n firebase.initializeApp({\/* credentials here */})\n})",
1487-
tags: "import code url require firebase library module"
14881514
}]
14891515
}
14901516
},
@@ -1557,7 +1583,7 @@
15571583
}
15581584
var newMenus = {}
15591585
for (var menu in menus) {
1560-
if (menu == 'Sprites & Backgrounds') {
1586+
if (menu == 'Sprites & Backgrounds' || menu == 'Integrations') {
15611587
var s = this.searched(menus[menu])
15621588
if (Object.keys(s).length > 0) {
15631589
newMenus[menu] = s

src/woof.es6.js

+24
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,30 @@ Woof.prototype.pow = function(a,b) {
16271627
return Math.pow(a,b);
16281628
};
16291629

1630+
//IN THE MIDDLE OF ADDING CURRENCY FUNCTIONS
1631+
// const getData = (url, callback) => {
1632+
// fetch(url,{mode:'cors',header:{'Access-Control-Allow-Origin':'*'}}).then(result => {
1633+
// result.json().then(data => {
1634+
// callback(data)
1635+
// })
1636+
// })
1637+
// }
1638+
1639+
// function func(data){
1640+
// return data.rates;
1641+
// }
1642+
1643+
// Woof.prototype.currencyConversionRate = function(from, to) {
1644+
// // httpGetAsync("http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b1b15e88fa797225412429c1c50c122a1", "");
1645+
// var rate = undefined;
1646+
// var url = "http://api.fixer.io/latest?base=" + from;
1647+
// getData(url, data => {
1648+
// rate = data;
1649+
// console.log(rate);
1650+
// })
1651+
// return rate;
1652+
// };
1653+
16301654
// find the woof.js script tag in the page
16311655
var currentScript = document.currentScript || Array.prototype.slice.call(document.getElementsByTagName('script')).find(s => s.src.includes('woof.js'))
16321656

0 commit comments

Comments
 (0)