(function () { 'use strict'; var serviceId = 'validation'; angular.module('app').factory(serviceId, [validation]); function validation() { var service = { userValidationConfig: userValidationConfig, getEmbedPattern: getEmbedPattern, getEmbedPlaceholder: getEmbedPlaceholder }; function userValidationConfig() { return { userFirstName: { regex: /^([A-Za-z\s\-\']*)$/, maxCharacters:20 }, userLastName: { regex: /^([A-Za-z\s\-\']*)$/, maxCharacters:30 }, email:{ regex: /^[a-zA-Z0-9_.'+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/, maxCharacters: 100 }, password: { regex: /./, maxCharacters: 20, minCharacters:6 } } } function getEmbedPattern(embedType) { var pattern='/./'; switch (embedType) { case "youtube": pattern = new RegExp("(youtube.com/|youtu.be/)"); break; case "vimeo": pattern = new RegExp('/vimeo.com/'); break; case "dailymotion": pattern = new RegExp("dailymotion.com/|dai.ly/"); break; case "prezi": pattern = new RegExp("prezi.com/"); break; case "google-maps": pattern = new RegExp("(maps.google.com/|goo.gl.com/maps/|google.co.uk/maps|goo.gl/maps)"); break; case "sketchfab": pattern = new RegExp("sketchfab.com/"); break; case "flickr": pattern = new RegExp("(?:flickr.com/photos | flic.kr)"); break; case "slideshare": pattern = new RegExp("(slideshare.net|slidesha.re)"); break; } return pattern; } //not really validation but heh-ho function getEmbedPlaceholder(embedType) { var placeholder = 'url goes here'; switch (embedType) { case "youtube": placeholder = "e.g. http://www.youtube.com/watch?v=iZWaFLPsQkk"; break; case "embed-item": placeholder = "e.g. https://www.linkedin.com/in/williamhgates"; break; case "vimeo": placeholder = "e.g. http://vimeo.com/69057206"; break; case "dailymotion": placeholder = "e.g. http://www.dailymotion.com/video/x26lc3v_great-british-bake-off-quarter-final-review_lifestyle"; break; case "prezi": placeholder = "e.g. http://prezi.com/toncjnvzed36/?utm_campaign=share&utm_medium=copy&rc=ex0share"; break; case "google-maps": placeholder = "e.g. https://goo.gl/maps/9iKqz"; break; case "sketchfab": placeholder = "e.g. https://sketchfab.com/models/11a921b47ed34d4dbdf40e3dbca00223"; break; case "flickr": placeholder = ""; break; case "slideshare": placeholder = "e.g. http://www.slideshare.net/aoweiyang/10-deceptions-revealed-through-body-language"; break; } return placeholder; } return service; } })();