<tr><td><ol start="<?php echo $i + 1; ?> "><li><a class="word-ref format-word-<?php echo $word->lang(); ?> " href="dictionary.php?id=<?php echo $word->id(); ?> "><?php echo $word->name(); ?> </ol></td><td style="border-spacing: 0px; padding: 0px;"><?php display_definitions($word); ?> </td><td style="border-spacing: 0px; padding: 0px;"><?php $infos = []; foreach ($word->read_attrs() as $attr) { $infos[] = format_attr($attr->tag(), $attr->value()); } echo implode(", ", $infos); ?> </td></tr><?php unset($ws[$i]); } ?> </table> <script> æ.format(); </script>
function display_word_info($w, $can_edit = FALSE) { $id = $w->id(); $lang = $w->lang(); $spart = $w->speechpart(); $common = false; $w->clear_connections(); $connections = $w->connections(); $w->read_paths(); $w->read_attrs(); display_lang($w); ?> <span class="word-name" id="word<?php echo $w->id(); ?> _name"><?php echo display_word_name($w, $common); ?> </span> <?php if ($common) { echo format_abbr("c.", "Common Gender") . " "; } elseif ($lang === "la" and $spart === "noun" and $genders = $w->path()->iterate("gender")) { foreach ($genders as $g) { echo format_abbr($g[0] . ".", capitalize($g)); } echo " "; } $infos = []; /* $stem = $w->path(); if ($stem->hasvalue()) $infos[] = format_word(str_replace("\n", ", ", $stem->get())); */ $infos[] = $spart; foreach ($w->read_attrs() as $attr) { if ($attr->tag()[0] != "-") { $infos[] = format_attr($attr->tag(), $attr->value()); } } ?> (<?php echo implode("; ", $infos); ?> )<?php if ($can_edit !== NULL and $can_edit) { $slug = slugify($w, $lang); $class = "word{$id}_toolbox"; ?> <?php display_icon("tools", "Tools", "word{$id}_tools", NULL, "hider hiding2"); ?> <script type="text/javascript"> $(function() { var id = <?php echo $id; ?> ; var state = -1; $('#word'+id+'_tools').on('mousedown', function(e) { if (state === -1) { $(this).removeClass('hiding2'); state = 0; } e.preventDefault(); return false; }).on('mouseup', function(e) { if (state === 0) state = 1; else if (state === 1) { $(this).addClass('hiding2'); state = -1; } e.preventDefault(); return false; }).on('click', function(e){e.preventDefault();return false;}); }); </script> <span class="<?php echo $class; ?> "> <?php display_icon("hardlink", "Link by ID", NULL, "dictionary.php?id={$id}"); ?> <?php display_icon("del", "Delete", "word{$id}_delete"); ?> <script type="text/javascript"> $(function() { var id = <?php echo $id; ?> ; $('#word'+id+'_delete').on("click", function() { dict.word_delete(id); }); }); </script> <?php display_icon("rename", "Rename", "word{$id}_rename"); ?> <script type="text/javascript"> $(function() { var id = <?php echo $id; ?> ; $('#word'+id+'_rename').on("mouseup.rename", function() { dict.word_rename(id, "<?php echo $w->name(); ?> "); }); }); </script> <?php display_icon("refresh", "Refresh", "word{$id}_refresh"); ?> <script type="text/javascript"> $(function() { var id = <?php echo $id; ?> ; $('#word'+id+'_refresh').on("mouseup.refresh", function() { dict.word_refresh(id); }); }); </script> <?php display_icon("change POS", "Change Part of Speech", "word{$id}_change_POS"); ?> <script type="text/javascript"> $(function() { var id = <?php echo $id; ?> ; $('#word'+id+'_change_POS').on('mouseup', function() { var pos = prompt('What part of speech?', '<?php echo $spart; ?> '); if (pos) dict.word_change_POS(id, pos); }); }); </script> </span> (size: <?php echo count($w->paths()); ?> ) <div class="<?php echo $class; ?> "> <a href="http://en.wiktionary.org/wiki/<?php echo $slug; ?> #<?php echo format_lang($w); ?> " target="_blank">Wiktionary</a> <?php if ($w->lang() === "la") { ?> – <a href="http://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:1999.04.0059:entry=<?php echo $slug; ?> " target="_blank">Lewis & Short</a> <?php } ?> <br> Pronunciation: <input id="word<?php echo $id; ?> _pronunciation_tool"> <span></span> </div> <script> $(function() { var transform = la_ipa.transforms["IPA transcription"]; $('#word<?php echo $id; ?> _pronunciation_tool').on('keyup', function() { var $this=$(this); $this.next().text(transform($this.val())); }); }); </script> <?php } $made_div = FALSE; $first = TRUE; $last_type = NULL; $using = []; $from = []; $sep = ""; foreach ($connections as $c) { if (!$made_div) { ?> <div class="word-more-info"><?php $made_div = TRUE; } if ($c->type() === "prefix") { $using[] = $c->to(); } elseif ($c->type() === "etymon") { $from[] = $c->to(); } } if ($from) { if (!$made_div) { ?> <div class="word-more-info"><?php $made_div = TRUE; } echo "From "; foreach ($using as $u) { word_link($u, $u->lang() === $w->lang()); echo " + "; } $sep = ""; foreach ($from as $u) { word_link($u, $u->lang() === $w->lang()); echo $sep; $sep = ", from "; } ?> <br><?php } if ($sep === ", from ") { ?> <br><?php } foreach ($w->pronunciations() as $pron) { if ((string) $pron->path()) { continue; } if (!$pron->value()) { continue; } if (!$made_div) { ?> <div class="word-more-info"><?php $made_div = TRUE; } if (!$first and $pron->type() === $last_type) { ?> ; <?php } else { if (!$first) { ?> <br><?php } echo $pron->type() . ": "; } $last_type = $pron->type(); if ($pron->sublang()) { ?> <sup>[<?php echo $pron->sublang(); ?> ]</sup><?php } ?> [<?php echo format_pron($pron->value()); ?> ]<?php $first = FALSE; } if ($made_div) { ?> </div><?php } if ($can_edit) { ?> <div> <input id="word<?php echo $id; ?> _value_attr" type="text" placeholder="[!]attr[=value]; ..." required> <button id="word<?php echo $id; ?> _button_enter_attr" onclick="dict.word_add_attr(<?php echo $id; ?> )">Add</button> <button id="word<?php echo $id; ?> _button_clear_attr" onclick="$('#word<?php echo $id; ?> _value_attr').val('')">Clear</button> </div> <script type="text/javascript"> $(function() { var id = <?php echo $id; ?> ; $('#word'+id+'_value_attr').keypress(function(e){if (e.which == 13)dict.word_add_attr(<?php echo $id; ?> )}); var lock=false; var splitter = /,\s*/; var last1 = $('#enter-names').val().split(splitter); var last2 = $('#enter-attrs').val().split(splitter); function getcheckbox(name) { var ret=[]; $('input:checkbox[name="'+name+'"]:checked:visible').each(function() { ret.push($(this).val()); }); return ret.join(); } $('#word'+id+'_value_attr').autocomplete(autocompletions['word-attributes'](id,'<?php echo $lang; ?> ','<?php echo $spart; ?> ')); }); </script> <?php } }