Skip to content

Instantly share code, notes, and snippets.

View happyDemon's full-sized avatar

Kerstens Maxim happyDemon

  • Shyfter
  • Belgium
View GitHub Profile
/**
* ValidateSpanishID. Returns the type of document and checks its validity.
*
* Usage:
* ValidateSpanishID( str );
*
* > ValidateSpanishID( '12345678Z' );
* // { type: 'dni', valid: true }
*
* > ValidateSpanishID( 'B83375575' );
@happyDemon
happyDemon / bash
Created February 24, 2017 19:26
Vue.js explained through pokemon #1 - install webpack
npm install -g vue-cli
vue init webpack-simple pokemon-vue
cd pokemon-vue
npm install
npm run dev
@happyDemon
happyDemon / style.css
Created February 24, 2017 19:36
Vue.js explained through pokemon #1
<style>
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed');
@import url('https://fonts.googleapis.com/css?family=PT+Sans+Narrow');
html, body {
height: 100%;
background: #3C7ACD;
}
body {
@happyDemon
happyDemon / data.js
Last active February 24, 2017 19:55
Vue.js explained through pokemon #1
<script>
export default {
data(){
return {
pokemon: {
opponent: {
image: "https://img.pokemondb.net/sprites/black-white/anim/normal/onix.gif",
name: 'Onyx',
hp: 100,
level: 50,
@happyDemon
happyDemon / template-bottom.html
Created February 24, 2017 20:04
Vue.js explained through Pokemon #1
<template>
<div class="battle-scene">
<div class="bottom-menu">
<div class="battle-text text-box-left">
{{battleText}}
</div>
<div class="text-box-right">
<!-- Show the main 4 options -->
<div v-if="menu == 'options'" id="battleOptions">
<h4 @click="processOption(1)" class="battle-text-top-left">{{battleOptions[0]}}</h4>
@happyDemon
happyDemon / main-menu.js
Created February 25, 2017 08:09
Vue.js explained through Pokemon #1
methods: {
processOption: function (option) {
switch (option) {
case 1:
//handle fight
// Show the attack menu
this.menu = 'attack';
break;
case 2:
@happyDemon
happyDemon / computed.js
Created February 25, 2017 08:23
Vue.js explained through Pokemon #1
computed: {
fightOptions(){
return Object.keys(this.pokemon.player.attacks);
}
},
@happyDemon
happyDemon / resetBattle.js
Last active February 25, 2017 08:33
Vue.js explained through Pokemon #1 Raw
resetBattle: function () {
//reset data to start new game
this.menu = 'options';
// Use a string literal to nicely render variables in your strings
// https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Template_literals
this.battleText = `What will ${this.pokemon.player.name} do?`;
this.pokemon.opponent.hp = 100;
this.pokemon.player.hp = 100;
}
@happyDemon
happyDemon / pokemon-props.js
Last active February 25, 2017 09:07
Vue.js explained through Pokemon #1
props: ['pokemon', 'position', 'type'],
@happyDemon
happyDemon / pokemon.vue
Last active February 25, 2017 12:18
Vue.js explained through Pokemon #1
<template>
<div>
<div :class="hpBoxClass">
<img :id="pokemonImageId" v-if="alive" :src="pokemon.image" class="pokemon-bottom"/>
</div>
<div :class="boxClass">
<h2 class="pokemon">{{pokemon.name}}</h2>
<div :class="hpBarClass">
<div :style="hpBarStyle" class="hp-bar-fill"></div>
</div>