Social cocos2d-x javascript
Oficial forum: http://discuss.cocos2d-x.org/c/cocos2d-x/javascript
⇐ back to the gist-blog at jrw.fi
Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.
I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.
This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso
Picking the right architecture = Picking the right battles + Managing trade-offs
| // Event: Display Books | |
| document.addEventListener("DOMContentLoaded", UI.displayBooks); | |
| // Event: Add a Book | |
| document.querySelector("#book-form").addEventListener("submit", (e) => { | |
| // Prevent actual submit | |
| e.preventDefault(); | |
| // Get form values | |
| const title = document.querySelector("#title").value; | |
| const author = document.querySelector("#author").value; |
| // We need to stringify before storing and parse it before retrieving it | |
| class Store { | |
| static getBooks() { | |
| let books; | |
| if (localStorage.getItem("books") === null) { | |
| books = []; | |
| } else { | |
| books = JSON.parse(localStorage.getItem("books")); | |
| } | |
| return books; |
| // UI Class: Handle UI Tasks | |
| class UI { | |
| static displayBooks() { | |
| const books = Store.getBooks(); | |
| books.forEach((book) => UI.addBookToList(book)); | |
| } | |
| static addBookToList(book) { | |
| const list = document.querySelector("#book-list"); | |
| const row = document.createElement("tr"); |
| class Book { | |
| constructor(title, author, isbn) { | |
| this.title = title; | |
| this.author = author; | |
| this.isbn = isbn; | |
| } | |
| } |
| function getMovie() { | |
| let movieId = sessionStorage.getItem("movieId"); | |
| axios | |
| .get("http://www.omdbapi.com/?i=" + movieId + "&apikey=796a6593") | |
| .then((response) => { | |
| console.log(response); | |
| let movie = response.data; | |
| let output = ` | |
| <div class="row"> | |
| <div class="col-md-4"> |
| function movieSelected(id) { | |
| sessionStorage.setItem("movieId", id); | |
| window.location = "movie.html"; | |
| return true; | |
| } |
| function getMovies(searchText) { | |
| axios | |
| .get( | |
| "http://www.omdbapi.com/?s=" + encodeURI(searchText) + "&apikey=796a6593" | |
| ) | |
| .then((response) => { | |
| console.log(response); | |
| let movies = response.data.Search; | |
| let output = ""; | |
| $.each(movies, (index, movie) => { |