Created Plugins (textile)
parent
eda76bb262
commit
0f9df953fc
1 changed files with 50 additions and 0 deletions
50
Plugins.textile
Normal file
50
Plugins.textile
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
This is a example plugin to get you started. It removes posts which contain one of the stopwords. Save the code in a file @~/Library/Application Support/Tentia/Plugin.js@. You have to create this directory yourself.
|
||||
|
||||
``` js
|
||||
$(document).ready(function() {
|
||||
if(tentia_instance.action == "timeline") {
|
||||
tentia_instance.body.addEventListener( 'DOMNodeInserted', filter, false );
|
||||
}
|
||||
});
|
||||
function filter(e) {
|
||||
var stopwords = [
|
||||
// Add the stopwords here
|
||||
"apple",
|
||||
"#iPhone"
|
||||
];
|
||||
var element = e.target;
|
||||
var parent = element.parentNode;
|
||||
if(parent != tentia_instance.body) return;
|
||||
var text = element.innerHTML;
|
||||
for(var i=0, count=stopwords.length; i<count; ++i) {
|
||||
if(text.indexOf(stopwords[i]) > -1) {
|
||||
parent.removeChild(element);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can use the embeded jQuery:
|
||||
|
||||
``` js
|
||||
$("ol").delegate('a', 'click', function(e) {
|
||||
e.stopPropagation();
|
||||
}).delegate('li', 'click', function(e) {
|
||||
debug(e.currentTarget.tagName)
|
||||
var li = $(this);
|
||||
if(li.hasClass("selected")) {
|
||||
$(this).removeClass("selected");
|
||||
} else {
|
||||
$(this).addClass("selected");
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
And you can add CSS too, create the file @~/Library/Application Support/Tentia/Plugin.css@ where you can put your personal CSS:
|
||||
|
||||
``` css
|
||||
.selected {
|
||||
border-right: 5px solid green;
|
||||
}
|
||||
```
|
||||
Reference in a new issue