JavaScript-Writer

 view release on metacpan or  search on metacpan

doc/slides/yapcasia2008.xul  view on Meta::CPAN

                                        oncommand="Presentation.showPage(parseInt(event.target.getAttribute('curpos')));"
                                        onclick="Presentation.showPage(parseInt(event.target.getAttribute('curpos')));"
                                        onmousedown="Presentation.onScrollerDragStart();"
                                        onmousemove="Presentation.onScrollerDragMove();"
                                        onmouseup="Presentation.onScrollerDragDrop();"/>
                                <spacer flex="1"/>
                        </vbox>
                        <toolbarseparator/>
                        <toolbarbutton label="Pen"
                                id="penButton"
                                type="checkbox"
                                autoCheck="false"
                                oncommand="StrokablePresentationService.toggleCheck();"/>
                        <spacer flex="1"/>
                        <toolbarbutton id="func-menu-button"
                                type="menu"
                                label="Function">
                                <menupopup
                                        onpopupshowing="Presentation.preventToShowHideToolbar = true;"
                                        onpopuphiding="Presentation.preventToShowHideToolbar = false;">
                                        <menuitem label="Set Timer"
                                                oncommand="Presentation.setTimer();" />
                                        <menuseparator/>
                                        <menuitem label="Start Auto-Cruise"
                                                id="autoButton"
                                                type="checkbox"
                                                autoCheck="false"
                                                oncommand="Presentation.toggleAutoCruiseMode();" />
                                        <menu id="auto-interval-button"
                                                label="Change Interval">
                                                <menupopup id="auto-interval-list"
                                                        onpopupshowing="(this.getElementsByAttribute('value', Presentation.autoCruiseInterval)[0] || this.lastChild).setAttribute('checked', true);"
                                                        oncommand="Presentation.changeAutoCruiseInterval(parseInt(event.target.value));">
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="1 sec" value="1000"/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="2 sec" value="2000"/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="3 sec" value="3000"/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="4 sec" value="4000"/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="5 sec" value="5000"/>
                                                        <menuseparator/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="1 min" value="60000"/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="2 min" value="120000"/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="3 min" value="180000"/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="4 min" value="240000"/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="5 min" value="300000"/>
                                                        <menuseparator/>
                                                        <menuitem type="radio" radiogroup="autocruise-interval"
                                                                label="Custom"
                                                                oncommand="
                                                                        var current = Presentation.autoCruiseInterval;
                                                                        var val = parseInt(prompt('input interval (sec)', parseInt(current/1000)));
                                                                        if (isNaN(val)) {
                                                                                event.preventBubble();
                                                                                return;
                                                                        }
                                                                        else
                                                                                val = val * 1000;
                                                                        this.value = val;
                                                                "/>
                                                </menupopup>
                                        </menu>
                                        <menuseparator/>
                                        <menuitem oncommand="Presentation.print();" label="Print"/>
                                        <menu id="auto-interval-button"
                                                label="Thumbnail Format">
                                                <menupopup
                                                        onpopupshowing="(this.getElementsByAttribute('value', Presentation.imageType)[0] || this.firstChild).setAttribute('checked', true);"
                                                        oncommand="Presentation.imageType = event.target.value;">
                                                        <menuitem type="radio" radiogroup="print-image-type"
                                                                label="PNG" value="png"/>
                                                        <menuitem type="radio" radiogroup="print-image-type"
                                                                label="JPEG (50%)" value="jpeg"/>
                                                </menupopup>
                                        </menu>
                                        <menuseparator/>
                                        <menuitem id="toggleEva" label="Eva Mode"
                                                type="checkbox"
                                                autoCheck="false"
                                                oncommand="Presentation.toggleEvaMode();"/>
                                </menupopup>
                        </toolbarbutton>
                        <toolbarseparator/>
                        <toolbarbutton label="Edit"
                                oncommand="Presentation.toggleEditMode();"/>
                        <toolbarbutton oncommand="Presentation.reload();" label="Reload"/>
                </toolbar>
        </toolbox>
        <vbox flex="1" id="canvas">
                <stack flex="1">
                        <vbox flex="1">
                                <hbox id="headerBox" flex="1">
                                        <label id="header"/>
                                        <spacer flex="1"/>
                                        <vbox>
                                                <image id="logo"/>
                                                <spacer flex="1"/>
                                        </vbox>
                                </hbox>
                                <spacer flex="19"/>
                                <hbox id="footerBox" flex="1">
                                        <spacer flex="1"/>
                                        <label id="footer"/>
                                </hbox>
                        </vbox>
                        <vbox flex="1"
                                onclick="Presentation.onPresentationClick(event);">
                                <spacer flex="1"/>
                                <hbox flex="1" id="contentBox">
                                        <spacer flex="1"/>
                                        <vbox id="content"/>
                                        <spacer flex="1"/>
                                </hbox>

doc/slides/yapcasia2008.xul  view on Meta::CPAN

                        if (location.hash.match(/edit/i) ||
                                param.match(/edit=(1|true|yes)/i))
                                this.toggleEditMode();

                        if (location.hash.match(/eva/i) ||
                                param.match(/eva=(1|true|yes)/i))
                                this.toggleEvaMode();

                        if (location.hash.match(/timer(\d+)\-(\d+)/i))
                                this.setTimer(RegExp.$1, RegExp.$2);

                        if (param.match(/(style|css)=([^&;]+)/i)) {
                                var style = unescape(RegExp.$2);
                                var pi = document.createProcessingInstruction('xml-stylesheet', 'href="'+style+'" type="text/css"');
                                document.insertBefore(pi, document.documentElement);
                        }

                        if (param.match(/data=([^&;]+)/i)) {
                                this.loadData(RegExp.$1);
                                return false;
                        }
                }
                return true;
        },
        loadData : function(aPath)
        {
                this.dataPath = aPath;
                var request = new XMLHttpRequest();
                request.open('GET', aPath);
                request.onload = function() {
                        Presentation.textbox.value = request.responseText;
                        Presentation.data = Presentation.textbox.value;
                        Presentation.init();
                };
                request.send(null);
        },



        resetTimer : function()
        {
                if (this.timerTimer) {
                        window.clearInterval(this.timerTimer);
                        this.timerTimer = null;
                }
                this.timer.setAttribute('value', 0);
                this.timer.setAttribute('collapsed', true);
                this.setHash('timer', '');
        },
        setTimer : function(aStart, aEnd)
        {
                var now = (new Date()).getTime();
                if (aStart === void(0) || aEnd === void(0)) {
                        var rest = prompt('Remaining Time (minits)');
                        if (rest == '') {
                                this.resetTimer();
                                return;
                        }
                        else {
                                rest = Number(rest);
                                if (!rest || isNaN(rest)) return;
                        }

                        rest = Math.abs(rest);
                        this.timerStart = now;
                        this.timerEnd   = this.timerStart + (rest * 60000);
                }
                else {
                        aStart = Number(aStart);
                        aEnd   = Number(aEnd);
                        if (isNaN(aStart) || isNaN(aEnd)) return;

                        this.timerStart = Math.min(aStart, aEnd);
                        this.timerEnd   = Math.max(aStart, aEnd);

                        if (this.timerStart >= now || this.timerEnd <= now) return;
                }

                this.resetTimer();

                this.timer.removeAttribute('collapsed');
                this.setHash('timer', 'timer'+this.timerStart+'-'+this.timerEnd);

                if (now != this.timerStart)
                        this.updateTimer(this);

                window.setInterval(this.updateTimer, Math.min(this.timerUpdatingInterval, (this.timerEnd-this.timerStart)/(this.data.length*2)), this);
        },
        updateTimer : function(aThis)
        {
                var now = (new Date()).getTime();
                if (now >= aThis.timerEnd) {
                        aThis.resetTimer();
                        aThis.timer.setAttribute('value', 100);
                        aThis.timer.removeAttribute('collapsed');
                        aThis.setHash('timer', '');
                }
                else {
                        var value = parseInt(((now - aThis.timerStart) / (aThis.timerEnd - aThis.timerStart)) * 100);
                        aThis.timer.setAttribute('value', value);
                }
        },
        timerStart : 0,
        timerEnd   : 0,
        timerTimer : null,



        print : function()
        {
                if (!this.canMove) {
                        alert('Please wait for a while, and retry later.');
                        return;
                }

                this.stopPrint();
                if (this.printWindow) {
                        this.printWindow.close();
                        this.printWindow = null;
                }

                if (!this.isToolbarHidden)
                        this.showHideToolbar(true);

                this.printWindow = window.open('output.htm', 'PresentationPrint', 'dependent=yes,hotkeys=yes,location=yes,menubar=yes,personalbar=yes,scrollbars=yes,status=yes,toolbar=yes');
                if (!this.printWindow) return;

                this.isPrinting = true;

                if (!this.printCanvas)
                        this.printCanvas = document.createElementNS(XHTMLNS, 'canvas');



( run in 1.280 second using v1.01-cache-2.11-cpan-df04353d9ac )