|
20 | 20 | <input id="searchbar" type="search" class="form-control" placeholder="Search blocks..." v-model="search"></input>
|
21 | 21 | </div>
|
22 | 22 | <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' "> |
24 | 24 | <button v-show="open == undefined || open == menu || search" :class="{highlight: !search}" class="all" :id="menu.split(' ')[0]" @click="toggle(menu)">{{ menu }}</button>
|
25 | 25 | <div v-show="open == menu || search" class="list" v-for="block in blocks">
|
26 | 26 | <vue-block :block="block"></vue-block>
|
|
47 | 47 | <script src="./docs.js"></script>
|
48 | 48 | <script id="block-template" type="text/x-template">
|
49 | 49 | <div class="block">
|
| 50 | + <div v-if="block.integrationDescription" class="alert" :class='block.integrationDescriptionClass' role='alert'>{{ block.integrationDescription }}</div> |
50 | 51 | <img v-if="block.url" ondragstart="event.dataTransfer.setData('text/plain', event.target.alt)" :alt="block.code" :src="block.url">
|
51 | 52 | <div v-if="block.description">{{ block.description }}</div>
|
52 | 53 | <div v-if="block.html" v-html="block.html"></div>
|
|
78 | 79 | search: "",
|
79 | 80 | open: undefined,
|
80 | 81 | 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 | + }, |
115 | 145 | "Sprites & Backgrounds": {
|
116 | 146 | Background: [
|
117 | 147 | {
|
|
1481 | 1511 | description: "But you can also create a function without a name, which is called an anonymous function:",
|
1482 | 1512 | code: "forever(() => {\n sprite.x++\n})",
|
1483 | 1513 | 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" |
1488 | 1514 | }]
|
1489 | 1515 | }
|
1490 | 1516 | },
|
|
1557 | 1583 | }
|
1558 | 1584 | var newMenus = {}
|
1559 | 1585 | for (var menu in menus) {
|
1560 |
| - if (menu == 'Sprites & Backgrounds') { |
| 1586 | + if (menu == 'Sprites & Backgrounds' || menu == 'Integrations') { |
1561 | 1587 | var s = this.searched(menus[menu])
|
1562 | 1588 | if (Object.keys(s).length > 0) {
|
1563 | 1589 | newMenus[menu] = s
|
|
0 commit comments