Draft Forbes Group Website (Build by Nikola). The official site is hosted at:
License: GPL3
ubuntu2004
1/*2Tipue Search 7.13Copyright (c) 2019 Tipue4Tipue Search is released under the MIT License5http://www.tipue.com/search6*/789(function($) {1011$.fn.tipuesearch = function(options) {1213var set = $.extend( {1415'contextBuffer' : 60,16'contextLength' : 60,17'contextStart' : 90,18'debug' : false,19'descriptiveWords' : 25,20'footerPages' : 3,21'highlightTerms' : true,22'imageZoom' : true,23'minimumLength' : 3,24'newWindow' : false,25'show' : 10,26'showContext' : true,27'showRelated' : true,28'showTime' : true,29'showTitleCount' : true,30'showURL' : true,31'wholeWords' : true32}, options);3334return this.each(function() {3536var tipuesearch_t_c = 0;3738var tipue_search_w = '';39if (set.newWindow)40{41tipue_search_w = ' target="_blank"';42}4344function getURLP(name)45{46var locSearch = location.search;47var splitted = (new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(locSearch)||[,""]);48var searchString = splitted[1].replace(/\+/g, '%20');49try50{51searchString = decodeURIComponent(searchString);52}53catch(e)54{55searchString = unescape(searchString);56}57return searchString || null;58}5960if (getURLP('q'))61{62$('#tipue_search_input').val(getURLP('q'));63getTipueSearch(0, true);64}6566$(this).keyup(function(event)67{68if(event.keyCode == '13')69{70getTipueSearch(0, true);71}72});737475function getTipueSearch(start, replace)76{77window.scrollTo(0, 0);7879var out = '';80var show_replace = false;81var show_stop = false;82var standard = true;83var c = 0;84var found = [];8586var d_o = $('#tipue_search_input').val();87d_o = d_o.replace(/\+/g, ' ').replace(/\s\s+/g, ' ');8889d_o = $.trim(d_o);90var d = d_o.toLowerCase();9192if ((d.match("^\"") && d.match("\"$")) || (d.match("^'") && d.match("'$")))93{94standard = false;95}9697var d_w = d.split(' ');9899if (standard)100{101d = '';102for (var i = 0; i < d_w.length; i++)103{104var a_w = true;105for (var f = 0; f < tipuesearch_stop_words.length; f++)106{107if (d_w[i] == tipuesearch_stop_words[f])108{109a_w = false;110show_stop = true;111}112}113if (a_w)114{115d = d + ' ' + d_w[i];116}117}118d = $.trim(d);119d_w = d.split(' ');120}121else122{123d = d.substring(1, d.length - 1);124}125126if (d.length >= set.minimumLength)127{128if (standard)129{130if (replace)131{132var d_r = d;133for (var i = 0; i < d_w.length; i++)134{135for (var f = 0; f < tipuesearch_replace.words.length; f++)136{137if (d_w[i] == tipuesearch_replace.words[f].word)138{139d = d.replace(d_w[i], tipuesearch_replace.words[f].replace_with);140show_replace = true;141}142}143}144d_w = d.split(' ');145}146147var d_t = d;148for (var i = 0; i < d_w.length; i++)149{150for (var f = 0; f < tipuesearch_stem.words.length; f++)151{152if (d_w[i] == tipuesearch_stem.words[f].word)153{154d_t = d_t + ' ' + tipuesearch_stem.words[f].stem;155}156}157}158d_w = d_t.split(' ');159160for (var i = 0; i < tipuesearch.pages.length; i++)161{162var score = 0;163var s_t = tipuesearch.pages[i].text;164for (var f = 0; f < d_w.length; f++)165{166if (set.wholeWords)167{168var pat = new RegExp('\\b' + d_w[f] + '\\b', 'gi');169}170else171{172var pat = new RegExp(d_w[f], 'gi');173}174if (tipuesearch.pages[i].title.search(pat) != -1)175{176var m_c = tipuesearch.pages[i].title.match(pat).length;177score += (20 * m_c);178}179if (tipuesearch.pages[i].text.search(pat) != -1)180{181var m_c = tipuesearch.pages[i].text.match(pat).length;182score += (20 * m_c);183}184if (tipuesearch.pages[i].tags)185{186if (tipuesearch.pages[i].tags.search(pat) != -1)187{188var m_c = tipuesearch.pages[i].tags.match(pat).length;189score += (10 * m_c);190}191}192if (tipuesearch.pages[i].url.search(pat) != -1)193{194score += 20;195}196197if (score != 0)198{199for (var e = 0; e < tipuesearch_weight.weight.length; e++)200{201if (tipuesearch.pages[i].url == tipuesearch_weight.weight[e].url)202{203score += tipuesearch_weight.weight[e].score;204}205}206}207208if (d_w[f].match('^-'))209{210pat = new RegExp(d_w[f].substring(1), 'i');211if (tipuesearch.pages[i].title.search(pat) != -1 || tipuesearch.pages[i].text.search(pat) != -1 || tipuesearch.pages[i].tags.search(pat) != -1)212{213score = 0;214}215}216}217218if (score != 0)219{220found.push(221{222"score": score,223"title": tipuesearch.pages[i].title,224"desc": s_t,225"img": tipuesearch.pages[i].img,226"url": tipuesearch.pages[i].url,227"note": tipuesearch.pages[i].note228});229c++;230}231}232}233else234{235for (var i = 0; i < tipuesearch.pages.length; i++)236{237var score = 0;238var s_t = tipuesearch.pages[i].text;239var pat = new RegExp(d, 'gi');240if (tipuesearch.pages[i].title.search(pat) != -1)241{242var m_c = tipuesearch.pages[i].title.match(pat).length;243score += (20 * m_c);244}245if (tipuesearch.pages[i].text.search(pat) != -1)246{247var m_c = tipuesearch.pages[i].text.match(pat).length;248score += (20 * m_c);249}250if (tipuesearch.pages[i].tags)251{252if (tipuesearch.pages[i].tags.search(pat) != -1)253{254var m_c = tipuesearch.pages[i].tags.match(pat).length;255score += (10 * m_c);256}257}258if (tipuesearch.pages[i].url.search(pat) != -1)259{260score += 20;261}262263if (score != 0)264{265for (var e = 0; e < tipuesearch_weight.weight.length; e++)266{267if (tipuesearch.pages[i].url == tipuesearch_weight.weight[e].url)268{269score += tipuesearch_weight.weight[e].score;270}271}272}273274if (score != 0)275{276found.push(277{278"score": score,279"title": tipuesearch.pages[i].title,280"desc": s_t,281"img": tipuesearch.pages[i].img,282"url": tipuesearch.pages[i].url,283"note": tipuesearch.pages[i].note284});285c++;286}287}288}289290if (c != 0)291{292if (set.showTitleCount && tipuesearch_t_c == 0)293{294var title = document.title;295document.title = '(' + c + ') ' + title;296tipuesearch_t_c++;297}298299if (c == 1)300{301out += '<div id="tipue_search_results_count">' + tipuesearch_string_4;302}303else304{305var c_c = c.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");306out += '<div id="tipue_search_results_count">' + c_c + ' ' + tipuesearch_string_5;307}308if (set.showTime)309{310var endTimer = new Date().getTime();311var time = (endTimer - startTimer) / 1000;312out += ' (' + time.toFixed(2) + ' ' + tipuesearch_string_14 + ')';313set.showTime = false;314}315out += '</div>';316317if (set.showRelated && standard)318{319var ront = '';320f = 0;321for (var i = 0; i < tipuesearch_related.Related.length; i++)322{323if (d == tipuesearch_related.Related[i].search)324{325if (!f)326{327out += '<div class="tipue_search_related">' + tipuesearch_string_10 + ': ';328}329if (show_replace)330{331d_o = d;332}333334if (tipuesearch_related.Related[i].include)335{336var r_d = d_o + ' ' + tipuesearch_related.Related[i].related;337}338else339{340var r_d = tipuesearch_related.Related[i].related;341}342343ront += '<a class="tipue_search_related_btn" id="' + r_d + '">' + tipuesearch_related.Related[i].related + '</a>, ';344f++;345}346}347if (f)348{349ront = ront.slice(0, -2);350ront += '.</div>';351out += ront;352}353}354355if (show_replace)356{357out += '<div id="tipue_search_replace">' + tipuesearch_string_2 + ' ' + d + '. ' + tipuesearch_string_3 + ' <a id="tipue_search_replaced">' + d_r + '</a></div>';358}359360found.sort(function(a, b) { return b.score - a.score } );361362var l_o = 0;363364if (set.imageZoom)365{366out += '<div id="tipue_search_image_modal"><div class="tipue_search_image_close">✕</div><div class="tipue_search_image_block"><a id="tipue_search_zoom_url"><img id="tipue_search_zoom_img"></a><div id="tipue_search_zoom_text"></div></div></div>';367}368369for (var i = 0; i < found.length; i++)370{371if (l_o >= start && l_o < set.show + start)372{373out += '<div class="tipue_search_result">';374375out += '<div class="tipue_search_content_title"><a href="' + found[i].url + '"' + tipue_search_w + '>' + found[i].title + '</a></div>';376377if (set.debug)378{379out += '<div class="tipue_search_content_debug">Score: ' + found[i].score + '</div>';380}381382if (set.showURL)383{384var s_u = found[i].url.toLowerCase();385if (s_u.indexOf('http://') == 0)386{387s_u = s_u.slice(7);388}389out += '<div class="tipue_search_content_url"><a href="' + found[i].url + '"' + tipue_search_w + '>' + s_u + '</a></div>';390}391392if (found[i].img)393{394if (set.imageZoom)395{396out += '<div class="tipue_search_image"><img class="tipue_search_img tipue_search_image_zoom" src="' + found[i].img + '" alt="' + found[i].title + '" data-url="' + found[i].url + '"></div>';397}398else399{400out += '<div class="tipue_search_image"><a href="' + found[i].url + '"' + tipue_search_w + '><img class="tipue_search_img" src="' + found[i].img + '" alt="' + found[i].title + '"></a></div>';401}402}403404if (found[i].desc)405{406var t = found[i].desc;407408if (set.showContext)409{410d_w = d.split(' ');411var s_1 = found[i].desc.toLowerCase().indexOf(d_w[0]);412if (s_1 > set.contextStart)413{414var t_1 = t.substr(s_1 - set.contextBuffer);415var s_2 = t_1.indexOf(' ');416t_1 = t.substr(s_1 - set.contextBuffer + s_2);417t_1 = $.trim(t_1);418419if (t_1.length > set.contextLength)420{421t = '... ' + t_1;422}423}424}425426if (standard)427{428d_w = d.split(' ');429for (var f = 0; f < d_w.length; f++)430{431if (set.highlightTerms)432{433var patr = new RegExp('(' + d_w[f] + ')', 'gi');434t = t.replace(patr, "<h0011>$1<h0012>");435}436}437}438else if (set.highlightTerms)439{440var patr = new RegExp('(' + d + ')', 'gi');441t = t.replace(patr, "<span class=\"tipue_search_content_bold\">$1</span>");442}443444var t_d = '';445var t_w = t.split(' ');446if (t_w.length < set.descriptiveWords)447{448t_d = t;449}450else451{452for (var f = 0; f < set.descriptiveWords; f++)453{454t_d += t_w[f] + ' ';455}456}457t_d = $.trim(t_d);458if (t_d.charAt(t_d.length - 1) != '.')459{460t_d += ' ...';461}462463t_d = t_d.replace(/h0011/g, 'span class=\"tipue_search_content_bold\"');464t_d = t_d.replace(/h0012/g, '/span');465466out += '<div class="tipue_search_content_text">' + t_d + '</div>';467}468469if (found[i].note)470{471out += '<div class="tipue_search_note">' + found[i].note + '</div>';472}473474out += '</div>';475}476l_o++;477}478479if (c > set.show)480{481var pages = Math.ceil(c / set.show);482var page = (start / set.show);483if (set.footerPages < 3)484{485set.footerPages = 3;486}487488out += '<div id="tipue_search_foot"><ul id="tipue_search_foot_boxes">';489490if (start > 0)491{492out += '<li role="navigation"><a class="tipue_search_foot_box" accesskey="b" id="' + (start - set.show) + '_' + replace + '">' + tipuesearch_string_6 + '</a></li>';493}494495if (page <= 2)496{497var p_b = pages;498if (pages > set.footerPages)499{500p_b = set.footerPages;501}502for (var f = 0; f < p_b; f++)503{504if (f == page)505{506out += '<li class="current" role="navigation">' + (f + 1) + '</li>';507}508else509{510out += '<li role="navigation"><a class="tipue_search_foot_box" id="' + (f * set.show) + '_' + replace + '">' + (f + 1) + '</a></li>';511}512}513}514else515{516var p_b = page + set.footerPages - 1;517if (p_b > pages)518{519p_b = pages;520}521for (var f = page - 1; f < p_b; f++)522{523if (f == page)524{525out += '<li class="current" role="navigation">' + (f + 1) + '</li>';526}527else528{529out += '<li role="navigation"><a class="tipue_search_foot_box" id="' + (f * set.show) + '_' + replace + '">' + (f + 1) + '</a></li>';530}531}532}533534if (page + 1 != pages)535{536out += '<li role="navigation"><a class="tipue_search_foot_box" accesskey="m" id="' + (start + set.show) + '_' + replace + '">' + tipuesearch_string_7 + '</a></li>';537}538539out += '</ul></div>';540}541542}543else544{545out += '<div id="tipue_search_error">' + tipuesearch_string_8 + '</div>';546}547}548else549{550if (show_stop)551{552out += '<div id="tipue_search_error">' + tipuesearch_string_8 + ' ' + tipuesearch_string_9 + '</div>';553}554else555{556if (set.minimumLength == 1)557{558out += '<div id="tipue_search_error">' + tipuesearch_string_11 + '</div>';559}560else561{562out += '<div id="tipue_search_error">' + tipuesearch_string_12 + ' ' + set.minimumLength + ' ' + tipuesearch_string_13 + '</div>';563}564}565}566567$('#tipue_search_content').hide().html(out).slideDown(200);568569$('#tipue_search_replaced').click(function()570{571getTipueSearch(0, false);572});573574$('.tipue_search_related_btn').click(function()575{576$('#tipue_search_input').val($(this).attr('id'));577getTipueSearch(0, true);578});579580$('.tipue_search_image_zoom').click(function()581{582$('#tipue_search_image_modal').fadeIn(300);583$('#tipue_search_zoom_img').attr('src', this.src);584585var z_u = $(this).attr('data-url');586$('#tipue_search_zoom_url').attr('href', z_u);587588var z_o = this.alt + '<div class="tipue_search_zoom_options"><a href="' + this.src + '" target="_blank">' + tipuesearch_string_15 + '</a> <a href="' + z_u + '">' + tipuesearch_string_16 + '</a></div>';589590$('#tipue_search_zoom_text').html(z_o);591});592593$('.tipue_search_image_close').click(function()594{595$('#tipue_search_image_modal').fadeOut(300);596});597598$('.tipue_search_foot_box').click(function()599{600var id_v = $(this).attr('id');601var id_a = id_v.split('_');602603getTipueSearch(parseInt(id_a[0]), id_a[1]);604});605}606607});608};609610})(jQuery);611612613