Spoilers for the Interim

15 posts
User avatar
Gender Male
Points 1115
Reviews 83
It took oo-gobs of effort to get this right, so humor me and go see my submitted "work" detailing how this is possible (and showing an example):

Testing a new Spoiler method..

If you like it, use it! But be careful. Only copy exactly. Otherwise you can make the site do silly things on your submission. If you have problems and get in over your head, PM me.

It's not magic; it's Javascript!

Be forever hortatory,

~Skorlir




User avatar
Gender Female
Points 26101
Reviews 1335
I have never used a spoiler in a literary work, but I hear the spoiler-loving people shout with joy at your discovery, Skor. Thanks!
you can message me with anything: questions, review requests, rants
are you a green room knight yet?
have you read this week's Squills?




User avatar
Gender Male
Points 11152
Reviews 303
WE CAN USE JAVASCRIPT ON YWS!

*facepalms.

>>

Thanks -_-
For I who am poor have only my dreams
I spread my dreams under your feet . . .

. . . tread softly for you tread on my dreams.


We are masters of our silences, and slaves of our words




User avatar
Gender None specified
Points 8890
Reviews 191
We can use javascript on yws?

*rubs palms dangerously*
_




User avatar
Gender Male
Points 1115
Reviews 83
@carbonCore :

Don't do anything too dangerous. I would hate for Nate to blame me for revealing this! ;)

In other news, you can just type "javascript:" followed by whatever you want to run in the address bar, and it will run immediately (you can then save the "scriptlet" as a bookmark, thus creating a "bookmarket" ;) ).




User avatar
Gender None specified
Points 8890
Reviews 191
Oh yes, I know about the javascript: trick, it's one way of activating javascript from html, by setting the href of a link to javascript:foo(); or whatever, with the other one being an onclick event.

I'm not quite a javascript hax0r yet, but I did want to make a system which would simulate flipping pages -- something like consecutive spoilers on one story. I noticed that people get turned off when they are greeted by a wall of text, and that list-based websites are usually the more successful ones (i.e. cracked.com). This leads me to believe that humans prefer their information broken up into sizeable, swallowable chunks. So the next time I post a longer story, I'll break it up using something like that.
_




User avatar
Gender Male
Points 1115
Reviews 83
If you work out something genius, let me know! :)
And feel free to borrow my spoiler code if it might be of use to you in any way.

Oh hey! And with the whole page-turning thing: check out CSS transitions (if you haven't already) to see if you can simulate something with zing. :D




User avatar
Gender Female
Points 5533
Reviews 696




User avatar
Gender Male
Points 11542
Reviews 426
Sorry all, but allowing javascript is actually a bug, and it's dangerous to allow. I have to remove it.




User avatar
Gender Male
Points 11152
Reviews 303
ja, understandable.
For I who am poor have only my dreams
I spread my dreams under your feet . . .

. . . tread softly for you tread on my dreams.


We are masters of our silences, and slaves of our words




User avatar
Gender Male
Points 1115
Reviews 83
Nate wrote:Sorry all, but allowing javascript is actually a bug, and it's dangerous to allow. I have to remove it.


I wondered if that might happen, but at least it was discovered innocuously, in the spirit of friendship and problem-solving! Anyway.

I'm unsure how you can actually disallow it within the editor, since the functionality is pretty much built-in, but maybe you can just screen for DOM attributes and disable them server-side?




User avatar
Gender Male
Points 11542
Reviews 426
Yep, ended up using DOM to remove the attributes. It's somewhat similar to this:

Code
        $dom = new DOMDocument;
   $dom->loadHTML($html);
   $xpath = new DOMXPath($dom);

   $nodes = $xpath->query('//@onmouseover');

        foreach ($nodes as $node) {
       $node->parentNode->removeAttribute($node->nodeName);
        }
   
   echo $dom->saveHTML();


The best method would be to simply disable all onevent attributes in the editor itself. But that's more difficult to do, and would likely cause tremendous speed issues.

Another method is to use regex, but I try to avoid regex when possible.




User avatar
Gender Male
Points 1115
Reviews 83
Well, now I guess I get to feel all exclusive, because my spoiler got posted before the edits. I'll be the only one! (At least until the feature possibly gets worked back in.)




User avatar
Gender Male
Points 1115
Reviews 83
@Nate

I don't know if this is related to the recent edit (it seems to coincide), but all my punctuation has broken upon editing a work...

All is Well, Perforce.




User avatar
Gender Male
Points 11542
Reviews 426
Looks like a UTF-8 encoding issue @skorlir. Can you send me the original document at nate@youngwriterssociety.com? In the meantime, I'll go ahead and clean it up.



Believe that life is worth living and your belief will help create the fact.
— William James