1'use strict'; 2 3var EventsObject = function() { 4 5 var eventStorage; 6 7 function init(){ 8 eventStorage = {}; 9 } 10 11 function dispose(){ 12 13 } 14 15 function subscribe(namespace, callback){ 16 //eventStorage[namespace] = PubSub.subscribe(namespace, callback); 17 PubSub.subscribe(namespace, callback); 18 } 19 20 function unsubscribe(namespace, callback){ 21 //PubSub.unsubscribe(eventStorage[namespace]); 22 PubSub.unsubscribe([namespace, callback]); 23 } 24 25 function publish(namespace, args){ 26 PubSub.publish(namespace, args); 27 } 28 29 //////// PUBLIC INTERFACE ///////// 30 31 this.namespace = 'EVENTS'; 32 this.subscribe = subscribe; 33 this.unsubscribe = unsubscribe; 34 this.publish = publish; 35 this.dispose = dispose; 36 37 init(); 38}; 39 40var Events = new EventsObject(); 41 42'use strict'; 43 44var PubSubObject = function(){ 45 46 var cache = {}; 47 48 function publish(topic, args, scope) { 49 if (cache[topic]) { 50 var thisTopic = cache[topic], 51 i = thisTopic.length - 1; 52 53 for (i; i >= 0; i -= 1) { 54 thisTopic[i].apply( scope || this, args || []); 55 } 56 } 57 } 58 59 function subscribe(topic, callback) { 60 if (!cache[topic]) { 61 cache[topic] = []; 62 } 63 cache[topic].push(callback); 64 return [topic, callback]; 65 } 66 67 function unsubscribe(handle, completly) { 68 var t = handle[0], 69 i = cache[t].length - 1; 70 71 if (cache[t]) { 72 for (i; i >= 0; i -= 1) { 73 if (cache[t][i] === handle[1]) { 74 cache[t].splice(i, 1); 75 if(completly){ delete cache[t]; } 76 } 77 } 78 } 79 } 80 81 return { 82 publish: publish, 83 subscribe: subscribe, 84 unsubscribe: unsubscribe 85 }; 86 87} 88 89var PubSub = new PubSubObject(); 90 91'use strict'; 92 93var FormatTextObject = function(){ 94 95 function init(){ 96 } 97 98 function dispose(){ 99 console.log('FormatText | Dispose::'); 100 101 } 102 103 function removeSpecialCharacters(text){ 104 var special = 'ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃãà áäâèéëêìÃïîòóöôùúüûÃñÃç'; 105 var replacement = 'AAAAAEEEEIIIIOOOOUUUUaaaaaeeeeiiiioooouuuunncc'; 106 for (var i=0; i<special.length; i++) { 107 if(text){ 108 text = text.replace(special.charAt(i), replacement.charAt(i)); 109 } 110 } 111 112 return text; 113 } 114 115 function testEmail(email){ 116 console.log('FormatText | testEmail'); 117 console.log(email); 118 119 var pattern = /^[a-zA-Z0-9._-]+@[^\.][a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i; 120 if (!pattern.test(email)) { 121 console.log('email no válido'); 122 return false; 123 }else{ 124 console.log('email válido'); 125 return true; 126 } 127 } 128 129 function testStandard(text){ 130 console.log('FormatText | testStandard'); 131 132 if(text){ 133 text = text.trim(); 134 135 if(text.length > 2){ 136 return true; 137 }else{ 138 return false; 139 } 140 }else{ 141 return false; 142 } 143 } 144 145 function capitalize(word){ 146 return word.substr(0, 1).toUpperCase() + word.substr(1); 147 } 148 149 150 //////// PUBLIC INTERFACE ///////// 151 152 this.namespace = 'FORMATTEXT'; 153 this.dispose = dispose; 154 this.removeSpecialCharacters = removeSpecialCharacters; 155 this.testEmail = testEmail; 156 this.testStandard = testStandard; 157 this.capitalize = capitalize; 158 159 160 init(); 161} 162 163var FormatText = new FormatTextObject(); 164 165/* globals define, require, jQuery */ 166var Main = function(){ 167 168 var $ = jQuery; 169 170 // if (!window.console) { 171 // function console() {} 172 // window.console = console; 173 // } 174 175 // Youtube API 176 window.isYouTubePlayerAPIReady = false; 177 window.onYouTubePlayerAPIReady = function () { 178 console.log('Main::onYouTubePlayerAPIReady: '); 179 Events.publish('YOUTUBE_API_READY'); 180 window.isYouTubePlayerAPIReady = true; 181 } 182 183 jQuery(window).resize(function () { 184 // Events.publish('WINDOW_CHANGE', []); 185 }); 186 187} 188 189Main();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.