(function() { var mobile = $('link[href$="?mobi"]')[0]; if (mobile) { window._mobileSearch = { // language settings lang : { search_stop : 'Stop searching', search_loading : '
Loading...
', // {GUEST?STRING} applies the STRING in the brackets if the user is a guest search_error : '
The page could not be retrieved. Please check with an administrator about your search permissions{GUEST? or login if you haven\'t yet}.
' }, // search presets presets : { 'Search Presets' : '', 'Advanced Search' : 'RESET', // RESET is a special value ( see preset.onchange ) 'Active Topics' : '/search?search_id=activetopics', 'New Posts' : '/search?search_id=newposts', 'Your Posts' : '/search?search_id=egosearch', 'Unanswered' : '/search?search_id=unanswered' }, active : false, // actively searching ? // open the search window open : function(href, callback) { if (_mobileSearch.active) _mobileSearch.close(); var box = document.createElement('DIV'), preset = document.createElement('SELECT'), i; box.id = 'fa_mobile_search'; box.innerHTML = '
' + _mobileSearch.lang.search_loading + '
 ' + _mobileSearch.lang.search_stop + '
'; for (i in _mobileSearch.presets) preset.innerHTML += ''; preset.onchange = function() { if (this.value) { if (this.value == 'RESET') document.getElementById('faMobileSearch').firstChild.click(); else _mobileSearch.open(this.value, function(content, data) { _mobileSearch.formatMobile(content); }); } }; box.lastChild.insertBefore(preset, box.lastChild.getElementsByTagName('A')[0]); $.get(href + (/\?/.test(href) ? '&' : '?') + 'change_version=prosilver', function(data) { var main = $('#main-content', data)[0], page; if (main) { box.firstChild.innerHTML = ''; box.firstChild.appendChild(main); $('.pagination:not(strong) span a', box.firstChild).click(_mobileSearch.getPage); callback && callback(box.firstChild, data); } else box.firstChild.innerHTML = _mobileSearch.lang.search_error.replace(/\{GUEST\?(.*?)\}/, _userdata.session_logged_in ? '' : '$1'); }); document.body.style.overflow = 'hidden'; document.body.appendChild(box); _mobileSearch.active = true; }, // close the search window close : function() { if (_mobileSearch.active) { var box = document.getElementById('fa_mobile_search'); box && document.body.removeChild(box); document.body.style.overflow = ''; _mobileSearch.active = false; } }, // get the next page getPage : function() { var content = document.getElementById('fa_mobile_search').firstChild; content.innerHTML = _mobileSearch.lang.search_loading; $.get(this.href + (/\?/.test(this.href) ? '&' : '?') + 'change_version=prosilver', function(data) { var main = $('#main-content', data)[0]; if (main) { content.scrollTop = 0; content.innerHTML = ''; content.appendChild(main); $('.pagination:not(strong) span a', content).click(_mobileSearch.getPage); _mobileSearch.formatMobile(content); } }); return false; }, // format elements with mobile classes formatMobile : function(context) { context = context ? context : document; var a = $('a', context), i = 0, j = a.length, pagination = $('p.pagination', context); $('h1', context).addClass('mobile_set'); $('.row', context).addClass('mobile_item'); pagination.addClass('mobile_title'); $('span a:not(.pag-img), span strong', pagination).attr('class', 'defaultBtn'); $('.postbody h2', context).addClass('post_header'); for (; i < j; i++) a[i].href = a[i].href.replace(/(?:&|\?)change_version=prosilver/, ''); } }; // write stylesheet into header document.write(''); // DOM ready modifications $(function() { var search = document.createElement('LI'); search.id = 'faMobileSearch'; search.innerHTML = '
Search
'; search.firstChild.onclick = function(e) { _mobileSearch.open(this.href, function(content, data) { $('h1, h2', content).addClass('mobile_set'); $('.panel', content).addClass('post'); $('.button1, .button2', content).attr('class', 'defaultBtn'); $('form[action^="/search"]', content).submit(function(e) { _mobileSearch.open('/search?' + $(this).serialize(), function(content, data) { _mobileSearch.formatMobile(content); }); e.preventDefault(); }); }); e.preventDefault(); }; $(function(){ var bar = document.getElementById('mNavbar'); bar && bar.appendChild(search); }); }); } })();