This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const allInputs = document.querySelectorAll( 'a' ); | |
const urlToSearch = 'https://github.com/byverdu'; | |
let found; | |
let position; | |
// Ways to iterate over a NodeList to find an element | |
// 1 | |
allInputs.forEach(( link, index ) => { | |
if (link.href.indexOf( urlToSearch ) !== -1 ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gulp from 'gulp'; | |
import browserSync from 'browser-sync'; | |
import nodemon from 'gulp-nodemon'; | |
const browserOpts = { | |
proxy: 'http://localhost:3000', | |
port: 9000, | |
open: false | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/client/views/item.pug | |
block content | |
.wrapper(ng-controller="ImdbController as imdb") | |
div(ng-show="!imdb.contentReady") Loading ... | |
div(ng-show="imdb.contentReady") | |
imdb-card(data="imdb.singleItem", call-action="imdb.showForm()" text-btn="Add Rating") | |
form(ng-submit="imdb.updateItem()", ng-show="imdb.revealForm") | |
h3 Add your Rating | |
input(type="text", ng-model="imdb.rating", placeholder="rating ...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/client/js/controllers/imdbController.js | |
module.exports = function( service, $routeParams, broadcaster, $rootScope, $timeout, Notification ) { | |
const $imdb = this; | |
$imdb.title = `${$routeParams.collection}`; | |
$imdb.collection = []; | |
$imdb.contentReady = false; | |
$imdb.singleItem = {}; | |
$imdb.rating = 0; | |
$imdb.revealForm = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// API, server side | |
router.get( '/api/all/:imdb', ( req, res ) => { | |
// req.params.imdb === 'movie' || 'series' | |
Imdb.find({ type: req.params.imdb }) | |
.exec() | |
.then(( response ) => { | |
res.type( 'json' ); | |
res.json( response ); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test/server-test/serverSpec.js | |
// Test cases for routing | |
import { expect } from 'chai'; | |
import request from 'supertest'; | |
import mongoose from 'mongoose'; | |
import { ImdbSchema } from '../../app/server/models/ImdbSchema'; | |
import server from '../../app/server/'; | |
import sampleData from '../sampleData'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/client/js/controllers/homeController.js | |
module.exports = function ( service, broadcaster, $rootScope, $timeout, Notification ) { | |
const $home = this; | |
$home.title = 'Welcome to ImdbApp'; | |
$home.imdbText = ''; // texto del formulario | |
$home.imdbType = 'movie'; // usar 'movie' como tipo por defecto | |
$home.imdbData = {}; | |
$home.links = [ | |
{ text: 'Movies', url: '/imdb/movie' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/client/js/services/directive.js | |
export function buildImdbCard() { | |
return { | |
restrict: 'E', | |
replace: true, | |
templateUrl: './views/imdbItem', | |
scope: { | |
data: '<', | |
callAction: '&', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/client/views/layout.pug | |
<!DOCTYPE html> | |
html(lang="en", ng-app="imdbApp") | |
head | |
meta(charset="UTF-8") | |
meta(name="viewport", content="width=device-width, initial-scale=1.0") | |
meta(http-equiv="X-UA-Compatible", content="ie=edge") | |
link(rel="stylesheet", type="text/css", href="../static/styles.css") | |
link(rel="stylesheet", type="text/css", href="../static/notification.css") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// build/tasks/browserify.js | |
const gulp = require( 'gulp' ); | |
const browserify = require( 'browserify' ); | |
const uglify = require( 'gulp-uglify' ); | |
const source = require( 'vinyl-source-stream' ); | |
const gutil = require( 'gulp-util' ); | |
const buffer = require( 'vinyl-buffer' ); | |
const sourcemaps = require( 'gulp-sourcemaps' ); | |
const notify = require( 'gulp-notify' ); |
NewerOlder