123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- var url = window.location.pathname;
- var moduleRegex = new RegExp('text\\/(\\w+)\\/');
- var regexArray = moduleRegex.exec(url);
- var modules = ['CALC', 'WRITER', 'IMPRESS', 'DRAW', 'BASE', 'MATH', 'CHART', 'BASIC', 'SHARED'];
- var indexEl = document.getElementsByClassName("index")[0];
- var fullLinks = fullLinkify(indexEl, bookmarks, modules, currentModule());
- var search = document.getElementById('search-bar');
- search.addEventListener('keyup', debounce(filter, 100, indexEl));
- search.value = sessionStorage.getItem('searchsave');
- if (search.value !== undefined) {
- filter(indexEl);
- }
- window.addEventListener('unload', function(event) {
- sessionStorage.setItem('searchsave', search.value);
- });
- fillIndex(indexEl, fullLinks, modules);
- function currentModule() {
- var module = '';
-
-
- if(url.indexOf('explorer/database/') !== -1) {
- module = 'BASE';
- } else {
- if (null === regexArray){
- module = 'HARED'
- } else {
- module = regexArray[1].toUpperCase().substring(1);
- }
- }
- return module;
- };
- function fullLinkify(indexEl, bookmarks, modules, currentModule) {
- var fullLinkified = '';
-
- if(currentModule !== 'HARED') {
- bookmarks = bookmarks.filter(function(obj) {
- return obj['app'] === currentModule || obj['app'] === 'SHARED';
- });
- }
- bookmarks.forEach(function(obj) {
- fullLinkified += '<a href="' + obj['url'] + '" class="' + obj['app'] + '">' + obj['text'] + '</a>';
- });
- return fullLinkified;
- }
- function fillIndex(indexEl, content, modules) {
- indexEl.innerHTML = content;
- var indexKids = indexEl.children;
- for (var i = 0, len = indexKids.length; i < len; i++) {
- indexKids[i].removeAttribute("id");
- }
- modules.forEach(function(module) {
- var moduleHeader = indexEl.getElementsByClassName(module)[0];
- if (typeof moduleHeader !== 'undefined') {
-
- moduleHeader.outerHTML = '<span id="' + module + '" class="' + module + '">' + moduleHeader.outerHTML + '</span>';
- }
- });
- Paginator(indexEl);
- }
- function filter(indexList) {
- var results = null;
- var target = search.value.trim();
- var filtered = '';
- if (target.length < 1) {
- fillIndex(indexEl, fullLinks, modules);
- return;
- }
- results = fuzzysort.go(target, bookmarks, {threshold: -15000, key:'text'});
- results.forEach(function(result) {
- filtered += '<a href="' + result.obj['url'] + '" class="' + result.obj['app'] + '">' + fuzzysort.highlight(result) + '</a>';
- });
- fillIndex(indexList, filtered, modules);
- };
- function debounce(fn, wait, indexList) {
- var timeout;
- return function() {
- clearTimeout(timeout);
- timeout = setTimeout(function() {
- fn.call(this, indexList);
- }, (wait || 150));
- };
- }
- divcopyable(document.getElementsByClassName("bascode"));
- divcopyable(document.getElementsByClassName("pycode"));
- function divcopyable(itemcopyable){
- for (var i = 0, len = itemcopyable.length; i < len; i++) {
- (function() {
- var item = itemcopyable[i];
- function changeBorder(item, color) {
- var saveBorder = item.style.border;
- item.style.borderColor = color;
- setTimeout(function() {
- item.style.border = saveBorder;
- }, 150);
- }
- item.onclick = function() {
- document.execCommand("copy");
- changeBorder(item, "#18A303");
- };
- item.addEventListener("copy", function(event) {
- event.preventDefault();
- if (event.clipboardData) {
- event.clipboardData.setData("text/plain", item.textContent);
- }
- });
- }());
- }
- }
- var copyable = document.getElementsByClassName("input");
- for (var i = 0, len = copyable.length; i < len; i++) {
- (function() {
- var item = copyable[i];
- function changeColor(item, color, colorToChangeBackTo) {
- item.style.backgroundColor = color;
- setTimeout(function() {
- item.style.backgroundColor = colorToChangeBackTo;
- }, 150);
- }
- item.onclick = function() {
- document.execCommand("copy");
- changeColor(item, "#18A303", "transparent");
- };
- item.addEventListener("copy", function(event) {
- event.preventDefault();
- if (event.clipboardData) {
- event.clipboardData.setData("text/plain", item.textContent);
- }
- });
- }());
- }
- var pathname = window.location.pathname;
- var pathRegex = /text\/.*\.html$/;
- var linkIndex = 0;
- var contentMatch = pathname.match(pathRegex);
- function linksMatch(content) {
- var linkMatch = new RegExp(content);
- var links = document.getElementById("Contents").getElementsByTagName("a");
- for (var i = 0, len = links.length; i < len; i++) {
- if (links[i].href.match(linkMatch)) {
- return i;
- }
- }
- }
- linkIndex = linksMatch(contentMatch);
- if (typeof linkIndex !== "undefined") {
- var current = document.getElementById("Contents").getElementsByTagName("a")[linkIndex];
- var cItem = current.parentElement;
- var parents = [];
- while (cItem.parentElement && !cItem.parentElement.matches("#Contents") && parents.indexOf(cItem.parentElement) == -1) {
- parents.push(cItem = cItem.parentElement);
- }
- var liParents = [].filter.call(parents, function(item) {
- return item.matches("li");
- });
- for (var i = 0, len = liParents.length; i < len; i++) {
- var input = liParents[i].querySelectorAll(':scope > input');
- document.getElementById(input[0].id).checked = true;
- }
- current.classList.add('contents-current');
- }
|