TOC html

From Redazione
Jump to navigation Jump to search
 
(60 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
 
  
 
<html>
 
<html>
Line 18: Line 16:
  
 
-->
 
-->
 +
 +
 +
<!--------------------------path-------------------------->
 +
 +
<div class="ci_form_section">
 +
<span class="ci_form_section_label">
 +
Target url
 +
</span>
 +
 +
<input class="ci_form_input" type="text" placeholder="" name="Form TOC[target url]" value="">
 +
 +
<span class="ci_form_section_help">
 +
Enter the target url of this set of pages, e.g.: https://culturaitaliana.org/organizations/Centro_italiano_Barcellona
 +
</span>
 +
 +
</div>
 +
 +
  
 
<div id="TOC_tree"></div>
 
<div id="TOC_tree"></div>
Line 35: Line 51:
 
-->
 
-->
  
<input type="hidden" name="Form TOC[contents]" />
+
<input id="TOC_contents" type="hidden" name="Form TOC[contents]" />
 
</div>
 
</div>
  
Line 42: Line 58:
 
<div class="ci_form_section_submit">
 
<div class="ci_form_section_submit">
 
<input type="hidden" name="wpSave" value="Save page">
 
<input type="hidden" name="wpSave" value="Save page">
<input type="hidden" name="pf_free_text" value="!free_text!">
+
<input type="hidden" id="pf_free_text" name="pf_free_text" value="">
  
 
<input class="ci_form_submit" type="submit" value="save">
 
<input class="ci_form_submit" type="submit" value="save">
Line 54: Line 70:
  
 
<script>
 
<script>
var isPublic = 1;
+
 
var contents = [{"id":"11","text":"Main Page previous","children":[],"path":"Main Page previous","language":"en","state":{"selected":true,"opened":true}},{"id":"67","text":"Team","children":[],"path":"Team","language":"","state":{"selected":true,"opened":true}},{"id":"62","text":"Calls and scholarships/Europa Creativa - MEDIA","children":[],"path":"Calls and scholarships/Europa Creativa - MEDIA","language":"it","state":{"selected":true,"opened":true}},{"id":"88","text":"Form announcement","children":[],"path":"Form announcement","language":"en","state":{"selected":true,"opened":true}},{"id":"690","text":"Geolocalizazzione prova","children":[],"path":"Geolocalizazzione prova","language":"it","state":{"selected":true,"opened":true}},{"id":"733","text":"Forms","children":[],"path":"Forms","language":"en","state":{"selected":true,"opened":true}},{"id":"_1","text":"Reading suggestions","children":[{"id":"408","text":"Reading suggestions","children":[],"path":"Reading suggestions","language":"","state":{"selected":true,"opened":true}},{"id":"761","text":"Giacomo Scotti, Mario Licciardi - Non si trova cioccolata","children":[],"path":"Reading suggestions/Giacomo Scotti, Mario Licciardi - Non si trova cioccolata","language":"en","state":{"selected":true,"opened":true}},{"id":"762","text":"Viviano Domenici - A cena con i cannibali. Taccuino di un giornalista esploratore","children":[],"path":"Reading suggestions/Viviano Domenici - A cena con i cannibali. Taccuino di un giornalista esploratore","language":"it","state":{"selected":true,"opened":true}},{"id":"830","text":"Alì Ehsani - Stanotte guardiamo le stelle","children":[],"path":"Reading suggestions/Alì Ehsani - Stanotte guardiamo le stelle","language":"it","state":{"selected":true,"opened":true}},{"id":"651","text":"Raymond Queneau - Fiori Blu","children":[],"path":"Reading suggestions/Raymond Queneau - Fiori Blu","language":"","state":{"selected":true,"opened":true}},{"id":"671","text":"Yambo (Enrico de’ Conti Novelli da Bertinoro) - L'allevatore di dinosauri ovvero L'uovo di pterodattilo","children":[],"path":"Reading suggestions/Yambo (Enrico de’ Conti Novelli da Bertinoro) - L'allevatore di dinosauri ovvero L'uovo di pterodattilo","language":"it","state":{"selected":true,"opened":true}}],"state":{"selected":true,"opened":true}},{"id":"692","text":"Prova geolocalizzazione con coordinate","children":[],"path":"Prova geolocalizzazione con coordinate","language":"","state":{"selected":true,"opened":true}},{"id":"774","text":"Form content created","children":[],"path":"Form content created","language":"en","state":{"selected":true,"opened":true}},{"id":"610","text":"Bibliotecaitaliana","children":[],"path":"Bibliotecaitaliana","language":"en","state":{"selected":true,"opened":true}},{"id":"828","text":"IDEA MAIN PAGE LUCA 1","children":[],"path":"IDEA MAIN PAGE LUCA 1","language":"en","state":{"selected":true,"opened":true}},{"id":"856","text":"How to use wikisource-proofread with pdf files","children":[],"path":"How to use wikisource-proofread with pdf files","language":"it","state":{"selected":true,"opened":true}},{"id":"_2","text":"Digital libraries","children":[{"id":"674","text":"Digital libraries","children":[],"path":"Digital libraries","language":"","state":{"selected":true,"opened":true}},{"id":"972","text":"OVL - Vatican Library","children":[],"path":"Digital libraries/OVL - Vatican Library","language":"en","state":{"selected":true,"opened":true}},{"id":"984","text":"World Digital Library","children":[],"path":"Digital libraries/World Digital Library","language":"en","state":{"selected":true,"opened":true}},{"id":"152","text":"Project Gutenberg","children":[],"path":"Digital libraries/Project Gutenberg","language":"en","state":{"selected":true,"opened":true}},{"id":"672","text":"Biblioteca Italiana","children":[],"path":"Digital libraries/Biblioteca Italiana","language":"en","state":{"selected":true,"opened":true}},{"id":"670","text":"Liber Liber","children":[],"path":"Digital libraries/Liber Liber","language":"en","state":{"selected":true,"opened":true}}],"state":{"selected":true,"opened":true}},{"id":"69","text":"Digital libraries (da catalogare)","children":[],"path":"Digital libraries (da catalogare)","language":"","state":{"selected":true,"opened":true}},{"id":"_3","text":"Opportunities","children":[{"id":"871","text":"Opportunities","children":[],"path":"Opportunities","language":"en","state":{"selected":true,"opened":true}},{"id":"829","text":"European Commission - Supporting the cultural and creative sectors in the ACP countries","children":[],"path":"Opportunities/European Commission - Supporting the cultural and creative sectors in the ACP countries","language":"en","state":{"selected":true,"opened":true}},{"id":"750","text":"General Secretariat of the Council - Traineeships at the General Secretariat of the Council","children":[],"path":"Opportunities/General Secretariat of the Council - Traineeships at the General Secretariat of the Council","language":"en","state":{"selected":true,"opened":true}},{"id":"751","text":"Language school \"Praticamente\" - Lavoro per un insegnante di inglese in Kazakistan per 3 mesi presso la Scuola di lingua Italiana “Praticamente”","children":[],"path":"Opportunities/Language school \"Praticamente\" - Lavoro per un insegnante di inglese in Kazakistan per 3 mesi presso la Scuola di lingua Italiana “Praticamente”","language":"en","state":{"selected":true,"opened":true}}],"state":{"selected":true,"opened":true}},{"id":"1001","text":"Feedback","children":[],"path":"Feedback","language":"en","state":{"selected":true,"opened":true}},{"id":"1021","text":"Sidebar LoggedIn","children":[],"path":"Sidebar LoggedIn","language":"en","state":{"selected":true,"opened":true}},{"id":"1022","text":"Sidebar SysOp","children":[],"path":"Sidebar SysOp","language":"en","state":{"selected":true,"opened":true}},{"id":"70","text":"Latest articles","children":[],"path":"Latest articles","language":"en","state":{"selected":true,"opened":true}},{"id":"525","text":"Instructions for use","children":[],"path":"Instructions for use","language":"en","state":{"selected":true,"opened":true}},{"id":"1051","text":"For administrators","children":[],"path":"For administrators","language":"en","state":{"selected":true,"opened":true}},{"id":"_4","text":"How it works","children":[{"id":"1042","text":"How it works","children":[],"path":"How it works","language":"en","state":{"selected":true,"opened":true}},{"id":"1043","text":"Introduction","children":[],"path":"How it works/Introduction","language":"en","state":{"selected":true,"opened":true}},{"id":"1049","text":"Banner","children":[],"path":"How it works/Banner","language":"en","state":{"selected":true,"opened":true}},{"id":"1058","text":"Private wiki","children":[],"path":"How it works/Private wiki","language":"en","state":{"selected":true,"opened":true}},{"id":"66","text":"Application form","children":[],"path":"How it works/Application form","language":"en","state":{"selected":true,"opened":true}},{"id":"1055","text":"Forms &amp; semantic data","children":[],"path":"How it works/Forms &amp; semantic data","language":"en","state":{"selected":true,"opened":true}},{"id":"1075","text":"Forms &amp; semantic data (naming convention)","children":[],"path":"How it works/Forms &amp; semantic data (naming convention)","language":"en","state":{"selected":true,"opened":true}},{"id":"68","text":"Join team","children":[],"path":"How it works/Join team","language":"en","state":{"selected":true,"opened":true}},{"id":"_5","text":"For administrators","children":[{"id":"1052","text":"For administrators","children":[],"path":"How it works/For administrators","language":"en","state":{"selected":true,"opened":true}},{"id":"1053","text":"Instructions for use","children":[],"path":"How it works/For administrators/Instructions for use","language":"en","state":{"selected":true,"opened":true}},{"id":"1069","text":"To-do","children":[],"path":"How it works/For administrators/To-do","language":"","state":{"selected":true,"opened":true}}],"language":"en","state":{"selected":true,"opened":true}},{"id":"1050","text":"Pages structure","children":[],"path":"How it works/Pages structure","language":"en","state":{"selected":true,"opened":true}},{"id":"1057","text":"Images upload &amp; gallery","children":[],"path":"How it works/Images upload &amp; gallery","language":"en","state":{"selected":true,"opened":true}},{"id":"1054","text":"Parser functions","children":[],"path":"How it works/Parser functions","language":"en","state":{"selected":true,"opened":true}},{"id":"1074","text":"Editing guidelines &amp; tips","children":[],"path":"How it works/Editing guidelines &amp; tips","language":"en","state":{"selected":false,"opened":true}},{"id":"1065","text":"Technology we use","children":[],"path":"How it works/Technology we use","language":"en","state":{"selected":true,"opened":true}},{"id":"1041","text":"APIs","children":[],"path":"How it works/APIs","language":"en","state":{"selected":true,"opened":true}},{"id":"1056","text":"Logically related questions","children":[],"path":"How it works/Logically related questions","language":"en","state":{"selected":true,"opened":true}}],"state":{"selected":true,"opened":true}},{"id":"64","text":"Organizations","children":[],"path":"Organizations","language":"en","state":{"selected":true,"opened":true}},{"id":"65","text":"Contacts","children":[],"path":"Contacts","language":"en","state":{"selected":true,"opened":true}},{"id":"1009","text":"To-do","children":[],"path":"To-do","language":"en","state":{"selected":true,"opened":true}},{"id":"717","text":"Mediawiki upload enhancement","children":[],"path":"Mediawiki upload enhancement","language":"en","state":{"selected":true,"opened":true}},{"id":"1","text":"Main Page","children":[],"path":"Main Page","language":"en","state":{"selected":true,"opened":true}}];
+
$ci(function() {
 +
 
 +
 
 +
var wiki_list = []
 +
 
 +
 
 +
function walk_through_TOC(children,parent,depth) {
 +
 
 +
if(!children || !Object.keys(children).length) {
 +
return
 +
}
  
  
$ci(function() {
+
depth++
 +
 
 +
 
 +
for(var value of children) {
 +
 
 +
// '&&' does not work !
 +
if(value.path) {
 +
 
 +
if(value.state.selected) {
 +
wiki_list.push('#'.repeat(depth) + '[[' + value.path + '|' + value.text + ']]')
 +
}
 +
 
 +
} else {
 +
 
 +
if(value.state.selected) {
 +
wiki_list.push('#'.repeat(depth) + value.text)
 +
}
 +
 
 +
}
 +
 
 +
 +
if(value.children) {
 +
walk_through_TOC(value.children,value,depth);
 +
}
 +
 +
}
 +
 
 +
 
 +
}
 +
 
 +
var contents = $ci('#TOC_contents').val();
 +
 
 +
contents = TOC_functions.base64_to_utf8(contents);
 +
 
 +
if(contents) {
 +
contents = JSON.parse(contents);
  
Frontend_Index.translate_index_rec(contents,'from');
+
TOC_functions.translate_TOC_rec(contents,'from');
  
  
var tree = $ci.ui.fancytree.createTree('#TOC_tree', {
+
var tree = $ci.ui.fancytree.createTree('#TOC_tree', {
extensions: ['edit', 'filter',"dnd5"],
+
extensions: ['edit', 'filter',"dnd5"],
checkbox: true,
+
checkbox: true,
source: contents,
+
source: contents,
checkbox: function(event, data) {
+
checkbox: function(event, data) {
// Hide checkboxes for folders
+
// Hide checkboxes for folders
return data.node.isFolder() ? false : true;
+
return data.node.isFolder()? false: true;
},
+
},
  dnd5: Frontend_Index.fancytree_dnd5_conf
+
  dnd5: TOC_functions.fancytree_dnd5_conf
});
+
});
 +
}
  
  
 
$ci('form').submit(function() {
 
$ci('form').submit(function() {
 +
 +
if(typeof tree == 'undefined') {
 +
return;
 +
}
 +
 +
var index_obj_saved = tree.toDict(true).children;
 +
 +
TOC_functions.translate_TOC_rec(index_obj_saved,'to');
 +
 +
// create wiki_list
 +
walk_through_TOC(index_obj_saved,null,0);
 +
 +
 +
index_obj_saved = TOC_functions.utf8_to_base64(JSON.stringify(index_obj_saved));
 +
 +
 +
$ci('#TOC_contents').val(index_obj_saved)
 +
var today = new Date();
 +
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
 +
var time = today.getHours() + ":" + (today.getMinutes() + '').padStart(2, '0') + ":" + (today.getSeconds() + '').padStart(2, '0');
 +
 +
 +
$ci('#pf_free_text').val(`<!--
 +
The content of this page has been created automatically on ` + date + ` at ` + time + `.
 +
Don't edit it without the form, since any additional content
 +
will be lost on the next automatic update!
 +
-->` + wiki_list.join("\n") + `
 +
 +
[[Category:TOCs]]`)
  
  
// ***attention !!!
 
// otherwise pageforms will not retrieve it!
 
$ci('input').removeAttr('disabled');
 
 
return true;
 
return true;
 +
 
});
 
});
  

Latest revision as of 22:35, 13 February 2021

Enter the target url of this set of pages, e.g.: https://culturaitaliana.org/organizations/Centro_italiano_Barcellona