Changeset 1494045
- Timestamp:
- 09/11/2016 12:27:13 PM (9 years ago)
- Location:
- russian-texts-proofreader-glvrd/tags/1.2.2
- Files:
-
- 1 added
- 3 edited
-
css/glvrd.css (modified) (2 diffs)
-
images/loader.gif (added)
-
js/glvrd-plugin.js (modified) (13 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
russian-texts-proofreader-glvrd/tags/1.2.2/css/glvrd.css
r1336247 r1494045 37 37 font-size: .8em; 38 38 line-height: 1.4em; 39 height: 2.3em; 39 40 overflow: hidden; 40 41 } … … 74 75 } 75 76 77 #glvrd_section .stats-score.green { 78 color: #077213; 79 } 80 81 #glvrd_section .stats-score.orange { 82 color: #da570f; 83 } 84 85 #glvrd_section .stats-score.red { 86 color: #bb0002; 87 } 88 76 89 #glvrd_section .stats .stats-sections { 77 90 margin-right: -1em; -
russian-texts-proofreader-glvrd/tags/1.2.2/js/glvrd-plugin.js
r1336247 r1494045 1 1 (function () { 2 2 3 tinymce.create('tinymce.plugins.glvrd', { 3 4 … … 6 7 hoverHintCls : 'glvrd-underline-hover', 7 8 9 myUrl : undefined, 8 10 isFirstLaunch : true, 9 11 delayedProofread : undefined, … … 19 21 init : function (ed, url) { 20 22 var me = this; 23 24 me.url = url; 21 25 22 26 ed.addButton('glvrd', { … … 46 50 jQuery(ed.getDoc()).find('.' + me.activeHintCls).toggleClass(me.activeHintCls).toggleClass(me.hintCls); 47 51 me.showTooltip(ed, html, target); 48 49 52 }); 50 53 }); … … 63 66 ed.on('SaveContent', function (e) { 64 67 e.content = me.removeMarkup(e.content); 68 }); 69 70 ed.on('change', function (e) { 71 me.hideTooltip(); 65 72 }); 66 73 … … 92 99 var me = this, 93 100 content = me.removeMarkup(editor.getContent({format : 'raw'})), 94 strippedContent = editor.getContent({format : 'text'}) 101 strippedContent = editor.getContent({format : 'text'}), 102 textInAttributes = me.getHtmlAttributes(content); 103 104 jQuery('#glvrd_section .stats .stats-score').removeClass('green orange red') 105 .html('<img src="' + me.url + '/../images/loader.gif" width="30"/>'); 95 106 96 107 window.glvrd.proofread(content, function (result) { 97 98 108 if (result.status = 'ok') { 99 109 if (strippedContent !== this.getContent({format: 'text'})) { … … 104 114 105 115 jQuery('#glvrd_section .info').hide('fast').remove(); 106 $statsBlock.find('.stats-score'). text(result.score);116 $statsBlock.find('.stats-score').addClass(me.getScoreColor(result.score)).text(result.score); 107 117 $statsBlock.find('.stats-stopwords').text(sprintf(me.pluralize(result.fragments.length, '%d стоп-слов', '%d стоп-слово', '%d стоп-слова'), result.fragments.length)); 108 118 … … 112 122 var wordQuantity = me.countWords(strippedContent); 113 123 $statsBlock.find('.stats-words').text(sprintf(me.pluralize(wordQuantity, '%d слов', '%d слово', '%d слово'), wordQuantity)); 114 var charQuantity = me.countChars(strippedContent, true); 115 var charQuantityWithoutSpaces = me.countChars(strippedContent, false); 116 $statsBlock.find('.stats-chars').text( 117 sprintf(me.pluralize(charQuantity, '%d знаков', '%d знак', '%d знака'), charQuantity) + 118 ' (' + charQuantityWithoutSpaces + ' без пробелов) ' 119 ); 124 var charQuantity = me.countChars(strippedContent); 125 $statsBlock.find('.stats-chars').text(sprintf(me.pluralize(charQuantity, '%d знаков', '%d знак', '%d знака'), charQuantity)); 120 126 121 127 if (result.fragments.length) { … … 127 133 var tagOpen = '<span class="glvrd-underline" data-glvrd="true" data-description="' + fragment.hint.description + '" data-name="' + fragment.hint.name + '" >', 128 134 tagClose = '</span>', 129 tagsLength = tagOpen.length + tagClose.length; 135 tagsLength = tagOpen.length + tagClose.length, 136 skip = textInAttributes.some(function(attributeContent) { 137 return attributeContent.start <=fragment.start && fragment.end <= attributeContent.end; 138 }); 139 140 if (skip) { 141 return; 142 } 130 143 131 144 content = content.substring(0, fragment.start + offset) … … 177 190 }, 178 191 192 hideTooltip: function() { 193 var me = this; 194 195 if (me.tooltip) { 196 me.tooltip.hide(); 197 } 198 }, 199 179 200 countSentences : function (text) { 180 201 if (text.length === 0) { … … 183 204 184 205 var sentencesQuantity = text.match(/[^\s](\.|…|\!|\?)(?!\w)(?!\.\.)/g).length; 185 if (! /(\.|…|\!|\?)/g.test(text.slice(-1))) {206 if (!(/(\.|…|\!|\?)/g).test(text.slice(-1))) { 186 207 sentencesQuantity++; 187 208 } … … 197 218 }, 198 219 199 countChars : function (text , countSpaces) {220 countChars : function (text) { 200 221 if (text.length === 0) { 201 222 return 0; 202 223 } 203 224 204 var regexp = countSpaces ? /[^А-Яа-яA-Za-z0-9-\s.,:()-]+/g : /[^А-Яа-яA-Za-z0-9-.,:()-]+/g; 205 return text.replace(regexp, "").length; 225 return text.replace(/[^А-Яа-яA-Za-z0-9-\s.,()-]+/g, "").length; 206 226 }, 207 227 … … 227 247 return zeroWord; 228 248 } 249 }, 250 251 getHtmlAttributes: function(content) { 252 var regexp = /\w+=\s*["|']([\sА-Яа-яё,.!?]+)["|']/g, 253 chunks = [], 254 attribute, attributeContent, globalStartPos, globalEndPos; 255 256 while ((result = regexp.exec(content))!== null) { 257 attribute = result[0]; 258 attributeContent = result[1]; 259 globalStartPos = result.index; 260 261 if (attributeContent.length > 0) { 262 globalStartPos += attribute.indexOf(attributeContent); 263 globalEndPos = globalStartPos + attributeContent.length; 264 chunks.push({ 265 text: attributeContent, 266 start: globalStartPos, 267 end: globalEndPos 268 }); 269 } 270 } 271 272 return chunks; 273 }, 274 275 getScoreColor: function(score) { 276 if (score < 5) { 277 return 'red'; 278 } 279 280 if (score < 7.5) { 281 return 'orange'; 282 } 283 284 return 'green'; 229 285 }, 230 286 -
russian-texts-proofreader-glvrd/tags/1.2.2/readme.txt
r1336247 r1494045 4 4 Donate link: https://paypal.me/NLopin 5 5 Requires at least: 4.2 6 Tested up to: 4. 46 Tested up to: 4.5 7 7 Stable tag: 1.2.2 8 8 License: GPLv2 or later … … 58 58 == Changelog == 59 59 = 1.2.2 = 60 * Добавлен счетчик знаков без пробелов 60 * Главред больше не ломает HTML разметку в тех случаях, когда внутри тегов есть текст на русском языке 61 * Цветные метки у оценок 61 62 62 63 = 1.2.1 =
Note: See TracChangeset
for help on using the changeset viewer.