1 var content_path="/img/contents/"; 2 3 var salas_path="/img/salas/"; 4 var provider_path="/img/providers/"; 5 var teacher_path = "/img/users/"; 6 var banners_path="/img/banners/"; 7 var videos_path="/video/videos/"; 8 var user_path = "/img/users/"; 9 var publi_path = "/img/publicidad/"; 10 var blog_path="/img/blog/"; 11 var com_path="/img/comunidad/"; 12 var days=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; 13 var contentIdentifierChanged = $.Deferred(); 14 //var pathVideoServerImg = "https://localhost:8443/classonlive-videos/imgContents/"; 15 //var pathVideoServerImg = "https://widgii.com/classonlive-videos/imgContents/"; 16 var pathVideoServerImg = "https://d28dhcwclph1gf.cloudfront.net/private/"; 17 var pathVideoServerResources = "https://d3c07diqtk9qlr.cloudfront.net/"; 18 //var zoomUrl = 'https://zoom.us/oauth/authorize?client_id=1Rd7yuxYTrTAs4Ry9x0fg&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A8443%2Fzoom.html&response_type=code'; 19 //var zoomUrl = 'https://zoom.us/oauth/signin?_rnd=1592387911239&client_id=7P5dshnxSm6aRiIqOiHIw&redirect_uri=https%3A%2F%2Fwww.classonlive.com%2Fzoom.html&response_type=code'; 20 var zoomUrl="https://zoom.us/oauth/authorize?response_type=code&client_id=7P5dshnxSm6aRiIqOiHIw&redirect_uri=https://"+conf.host+"/zoom.html&state=" 21 22 var youtubeUrl="https://accounts.google.com/o/oauth2/auth?client_id=844146820271-uh1soo87lvp0vqlvuoh3f3b6us4r8568.apps.googleusercontent.com&redirect_uri=https://"+conf.host+"/youtube.html&scope=https://www.googleapis.com/auth/youtube%20https://www.googleapis.com/auth/youtube.force-ssl&response_type=code&access_type=offline&prompt=consent&state=" 23 24 //var youtubeUrl="https://zoom.us/oauth/authorize?response_type=code&client_id=7P5dshnxSm6aRiIqOiHIw&redirect_uri=https://www.classonlive.com/zoom.html&state=" 25 26 var langMap={"English":"Inglés","Spanish":"Español"}; 27 var catMap={"ArtsCulture":["Arts & Culture","Arte & Cultura"],"BusinessCareer":["Business & Career","Negocios & Empresa"],"EducationLearning":["Education & Learning","Educacion & Enseñanza"],"HealthWellness":["Health & Wellness","Salud & Bienestar"],"HobbiesInterests":["Hobbies & Interests","Hobbies & Intereses"],"PoliticsActivisms":["Politics & Activisms","Politica & Activismos"],"ReligionSpirituality":["Religión & Spirituality","Religion & Espiritualidad"],"Technology":["Technology","TechnologÃa"],"Other":["Other","Otro"]}; 28 var methodMap={"One_to_One":["One to One","Uno a Uno"],"Many_to_Many":["Small Groups","Grupos Reducidos"],"Broadcast":["Webinar","Webinar"]}; 29 var durationMap={"d30m":["30 minutes","30 minutos"],"d1h":["1 hour","1 hora"],"d15h":["1,5 hours","1 hora 30 minutos"],"d2h":["2 hours","2 horas"],"d3h":["3 hours","3 horas"],"d4h":["4 hours","4 horas"],"d5h":["5 hours","5 horas"],"d6h":["6 hours","6 horas"],"d7h":["7 hours","7 horas"],"d8h":["8 hours","8 horas"]}; 30 var dayMap={"Monday":"Lunes","Tuesday":"Martes","Wednesday":"Miércoles","Thursday":"Jueves","Friday":"Viernes","Saturday":"Sábado","Sunday":"Domingo"}; 31 var planMap={"Basico":"Iniciación","VIP":"Profesional","Advance":"Avanzado"}; 32 var divisaMap={"EUR":"â¬","USD":"US$","MXN":"MXN$","COP":"COL$","ARS":"ARG$","PEN":"S/","CLP":"CLP$", "BRL":"R$"}; 33 34 var promoAcademyURL={"es":"/promo-academia","en":"/promo-academy","fr":"/promo-academie", "it":"/promo-accademia", "pt":"/promo-escola-pt" }; 35 36 var sessionStorage_transfer = function(event) { 37 if(!event) { event = window.event; } // ie suq 38 if(!event.newValue) return; // do nothing if no value to work with 39 if (event.key == 'getSessionStorage') { 40 // another tab asked for the sessionStorage -> send it 41 localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage)); 42 // the other tab should now have it, so we're done with it. 43 localStorage.removeItem('sessionStorage'); // <- could do short timeout as well. 44 } else if (event.key == 'sessionStorage' && !sessionStorage.length) { 45 // another tab sent data <- get it 46 var data = JSON.parse(event.newValue); 47 for (var key in data) { 48 sessionStorage.setItem(key, data[key]); 49 } 50 } 51 }; 52 53 // listen for changes to localStorage 54 if(window.addEventListener) { 55 window.addEventListener("storage", sessionStorage_transfer, false); 56 } else { 57 window.attachEvent("onstorage", sessionStorage_transfer); 58 }; 59 60 61 // Ask other tabs for session storage (this is ONLY to trigger event) 62 if (!sessionStorage.length) { 63 localStorage.setItem('getSessionStorage', 'foobar'); 64 localStorage.removeItem('getSessionStorage', 'foobar'); 65 }; 66 67 68 69function getMapSize(obj){ 70 var size=0; 71 for (key in obj) { 72 if (obj.hasOwnProperty(key)) size++; 73 } 74 return size; 75} 76 77function get_browser() { 78 var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; 79 if(/trident/i.test(M[1])){ 80 tem=/\brv[ :]+(\d+)/g.exec(ua) || []; 81 return {name:'IE',version:(tem[1]||'')}; 82 } 83 if(M[1]==='Chrome'){ 84 tem=ua.match(/\bOPR|Edge\/(\d+)/) 85 if(tem!=null) {return {name:'Opera', version:tem[1]};} 86 } 87 M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; 88 if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);} 89 return { 90 name: M[0], 91 version: M[1] 92 }; 93 } 94 95function isSafari(){ 96 var ua = get_browser(); 97 if (ua.name.indexOf('Safari') != -1) { 98 if (ua.name.indexOf('chrome') > -1) { 99 return false;// Chrome 100 } else { 101 if(parseInt(ua.version)<11){ 102 return false; 103 }else{ 104 return true; 105 } 106 } 107 } 108 return false; 109} 110 111function isEdge(){ 112 return window.navigator.userAgent.indexOf("Edg/") != -1; 113} 114 115function isIOS() { 116 117 if (/iPad|iPhone|iPod/.test(navigator.platform)) { 118 return true; 119 } else { 120 return navigator.maxTouchPoints && 121 navigator.maxTouchPoints > 2 && 122 /MacIntel/.test(navigator.platform); 123 } 124} 125 126function aplicateNewSetting(classname, value, type){ 127 if($('.'+classname).length != 0) { 128 if(type == 'style'){ 129 $('.'+classname).each(function(index){ 130 var property = value.split(':')[0]; 131 this.style[property] = value.split(':')[1]; 132 }); 133 } 134 if(type == 'source'){//siimg/providers..... to-do 135 if(value.indexOf('removed') == -1){ 136 $('.'+classname)[0].src = value.indexOf('embed') == -1 && value.indexOf('/images/') == -1 ? pathVideoServerImg+"providers/"+value : value; 137 }else{ 138 $('.'+classname).hide(); 139 } 140 } 141 if(type == 'textContent'){ 142 $('.'+classname)[0].innerHTML = value; 143 } 144 if(type == "bgImg"){ 145 var valueBigImg = value.indexOf('/images/') == -1?pathVideoServerImg+"providers/"+value : value; 146 $('.'+classname).css('background-image','url("'+valueBigImg+'")'); 147 } 148 } 149} 150 151 152function detectIE() { 153 var ua = window.navigator.userAgent; 154 155 // Test values; Uncomment to check result ⦠156 157 // IE 10 158 // ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)'; 159 160 // IE 11 161 // ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; 162 163 // Edge 12 (Spartan) 164 // ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0'; 165 166 // Edge 13 167 // ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586'; 168 169 var msie = ua.indexOf('MSIE '); 170 if (msie > 0) { 171 // IE 10 or older => return version number 172 return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); 173 } 174 175 var trident = ua.indexOf('Trident/'); 176 if (trident > 0) { 177 // IE 11 => return version number 178 var rv = ua.indexOf('rv:'); 179 return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); 180 } 181 182 var edge = ua.indexOf('Edge/'); 183 if (edge > 0) { 184 // Edge (IE 12+) => return version number
185 return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); 186 } 187 188 // other browser 189 return false; 190 } 191 192 193function isEmptyHash(map) { 194 for(var key in map) { 195 if (map.hasOwnProperty(key)) { 196 return false; 197 } 198 } 199 return true; 200 } 201 202function arrayContains(arr,element){ 203 for(var i=0;i<arr.length;i++){ 204 if(arr[i]===element){ 205 return true; 206 } 207 } 208 return false; 209} 210 211function removeFromArray(array,element){ 212const index = array.indexOf(element); 213 214 if (index !== -1) { 215 array.splice(index, 1); 216 } 217 return array; 218 219 220} 221 222function extractDomain(url) { 223 var domain; 224 //find & remove protocol (http, ftp, etc.) and get domain 225 if (url.indexOf("://") > -1) { 226 domain = url.split('/')[2]; 227 } 228 else { 229 domain = url.split('/')[0]; 230 } 231 232 //find & remove port number 233 domain = domain.split(':')[0]; 234 235 return domain; 236} 237 238var currency_symbols = { 239 'USD': '$', // US Dollar 240 'EUR': 'â¬', // Euro 241 'CRC': 'â¡', // Costa Rican Colón 242 'GBP': '£', // British Pound Sterling 243 'ILS': 'âª', // Israeli New Sheqel 244 'INR': 'â¹', // Indian Rupee 245 'JPY': 'Â¥', // Japanese Yen 246 'KRW': 'â©', // South Korean Won 247 'NGN': 'â¦', // Nigerian Naira 248 'PHP': 'â±', // Philippine Peso 249 'PLN': 'zÅ', // Polish Zloty 250 'PYG': 'â²', // Paraguayan Guarani 251 'THB': '฿', // Thai Baht 252 'UAH': 'â´', // Ukrainian Hryvnia 253 'VND': 'â«', // Vietnamese Dong 254 }; 255 256 257function increaseDay(day){ 258 if(day=="Monday")return "Tuesday"; 259 if(day=="Tuesday")return "Wednesday"; 260 if(day=="Wednesday")return "Thursday"; 261 if(day=="Thursday")return "Friday"; 262 if(day=="Friday")return "Saturday"; 263 if(day=="Saturday")return "Sunday"; 264 if(day=="Sunday")return "Monday"; 265 266} 267 268function decreaseDay(day){ 269 if(day=="Monday")return "Sunday"; 270 if(day=="Tuesday")return "Monday"; 271 if(day=="Wednesday")return "Tuesday"; 272 if(day=="Thursday")return "Wednesday"; 273 if(day=="Friday")return "Thursday"; 274 if(day=="Saturday")return "Friday"; 275 if(day=="Sunday")return "Saturday"; 276 277 278} 279 280function getAllAudioVideoDevices(successCallback, failureCallback) { 281 if(isSafari()){ 282 // Safari requires the user to grant device access before providing 283 // all necessary device info, so do that first. 284 var constraints = { 285 audio: true, 286 video: true, 287 }; 288 navigator.mediaDevices.getUserMedia(constraints). 289 then(function(){getDevices(successCallback, failureCallback)}).catch(function(error) { 290 console.error('getUserMedia() error: ', error); 291 }); 292 }else{ 293 getDevices(successCallback, failureCallback); 294 } 295} 296 297function getMenorPrice(price1,price2){ 298 var min=null;
299 if((price1!=null)&&(price1!=undefined)){ 300 var nump1=parseInt(price1); 301 min=nump1; 302 } 303 if((price2!=null)&&(price2!=undefined)){ 304 var nump2=parseInt(price2); 305 if((min==null)||(nump2<min)){ 306 min=nump2; 307 } 308 } 309 310 311 return min; 312} 313 314function detectLanguage(url){ 315 var lang=window.navigator.language; 316 if(lang){ 317 lang = language.substring(0,2); 318 }else{ 319 lang="es"; 320 } 321 if(url.indexOf("/en/")){ 322 lang="en" 323 } 324 if(url.indexOf("/fr/")){ 325 lang="fr" 326 } 327 if(url.indexOf("/it/")){ 328 lang="it" 329 } 330 if(url.indexOf("/pt/")){ 331 lang="pt" 332 } 333 334 return lang; 335 336} 337 338function matchYoutubeUrl(url) { 339 var p = /^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:shorts\/|embed\/|v\/|watch\?v=|watch\?.+&v=))(([\w-]{11}))(?:\S+)?$/; 340 if(url.match(p)){ 341 return url.match(p)[1]; 342 } 343 return false; 344} 345 346function matchVimeoUrl(url) { 347 if(url.indexOf("https://vimeo.com/")!=-1) return true; 348 return false; 349} 350 351function getVimeoUrl(url){ 352 if(url.substring(18).indexOf("/")!=-1){ 353 if(url.indexOf("?")!=-1) { 354 url=url.substring(18,url.indexOf("?")).replace("/","?h="); 355 }else { 356 url=url.substring(18).replace("/","?h="); 357 } 358 359 }else{ 360 url=url.substring(18); 361 } 362 return url; 363} 364 365function getQueryVariable(variable) 366{ 367 var query = window.location.search.substring(1); 368 var vars = query.split("&"); 369 for (var i=0;i<vars.length;i++) { 370 var pair = vars[i].split("="); 371 if (pair[0] == variable){return pair[1];} 372 } 373 return(false); 374}; 375function getQueryVariableFromRewrite() 376{ 377 var URI=decodeURIComponent($(location).attr('href')); 378 // if(URI.indexOf("?code=")!=-1){ 379 // Entrada a sala directa 380 // URI=URI.substring(0,URI.indexOf("?")); 381 // } 382 // if(URI.indexOf("?token=")!=-1){ 383 // Entrada a sala directa 384 // URI=URI.substring(0,URI.indexOf("?")); 385 // } 386 if(URI.indexOf("?")!=-1){ 387 URI=URI.substring(0,URI.indexOf("?")); 388 } 389 parts = URI.split('/'); 390 lastPart =parts[parts.length-1] 391 if((lastPart.indexOf("#")>0)||(lastPart.indexOf("?")>0)){//Link from Linkedin 392 if(lastPart.indexOf("#")>0) 393 lastPart=lastPart.substring(0,lastPart.indexOf("#")); 394 //Linkedin 395 if(lastPart.indexOf("?")>0){ 396 lastPart=lastPart.substring(0,lastPart.indexOf("?")); 397 } 398 } 399 if((lastPart!=null)&&(lastPart!='undefined')){ 400 return lastPart.toString(); 401 } 402 return(false); 403}; 404 405function getLoadingIcon() 406{ 407 return '<div class="loading-icon"><img src="/images/new/loading.gif"><span>loading...</span></img></div>'; 408} 409 410function getLoadingIconOnly() 411{ 412 return '<div class="loading-icon-only"><img src="/images/new/loading.gif"></img></div>'; 413} 414 415function removeLoadingIcon(node) 416{ 417 if (node) { 418 node.find('[class^=loading-icon]').remove(); 419 } 420} 421 422function isNumeric(str) { 423 return str.match(/^[0-9]+$/i) != null; 424} 425 426function isAmount(str) { 427 return str.match(/^\d+(\.\d{1,2})?$/) != null; 428} 429 430 431function isAlphaNumeric(str) { 432 return str.match(/^[a-z0-9]+$/i) != null; 433} 434 435function clearFormError(elem) { 436 var padre=$(elem).parent(); 437 var parent = $(elem).parents('.control-group.error'); 438 parent.attr('class', 'control-group'); 439 parent.find('span').filter(function(index) { 440 return $(this).attr('class') === "help-inline"; 441 }).css('display', 'none'); 442} 443 444function clearTextAreaError(elem) { 445 elem.find('span').filter(function(index) { 446 return $(this).attr('class') === "help-inline"; 447 }).css('display', 'none'); 448 449} 450 451function validateMail(mail){ 452 var re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[A-Za-z0-9\-\+]+\.[A-Za-z0-9\-\+]+(\.[A-Za-z0-9\-\+]+)*\s*$/; 453 return re.test(mail) 454} 455 456function validateForm(div, formCheck) { 457 var error = formCheck(); 458 if (error.num === 0) return true; 459 var elem = $(div + ' [-form-error-' + error.num + ']'); 460 if (elem.size() == 0) {alert('Form is not valid!'); return false;} 461 462 elem.attr('class', 'control-group error'); 463 elem.find("span").filter(function(index) { 464 return $(this).attr('class') === "help-inline"; 465 }).text(error.str); 466 elem.find("span").filter(function(index) { 467 return $(this).attr('class') === "help-inline"; 468 }).css('display', ''); 469 470 return false; 471} 472 473function js_yyyy_mm_dd_hh_mm(date) { 474 now = new Date(date); 475 year = "" + now.getFullYear();
476 month = "" + (now.getMonth() + 1); if (month.length == 1) { month = "0" + month; } 477 day = "" + now.getDate(); if (day.length == 1) { day = "0" + day; } 478 hour = "" + now.getHours(); if (hour.length == 1) { hour = "0" + hour; } 479 minute = "" + now.getMinutes(); if (minute.length == 1) { minute = "0" + minute; } 480 return year + "-" + month + "-" + day + " " + hour + ":" + minute; 481 } 482 483//function isValidEmailAddress(emailAddress) { 484// var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i); 485// return pattern.test(emailAddress); 486//}; 487 488function isValidEmailAddress(mail) { 489 var re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[A-Za-z0-9\-\+]+\.[A-Za-z0-9\-\+]+(\.[A-Za-z0-9\-\+]+)*\s*$/; 490 return re.test(mail) 491} 492 493function isValidName(name) { 494 if(/^[a-zA-Z0-9- ñÃ]*$/.test(name) == false) { 495 return false; 496 } 497 return true; 498}; 499 500function isValidDomain(name) { 501 return /^[a-zA-Z0-9-_]+$/.test(name); 502}; 503 504 505 506function getNameToShow(name){ 507 if(name.indexOf("ID-")!=-1){ 508 name=name.substring(0,name.indexOf("ID-")); 509 } 510 return name; 511} 512 513function convertDateToUTC(date) { 514 return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()); 515} 516function convertUTCDateToLocalDate(date) { 517 var newDate = new Date(date.getTime()); 518 519 var offset = date.getTimezoneOffset() / 60; 520 var hours = date.getHours(); 521 522 newDate.setHours(hours - offset); 523 524 return newDate; 525} 526 527 528function SaveToDisk(fileURL, fileName) { 529 fileName.replace(".","-"); 530 fileName.replace(",","-"); 531 var hyperlink = document.createElement('a'); 532 hyperlink.href = fileURL; 533 hyperlink.target = '_blank'; 534 hyperlink.download = fileName || fileURL; 535 536 (document.body || document.documentElement).appendChild(hyperlink); 537 hyperlink.onclick = function() { 538 (document.body || document.documentElement).removeChild(hyperlink); 539 }; 540 541 var mouseEvent = new MouseEvent('click', { 542 view: window, 543 bubbles: true, 544 cancelable: true 545 }); 546 547 hyperlink.dispatchEvent(mouseEvent); 548 549 // NEVER use "revoeObjectURL" here 550 // you can use it inside "onclick" handler, though. 551 // (window.URL || window.webkitURL).revokeObjectURL(hyperlink.href); 552 553 // if you're writing cross-browser function: 554 if(!navigator.mozGetUserMedia) { // i.e. if it is NOT Firefox 555 window.URL.revokeObjectURL(hyperlink.href); 556 } 557 558 // for non-IE 559 560 561 if (!window.ActiveXObject) { 562 var save = document.createElement('a'); 563 save.href =fileURL; 564 save.target = '_blank'; 565 save.download = fileName || 'unknown'; 566 567 var event = document.createEvent('Event'); 568 event.initEvent('click', true, true); 569 save.dispatchEvent(event); 570 (window.URL || window.webkitURL).revokeObjectURL(save.href); 571 } 572 573 // for IE 574 else if ( !! window.ActiveXObject && document.execCommand) { 575 var _window = window.open(fileURL, '_blank'); 576 _window.document.close(); 577 _window.document.execCommand('SaveAs', true, fileName || fileURL) 578 _window.close(); 579 } 580} 581 582function determineTimeZone(){ 583 var timezone = jstz.determine(); 584 var zone=timezone.name(); 585 return zone; 586} 587function resetForm($form) {
588 $form.find('input:text, input:password, input:file,textarea').val(''); 589 $form.find('select').val('none'); 590 $form.find('input:radio, input:checkbox') 591 .removeAttr('checked').removeAttr('selected'); 592} 593 594function resizeImg(elemImg, maxWidth, maxHeight) { 595 var widthRatioNat = elemImg.naturalWidth/elemImg.naturalHeight; 596 var widthRatioMax = maxWidth/maxHeight; 597 598 var resizeRatio; 599 if (widthRatioNat > widthRatioMax) { 600 resizeRatio = maxWidth/elemImg.naturalWidth; 601 } 602 else { 603 resizeRatio = maxHeight/elemImg.naturalHeight; 604 } 605 606 elemImg.width=elemImg.naturalWidth*resizeRatio; 607 elemImg.height=elemImg.naturalHeight*resizeRatio; 608 $(elemImg).css('width',elemImg.naturalWidth*resizeRatio+'px'); 609 $(elemImg).css('height',elemImg.naturalHeight*resizeRatio+'px'); 610} 611 612function resizeImgToFill(elemImg, minWidth, minHeight) { 613 var widthRatioNat = elemImg.naturalWidth/elemImg.naturalHeight; 614 var widthRatioMin = minWidth/minHeight; 615 616 var resizeRatio; 617 if (widthRatioNat < widthRatioMin) { 618 resizeRatio = minWidth/elemImg.naturalWidth; 619 } 620 else { 621 resizeRatio = minHeight/elemImg.naturalHeight; 622 } 623 624 elemImg.width=elemImg.naturalWidth*resizeRatio; 625 elemImg.height=elemImg.naturalHeight*resizeRatio; 626} 627 628function dataURItoBlob(dataURI) { 629 // convert base64 to raw binary data held in a string 630 // doesn't handle URLEncoded DataURIs 631 632 var byteString; 633 if (dataURI.split(',')[0].indexOf('base64') >= 0) { 634 byteString = atob(dataURI.split(',')[1]);} 635 else {byteString = unescape(dataURI.split(',')[1]);} 636 637 // separate out the mime component 638 var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0] 639 640 // write the bytes of the string to an ArrayBuffer 641 var ab = new ArrayBuffer(byteString.length); 642 var ia = new Uint8Array(ab); 643 for (var i = 0; i < byteString.length; i++) { 644 ia[i] = byteString.charCodeAt(i); 645 } 646 647 // write the ArrayBuffer to a blob, and you're done 648 return new Blob([ab],{type:mimeString}); 649} 650function getBase64Image(img) { 651 // Create an empty canvas element 652 var canvas = document.createElement("canvas"); 653 canvas.width = img.width; 654 canvas.height = img.height; 655 656 // Copy the image contents to the canvas 657 var ctx = canvas.getContext("2d"); 658 ctx.drawImage(img, 0, 0); 659 660 // Get the data-URL formatted image 661 // Firefox supports PNG and JPEG. You could check img.src to 662 // guess the original format, but be aware the using "image/jpg" 663 // will re-encode the image. 664 var dataURL = canvas.toDataURL("image/png"); 665 666 return dataURL.replace(/^data:image\/(png|jpg);base64,/, ""); 667} 668 669function compruebaCCC(iban,entidad,nCuenta){ 670 entidad = rellenaCeros(entidad,4); 671 sucursal = rellenaCeros(sucursal,4); 672 dc = rellenaCeros(dc,2); 673 nCuenta = rellenaCeros(nCuenta,10); 674 675 var concatenado = entidad+sucursal; 676 var dc1 = calculaDCParcial(concatenado); 677 var dc2 = calculaDCParcial(nCuenta); 678 return (dc==(dc1+dc2)); 679} 680//Función que devuelve los números correspondientes a cada letra 681function getNumIBAN(letra){ 682var letras = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; 683return letras.search(letra) + 10; 684} 685 686// Función que calcula el módulo sin hacer ninguna división 687function mod(dividendo, divisor){ 688 var cDividendo = ''; 689 var cResto = ''; 690 691 for (var i in dividendo){
692 var cChar = dividendo[i]; 693 var cOperador = cResto + '' + cDividendo + '' + cChar; 694 695 if (cOperador < parseInt(divisor)){ 696 cDividendo += '' + cChar; 697 }else{ 698 cResto = cOperador % divisor; 699 if (cResto == 0){ 700 cResto = ''; 701 } 702 cDividendo = ''; 703 } 704 } 705 cResto += '' + cDividendo; 706 if (cResto == ''){ 707 cResto = 0; 708 } 709 return cResto; 710} 711 712// El tÃpico trim que inexplicamente JavaScript no trae implementado 713function trim(texto){ 714return texto.replace(/^\s+/g,'').replace(/\s+$/g,''); 715} 716 717// Función que comprueba el IBAN 718function validaIBAN(IBAN){ 719IBAN = IBAN.toUpperCase(); 720IBAN = trim(IBAN); // Quita espacios al principio y al final 721IBAN = IBAN.replace(/\s/g, ""); // Quita espacios del medio 722var num1,num2; 723var isbanaux; 724if (IBAN.length != 24){ // En España el IBAN son 24 caracteres 725return false; 726}else{ 727num1 = getNumIBAN(IBAN.substring(0, 1)); 728num2 = getNumIBAN(IBAN.substring(1, 2)); 729isbanaux = IBAN.substr(4) + String(num1) + String(num2) + IBAN.substr(2,2); 730resto = mod(isbanaux,97); 731return (resto==1); 732} 733} 734 735function calculaDCParcial(cadena){ 736 var dcParcial = 0; 737 var tablaPesos = [6,3,7,9,10,5,8,4,2,1]; 738 var suma = 0; 739 var i; 740 for(i=0;i<cadena.length;i++){ 741 suma = suma + cadena.charAt(cadena.length-1-i)*tablaPesos[i]; 742 } 743 dcParcial = (11-(suma % 11)); 744 if(dcParcial==11) 745 dcParcial=0; 746 else if(dcParcial==10) 747 dcParcial=1; 748 return dcParcial.toString(); 749} 750 751function rellenaCeros(numero,longitud){ 752 var ceros = ''; 753 var i; 754 numero = numero.toString(); 755 for(i=0;(longitud-numero.length)>i;i++){ 756 ceros += '0'; 757 } 758 return ceros+numero; 759} 760 761function onImgError(imgElem, imgPath) { 762 $(imgElem).attr("src", imgPath); 763} 764 765function adaptMilisecToLocalTimezone(milisec) { 766 return (milisec + (60*60*1000)); 767} 768 769function setDowncount(totalTime, viewElem, finalFunc) { 770 if ($(viewElem).data('inprogress')) {return;} 771 $(viewElem).data('inprogress', 'true'); 772 downcountSecs(totalTime, $(viewElem).css('display',''), finalFunc); 773} 774function downcountSecs(timeLeft, viewElem, finalFunc) { 775 if (timeLeft > 0) { 776 $(viewElem).trigger('downcount', timeLeft/1000); 777 timeLeft-=1000; 778 setTimeout(function(){downcountSecs(timeLeft, viewElem, finalFunc);}, 1000); 779 } 780 else if (timeLeft==0) { 781 $(viewElem).trigger('downcount', 0); 782 if (finalFunc) {finalFunc.call();} 783 } 784} 785 786function replaceInvalidHtml(shortDescription){ 787 788 shortDescription=shortDescription.replace(new RegExp('target="_blank"', 'g'),""); 789 shortDescription=shortDescription.replace(new RegExp('rel="nofollow"', 'g'),""); 790 shortDescription=shortDescription.replace(new RegExp('target=""', 'g'),""); 791 shortDescription=shortDescription.replace(new RegExp('rel=""', 'g'),""); 792 shortDescription=shortDescription.replace(new RegExp("<span>", 'g'),"<p>"); 793 shortDescription=shortDescription.replace(new RegExp("</span>", 'g'),"</p>"); 794 shortDescription=shortDescription.replace(new RegExp(" ", 'g')," "); 795 796 return shortDescription; 797 798} 799 800function millisToDays(millis) { 801 var minutesPerDay=60*24; 802 var seconds = millis / 1000; 803 var totalMinutes = seconds / 60; 804 805 var days = totalMinutes / minutesPerDay; 806 807 808 return days; 809} 810 811function prepareErrorMessage(message,elem){ 812 var alertTemplate = document.querySelector("#alert-template"); 813 var alert = alertTemplate.cloneNode(true); 814 $(alert).css('display','').attr('id',''); 815 alert.querySelector("#alertType").setAttribute("class", "alert alert-error"); 816 alert.querySelector(".message").innerHTML =message; 817 elem.append(alert); 818 elem.show(); 819} 820 821var defaultDiacriticsRemovalMap = [ 822 {'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g}, 823 {'base':'AA','letters':/[\uA732]/g}, 824 {'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g}, 825 {'base':'AO','letters':/[\uA734]/g}, 826 {'base':'AU','letters':/[\uA736]/g}, 827 {'base':'AV','letters':/[\uA738\uA73A]/g}, 828 {'base':'AY','letters':/[\uA73C]/g}, 829 {'base':'B', 'letters':/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g}, 830 {'base':'C', 'letters':/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g}, 831 {'base':'D', 'letters':/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g}, 832 {'base':'DZ','letters':/[\u01F1\u01C4]/g}, 833 {'base':'Dz','letters':/[\u01F2\u01C5]/g}, 834 {'base':'E', 'letters':/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g}, 835 {'base':'F', 'letters':/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g}, 836 {'base':'G', 'letters':/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g}, 837 {'base':'H', 'letters':/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g}, 838 {'base':'I', 'letters':/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g}, 839 {'base':'J', 'letters':/[\u004A\u24BF\uFF2A\u0134\u0248]/g}, 840 {'base':'K', 'letters':/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g}, 841 {'base':'L', 'letters':/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u014
8411\u023D\u2C62\u2C60\uA748\uA746\uA780]/g}, 842 {'base':'LJ','letters':/[\u01C7]/g}, 843 {'base':'Lj','letters':/[\u01C8]/g}, 844 {'base':'M', 'letters':/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g}, 845 {'base':'N', 'letters':/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g}, 846 {'base':'NJ','letters':/[\u01CA]/g}, 847 {'base':'Nj','letters':/[\u01CB]/g}, 848 {'base':'O', 'letters':/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g}, 849 {'base':'OI','letters':/[\u01A2]/g}, 850 {'base':'OO','letters':/[\uA74E]/g}, 851 {'base':'OU','letters':/[\u0222]/g}, 852 {'base':'P', 'letters':/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g}, 853 {'base':'Q', 'letters':/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g}, 854 {'base':'R', 'letters':/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g}, 855 {'base':'S', 'letters':/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g}, 856 {'base':'T', 'letters':/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g}, 857 {'base':'TZ','letters':/[\uA728]/g}, 858 {'base':'U', 'letters':/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g}, 859 {'base':'V', 'letters':/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g}, 860 {'base':'VY','letters':/[\uA760]/g}, 861 {'base':'W', 'letters':/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g}, 862 {'base':'X', 'letters':/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g}, 863 {'base':'Y', 'letters':/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g}, 864 {'base':'Z', 'letters':/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g}, 865 {'base':'a', 'letters':/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g}, 866 {'base':'aa','letters':/[\uA733]/g}, 867 {'base':'ae','letters':/[\u00E6\u01FD\u01E3]/g}, 868 {'base':'ao','letters':/[\uA735]/g}, 869 {'base':'au','letters':/[\uA737]/g}, 870 {'base':'av','letters':/[\uA739\uA73B]/g}, 871 {'base':'ay','letters':/[\uA73D]/g}, 872 {'base':'b', 'letters':/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g}, 873 {'base':'c', 'letters':/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g}, 874 {'base':'d', 'letters':/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g}, 875 {'base':'dz','letters':/[\u01F3\u01C6]/g}, 876 {'base':'e', 'letters':/[\u006
8765\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g}, 877 {'base':'f', 'letters':/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g}, 878 {'base':'g', 'letters':/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g}, 879 {'base':'h', 'letters':/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g}, 880 {'base':'hv','letters':/[\u0195]/g}, 881 {'base':'i', 'letters':/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g}, 882 {'base':'j', 'letters':/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g}, 883 {'base':'k', 'letters':/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g}, 884 {'base':'l', 'letters':/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g}, 885 {'base':'lj','letters':/[\u01C9]/g}, 886 {'base':'m', 'letters':/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g}, 887 {'base':'n', 'letters':/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g}, 888 {'base':'nj','letters':/[\u01CC]/g}, 889 {'base':'o', 'letters':/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g}, 890 {'base':'oi','letters':/[\u01A3]/g}, 891 {'base':'ou','letters':/[\u0223]/g}, 892 {'base':'oo','letters':/[\uA74F]/g}, 893 {'base':'p','letters':/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g}, 894 {'base':'q','letters':/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g}, 895 {'base':'r','letters':/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g}, 896 {'base':'s','letters':/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g}, 897 {'base':'t','letters':/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g}, 898 {'base':'tz','letters':/[\uA729]/g}, 899 {'base':'u','letters':/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g}, 900 {'base':'v','letters':/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g}, 901 {'base':'vy','letters':/[\uA761]/g}, 902 {'base':'w','letters':/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g}, 903 {'base':'x','letters':/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g}, 904 {'base':'y','letters':/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g}, 905 {'base':'z','letters':/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g} 906 ]; 907var changes; 908function removeDiacritics (str) { 909 if(!changes) { 910 changes = defaultDiacriticsRemovalMap; 911 } 912 for(var i=0; i<changes.length; i++) { 913 str = str.replace(changes[i].letters, changes[i].base); 914 } 915 return str; 916} 917 918 919 920////validations 921 922 923function validateNotEmpty(str){ 924 if (str == "" || !str.replace(/\s/g, '').length) return false; 925 return true; 926} 927 928function validateDate(date){ 929 if(date < new Date() || date.getTime() !== date.getTime()) 930 return false; 931 return true; 932} 933 934function validateKeyWords(str){ 935 if (str == "") return true; 936 var split = str.split(","); 937 var result = true; 938 split.forEach(function(i){ result = i == '' ? false : true; }) 939 if (str.split(',')[0] == "" || str.split(',')[str.split(',').length - 1] == "") return false; 940 return result; 941} 942 943 944 945function fillTeachers(){ 946 rest.getExpertsFromCompany().done(function(result) {
947 var num=result["num"]; 948 if(num==0){ 949 var experts=result["str"]; 950 if((experts==null)||(experts.length==0)){ 951 $("#inputOtroInstructor").attr("disabled",true); 952 }else{ 953 for(var i=0;i<experts.length;i++){ 954 $("#otherInstructor").append(new Option(experts[i].name, experts[i].userAccountId)); 955 } 956 } 957 958 } 959 960 }); 961} 962 963function goToPlanes(){ 964 965 $(".nav").find(".active").removeClass("active"); 966 $(this).parent().addClass("active"); 967 968 loadPrivateZone("/zona-privada/Cambiar-Plan"); 969} 970 971function getParameterByName(name, url) { 972 if (!url) { 973 url = window.location.href; 974 } 975 name = name.replace(/[\[\]]/g, "\\$&"); 976 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), 977 results = regex.exec(url); 978 if (!results) return null; 979 if (!results[2]) return ''; 980 return decodeURIComponent(results[2].replace(/\+/g, " ")); 981} 982 983function stripHtml(html){ 984 // Create a new div element 985 var temporalDivElement = document.createElement("div"); 986 // Set the HTML content with the providen 987 temporalDivElement.innerHTML = DOMPurify.sanitize(html); 988 $(temporalDivElement).find('style').remove(); 989 // Retrieve the text property of the element (cross-browser support) 990 return temporalDivElement.textContent || temporalDivElement.innerText || ""; 991} 992 993function isHTML(str) { 994 var a = document.createElement('div'); 995 a.innerHTML = str; 996 997 for (var c = a.childNodes, i = c.length; i--; ) { 998 if (c[i].nodeType == 1) return true; 999 } 1000 1001 return false; 1002 } 1003 1004function preloadVideoJsHlsPlayer(videoElementHTML, url, options) { 1005 var player = null; 1006 var selectedBitrate = "auto"; 1007 var lastPosition = 0; 1008 var qLevels = []; 1009 var srcOptions = options ? options : null; 1010 if(srcOptions == null){ 1011 srcOptions = { 1012 src: url, 1013 type: 'application/x-mpegurl' 1014 }; 1015 } 1016 var optionsVideo = { 1017 inactivityTimeout: 0, 1018 controls: true, 1019 autoplay: true, 1020 preload: "auto", 1021 notSupportedMessage: "Please use different browser (Mozzila Firefox, Google Chrome, Safari, Microsoft Edge)", 1022 fluid: true 1023 }; 1024 1025 $('#'+videoElementHTML).find('source').attr('src', url); 1026 var player = videojs(videoElementHTML); 1027 player.qualityLevels().on('addqualitylevel', function (event) { 1028 event.qualityLevel.enabled = selectedBitrate === "auto" || event.qualityLevel.height.toString() === selectedBitrate; 1029 }); 1030 1031 player.on("loadedmetadata", function () { 1032 var qualityLevels = player.qualityLevels(); 1033 for (var i = 0; i < qualityLevels.length; i++) { 1034 var quality = qualityLevels[i]; 1035 1036 if (quality.height != undefined && $.inArray(quality.height, qLevels) === -1) { 1037 qLevels.push(quality.height); 1038 1039 if (!$('.quality_ul').length) { 1040 var h = '<div class="quality_setting vjs-menu-button vjs-menu-button-popup vjs-control vjs-button">' + 1041 '<button class="vjs-menu-button vjs-menu-button-popup vjs-button" type="button" aria-live="polite" aria-disabled="false" title="Quality" aria-haspopup="true" aria-expanded="false">' + 1042 '<span aria-hidden="true" class="vjs-icon-cog"></span>' + 1043 '<span class="vjs-control-text">Quality</span></button>' + 1044 '<div class="vjs-menu"><ul class="quality_ul vjs-menu-content" role="menu"></ul></div></div>'; 1045 1046 $(".vjs-fullscreen-control").before(h); 1047 } else { 1048 $('.quality_ul').empty(); 1049 } 1050 1051 qLevels.sort(); 1052 qLevels.reverse(); 1053 1054 var j = 0; 1055 1056 $.each(qLevels, function (i, val) { 1057 if(val == 720){ 1058 $(".quality_ul").append('<li class="vjs-menu-item" style="text-align:right !important;
1058" tabindex="' + i + '" role="menuitemcheckbox" aria-live="polite" aria-disabled="false" aria-checked="false" bitrate="' + val + 1059 '"><span class="vjs-menu-item-text" style="margin-right: 0.4em;">' + val + 'p<sup style="color: red;font-weight: bold;text-transform: uppercase;">HD</sup></span></li>'); 1060 j = i; 1061 }else{ 1062 $(".quality_ul").append('<li class="vjs-menu-item" style="text-align:right !important;" tabindex=" tabindex="' + i + '" role="menuitemcheckbox" aria-live="polite" aria-disabled="false" aria-checked="false" bitrate="' + val + 1063 '"><span class="vjs-menu-item-text" style="margin-right: 0.4em;">' + val + 'p</span></li>'); 1064 j = i; 1065 } 1066 }); 1067 1068 $(".quality_ul").append('<li class="vjs-menu-item vjs-selected" style="text-align:right !important;" tabindex="' + (j + 1) + '" role="menuitemcheckbox" aria-live="polite" aria-disabled="false" aria-checked="true" bitrate="auto">' + 1069 '<span class="vjs-menu-item-text" style="margin-right: 0.4em;">Auto</span></li>'); 1070 } 1071 } 1072 player.currentTime(lastPosition); 1073 }); 1074 1075 1076 $("body").on("click", ".quality_ul li", function () { 1077 $(".quality_ul li").removeClass("vjs-selected"); 1078 $(".quality_ul li").prop("aria-checked", "false"); 1079 1080 $(this).addClass("vjs-selected"); 1081 $(this).prop("aria-checked", "true"); 1082 1083 selectedBitrate = $(this).attr("bitrate"); 1084 lastPosition = player.currentTime(); 1085 var levels = player.qualityLevels(); 1086 var level = levels[levels.selectedIndex].height; 1087 if (selectedBitrate !== level.toString() && (selectedBitrate !== "auto" || levels.selectedIndex !== (levels.length - 1))) { 1088 player.src(srcOptions); 1089 } 1090 else { 1091 for (var i = 0; i < levels.length; i++) 1092 levels[i].enabled = selectedBitrate === "auto" || levels[i].height.toString() === selectedBitrate; 1093 } 1094 }); 1095 1096 player.on('fullscreenchange', function () { 1097 $('#hlsVideo_html5_api').css("height","auto"); 1098 var levels = player.qualityLevels(); 1099 if (selectedBitrate === "auto" && player.isFullscreen() && levels.selectedIndex !== (levels.length - 1)) { 1100 lastPosition = player.currentTime(); 1101 player.src(srcOptions); 1102 }else{ 1103 // $('#hlsVideo_html5_api').css("height","320px"); 1104 } 1105 }); 1106 player.src(srcOptions); 1107 1108} 1109 1110function setContentIdentifier(identifier,errorDiv,contentId){ 1111 contentIdentifierChanged = $.Deferred(); 1112 $(errorDiv).empty(); 1113 if(!isUrlValid(identifier)){ 1114 $(errorDiv).append('<p style="color:red">Debe contener solo letras,números y guiones. <b>Sin acentos.</b></p>') 1115 hiddenLoader(); 1116 return; 1117 } 1118 var data = JSON.stringify({contentId:contentId,contentIdentifier:identifier}); 1119 rest.setContentIdentifier(data).done(function(result){ 1120 if(result.num == 0){ 1121 course.contentIdentifier = identifier; 1122 contentIdentifierChanged.resolve(); 1123 }else{ 1124 hiddenLoader(); 1125 var color = result.num == 0 ? 'green' : 'red'; 1126 $(errorDiv).append('<p style="color:'+color+'">'+result.str+'</p>') 1127 } 1128 }); 1129} 1130 1131function validateNewPassword(userNewPassword) { 1132 var res = userNewPassword.match(/^[A-Za-z0-9.!@#$%^&*_-]+$/g); 1133 if (res == null){ 1134 return false; 1135 }else{ 1136 return true; 1137 } 1138} 1139 1140function isUrlValid(userInput) { 1141 var res = userInput.match(/^[a-zA-Z0-9_-]+$/ig); 1142 if(res == null) 1143 return false; 1144 else 1145 return true; 1146} 1147 1148 1149function getDevices(successCallback, failureCallback){ 1150 if (!navigator.enumerateDevices && window.MediaStreamTrack && window.MediaStreamTrack.getSources) { 1151 navigator.enumerateDevices = window.MediaStreamTrack.getSources.bind(window.MediaStreamTrack); 1152 } 1153 1154 if (!navigator.enumerateDevices && navigator.enumerateDevices) { 1155 navigator.enumerateDevices = navigator.enumerateDevices.bind(navigator); 1156 } 1157 1158 if (!navigator.enumerateDevices) { 1159 failureCallback(null, 'Neither navigator.mediaDevices.enumerateDevices NOR MediaStreamTrack.getSources are available.'); 1160 return; 1161 } 1162 1163 var allMdiaDevices = []; 1164 var allAudioDevices = []; 1165 var allVideoDevices = []; 1166 1167 var audioInputDevices = []; 1168 var audioOutputDevices = []; 1169 var videoInputDevices = []; 1170 var videoOutputDevices = []; 1171 1172 navigator.enumerateDevices(function(devices) {
1173 devices.forEach(function(_device) { 1174 var device = {}; 1175 for (var d in _device) { 1176 device[d] = _device[d]; 1177 } 1178 1179 // make sure that we are not fetching duplicate devics 1180 var skip; 1181 allMdiaDevices.forEach(function(d) { 1182 if (d.id === device.id) { 1183 skip = true; 1184 } 1185 }); 1186 1187 if (skip) { 1188 return; 1189 } 1190 1191 // if it is MediaStreamTrack.getSources 1192 if (device.kind === 'audio') { 1193 device.kind = 'audioinput'; 1194 } 1195 1196 if (device.kind === 'video') { 1197 device.kind = 'videoinput'; 1198 } 1199 1200 if (!device.deviceId) { 1201 device.deviceId = device.id; 1202 } 1203 1204 if (!device.id) { 1205 device.id = device.deviceId; 1206 } 1207 1208 if (!device.label) { 1209 device.label = 'Please invoke getUserMedia once.'; 1210 } 1211 1212 if (device.kind === 'audioinput' || device.kind === 'audio') { 1213 audioInputDevices.push(device); 1214 } 1215 1216 if (device.kind === 'audiooutput') { 1217 audioOutputDevices.push(device); 1218 } 1219 1220 if (device.kind === 'videoinput' || device.kind === 'video') { 1221 videoInputDevices.push(device); 1222 } 1223 1224 if (device.kind.indexOf('audio') !== -1) { 1225 allAudioDevices.push(device); 1226 } 1227 1228 if (device.kind.indexOf('video') !== -1) { 1229 allVideoDevices.push(device); 1230 } 1231 1232 // there is no 'videoouput' in the spec. 1233 // so videoOutputDevices will always be [empty] 1234 1235 allMdiaDevices.push(device); 1236 }); 1237 1238 if (successCallback) { 1239 successCallback({ 1240 allMdiaDevices: allMdiaDevices, 1241 allVideoDevices: allVideoDevices, 1242 allAudioDevices: allAudioDevices, 1243 videoInputDevices: videoInputDevices, 1244 audioInputDevices: audioInputDevices, 1245 audioOutputDevices: audioOutputDevices 1246 }); 1247 } 1248 }); 1249} 1250 1251 1252function getDurs() { 1253 var durs = []; 1254 durs["d30m"] = "30 min"; 1255 durs["d1h"] = "1 Hora"; 1256 durs["d15h"] = "1 Hora y media"; 1257 durs["d2h"] = "2 Horas"; 1258 durs["d3h"] = "3 Horas"; 1259 durs["d4h"] = "4 Horas"; 1260 durs["d5h"] = "5 Horas"; 1261 durs["d6h"] = "6 Horas"; 1262 durs["d7h"] = "7 Horas"; 1263 durs["d8h"] = "8 Horas"; 1264 return durs; 1265} 1266 1267function activateTooltip(parent,child){ 1268 var mql = window.matchMedia("(orientation: portrait)"); 1269 if (!mql.matches) { 1270 // Landscape orientationç 1271 if (windowsWidth <= '800') { 1272 console.log('entro 2') 1273 $(parent).on('click', child, function(e){ 1274 $(this).tooltip('toggle'); 1275 }); 1276 } 1277 } else{ 1278 1279 } 1280 1281} 1282 1283function summernoteHasImages(snText){ 1284 if(snText.indexOf('data:image/') != -1){ 1285 return true; 1286 }else{ 1287 return false; 1288 } 1289 1290} 1291 1292var delete_cookie = function(name) { 1293 document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;domain='+location.hostname; 1294}; 1295 1296function cerrarSesion() { 1297 debugger; 1298 sessionStorage.removeItem('idCourseTime'); 1299 delete_cookie("classonliveToken"); 1300 logInfo = null; 1301 sessionStorage.removeItem('login'); 1302 if (window.google && google.accounts && google.accounts.id) { 1303 google.accounts.id.disableAutoSelect(); 1304 } 1305 1306 let fromLogged=null; 1307 if (typeof getCookie === "function") { 1308 1309 fromLogged = 1310 getCookie("fromLogged"); 1311 delete_cookie("fromLogged"); 1312 } 1313 if (fromLogged === "public") { 1314 window.location = conf.protocol_plus_host+"/"+userLang; 1315 }else{ 1316 window.location = "/index.html"; 1317 } 1318 1319} 1320 1321function adjustModalHeight(modalToResize, referenceModal) {
1322 var height = $(referenceModal).find('.modal-content').outerHeight(); 1323 $(modalToResize).find('.modal-content').height(height); 1324} 1325 1326function capturePosthog(eventName, properties) { 1327 1328 if ( 1329 typeof window.posthog === 'undefined' || 1330 typeof window.posthog.capture !== 'function' 1331 ) { 1332 return; 1333 } 1334 1335 window.posthog.capture(eventName, properties); 1336}
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.