1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| function get_post_view($archive) { $cid = $archive->cid; $db = Typecho_Db::get(); $prefix = $db->getPrefix(); if (!array_key_exists('views', $db->fetchRow($db->select()->from('table.contents')))) { $db->query('ALTER TABLE `' . $prefix . 'contents` ADD `views` INT(10) DEFAULT 0;'); echo 0; return; } $row = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $cid)); if ($archive->is('single')) { $db->query($db->update('table.contents')->rows(array('views' => (int) $row['views'] + 1))->where('cid = ?', $cid)); } echo $row['views']; }
Typecho_Plugin::factory('admin/write-post.php')->bottom = array('myyodu', 'one'); Typecho_Plugin::factory('admin/write-page.php')->bottom = array('myyodu', 'one'); class myyodu { public static function one() { ?> <style> .field.is-grouped{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start; -ms-flex-wrap: wrap;flex-wrap: wrap;}.field.is-grouped>.control{-ms-flex-negative:0;flex-shrink:0}.field.is-grouped>.control:not(:last-child){margin-bottom:.5rem;margin-right:.75rem}.field.is-grouped>.control.is-expanded{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-negative:1;flex-shrink:1}.field.is-grouped.is-grouped-centered{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.field.is-grouped.is-grouped-right{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}.field.is-grouped.is-grouped-multiline{-ms-flex-wrap:wrap;flex-wrap:wrap}.field.is-grouped.is-grouped-multiline>.control:last-child,.field.is-grouped.is-grouped-multiline>.control:not(:last-child){margin-bottom:.75rem}.field.is-grouped.is-grouped-multiline:last-child{margin-bottom:-.75rem}.field.is-grouped.is-grouped-multiline:not(:last-child){margin-bottom:0}.tags{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.tags .tag{margin-bottom:.5rem}.tags .tag:not(:last-child){margin-right:.5rem}.tags:last-child{margin-bottom:-.5rem}.tags:not(:last-child){margin-bottom:1rem}.tags.has-addons .tag{margin-right:0}.tags.has-addons .tag:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.tags.has-addons .tag:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.tag{-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color: </style> <script language="javascript"> var EventUtil = function() {}; EventUtil.addEventHandler = function(obj, EventType, Handler) { if (obj.addEventListener) { obj.addEventListener(EventType, Handler, false); } else if (obj.attachEvent) { obj.attachEvent('on' + EventType, Handler); } else { obj['on' + EventType] = Handler; } } if (document.getElementById("text")) { EventUtil.addEventHandler(document.getElementById('text'), 'propertychange', CountChineseCharacters); EventUtil.addEventHandler(document.getElementById('text'), 'input', CountChineseCharacters); } function showit(Word) { alert(Word); } function CountChineseCharacters() { Words = document.getElementById('text').value; var W = new Object(); var Result = new Array(); var iNumwords = 0; var sNumwords = 0; var sTotal = 0; var iTotal = 0; var eTotal = 0; var otherTotal = 0; var bTotal = 0; var inum = 0; var znum = 0; var gl = 0; var paichu = 0; for (i = 0; i < Words.length; i++) { var c = Words.charAt(i); if (c.match(/[\u4e00-\u9fa5]/) || c.match(/[\u0800-\u4e00]/) || c.match(/[\uac00-\ud7ff]/)) { if (isNaN(W[c])) { iNumwords++; W[c] = 1; } iTotal++; } } for (i = 0; i < Words.length; i++) { var c = Words.charAt(i); if (c.match(/[^\x00-\xff]/)) { if (isNaN(W[c])) { sNumwords++; } sTotal++; } else { eTotal++; } if (c.match(/[0-9]/)) { inum++; } if (c.match(/[a-zA-Z]/)) { znum++; } if (c.match(/[\s]/)) { gl++; } if (c.match(/[ ◕‿↑↓←→↖↗↘↙↔↕。《》、【】“”•‘’❝❞′……—―‐〈〉„╗╚┐└‖〃「」‹›『』〖〗〔〕∶〝〞″≌∽≦≧≒≠≤≥㏒≡≈✓✔◐◑◐◑✕✖★☆₸₹€₴₰₤₳र₨₲₪₵₣₱฿₡₮₭₩₢₧₥₫₦₠₯○㏄㎏㎎㏎㎞㎜㎝㏕㎡‰〒々℃℉ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦㄧㄨㄩ]/)) { paichu++; } } document.getElementById('hanzi').innerText = iTotal - paichu; document.getElementById('zishu').innerText = inum + iTotal - paichu; document.getElementById('biaodian').innerText = sTotal - iTotal + eTotal - inum - znum - gl + paichu; document.getElementById('zimu').innerText = znum; document.getElementById('shuzi').innerText = inum; document.getElementById("zifu").innerHTML = iTotal * 2 + (sTotal - iTotal) * 2 + eTotal; } </script> <script> $(document).ready(function(){ $("#wmd-editarea").append('<div class="field is-grouped"><span class="tag">共计:</span><div class="control"><div class="tags has-addons"><span class="tag is-dark" id="zishu">0</span> <span class="tag is-primary">个字数</span></div></div><div class="control"><div class="tags has-addons"><span class="tag is-dark" id="zifu">0</span> <span class="tag is-primary">个字符</span></div></div><span class="tag">包含:</span><div class="control"><div class="tags has-addons"><span class="tag is-light" id="hanzi">0</span> <span class="tag is-danger">个文字</span></div></div><div class="control"><div class="tags has-addons"><span class="tag is-light" id="biaodian">0</span> <span class="tag is-info">个符号</span></div></div><div class="control"><div class="tags has-addons"><span class="tag is-light" id="zimu">0</span> <span class="tag is-success">个字母</span></div></div><div class="control"><div class="tags has-addons"><span class="tag is-light" id="shuzi">0</span> <span class="tag is-warning">个数字</span></div></div></div>'); CountChineseCharacters(); }); </script> <?php } }
|