Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
wordcount
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewnuk committed Jul 29, 2014
1 parent e79acb3 commit 1907114
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
13 changes: 13 additions & 0 deletions build/onion-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10807,6 +10807,19 @@ define('onion-editor',[
}));


// Word count

if (options.statsContainer) {
function wordcount() {
$(options.statsContainer).html(
$(scribe.el).text().split(' ').length
);
}
wordcount();
setInterval(wordcount, 3000);
}


/* This is necessary for a few dumb reasons. Scribe's transaction manager doesn't work when there
ins't a selection inside of the editor. This means any changes made when the editor ins't in focus,
like adding an image, stuff breaks. This works around that particular issue.
Expand Down
2 changes: 1 addition & 1 deletion build/onion-editor.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>

<body>
<div>WORDCOUNT <span class="wordcount"></span></div>
<div id="content-wrapper" class="container">
<div class="editor-wrapper">
<div class="editorPlaceholder" style="display: block;"></div>
Expand Down Expand Up @@ -137,14 +138,15 @@ <h4 class="modal-title">Embed something</h4>
text: "<p>WRITE HERE, COWBOY</p>",
container: document.getElementsByClassName('editorPlaceholder')[0]
},
statsContainer: ".wordcount",
link: {
domain: 'avclub.com',
searchHandler: function(term, resultsElement) {
resultsElement.html("<b>" + term + "</b><br><a href='/fart/'><i>Fart</i> Fart</a><br><a href='/butt/'><i>Fart</i> Butt</a><br><a href='/dumb/'><i>Fart</i> Dumb</a><br>");
}
}
});
editor.setChangeHandler(function() { console.log("REGISTERED A CHANGE UPSTREAM, BRO") });
editor.setChangeHandler(function() { });
editor.setContent($("#content").html());
</script>
</body>
Expand Down
12 changes: 12 additions & 0 deletions src/js/onion-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ define('onion-editor',[
}));


// Word count

if (options.statsContainer) {
function wordcount() {
$(options.statsContainer).html(
$(scribe.el).text().split(' ').length
);
}
setInterval(wordcount, 3000);
}


/* This is necessary for a few dumb reasons. Scribe's transaction manager doesn't work when there
ins't a selection inside of the editor. This means any changes made when the editor ins't in focus,
like adding an image, stuff breaks. This works around that particular issue.
Expand Down

0 comments on commit 1907114

Please sign in to comment.