// PAPERWEB - GPLv3 licence // Copyright 2006-2016 Yves Gablin // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // var paperweb = { //private static function purgeSection() purgeSection: function(section) { for (var i = section.childNodes.length; i--;) { section.removeChild(section.childNodes[i]); } }, // public static function prepareQuery() prepareQuery: function() { var button = document.querySelector('header button'); ajax.link(button, function(thisButton) { var inputs = document.querySelectorAll('header input'); return encodeURI('query.ajax.php?doQuery=1&D='+inputs[0].value +'&L='+inputs[1].value+'&K='+inputs[2].value); }, paperweb.updateResult, ajax.XML, true); }, // public static function prepareThumbs() prepareThumbs: function() { var buttons = document.querySelectorAll('#result button'); for (var i = buttons.length; i--;) { buttons[i].addEventListener('click', paperweb.changeCurrentDocument); ajax.link(buttons[i], function(thisButton) { return encodeURI('thumbs.ajax.php?doThumbnails='+thisButton.value); }, paperweb.updateThumbs, ajax.XML, true); } }, // public static function updateResult(xml) updateResult: function(xml) { var newSection = ajax.importNode(xml.documentElement, document); var section = document.getElementById('result'); section.parentNode.replaceChild(newSection, section); paperweb.purgeSection(document.getElementById('thumbs')); paperweb.prepareThumbs(); }, // public static function updateThumbs(xml) updateThumbs: function(xml) { var section = document.getElementById('thumbs'); section.parentNode.replaceChild(ajax.importNode(xml.documentElement, document), section); }, // public static function changeCurrentDocument(evt) changeCurrentDocument: function(evt) { var buttons = document.querySelectorAll('#result button'); for (var i = buttons.length; i--;) { buttons[i].disabled = (buttons[i] === this); } } }; window.addEventListener('load', paperweb.prepareQuery);