Loading plugins/breadcrumb/breadcrumb.jsdeleted 100644 → 0 +0 −23 Original line number Diff line number Diff line import {Plugin} from '../../core/ui/js/Plugin.js'; class BreadcrumbPlugin extends Plugin{ constructor(name) { super(name); } run(){ // let currentPart = $("#text").find(".subpart").first().clone().html(); // if(route === '') // return; // let breadcrumbRoute = route.replace('doc/',''); // if(fragmentId)//global var // breadcrumbRoute += '/' + fragmentId; // $.get( MAX.getPluginsBaseURL() +"/breadcrumb/" + breadcrumbRoute, function(data){ // var breadcrumb = data; // $(breadcrumb).insertAfter($('#topbar')); // }); } } MAX.addPlugin(new BreadcrumbPlugin('Breadcrumb')); plugins/img_viewer/img_viewer.js +0 −2 Original line number Diff line number Diff line Loading @@ -101,6 +101,4 @@ class ImageViewer extends Plugin { } console.log(MAX.plugins) MAX.addPlugin(new ImageViewer('img_viewer')); No newline at end of file plugins/search/search.js +50 −26 Original line number Diff line number Diff line Loading @@ -11,20 +11,31 @@ class SearchPlugin extends Plugin{ } runSearch(search, docs, transform, divToFeed){ let self = this; $.post( window.MAX.getBaseURL() + window.MAX.getProjectID() + "/search", { search: search, docs: docs, transform: transform }, function(data){ divToFeed.html(data); self.updateHitsInfo(docs); } ); runSearch(search, docs, divToFeed){ let url = window.MAX.getBaseURL() + window.MAX.getProjectID() + "/search?search="+search; docs.forEach(d => { url += "&docs[]=" + d }); console.log(url); fetch(url) .then(response => response.text()) .then(data => { console.log(data); divToFeed.innerHTML = data; this.updateHitsInfo(docs) }) // $.post( // window.MAX.getBaseURL() + window.MAX.getProjectID() + "/search", // { // search: search, // docs: docs, // transform: transform // }, // function(data){ // divToFeed.html(data); // self.updateHitsInfo(docs); // } // ); } searchModeChanged(){ Loading @@ -43,29 +54,42 @@ class SearchPlugin extends Plugin{ Performs search according to form parameters */ runSearchFromForm(){ let search = $('#searchInput').val(); let search = document.getElementById('searchInput').value; if(search.trim() === ''){ window.alert('Recherche vide ou incorrecte.'); return; } $("#searchLoading").show(); document.getElementById('searchLoading').style.display = 'block'; let docs = $('#searchSelect').val(); let transform = $('#searchTransform').prop('checked') ?'yes' : 'no' let options = document.getElementById('searchSelect').selectedOptions; let docs = Array.from(options).map(({ value }) => value); this.runSearch(search, this.searchMode === ALL_TXT_SEARCH ? [] : docs, transform, $("#searchResults")); this.runSearch(search, docs, document.getElementById("searchResults")); } updateHitsInfo(){ $('.manchette_droite').remove(); $(".hit").each(function(){ $(this).prepend("<span class='hit_range'>["+ ($(this).prevAll(".hit").length+ 1) +"]</span>") document.querySelectorAll(".manchette_droite").forEach(e => e.remove()); let index = 1; document.querySelectorAll(".hit").forEach((hit) => { let rangeNode = document.createElement('span'); rangeNode.classList.add('hit_range'); rangeNode.innerHTML = index; index++; hit.prepend(rangeNode); //$(this).prepend("<span class='hit_range'></span>") }); $("#searchResults").prepend("<h3 class='n-search-result'>"+$('.hit').length+" résultat(s)</h3>") $("#hits").css('visibility', 'visible'); $("#searchLoading").hide(); let totalNode = document.createElement("h3"); totalNode.classList.add('n-search-result'); totalNode.innerHTML = index - 1 + " résultat(s)"; document.getElementById('searchResults').prepend(totalNode); document.getElementById('searchLoading').style.display = 'none'; // $("#searchResults").prepend("<h3 class='n-search-result'>"+$('.hit').length+" résultat(s)</h3>") // $("#hits").css('visibility', 'visible'); // $("#searchLoading").hide(); } } Loading plugins/search/search.xqm +42 −42 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ function max.plugin.search:searchPage($project){ if(max.config:isIgnored($docName, $project)) then () else <option value="{tokenize($route, $max.cons:TOC||'/')[last()]}">{$docName}</option> <option value="{tokenize($route, $max.cons:TOC||'/')[last()]}" selected="true">{$docName}</option> } </select> return Loading @@ -50,7 +50,6 @@ function max.plugin.search:searchPage($project){ </div> {$routeSelect} <input id= 'searchInput' type='text'/> <input type="checkbox" id="searchTransform"/> Transformer <button class="btn btn-secondary" onclick="search.runSearchFromForm();">Chercher</button> </div> <div id='searchLoading'>{max.i18n:getText($project,'search.loading')}</div> Loading Loading @@ -83,7 +82,7 @@ function max.plugin.search:check($project){ declare %rest:POST %rest:GET %output:method("html") %rest:query-param("search", "{$search}") %rest:query-param("docs[]", "{$docs}") Loading @@ -104,7 +103,7 @@ function max.plugin.search:search($project,$search, $docs as item()*){ let $res := for $h in doc($docPath)//*[local-name(.) = $tag] let $hits := for $hit in ft:mark($h[.//text() contains text {$search}]) for $hit at $n in ft:mark($h[.// text () contains text {$search}]) let $path := replace($docPath, $dbPath || "/", '') let $b2txt := max.config:getBaseURI() || $project || $path || "/" || string($h/@xml:id) || '.html' return <div class='hit'> Loading @@ -116,22 +115,23 @@ function max.plugin.search:search($project,$search, $docs as item()*){ let $xsltDoc := max.util:buildXSLTDoc(max.util:getDefaultTextXSL($project),()) return (admin:write-log('MaX DEBUG - SEARCH in '||$docPath||': ' ||$search),if ($docs = $max.plugin.search:ALL_TXT) then if ($res != '') then xslt:transform( return (admin:write-log('MaX DEBUG - SEARCH in '||$docPath||': ' ||$search), if ($res != '') then xslt:transform( <div class='hits'> <details> <summary>{$docPath}</summary> <details open=""> <summary>{$docPath}-{count($res)}</summary> {$res} </details> </div>, $xsltDoc, ()) else () else xslt:transform( <div class='hits'> <details open=""> <summary>{$docPath}</summary> {$res} </details> </div>, $xsltDoc, ())) ) }; (: }; :) No newline at end of file Loading
plugins/breadcrumb/breadcrumb.jsdeleted 100644 → 0 +0 −23 Original line number Diff line number Diff line import {Plugin} from '../../core/ui/js/Plugin.js'; class BreadcrumbPlugin extends Plugin{ constructor(name) { super(name); } run(){ // let currentPart = $("#text").find(".subpart").first().clone().html(); // if(route === '') // return; // let breadcrumbRoute = route.replace('doc/',''); // if(fragmentId)//global var // breadcrumbRoute += '/' + fragmentId; // $.get( MAX.getPluginsBaseURL() +"/breadcrumb/" + breadcrumbRoute, function(data){ // var breadcrumb = data; // $(breadcrumb).insertAfter($('#topbar')); // }); } } MAX.addPlugin(new BreadcrumbPlugin('Breadcrumb'));
plugins/img_viewer/img_viewer.js +0 −2 Original line number Diff line number Diff line Loading @@ -101,6 +101,4 @@ class ImageViewer extends Plugin { } console.log(MAX.plugins) MAX.addPlugin(new ImageViewer('img_viewer')); No newline at end of file
plugins/search/search.js +50 −26 Original line number Diff line number Diff line Loading @@ -11,20 +11,31 @@ class SearchPlugin extends Plugin{ } runSearch(search, docs, transform, divToFeed){ let self = this; $.post( window.MAX.getBaseURL() + window.MAX.getProjectID() + "/search", { search: search, docs: docs, transform: transform }, function(data){ divToFeed.html(data); self.updateHitsInfo(docs); } ); runSearch(search, docs, divToFeed){ let url = window.MAX.getBaseURL() + window.MAX.getProjectID() + "/search?search="+search; docs.forEach(d => { url += "&docs[]=" + d }); console.log(url); fetch(url) .then(response => response.text()) .then(data => { console.log(data); divToFeed.innerHTML = data; this.updateHitsInfo(docs) }) // $.post( // window.MAX.getBaseURL() + window.MAX.getProjectID() + "/search", // { // search: search, // docs: docs, // transform: transform // }, // function(data){ // divToFeed.html(data); // self.updateHitsInfo(docs); // } // ); } searchModeChanged(){ Loading @@ -43,29 +54,42 @@ class SearchPlugin extends Plugin{ Performs search according to form parameters */ runSearchFromForm(){ let search = $('#searchInput').val(); let search = document.getElementById('searchInput').value; if(search.trim() === ''){ window.alert('Recherche vide ou incorrecte.'); return; } $("#searchLoading").show(); document.getElementById('searchLoading').style.display = 'block'; let docs = $('#searchSelect').val(); let transform = $('#searchTransform').prop('checked') ?'yes' : 'no' let options = document.getElementById('searchSelect').selectedOptions; let docs = Array.from(options).map(({ value }) => value); this.runSearch(search, this.searchMode === ALL_TXT_SEARCH ? [] : docs, transform, $("#searchResults")); this.runSearch(search, docs, document.getElementById("searchResults")); } updateHitsInfo(){ $('.manchette_droite').remove(); $(".hit").each(function(){ $(this).prepend("<span class='hit_range'>["+ ($(this).prevAll(".hit").length+ 1) +"]</span>") document.querySelectorAll(".manchette_droite").forEach(e => e.remove()); let index = 1; document.querySelectorAll(".hit").forEach((hit) => { let rangeNode = document.createElement('span'); rangeNode.classList.add('hit_range'); rangeNode.innerHTML = index; index++; hit.prepend(rangeNode); //$(this).prepend("<span class='hit_range'></span>") }); $("#searchResults").prepend("<h3 class='n-search-result'>"+$('.hit').length+" résultat(s)</h3>") $("#hits").css('visibility', 'visible'); $("#searchLoading").hide(); let totalNode = document.createElement("h3"); totalNode.classList.add('n-search-result'); totalNode.innerHTML = index - 1 + " résultat(s)"; document.getElementById('searchResults').prepend(totalNode); document.getElementById('searchLoading').style.display = 'none'; // $("#searchResults").prepend("<h3 class='n-search-result'>"+$('.hit').length+" résultat(s)</h3>") // $("#hits").css('visibility', 'visible'); // $("#searchLoading").hide(); } } Loading
plugins/search/search.xqm +42 −42 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ function max.plugin.search:searchPage($project){ if(max.config:isIgnored($docName, $project)) then () else <option value="{tokenize($route, $max.cons:TOC||'/')[last()]}">{$docName}</option> <option value="{tokenize($route, $max.cons:TOC||'/')[last()]}" selected="true">{$docName}</option> } </select> return Loading @@ -50,7 +50,6 @@ function max.plugin.search:searchPage($project){ </div> {$routeSelect} <input id= 'searchInput' type='text'/> <input type="checkbox" id="searchTransform"/> Transformer <button class="btn btn-secondary" onclick="search.runSearchFromForm();">Chercher</button> </div> <div id='searchLoading'>{max.i18n:getText($project,'search.loading')}</div> Loading Loading @@ -83,7 +82,7 @@ function max.plugin.search:check($project){ declare %rest:POST %rest:GET %output:method("html") %rest:query-param("search", "{$search}") %rest:query-param("docs[]", "{$docs}") Loading @@ -104,7 +103,7 @@ function max.plugin.search:search($project,$search, $docs as item()*){ let $res := for $h in doc($docPath)//*[local-name(.) = $tag] let $hits := for $hit in ft:mark($h[.//text() contains text {$search}]) for $hit at $n in ft:mark($h[.// text () contains text {$search}]) let $path := replace($docPath, $dbPath || "/", '') let $b2txt := max.config:getBaseURI() || $project || $path || "/" || string($h/@xml:id) || '.html' return <div class='hit'> Loading @@ -116,22 +115,23 @@ function max.plugin.search:search($project,$search, $docs as item()*){ let $xsltDoc := max.util:buildXSLTDoc(max.util:getDefaultTextXSL($project),()) return (admin:write-log('MaX DEBUG - SEARCH in '||$docPath||': ' ||$search),if ($docs = $max.plugin.search:ALL_TXT) then if ($res != '') then xslt:transform( return (admin:write-log('MaX DEBUG - SEARCH in '||$docPath||': ' ||$search), if ($res != '') then xslt:transform( <div class='hits'> <details> <summary>{$docPath}</summary> <details open=""> <summary>{$docPath}-{count($res)}</summary> {$res} </details> </div>, $xsltDoc, ()) else () else xslt:transform( <div class='hits'> <details open=""> <summary>{$docPath}</summary> {$res} </details> </div>, $xsltDoc, ())) ) }; (: }; :) No newline at end of file