-
-
Save gialloporpora/13101 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.CreateCommand({ | |
name: "about-selection", | |
takes: {"url": noun_arb_text}, | |
icon: "http://digg.com/favicon.ico", | |
homepage: "http://www.gialloporpora.netsons.org", | |
author: { name: "Sandro Della Giustina", email: "[email protected]"}, | |
license: "MPL,GPL", | |
description: "Show information about your text selection", | |
help: "Select a text and launch this command to view the number of selected words and characters.", | |
_aboutsel: function(text){ | |
var no_sel_msg="You must select a text to use this command."; | |
var html=''; | |
if (text.length>0) { | |
html+='<ul>'; | |
html+='<li>You have selected <b>'+text.length+'</b> characters. </li>'; | |
html+='<li>You have selected <b>'+text.match(/\b\w+\b/g).length+'</b> words.</li>'; | |
html+='</ul>'; | |
} | |
else html+=no_sel_msg; | |
return html; | |
}, | |
preview: function( previewBlock, directObject){ | |
var html=this._aboutsel(directObject.text); | |
previewBlock.innerHTML=CmdUtils.renderTemplate(html); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment