/* domucgiare - Menu "Kien thuc & Huong dan" (v2): gop Tin tuc, Hoc nghe sua may in, Tu van, Sua nguon may tinh vao 1 menu tha xuong tren may tinh. Link goc van giu trong trang (an tren may tinh) de Google doc. */ (function () { var nav = document.querySelector('#nav-menu .navbar-nav'); if (!nav || nav.getAttribute('data-tvkt')) return; nav.setAttribute('data-tvkt', '1'); var ITEMS = [ { u: '/tin-tuc/hoc-nghe', t: 'Học nghề sửa máy in', d: 'Lộ trình học, kinh nghiệm thực tế, cơ hội việc làm', ic: 'M22 9 12 4 2 9l10 5 10-5zM6 11.2v4.3c0 1.4 2.7 3 6 3s6-1.6 6-3v-4.3l-6 3-6-3z' }, { u: '/tin-tuc/kien-thuc-nguon-may-tinh', t: 'Sửa nguồn máy tính', d: 'Kiến thức nguồn PC, laptop, cách kiểm tra và xử lý lỗi', ic: 'M13 2 4 14h7l-1 8 9-12h-7l1-8z' }, { u: '/tu-van', t: 'Tư vấn chọn máy', d: 'Chọn máy in, máy photocopy, linh kiện phù hợp nhu cầu', ic: 'M12 2a7 7 0 0 0-4 12.7V17a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-2.3A7 7 0 0 0 12 2zM9 20h6v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1v-1z' }, { u: '/tin-tuc', t: 'Tin tức & mẹo hay', d: 'Hướng dẫn xử lý lỗi máy in, máy tính tại nhà', ic: 'M4 4h13v14a2 2 0 0 0 2 2H6a2 2 0 0 1-2-2V4zm3 3v2h7V7H7zm0 4v2h7v-2H7zm0 4v2h5v-2H7zM18 8h2v10a2 2 0 0 1-2 2V8z' }, { u: 'https://www.youtube.com/@mayinmucinthanvu', t: 'Video hướng dẫn', d: 'Kênh YouTube Thần Vũ: sửa lỗi, thay linh kiện', ic: 'M10 8.6v6.8l5.6-3.4L10 8.6zM21.6 7.2c.4 1.5.4 4.8.4 4.8s0 3.3-.4 4.8a2.5 2.5 0 0 1-1.8 1.8C18.3 19 12 19 12 19s-6.3 0-7.8-.4a2.5 2.5 0 0 1-1.8-1.8C2 15.3 2 12 2 12s0-3.3.4-4.8a2.5 2.5 0 0 1 1.8-1.8C5.7 5 12 5 12 5s6.3 0 7.8.4c.9.2 1.6.9 1.8 1.8z', ext: 1 } ]; var lis = [].slice.call(nav.children), hide = [], first = null; lis.forEach(function (li) { var a = li.querySelector(':scope > a'); if (!a) return; var h = (a.getAttribute('href') || '').replace(/^https?:\/\/[^\/]+/, '').replace(/\/$/, ''); if (h === '/tin-tuc' || h === '/tu-van' || h === '/tin-tuc/hoc-nghe' || h === '/tin-tuc/kien-thuc-hoc-nghe-sua-may-in' || h === '/tin-tuc/kien-thuc-nguon-may-tinh') { hide.push(li); if (!first) first = li; } }); if (!first) return; hide.forEach(function (li) { li.classList.add('tvkt-x'); }); var css = '@media (min-width:992px){' + '#nav-menu li.tvkt-x{display:none!important}' + '#nav-menu li.tvkt{display:block;position:relative}' + '#nav-menu li.tvkt > a::after{content:"";display:inline-block;margin-left:6px;vertical-align:middle;border-top:5px solid currentColor;border-left:4px solid transparent;border-right:4px solid transparent}' + '.tvkt-p{display:none;position:absolute;top:100%;left:-20px;width:660px;background:#fff;border-radius:0 0 14px 14px;box-shadow:0 18px 40px rgba(16,34,66,.22);border-top:3px solid #d62828;z-index:1000;padding:18px 20px 14px;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);gap:18px;text-align:left;font-family:Arial,Helvetica,sans-serif;text-transform:none}' + '#nav-menu li.tvkt:hover > .tvkt-p,#nav-menu li.tvkt:focus-within > .tvkt-p{display:grid}' + '.tvkt-h{font-size:11.5px;font-weight:700;letter-spacing:.8px;text-transform:uppercase;color:#5c6b80;margin:0 0 8px}' + '.tvkt-p a.tvkt-i{display:flex;gap:11px;align-items:flex-start;padding:8px 10px;border-radius:9px;text-decoration:none!important;color:#14284b!important;line-height:1.35;margin:0!important;background:none!important;float:none!important;height:auto!important;white-space:normal!important;text-transform:none!important}' + '.tvkt-p a.tvkt-i:hover{background:#f1f4f9!important}' + '.tvkt-ic{flex:0 0 34px;width:34px;height:34px;border-radius:9px;background:#eef2f8;color:#14284b;display:flex;align-items:center;justify-content:center}' + '.tvkt-ic svg{width:18px;height:18px}' + '.tvkt-i.tvkt-yt .tvkt-ic{background:#fdecea;color:#e4342b}' + '.tvkt-i b{display:block;font-size:14px;font-weight:700}' + '.tvkt-i small{display:block;font-size:12.5px;color:#5c6b80;font-weight:400;margin-top:2px}' + '.tvkt-r{background:#f7f9fc;border-radius:10px;padding:12px 14px}' + '.tvkt-r ul{list-style:none;margin:0;padding:0}' + '.tvkt-r li{margin:0 0 9px;padding:0;display:block!important;float:none!important}' + '.tvkt-r li a{display:block!important;padding:0!important;color:#14284b!important;font-size:13.5px!important;font-weight:400!important;line-height:1.4!important;text-transform:none!important;white-space:normal!important;background:none!important;height:auto!important}' + '.tvkt-r li a:hover{color:#d62828!important;text-decoration:underline!important}' + '.tvkt-r .tvkt-ld{color:#8a93a3;font-size:13px}' + '.tvkt-all{display:inline-block!important;margin-top:4px;padding:0!important;color:#d62828!important;font-weight:700!important;font-size:13.5px!important;background:none!important;height:auto!important;text-transform:none!important}' + '}'; var st = document.createElement('style'); st.id = 'tvkt-css'; st.textContent = css; document.head.appendChild(st); var li = document.createElement('li'); li.className = 'tvkt hidden-xs hidden-sm'; var h = '\x3ca href="/tin-tuc" title="Kiến thức sửa máy in, máy tính và hướng dẫn" aria-haspopup="true">Kiến thức & Hướng dẫn\x3c/a>\x3cdiv class="tvkt-p">\x3cdiv>\x3cp class="tvkt-h">Chuyên mục\x3c/p>'; ITEMS.forEach(function (x) { h += '\x3ca class="tvkt-i' + (x.ext ? ' tvkt-yt' : '') + '" href="' + x.u + '"' + (x.ext ? ' target="_blank" rel="noopener"' : '') + '>' + '\x3cspan class="tvkt-ic">\x3csvg viewBox="0 0 24 24" aria-hidden="true">\x3cpath fill="currentColor" d="' + x.ic + '"/>\x3c/svg>\x3c/span>' + '\x3cspan>\x3cb>' + x.t + '\x3c/b>\x3csmall>' + x.d + '\x3c/small>\x3c/span>\x3c/a>'; }); h += '\x3c/div>\x3cdiv class="tvkt-r">\x3cp class="tvkt-h">Bài mới\x3c/p>\x3cul>\x3cli class="tvkt-ld">Đang tải…\x3c/li>\x3c/ul>\x3ca class="tvkt-all" href="/tin-tuc">Xem tất cả bài viết →\x3c/a>\x3c/div>\x3c/div>'; li.innerHTML = h; nav.insertBefore(li, first); var loaded = false; function load() { if (loaded) return; loaded = true; var ul = li.querySelector('.tvkt-r ul'); var KEY = 'tvktNew3', c = null; try { c = JSON.parse(localStorage.getItem(KEY) || 'null'); } catch (e) {} function show(list) { if (!list || !list.length) { ul.innerHTML = ''; return; } ul.innerHTML = list.map(function (x) { return '\x3cli>\x3ca href="' + x.u + '">' + x.t.replace(/\x3c/g, '<') + '\x3c/a>\x3c/li>'; }).join(''); } if (c && Date.now() - c.at < 6 * 3600 * 1000) { show(c.d); return; } fetch('/tin-tuc', { credentials: 'same-origin' }).then(function (r) { return r.text(); }).then(function (t) { var d = new DOMParser().parseFromString(t, 'text/html'), seen = {}, out = []; [].forEach.call(d.querySelectorAll('#content a[href*="/tin-tuc/"]'), function (a) { var im = a.querySelector('img'); if (!im) return; var u = a.getAttribute('href'), tx = (a.getAttribute('title') || im.getAttribute('alt') || '').trim().replace(/\s+/g, ' '); if (out.length >= 5 || seen[u] || tx.length < 20 || /\/(hoc-nghe|kien-thuc-hoc-nghe-sua-may-in|kien-thuc-nguon-may-tinh)\/?$/.test(u) || !/\.html$|\/[^\/]+\/[^\/]+$/.test(u)) return; seen[u] = 1; out.push({ u: u, t: tx.charAt(0).toUpperCase() + tx.slice(1) }); }); try { localStorage.setItem(KEY, JSON.stringify({ at: Date.now(), d: out })); } catch (e) {} show(out); }).catch(function () { ul.innerHTML = ''; }); } li.addEventListener('mouseenter', load); li.addEventListener('focusin', load); })();