Poll Javascript

Embed

<html>
    <head>
        <title>Wikidot Embed Poll</title>
    </head>
    <body>
        <script type="text/javascript">
            var url_params = /^#([^#]*)(#.*)?$/;
            var dom_params = /^(.*)\.wdfiles\.com/;
 
            var match = url_params.exec(unescape(window.location.hash)); // #'s may be escaped (they may be written as %23 instead of #)
            var domain = dom_params.exec(window.location.host)[1];
 
            if (match) {
                document.write('<iframe src="http://' + domain + '.wikidot.com/' + match[1] + '?theme_url=/local--code/poll:_css" scrolling="no" frameborder="0" style="width: 100%; height: 100%;"></iframe>');
            }
            else {
                document.write('<i>Invalid URL syntax</i>');
            }
        </script>
        <noscript>
            <i>Your Javascript has been disabled. This poll requires Javascript to function.</i>
        </noscript>
    </body>
</html>

Poll

<html>
    <head>
        <title>Wikidot Poll</title>
        <style type="text/css">
            @import url("http://www.wikidot.com/common--theme/base/css/style.css");
            @import url("http://polls.wdfiles.com/local--code/poll:_css/2");
        </style>
    </head>
    <body class="poll">
        <script type="text/javascript">
            var newCSS = document.createElement('link');
            newCSS.rel = 'stylesheet';
 
            document.getElementsByTagName("head")[0].appendChild(newCSS);
            var css_params = /^#([^#]*)(#.*)$/;
            var css = css_params.exec(unescape(parent.parent.location.hash));
 
            if (css) {
                newCSS.href = 'data:text/css,' + '@import url("' + css[2].substring(1) + '");';
            }
 
            document.getElementsByTagName("head")[0].appendChild(newCSS);
        </script>
 
        <script type="text/javascript">
        var url_params = /^#([^#]*)((##[^#]*#[^#]*)*)$/;    // (...#)Poll Question (## Poll Option Page # Poll Option)
        var dom_params = /^(.*)\.wdfiles\.com/;
 
        var match = url_params.exec(unescape(window.location.hash));    // #'s may be escaped (they may be written as %23 instead of #)
        var domain = dom_params.exec(window.location.host)[1];
        if (match) {
            var title_array = new Array();
            var page_array = new Array();
            var tmp_count = 0;
 
            match[2] = match[2] + '#';
 
            while (0<=match[2].search(/##/)) {
            page_array[tmp_count] = match[2].substring(2,match[2].search(/[^#]#[^#]/)+1);
            match[2] = match[2].substring(match[2].search(/[^#]#[^#]/)+2);
            title_array[tmp_count] = match[2].substring(0,match[2].search(/[^#]#/)+1);
            match[2] = match[2].substring(match[2].search(/[^#]#/)+1);
            tmp_count = tmp_count+1;
            }
 
            document.write('<span class="question">' + match[1] + '</span><table>');
            for (tmp_count=0;tmp_count<=page_array.length-1;tmp_count++) {
                document.write('<tr><td class="index">'+ (tmp_count+1) +')</td><td class="option">' + title_array[tmp_count] + '</td><td class="votes">' + '<iframe src="http://' + domain + '.wikidot.com/' + page_array[tmp_count] + '/noredirect/true?theme_url=/local--code/poll:_css" frameborder="0" scrolling="no"></iframe></td></tr>');
            }
            document.write('</table><span class="footer">Poll powered by <a href="http://www.wikidot.com" target="_top"><img src="http://www.wikidot.com/common--images/navibar/logo20.png" alt="Wikidot.com" /></a> <a href="http://polls.wikidot.com/" target="_top">Create yours now!</a></span>');
        }
        else
            document.write('<i>Invalid URL syntax</i>');
        </script>
        <noscript>
            <i>Your Javascript has been disabled. This poll requires Javascript to function.</i>
        </noscript>
    </body>
</html>

Closed Poll

<html>
    <head>
        <title>Wikidot Poll</title>
        <style type="text/css">
            @import url("http://www.wikidot.com/common--theme/base/css/style.css");
            @import url("http://polls.wdfiles.com/local--code/poll:_css/2");
        </style>
    </head>
    <body class="poll">
        <script type="text/javascript">
            var newCSS = document.createElement('link');
            newCSS.rel = 'stylesheet';
 
            document.getElementsByTagName("head")[0].appendChild(newCSS);
            var css_params = /^#([^#]*)(#.*)$/;
            var css = css_params.exec(unescape(parent.parent.location.hash));
 
            if (css) {
                newCSS.href = 'data:text/css,' + '@import url("' + css[2].substring(1) + '");';
            }
 
            document.getElementsByTagName("head")[0].appendChild(newCSS);
        </script>
 
        <script type="text/javascript">
        var url_params = /^#([^#]*)((##[^#]*#[^#]*)*)$/;    // (...#)Poll Question (## Poll Rating # Poll Option)
        var dom_params = /^(.*)\.wdfiles\.com/;
 
        var match = url_params.exec(unescape(window.location.hash));    // #'s may be escaped (they may be written as %23 instead of #)
        var domain = dom_params.exec(window.location.host)[1];
        if (match) {
            var title_array = new Array();
            var page_array = new Array();
            var tmp_count = 0;
 
            match[2] = match[2] + '#';
 
            while (0<=match[2].search(/##/)) {
            page_array[tmp_count] = match[2].substring(2,match[2].search(/[^#]#[^#]/)+1);
            match[2] = match[2].substring(match[2].search(/[^#]#[^#]/)+2);
            title_array[tmp_count] = match[2].substring(0,match[2].search(/[^#]#/)+1);
            match[2] = match[2].substring(match[2].search(/[^#]#/)+1);
            tmp_count = tmp_count+1;
            }
 
            document.write('<span class="question">' + match[1] + '</span><table>');
            for (tmp_count=0;tmp_count<=page_array.length-1;tmp_count++) {
                document.write('<tr><td class="index">'+ (tmp_count+1) +')</td><td class="option">' + title_array[tmp_count] + '</td><td class="votes"><span>Votes: </span>' + page_array[tmp_count] + '</td></tr>');
            }
            document.write('</table><span class="footer">Poll powered by <a href="http://www.wikidot.com" target="_top"><img src="http://www.wikidot.com/common--images/navibar/logo20.png" alt="Wikidot.com" /></a> <a href="http://polls.wikidot.com/" target="_top">Create yours now!</a></span>');
        }
        else
            document.write('<i>Invalid URL syntax</i>');
        </script>
        <noscript>
            <i>Your Javascript has been disabled. This poll requires Javascript to function.</i>
        </noscript>
    </body>
</html>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License