Cross Sticker

By diego.devita Last update Jul 31, 2008 — Installed 107 times.

Archived Comments (locked)

in
Subscribe to Archived Comments 7 posts, 3 voices



Jesse Andrews Admin

The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)

 
diego.devita Script's Author

I added another script instead of updating this with new features.
I decided to start a new branch due to added complexity. the other one, custom sticker, allows you to decide what and when to stick notes. You have to press a key while clicking the mouse so you don't get annoyed with red cross along the page while clicking for other reasons, plus the char displayed is the pressed key.

 
diego.devita Script's Author

ok, I'm following your suggestion
actually the name of the script is cross-sticker so the sticky shouldn't be custom at all!

anyway I'm going to add the possibility to choose the wanted character to stick pressing it on the keyboard while clicking with the mouse.

thanks

 
JoeSimmons Scriptwright

because innerHTML is a slow access way

 
diego.devita Script's Author

just to say, now I applied my intended fix I failed this morning. It works nice even where it didn't before. I use the style attribute instead of accessing the top and left properties using dom.

for the next versions I'm going to:
- add a special key to actually stick the cross
- eventually clear the notes
- maybe save the annotations in some way
- shift the coordinates in a way the mouse cursor stays on the middle
- use the greasemonkey custom field to edit easily some vars like the sticky content

 
diego.devita Script's Author

yes you're right...I forgot something and the code was not correct. I did a correction this morning because I noticed it didn't work in some situations. the correction didn't work and I was busy to fix it again. For now I'm going to restore the first version.

anyway, I decided to use the innerHtml because it was easier to modify the div content for the user. I wanted the div to be a general container for a customized sticky. And so I put my default content on top in a var used to fill the innerHtml. It did work in most of the cases, but I couldn't understand why in some special circumstances the div didn't get positioned at the right coordinates.

why do you think I shouldn't use the innerHtml?

 
JoeSimmons Scriptwright

Cool but you really shouldn't use innerHTML. You should do it like this... (also you forgot a ); after the second setAttribute command)

function newSticky(x,y) {
var name = 'sticky'+getRnd();
var newdiv = document.createElement('div');
var span = document.createElement('span');
newdiv.setAttribute('id', name);
newdiv.setAttribute('style', 'position: absolute; left: ' + x + 'pt; top: ' + y + 'pt;');
newdiv.setAttribute('style', 'color:red; font-weight:bold;');
newdiv.appendChild(document.createTextNode('X'));
span.appendChild(newdiv);
document.getElementsByTagName('body')[0].appendChild(span);
}

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel