Successful Negotiations: A MasterClass
Learn to use all the related tools, walk into a job and be a rockstar from day one
class SearchMenu {
constructor() {
this.searchInput = document.getElementById("mi-buscador");
this.resultsContainer = document.getElementById("mis-resultados");
this.resultsList = ""; // Esta variable no se está utilizando
}
async fetchJSON(url) {
const options = {
method: 'GET',
headers: {'x-api-key': '', Authorization: '', Accept: 'application/json'}
};
if (url.includes("ubitslearning")) {
options.headers["x-api-key"] = "xDVMRFwySI3stuznQbZfW4RVRzzyBCJE79W2NsX1";
options.headers.Authorization = "eyJraWQiOiJNNW4xR2pHQ2RFVk43a3R5dTRlNFdSeDE0YzRTU2xkeXRqTUxYcUFzSE5nPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiIxOTRjMzJlNy1iZmZkLTQ1Y2MtYjhmNC1hNDc1OTI5OWVlNWUiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfTDFnTHl1TWV6IiwiY29nbml0bzp1c2VybmFtZSI6ImNvbWZhbWEtYXBpLWluZ2xlcy1jb21tdW5pdHkiLCJjdXN0b206Y29tcGFueV9pZCI6IjI2NjIiLCJvcmlnaW5fanRpIjoiODZmY2Y3OGItYzgwMi00NDRhLTliODktYTAzZTc3ZjdjYzkyIiwiYXVkIjoiNWhuN2xtcHBmcDVtaGx2MmpvdGZxMXBvdGoiLCJldmVudF9pZCI6ImMzMzZiYTIwLThlZTItNGEyMC04NmJlLWY0YzhlNjUwYjUxYyIsInRva2VuX3VzZSI6ImlkIiwiYXV0aF90aW1lIjoxNzI0OTQ0MjI1LCJleHAiOjE3MjUwMzA2MjUsImlhdCI6MTcyNDk0NDIyNSwianRpIjoiZmZkYjQyMGQtOTI2My00NzMwLTk1NTItZjczZjI3ZWZjMDE4IiwiZW1haWwiOiJqdWFucm9qYXNAY29tZmFtYS5jb20uY28ifQ.0Y3XzlRJYyjuj9qdc0EIrbgd7lSM_pbahjGY8K6F8jgwhZbx1GesYwMVP1Vy8Gc89xNEd9deXOavS3hE9bGd4BCNo7omrZSxcOl8PSSduN65GVJQB_tqVIoG0JtsdvGPRPyvCoR0vnmqdAy_epwHz23q7iC3zoVJNXmMX7Y29u8CxXxg8E8rDW3SlYLBrN4ogdollIcwcQ4CsMHBGcruIZEsPJLhSUYEOLRycGWZGrXHKa2MgwzKLoUvDSy0stAb4mzxlyBivHQb4f2DWz3oZCQmlU5VYB59P4MCsf9ASz9pHdESBpHoAXvUnyZbafM6-tsX3bRrrxJagTxDW0vYRQ";
try {
const response = await fetch(url, options);
if (response.ok) {
return await response.json();
} else {
throw new Error(`Error: ${response.status}`);
}
} catch (error) {
alert("Error", error);
// console.log("error", error);
return null;
}
}
}
filterReset(filtered, searchParam) {
return filtered.filter((field) => {
return (
field.title &&
field.title
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase()
.includes(searchParam.trim().toLowerCase()) &&
!["draft", "private", "view-locked"].includes(field.access)
);
});
}
renderResults(results) {
this.resultsContainer.innerHTML = "";
if (results.length === 0) {
const item = document.createElement("li");
item.innerText = "No tenemos resultados en tu búsqueda";
this.resultsContainer.appendChild(item);
} else {
results.forEach((result) => {
this.createResultItem(result);
});
}
}
createResultItem(result) {
const item = document.createElement("li");
let link, redirectUrl, spanIcon, attLink;
if (result.titleId) {
link = result.title;
redirectUrl = `/course/${result.titleId}`;
const graduationIcon = document.createElement("i");
graduationIcon.className = "fas fa-graduation-cap";
graduationIcon.setAttribute("data-node-type", "icon");
graduationIcon.setAttribute(
"class",
"standalone normal learnworlds-icon fas fa-graduation-cap lw-element-selected lw-dark-bg-text"
);
graduationIcon.setAttribute("data-element-id", "icon-graduation-cap");
graduationIcon.setAttribute("contenteditable", "false");
graduationIcon.setAttribute("tabindex", "0");
graduationIcon.style.fontSize = "18px";
spanIcon = graduationIcon;
attLink = document.createElement("a");
attLink.href = redirectUrl;
attLink.textContent = link;
} else if (result.short_name) {
// Validar tag del usuario????
link = result.name;
redirectUrl = `https://ubitslearning.com/sso/comfama2?ubitsCourseId=${result.id}`;
const ubitsIcon = document.createElement("span");
ubitsIcon.className = "flexible-part learnworlds-icon lw-element-selected learnworlds-main-text-normal lw-dark-bg-text no-margin-bottom";
ubitsIcon.innerHTML = `
`;
ubitsIcon.setAttribute("data-node-type", "icon");
spanIcon = ubitsIcon;
attLink = document.createElement("a");
attLink.href = redirectUrl;
attLink.textContent = link;
} else {
link = result.title;
redirectUrl = `/blog/${result.slug}`;
let uploadSVGIcon = document.createElement("span");
uploadSVGIcon.setAttribute("data-node-type", "icon");
uploadSVGIcon.setAttribute(
"class",
"lw-brand-text standalone normal learnworlds-icon lw-element-selected fas fa-edit lw-dark-bg-text"
);
uploadSVGIcon.setAttribute("data-element-id", "uploadSVG");
uploadSVGIcon.setAttribute("contenteditable", "false");
uploadSVGIcon.setAttribute("tabindex", "0");
uploadSVGIcon.style.fontSize = "18px";
spanIcon = uploadSVGIcon;
attLink = document.createElement("a");
attLink.href = redirectUrl;
// attLink.textContent = ` ${link}`;
attLink.textContent = `Blog: ${link}`;
}
item.appendChild(spanIcon);
item.appendChild(attLink);
item.addEventListener("click", () => {
window.location.href = redirectUrl;
});
this.resultsContainer.appendChild(item);
}
init() {
this.searchInput.addEventListener("keyup", async (e) => {
if (e.target.value.length < 3) {
this.resultsContainer.style.display = "none";
return;
} else {
this.resultsContainer.style.display = "block";
}
const allCProCourses = await this.fetchJSON(
"https://www.comfamapro.com/api/products_all"
);
const allUbitsCourses = await this.fetchJSON(
"https://api.ubitslearning.com/v1/courses"
);
const allBlogs = await this.fetchJSON(
"https://www.comfamapro.com/api/blogPostsAllPublic"
);
if (!allCProCourses || !allBlogs || !allUbitsCourses) {
// Explicación
// Handle error or return early
return;
}
const cproCourses = Object.values(allCProCourses.courses); // Por qué la conversión a Object values?
const ubitsCourses = Object.values(allUbitsCourses);
const blogs = allBlogs.blogPosts;
const filterCProCourses = this.filterReset(cproCourses, e.target.value);
const filterUbitsCourses = this.filterReset(ubitsCourses, e.target.value);
const filterBlogs = this.filterReset(blogs, e.target.value);
const filterResults = [...filterCProCourses, ...filterUbitsCourses, ...filterBlogs];
this.renderResults(filterResults);
});
document.addEventListener("click", (event) => {
if (!this.searchInput.contains(event.target)) {
this.resultsContainer.style.display = "none";
}
});
this.searchInput.addEventListener("focus", () => {
if (this.resultsContainer.childElementCount > 0) {
this.resultsContainer.style.display = "block";
}
});
}
}
const searchMenu = new SearchMenu();
searchMenu.init(); // Inicializa el comportamiento global del buscador
Derechos de autor © .
ComfamaPro
Ayuda y soporte
¡Puedes pagar por otros
medios de pago!
Pero recuerda
-
Puedes acceder 12 horas después del pago
-
Sólo puedes comprar plan anual o semestral
-
Debes registrarte con el mismo correo que ingresaste a ComfamaPro
-
La tarifa puede cambiar de acuerdo a tu categoría
Empty space, drag to resize
Déjanos tus datos
y uno de nuestros consultores te
contactará
Empty space, drag to resize