Unresponsive script warning while executing iim from js file

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Unresponsive script warning while executing iim from js file

by sightunseen on Mon Feb 10, 2014 3:02 pm

Hi I am using iMacros 8.6.0 in Firefox 24. I have worked with a few iim scripts but I've just started to write some js scripts that I can execute via iMacros to call the iim scripts conditionally. Since I started I have encountered on executing dozens of my iim scripts via js iimPlay(), Firefox will give an unresponsive script warning. These scripts have always worked fine when executed directly.

I will see one of two warnings:

The first is very rare and cannot be reproduced:
Code: Select all
A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.

Script: chrome://imacros/content/MacroPlayer.js:5
Line 5 is a single line that's 100k long since the javascript in MacroPlayer.js is stripped of whitespace and newlines so I have no idea what's happening there.

The second is not rare and is easily reproducible:
Code: Select all
A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.

I have a simple example to reproduce:
Code: Select all
iimPlay("CODE:WAIT SECONDS=30");

iimPlay is blocking when it runs a script, and I'm guessing that when an iim script is executing for over n seconds it makes Firefox think the javascript that called iimPlay() is unresponsive. That example above is just an example to demonstrate that.

I found a related thread here:
iOpus • View topic - Firefox javascript timeout

Globally I could change Firefox preferences dom.max_chrome_script_run_time (default 20 sec) and dom.max_script_run_time (default 10 sec). I am in the same predicament though where I only want to stop the unresponsive warnings when I'm calling iMacros javascript files, and not all the time.

If I check the "don't ask again" option to the dialog, Firefox will set globally dom.max_script_run_time to 0 and that'll do until I find something better. Does anyone have any suggestions for how to deal with this issue? How do you handle it in your javascript? Do you all have unresponsive script disabled? For how frequently it happens with my iMacros js calls to iimPlay I'm surprised from what I've found on the internet that there aren't more reports of it.

Could the developers consider setting dom.max_script_run_time to 0 maybe only when an iMacros js script is executing, and then revert it back to its original setting afterwards? or maybe could the warning be continually handled (press continue each time) when iimPlay() is called? The ONDIALOG solution in the other thread sounds great (to click continue every time) but it doesn't sound to be always reliable.

I've looked at the iMacros source but it's stripped of whitespace and newlines. Conceivably I could edit the iimPlay function myself to set the dom.max_script_run_time to 0 only when running an iim file. I just need a source file I can read and to know where the iimPlay function is so I can add some code.

Thanks
sightunseen
 
Posts: 67
Joined: Thu Apr 18, 2013 9:54 pm

Re: Unresponsive script warning while executing iim from js

by chivracq on Tue Feb 11, 2014 2:57 am

Hum...!, I'm starting to like you!

OK, good you found yourself the other Thread where I gave the tip/possible Workaround about the max_*script_run_time FF Setting and the ONDIALOG's as that was my first idea when I started to read your Question...

Other idea would be to set those 2 Settings programmaticly at the Beginning and the End of your Macro, but that's supposed to be impossible (or at least we didn't find a way and TechSupport didn't jump into the Thread...), see this Thread:
Can I edit about:config with iMacros?

My next idea would be for you to create a new Firefox Profile that you could dedicate to your iMacros Script and for which you could change (permanently) the 2 Max Settings.

And for the last part of your previous msg, see this Thread for the Technique I use myself to modify the iMacros Source Code and customize the Add-on. Welcome to the Club!! I may feel less lonely...!
Extend Imacros with new commands?

Concerning your main Question about the unresponsive Script Warnings with iimPlay(), I haven't run into it yet, because I still only use .iim Scripts in which I have developed high Skills to until now always succeed to manage to handle the Conditional Behaviour using EVAL, Relative Positioning and very short !TIMEOUT, though converting my 10.000+ Lines of Code to smaller .iim Macros run from .js Scripts is my next big Project, but that would require a major Rewrite of the complete Workflow, so I haven't started yet... :oops:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Unresponsive script warning while executing iim from js

by sightunseen on Tue Feb 11, 2014 11:05 pm

chivracq wrote:Other idea would be to set those 2 Settings programmaticly at the Beginning and the End of your Macro, but that's supposed to be impossible (or at least we didn't find a way and TechSupport didn't jump into the Thread...), see this Thread:
Can I edit about:config with iMacros?
Thanks I've reviewed that. Short of writing an extension to communicate with iMacros or hacking iMacros' extension I don't have any good ideas unfortunately. BTW I used to have external programs communicate with iMacros by setting the clipboard and then I'd have the external program loop GetClipboardSequenceNumber() and if change then GetClipboardData() to see if it contained my special string. Not that it's relevant for here.

chivracq wrote:My next idea would be for you to create a new Firefox Profile that you could dedicate to your iMacros Script and for which you could change (permanently) the 2 Max Settings.
That is probably the right way to go, to have a dedicated profile for iMacros. Thanks for the suggestion!

chivracq wrote:And for the last part of your previous msg, see this Thread for the Technique I use myself to modify the iMacros Source Code and customize the Add-on. Welcome to the Club!! I may feel less lonely...!
Extend Imacros with new commands?
Thanks. I've also done the same thing. I unzipped the jar file. I'm pretty sure you can leave them unzipped and do away with the jar. I have a js-beautifier that I could run on the javascript but it seems like a lot of work to go in and find out what's going on so I was hoping for an easy fix.

chivracq wrote:Concerning your main Question about the unresponsive Script Warnings with iimPlay(), I haven't run into it yet, because I still only use .iim Scripts in which I have developed high Skills to until now always succeed to manage to handle the Conditional Behaviour using EVAL, Relative Positioning and very short !TIMEOUT, though converting my 10.000+ Lines of Code to smaller .iim Macros run from .js Scripts is my next big Project, but that would require a major Rewrite of the complete Workflow, so I haven't started yet... :oops:
That's very interesting. I had heard a few years ago of people using iMacros iim files with conditional behavior, and without wrapping in a js file. How are you doing it?
sightunseen
 
Posts: 67
Joined: Thu Apr 18, 2013 9:54 pm

Re: Unresponsive script warning while executing iim from js

by chivracq on Sun Feb 16, 2014 7:11 pm

OK, Reply took a while, as I wanted to give you some structured Answer and I needed to find some older Threads for Reference...

sightunseen wrote:
chivracq wrote:Other idea would be to set those 2 Settings programmaticly at the Beginning and the End of your Macro, but that's supposed to be impossible (or at least we didn't find a way and TechSupport didn't jump into the Thread...), see this Thread:
Can I edit about:config with iMacros?
Thanks I've reviewed that. Short of writing an extension to communicate with iMacros or hacking iMacros' extension I don't have any good ideas unfortunately. BTW I used to have external programs communicate with iMacros by setting the clipboard and then I'd have the external program loop GetClipboardSequenceNumber() and if change then GetClipboardData() to see if it contained my special string. Not that it's relevant for here.

OK, interesting Technique, and you actually gave me some interesting Idea, to palliate in a way to some imo shortcoming of iMacros (Variables Scope) and I will need to test it, but I'm nearly sure it will work...

sightunseen wrote:
chivracq wrote:And for the last part of your previous msg, see this Thread for the Technique I use myself to modify the iMacros Source Code and customize the Add-on. Welcome to the Club!! I may feel less lonely...!
Extend Imacros with new commands?
Thanks. I've also done the same thing. I unzipped the jar file. I'm pretty sure you can leave them unzipped and do away with the jar. I have a js-beautifier that I could run on the javascript but it seems like a lot of work to go in and find out what's going on so I was hoping for an easy fix.

OK, "js-beautifier" sounds interesting, the inner Code of the Add-on is indeed not very fun and easy to read, you need to get drunk or very motivated before you want to dig in it...!
I use File-Diff to check the Changes between Versions (and revert some I don't like...) and simple Text Search at the Root of the Add-on to locate the Functions I'm looking for and I slowly begin to know where most Functionalities are located...

sightunseen wrote:
chivracq wrote:Concerning your main Question about the unresponsive Script Warnings with iimPlay(), I haven't run into it yet, because I still only use .iim Scripts in which I have developed high Skills to until now always succeed to manage to handle the Conditional Behaviour using EVAL, Relative Positioning and very short !TIMEOUT, though converting my 10.000+ Lines of Code to smaller .iim Macros run from .js Scripts is my next big Project, but that would require a major Rewrite of the complete Workflow, so I haven't started yet... :oops:
That's very interesting. I had heard a few years ago of people using iMacros iim files with conditional behavior, and without wrapping in a js file. How are you doing it?

I already explained some of my Methods in this Thread:
Decision Making using iMacros/Possible Workarounds
I gave a few Examples, maybe not the best ones, or I have some more and maybe better, we can continue that Discussion in the other Thread if you want, in order not to "pollute" your original Question in this current Thread, or I will make it into a HowTo one day..., but basically, I play (cleverly!) with EVAL, !ERRORIGNORE, Relative Positioning based on some Text Info, and !TIMEOUT and !TIMEOUT_STEP... And I use EVAL often to spit out a "1" or a "0" to use for TAG POS=1/0, knowing that POS=0 won't do anything... or some String that I will reuse for URL or ID or CONTENT, being valid or not...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Unresponsive script warning while executing iim from js

by petr on Tue Feb 18, 2014 2:44 am

Code: Select all
basically, I play (cleverly!) with EVAL, !ERRORIGNORE, Relative Positioning based on some Text Info, and !TIMEOUT and !TIMEOUT_STEP... And I use EVAL often to spit out a "1" or a "0" to use for TAG POS=1/0, knowing that POS=0 won't do anything... or some String that I will reuse for URL or ID or CONTENT, being valid or not...


I'm sorry this is off topic, but I just wanted to say thanks to chivracq for this idea, it's brilliant! Now I know how to rewrite some older, awful written macros of mine. Also if you'd have some other tips, I'd really appreciate it!

Edit: OMG this is really fu***ng brilliant!!! Using this method I've rewritten 3 very long and hard to read macros and now the code is simply beautiful! Thanks again!!
petr
 
Posts: 53
Joined: Thu Jun 27, 2013 2:19 pm

Re: Unresponsive script warning while executing iim from js

by chivracq on Tue Feb 18, 2014 4:39 am

petr wrote:
Code: Select all
basically, I play (cleverly!) with EVAL, !ERRORIGNORE, Relative Positioning based on some Text Info, and !TIMEOUT and !TIMEOUT_STEP... And I use EVAL often to spit out a "1" or a "0" to use for TAG POS=1/0, knowing that POS=0 won't do anything... or some String that I will reuse for URL or ID or CONTENT, being valid or not...


I'm sorry this is off topic, but I just wanted to say thanks to chivracq for this idea, it's brilliant! Now I know how to rewrite some older, awful written macros of mine. Also if you'd have some other tips, I'd really appreciate it!

Edit: OMG this is really fu***ng brilliant!!! Using this method I've rewritten 3 very long and hard to read macros and now the code is simply beautiful! Thanks again!!


Yes, this is indeed off Topic, that's why I mentioned in my previous Msg to continue the Discussion on that Subject in the other (dedicated) Thread... where I will post my Reply... But glad to hear you are already happy, Petr...! :D

Decision Making using iMacros/Possible Workarounds
Last edited by chivracq on Tue Feb 18, 2014 4:41 am, edited 1 time in total.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Unresponsive script warning while executing iim from js

by petr on Tue Feb 18, 2014 4:41 am

chivracq I was referring to my "thanks post" post :p not yours
petr
 
Posts: 53
Joined: Thu Jun 27, 2013 2:19 pm

Re: Unresponsive script warning while executing iim from js

by sightunseen on Thu Feb 20, 2014 10:40 pm

chivracq wrote:OK, "js-beautifier" sounds interesting, the inner Code of the Add-on is indeed not very fun and easy to read, you need to get drunk or very motivated before you want to dig in it...!

FYI I tried to use js beautifier and it spit out all kinds of errors trying to beautify the javascript files. If any dev is reading this it would be great if we could get them unpacked, or at least more information on the packer you guys are using.
sightunseen
 
Posts: 67
Joined: Thu Apr 18, 2013 9:54 pm

Re: Unresponsive script warning while executing iim from js

by chivracq on Fri Feb 21, 2014 4:48 am

sightunseen wrote:
chivracq wrote:OK, "js-beautifier" sounds interesting, the inner Code of the Add-on is indeed not very fun and easy to read, you need to get drunk or very motivated before you want to dig in it...!

FYI I tried to use js beautifier and it spit out all kinds of errors trying to beautify the javascript files. If any dev is reading this it would be great if we could get them unpacked, or at least more information on the packer you guys are using.


Maybe none!! LOL...!!

OK, I was up to going to give it a try using Sublime Text and/or Notepad++ with some jsBeautifuler Plugin following the Tips here, but it works straight away using the online jsBeautifuler at http://jsbeautifier.org/

Example on ControlPanel.js (still from v8.60 (for FF), I haven't unpacked v8.8.1 yet...):
Code: Select all
//*/
/*
(c) Copyright 2008 iOpus Software GmbH - http://www.iopus.com
*/
iMacros.panel = (function () {
    var scope = {};
    Components.utils.import("resource://imacros/utils.js", scope);
    var __loginf = scope.__loginf;
    var imns = scope.imns;

    function iMacrosControlPanel() {
        this._statLine1 = "";
        this._statLine2 = "";
        this._statLine3 = "";
        this._statLine1Status = "";
        this._statLine2Status = "";
        this._statLine3Status = "";
        this._errorMessage = "";
        this._infoMessage = "";
        this._mboxType = "message";
        this._mboxStatus = "closed";
        this._currentLoop = 1;
        this._currentLine = 0;
        this.sidebar = null;
        this.registerObservers();
    };
    iMacrosControlPanel.prototype.registerObservers = function () {
        imns.osvc.addObserver(this, "imacros-sidebar-loaded", false);
        imns.osvc.addObserver(this, "imacros-sidebar-closed", false);
    };
    iMacrosControlPanel.prototype.unregisterObservers = function () {
        imns.osvc.removeObserver(this, "imacros-sidebar-loaded", false);
        imns.osvc.removeObserver(this, "imacros-sidebar-closed", false);
    };
    window.addEventListener("unload", function () {
        iMacros.panel.unregisterObservers();
    }, false);
    iMacrosControlPanel.prototype.observe = function (subject, topic, data) {
        if (topic == "imacros-sidebar-loaded") {
            var t = document.getElementById("sidebar").contentWindow;
            var sidebar_url = "chrome://imacros/content/iMacrosSidebar.xul";
            if (t.location.href != sidebar_url) return;
            if (t == subject) {
                if (this.panelIsOpen) this.closePanel();
                this.sidebar = subject;
                this.sidebar.mainwindow = window;
                if (this.treeViewState) {
                    var mtree = this.sidebar.getMTreeObject();
                    mtree.applyState(this.treeViewState);
                }
                if (this.sidebarIsOpening) this.sidebarIsOpening = false;
                if (this.sidebarLoadedCallback) {
                    this.sidebarLoadedCallback();
                    this.sidebarLoadedCallback = null;
                }
            }
        } else if (topic == "imacros-sidebar-closed") {
            if (subject != window) return;
            this.treeViewState = JSON.parse(data);
            this.sidebar = null;
        }
        this.updateControlPanel();
    };
    iMacrosControlPanel.prototype.ensureSidebarIsOpen = function (callback) {
        var broadcaster = document.getElementById("imacros_ControlPanel");
        var checked = broadcaster.getAttribute("checked") == "true";
        if (this.sidebarIsOpen) {
            setTimeout(callback, 0);
        } else if (!this.sidebarIsOpening) {
            this.sidebarLoadedCallback = callback;
            if (!checked) {
                imns.Pref.setBoolPref("close-sidebar", true);
                this.sidebarIsOpening = true;
                toggleSidebar("imacros_ControlPanel");
                setTimeout(function () {
                    if (!iMacros.panel.sidebarIsOpen) iMacros.panel.ensureSidebarIsOpen(callback);
                }, 200);
            }
        }
    };
    iMacrosControlPanel.prototype.closeSidebar = function () {
        if (!this.sidebar) return;
        toggleSidebar("imacros_ControlPanel");
    };
    iMacrosControlPanel.prototype.__defineGetter__("sidebarIsOpen", function () {
        return !!this.sidebar;
    });
    iMacrosControlPanel.prototype.showPanel = function () {
        if (!this.panelIsOpen) this.panel.openPopup(document.getElementById('imacros-toggle-button'), "after_end", 0, 0, false, false, null);
    };
    iMacrosControlPanel.prototype.__defineGetter__("panelIsOpen", function () {
        return (this.panel.state == "open" || this.panel.state == "showing");
    });
    iMacrosControlPanel.prototype.__defineGetter__("list", function () {
        if (this.sidebarIsOpen) {
            var doc = this.sidebar.document;
            var list = doc.getElementById('listbox');
            return list;
        }
        return null;
    });
    iMacrosControlPanel.prototype.showLines = function (code) {
        try {
            if (!this.sidebarIsOpen) return;
            var doc = this.sidebar.document;
            this.clearAllLines();
            if (code) {
                var lines = code.split("\n");
                for (var i = 0; i < lines.length; i++) {
                    this.list.appendItem(imns.str.trim(lines[i]));
                }
            }
            var deck = doc.getElementById("tree-box-deck");
            deck.selectedIndex = 1;
            var edit = doc.getElementById('editname');
            var rename = doc.getElementById('im-rename-button');
            edit.collapsed = true;
            rename.collapsed = true;
            this.list.scrollToIndex(0);
        } catch (e) {
            Components.utils.reportError(e);
        }
    };
    iMacrosControlPanel.prototype.addLine = function (line) {
        try {
            if (iMacros.recording) {
                this.statLine3 = this._statLine3.replace(/(\s+\(\d+\))?$/, " (" + iMacros.recorder.actions.length + ")");
            }
            if (!this.sidebarIsOpen) return;
            this.list.appendItem(line);
            var count = this.list.getRowCount();
            this.list.ensureIndexIsVisible(count - 1);
        } catch (e) {
            Components.utils.reportError(e);
        }
    };
    iMacrosControlPanel.prototype.removeLastLine = function () {
        if (iMacros.recording) {
            this.statLine3 = this._statLine3.replace(/(\s+\(\d+\))?$/, " (" + iMacros.recorder.actions.length + ")");
        }
        if (!this.sidebarIsOpen) return;
        this.list.removeItemAt(this.list.getRowCount() - 1);
    };
    iMacrosControlPanel.prototype.highlightLine = function (line) {
        this._currentLine = line;
        if (this.sidebarIsOpen) {
            this.statLine1 = imns.strings('imacrosreplaystep') + (line);
            this.list.ensureIndexIsVisible(line - 1);
            this.list.selectedIndex = line - 1;
        } else if (this.panelIsOpen) {
            this.statLine3 = this._statLine3.replace(/(\s+\(\d+\))?$/, " (" + line + ")");
        }
    };
    iMacrosControlPanel.prototype.clearAllLines = function () {
        if (!this.sidebarIsOpen) return;
        while (this.list.getRowCount()) this.list.removeChild(this.list.firstChild);
    };
    iMacrosControlPanel.prototype.__defineSetter__("statLine1", function (str) {
        this._statLine1 = str;
        if (this.sidebarIsOpen) {
            var doc = this.sidebar.document;
            var stat = doc.getElementById('replaystat');
            stat.value = str;
        } else {
            var stat = document.getElementById("imacros-info-panel-status2");
            if (/^Waiting:\s+\d+/.test(str)) {
                stat.setAttribute("state", "waiting");
                stat.value = str;
            } else {
                stat.removeAttribute("state");
                stat.value = "";
            }
        }
    });
    iMacrosControlPanel.prototype.__defineSetter__("statLine1Status", function (val) {
        this._statLine1Status = val;
        if (this.sidebarIsOpen) {
            var doc = this.sidebar.document;
            var stat = doc.getElementById('replaystat');
        } else {
            var stat = document.getElementById("imacros-info-panel-status2");
        } if (/playing|recording/.test(val.toString())) {
            stat.setAttribute("status", val);
        } else {
            stat.value = "";
            stat.removeAttribute("status");
        }
    });
    iMacrosControlPanel.prototype.__defineSetter__("statLine2", function (str) {
        this._statLine2 = str;
        if (this.sidebarIsOpen) {
            var doc = this.sidebar.document;
            var stat = doc.getElementById('delaystat');
        } else {
            var stat = document.getElementById("imacros-info-panel-status2");
        }
        stat.value = str;
    });
    iMacrosControlPanel.prototype.__defineSetter__("statLine2Status", function (val) {
        this._statLine2Status = val;
        if (this.sidebarIsOpen) {
            var doc = this.sidebar.document;
            var stat = doc.getElementById('delaystat');
        } else {
            var stat = document.getElementById("imacros-info-panel-status2")
        } if ("loading" == val.toString()) {
            stat.setAttribute("state", "loading");
        } else {
            stat.value = "";
            stat.removeAttribute("state");
        }
    });
    iMacrosControlPanel.prototype.__defineSetter__("statLine3", function (str) {
        this._statLine3 = str;
        if (!this.sidebarIsOpen) {
            var stat = document.getElementById("imacros-info-panel-status3");
            stat.value = str;
        }
    });
    iMacrosControlPanel.prototype.__defineSetter__("statLine3Status", function (val) {
        this._statLine3Status = val;
        if (this.sidebarIsOpen) return;
    });
    iMacrosControlPanel.prototype.__defineGetter__("panel", function () {
        return document.getElementById('imacros-info-panel');
    });
    iMacrosControlPanel.prototype.closePanel = function () {
        if (this.panelIsOpen) this.panel.hidePopup();
    };
    iMacrosControlPanel.prototype.onPanelClick = function () {
        if (this.panelIsOpen) this.panel.hidePopup();
        if (!this.sidebarIsOpen) toggleSidebar("imacros_ControlPanel");
    };
    iMacrosControlPanel.prototype.showMacroTree = function () {
        this.statLine1Status = "idle";
        this.statLine2Status = "idle";
        this.statLine3Status = "idle";
        if (this.panelIsOpen) {
            if (this._mboxStatus != "open") {
                var self = this;
                this.closePanelTimeout = setTimeout(function () {
                    self.closePanelTimeout = null;
                    self.closePanel();
                }, 2000);
            }
        }
        if (this.sidebarIsOpen) {
            var doc = this.sidebar.document;
            var deck = doc.getElementById("tree-box-deck");
            deck.selectedIndex = 0;
            if (imns.Pref.getBoolPref("close-sidebar")) {
                imns.Pref.setBoolPref("close-sidebar", false);
                this.closeSidebar();
            }
        }
        this.updateControlPanel();
    };
    iMacrosControlPanel.prototype.__defineGetter__("selectedItem", function () {
        if (!this.sidebarIsOpen) return null;
        var mtree = this.sidebar.getMTreeObject();
        return mtree.getSelectedItem();
    });
    iMacrosControlPanel.prototype.updateMacroTree = function () {
        if (this.sidebarIsOpen) {
            this.sidebar.initMTree();
        }
    };
    iMacrosControlPanel.prototype.updateControlPanel = function () {
        if (this.sidebarIsOpen) {
            this.updateSidebarState();
        } else {
            var __x = function (btns, state) {
                if (typeof btns == "string") btns = [btns];
                for (let n = 0; n < btns.length; n++) {
                    let btn = document.getElementById("imacros-info-panel-" + btns[n] + "-button");
                    btn.collapsed = state;
                }
            };
            var on = function (btns) {
                __x(btns, null);
            };
            var off = function (btns) {
                __x(btns, true);
            };
            if (iMacros.playing || iMacros.jsplaying || iMacros.recording || iMacros.paused == "playing" || iMacros.paused == "jsplaying" || iMacros.paused == "recording") {
                if (!this.panelIsOpen) {
                    this.showPanel();
                } else if (this.closePanelTimeout) {
                    clearTimeout(this.closePanelTimeout);
                    this.closePanelTimeout = null;
                }
            } else {
                this.statLine3 = this._statLine3.replace(/(?:\s+\(\d+\))$/, "");
                on(["play", "record"]);
                off(["pause", "stop"]);
                return;
            }
            let pause_btn = document.getElementById("imacros-info-panel-pause-button");
            if (iMacros.paused == "playing" || iMacros.paused == "jsplaying") {
                on(['pause', 'stop']);
                off(['play', 'record']);
                pause_btn.setAttribute("icon", "play");
                pause_btn.setAttribute("label", "Continue");
            } else if (iMacros.paused == "recording") {
                on(['stop', 'pause']);
                off(['play', 'record']);
                pause_btn.setAttribute("icon", "record");
                pause_btn.setAttribute("label", "Continue");
            } else if (iMacros.playing || iMacros.jsplaying) {
                this.statLine3 = this._statLine3.replace(/(\s+\(\d+\))?$/, " (" + this._currentLine + ")");
                on(['pause', 'stop']);
                off(['play', 'record']);
                pause_btn.setAttribute("icon", "pause");
                pause_btn.setAttribute("label", "Pause");
            } else if (iMacros.recording) {
                this.statLine3 = this._statLine3.replace(/(\s+\(\d+\))?$/, " (" + iMacros.recorder.actions.length + ")");
                on(['stop', 'pause']);
                off(['play', 'record']);
                pause_btn.setAttribute("icon", "pause");
                pause_btn.setAttribute("label", "Pause");
            }
        }
        this.statLine1 = this._statLine1;
        this.statLine1Status = this._statLine1Status;
        this.statLine2 = this._statLine2;
        this.statLine2Status = this._statLine2Status;
        this.statLine3 = this._statLine3;
        this.statLine2Status = this._statLine3Status;
        if (this._mboxStatus == "open") {
            if (this._mboxType == "error") this.showErrorMessage(this._errorMessage);
            else if (this._mboxType == "message") this.showInfoMessage(this._infoMessage);
        }
    };
    iMacrosControlPanel.prototype.updateSidebarState = function () {
        if (!this.sidebarIsOpen) return;
        var doc = this.sidebar.document;
        var deck = doc.getElementById("tree-box-deck");
        var makeObject = function (constructor) {
            var obj = new Object();
            for (var x = 1; x < arguments.length; x++) obj[arguments[x]] = constructor(arguments[x]);
            return obj;
        };
        var butts = makeObject(function (name) {
            return doc.getElementById("im-" + name + "-button");
        }, "play", "pause", "stopplay", "playloop", "record", "save", "stoprecord", "waitreplay", "edit", "share");
        var tabs = makeObject(function (name) {
            return doc.getElementById("im-" + name + "-tab");
        }, "play", "record", "edit");
        var off = function (obj) {
            for (var x = 1; x < arguments.length; x++) obj[arguments[x]].disabled = true;
        };
        var on = function (obj) {
            for (var x = 1; x < arguments.length; x++) obj[arguments[x]].disabled = null;
        };
        var tabbox = doc.getElementById("im-tabbox");
        if (iMacros.playing || iMacros.jsplaying || iMacros.paused == "playing" || iMacros.paused == "jsplaying") {
            off(butts, "play", "playloop");
            on(butts, "pause", "stopplay");
            off(tabs, "record", "edit");
            tabbox.selectedIndex = 0;
            butts["pause"].label = iMacros.paused ? imns.strings('imacrospausestate2') : imns.strings('imacrospausestate1');
            if (deck.selectedIndex != 1) {
                if (iMacros.playing) this.showLines(iMacros.player.source);
                else if (iMacros.jsplaying) this.showLines(iMacros.jssrc);
                this.highlightLine(this.currentLine);
            }
        } else if (iMacros.recording || iMacros.paused == "recording") {
            off(butts, "record", "save");
            on(butts, "stoprecord", "waitreplay");
            off(tabs, "play", "edit");
            tabbox.selectedIndex = 1;
            if (deck.selectedIndex != 1) {
                this.showLines(iMacros.recorder.getRecordedMacro());
            }
        } else {
            on(tabs, "play", "record", "edit");
            var item = this.selectedItem;
            if (item && !item.isContainer) {
                on(butts, "play", "playloop", "save", "edit", "share");
            } else {
                off(butts, "play", "playloop", "save", "edit", "share");
            }
            on(butts, "record");
            off(butts, "pause", "stopplay", "stoprecord", "waitreplay");
            deck.selectedIndex = 0;
        }
        var rec_mode = imns.Pref.getCharPref("record-mode");
        var elem = doc.getElementById("im-record-label");
        if (elem) {
            if (rec_mode == "auto") elem.value = "Auto";
            else if (rec_mode == "conventional") elem.value = "HTM";
            else if (rec_mode == "events") elem.value = "Event";
            else {
                elem.value = "Auto";
                imns.Pref.setCharPref("record-mode", "auto");
            }
        }
    };
    iMacrosControlPanel.prototype.mboxClose = function () {
        this.mboxClearMessage();
        if (this.panelIsOpen) {
            this.closePanel();
        }
    };
    iMacrosControlPanel.prototype.mboxHelp = function () {
        if (this.mboxErrorNumber == 31415) iMacros.addTab("http://www.iopus.com/imacros/home/fx/rd.asp?helpid=macrotoolong");
        else iMacros.addTab("http://www.iopus.com/imacros/home/fx/e.asp?browser=fx&error=" + this.mboxErrorNumber);
    };
    iMacrosControlPanel.prototype.mboxEdit = function () {
        var macro = iMacros.currentMacro;
        if (!macro.path) {
            var t = imns.Cc["@mozilla.org/file/directory_service;1"].getService(imns.Ci.nsIProperties).get("TmpD", imns.Ci.nsILocalFile);
            t.append("iMacros_tmpfile.iim");
            imns.FIO.writeTextFile(t, iMacros.player.source);
            macro.path = t.path;
        }
        iMacros.edit(macro, this.mboxErrorLine);
    };
    iMacrosControlPanel.prototype.mboxResetError = function () {
        if (this._mboxType != "error") return;
        this.mboxClearMessage();
    };
    iMacrosControlPanel.prototype.mboxClearMessage = function () {
        if (this.sidebarIsOpen) {
            var doc = this.sidebar.document;
            var box = doc.getElementById("imacros-message-box");
            var deck = doc.getElementById("logo-message-deck");
            if (deck.selectedIndex == 0) {
                deck.selectedIndex = 1;
            }
        } else if (this.panelIsOpen) {
            document.getElementById("imacros-message-box-container").collapsed = true;
        }
        this._mboxType = "message";
        this._mboxStatus = "closed";
        this._errorMessage = "";
        this._infoMessage = "";
    };
    iMacrosControlPanel.prototype.showInfoMessage = function (msg) {
        this._infoMessage = msg;
        this._mboxType = "message";
        this._mboxStatus = "open";
        if (this.sidebarIsOpen) {
            var doc = this.sidebar.document;
            var tabbox = doc.getElementById("im-tabbox");
            tabbox.selectedIndex = 0;
            var deck = doc.getElementById("logo-message-deck");
            deck.selectedIndex = 0;
            var msgbox = doc.getElementById("imacros-message-box");
            var help_btn = doc.getElementById("message-box-button-help");
            var edit_btn = doc.getElementById("message-box-button-edit");
            help_btn.collapsed = true;
            edit_btn.collapsed = true;
            msgbox.setAttribute("msgtype", this._mboxType);
            msgbox.value = msg;
        } else {
            if (!this.panelIsOpen) this.showPanel();
            var con = document.getElementById("imacros-message-box-container");
            con.collapsed = null;
            var msgbox = document.getElementById("imacros-message-box");
            var help_btn = document.getElementById("imacros-message-box-button-help");
            var edit_btn = document.getElementById("imacros-message-box-button-edit");
            help_btn.collapsed = true;
            edit_btn.collapsed = true;
            msgbox.setAttribute("msgtype", this._mboxType);
            msgbox.value = msg;
        }
    };
    iMacrosControlPanel.prototype.showErrorMessage = function (msg, errnum) {
        if (errnum && !/\(error code: -?\d+\)$/i.test(msg)) {
            msg += " (Error code: " + errnum + ")";
        }
        this._errorMessage = msg;
        this._mboxType = "error";
        this._mboxStatus = "open";
        if (this.sidebarIsOpen) {
            var doc = this.sidebar.document;
            var tabbox = doc.getElementById("im-tabbox");
            tabbox.selectedIndex = 0;
            var deck = doc.getElementById("logo-message-deck");
            deck.selectedIndex = 0;
            var msgbox = doc.getElementById("imacros-message-box");
            var help_btn = doc.getElementById("message-box-button-help");
            var edit_btn = doc.getElementById("message-box-button-edit");
            help_btn.collapsed = null;
            edit_btn.collapsed = null;
            msgbox.setAttribute("msgtype", this._mboxType);
            msgbox.value = msg;
        } else {
            if (!this.panelIsOpen) this.showPanel();
            var con = document.getElementById("imacros-message-box-container");
            con.collapsed = null;
            var msgbox = document.getElementById("imacros-message-box");
            var help_btn = document.getElementById("imacros-message-box-button-help");
            var edit_btn = document.getElementById("imacros-message-box-button-edit");
            help_btn.collapsed = null;
            edit_btn.collapsed = null;
            msgbox.setAttribute("msgtype", this._mboxType);
            msgbox.value = msg;
        }
        this.mboxErrorNumber = errnum;
        this.mboxErrorLine = 0;
        if (/, line:\s*(\d+)(?:\s+\(.*\))?$/.test(msg)) this.mboxErrorLine = parseInt(RegExp.$1);
    };
    iMacrosControlPanel.prototype.onLoopValueInput = function () {
        var textbox = this.sidebar.document.getElementById('im-loopval-textbox');
        textbox.value = textbox.value.replace(/^0+|[^\d]/g, "");
    };
    iMacrosControlPanel.prototype.onLoopValueChange = function () {
        var textbox = this.sidebar.document.getElementById('im-loopval-textbox');
        if (!textbox.value.length) textbox.value = "3";
    };
    iMacrosControlPanel.prototype.__defineGetter__("maxLoopValue", function () {
        if (!this.sidebarIsOpen) return this._maxLoopValue;
        var doc = this.sidebar.document;
        var value = doc.getElementById('im-loopval-textbox');
        return (this._maxLoopValue = imns.s2i(value.value));
    });
    iMacrosControlPanel.prototype.__defineSetter__("currentLoopValue", function (val) {
        this._currentLoopValue = val;
        if (!this.sidebarIsOpen) return;
        var doc = this.sidebar.document;
        var value = doc.getElementById('im-curloop-textbox');
        value.value = val;
    });
    return new iMacrosControlPanel();
})();
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Unresponsive script warning while executing iim from js

by sightunseen on Fri Feb 21, 2014 2:47 pm

chivracq wrote:it works straight away using the online jsBeautifuler at http://jsbeautifier.org/

Interesting. I tried the python version of that script but it spit out all kinds of errors. I tried via FOREACH on every js file in chrome and its subdirectories.
sightunseen
 
Posts: 67
Joined: Thu Apr 18, 2013 9:54 pm

Re: Unresponsive script warning while executing iim from js

by chivracq on Fri Feb 21, 2014 9:16 pm

sightunseen wrote:
chivracq wrote:it works straight away using the online jsBeautifuler at http://jsbeautifier.org/

Interesting. I tried the python version of that script but it spit out all kinds of errors. I tried via FOREACH on every js file in chrome and its subdirectories.


I just got lucky I would say with that online jsBeautifuler because I was already studying the Code of the Add-on and modifying it (in its raw Version!), but that makes it now indeed a bit easier, at least to understand and to locate where I have to modify things... And I asked a while ago to have access to !LOOP_MAX in Scripts, never got any Answer, said I was going to implement it myself, that makes it closer...!

I normally don't really get excited by online Compilers and Decompilers and same kind, though I once helped a Web-Site I use a lot with my Macros to locate and get rid of a Virus that had infected one of their Flash-Objects..., yes using an online Russian Flash-Decompiler...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How to make things complicated when they can be simple?

by chivracq on Wed Mar 12, 2014 4:48 am

How to make things complicated when they can be so simple!?

I was doing some digging yesterday, looking for an Archive on Internet for older Versions of iMacros for Chrome for this Thread (and I didn't find any...) but at some point, I landed (again) on the Mozilla Archive for iMacros for Firefox (where btw I downloaded all 79 (-3 with no Link) current and older Versions of iMacros for FF when I saw the hassle it is to downgrade iMacros on CR...) and I noticed that iMacros is advertised as being "Open Source" (at least on the Chrome Add-ons Web-Store, I didn't check for Firefox), so I thought, if it's Open Source, the Source Code must be found somewhere..., with all (older) Versions..., and that's how I landed again on the Mozilla Archive for iMacros for FF where indeed all JavaScript Files are already "jsBeautified" by Mozilla or delivered in a clean State by iOpus.

Example (for the same 'ControlPanel.js' that I already jsBeautified and posted earlier, except this time from v8.8.1):
https://addons.mozilla.org/en-us/firefo ... nel.js#top
(Accessed from the "View the source" Link underneath each Version...)

Related Threads:
- iMacros source (2008)
- How is iMacros Open Source? (2011-2012)
Last edited by chivracq on Wed Mar 12, 2014 3:33 pm, edited 1 time in total.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How to make things complicated when they can be simple?

by sightunseen on Wed Mar 12, 2014 12:32 pm

chivracq wrote:and that's how I landed again on the Mozilla Archive for iMacros for FF where indeed all JavaScript Files are already "jfBeautified" by Mozilla or delivered in a clean State by iOpus.

Example (for the same 'ControlPanel.js' that I already jsBeautified and posted earlier, except this time from v8.8.1):
https://addons.mozilla.org/en-us/firefo ... nel.js#top
(Accessed from the "View the source" Link underneath each Version...)

I just went there in my browser (FIrefox 24) and it's not beautified. Line 5 is one long line containing all the code. I can beautify it using the python js beautify utility or the online version (which I think uses the same code). Only problem is a lot of the iMacros files the beautifier will choke on. The developers know we're here maybe they could release it unpacked.
sightunseen
 
Posts: 67
Joined: Thu Apr 18, 2013 9:54 pm

Re: Unresponsive script warning while executing iim from js

by chivracq on Wed Mar 12, 2014 3:32 pm

Hi SightUnseen, nice to see that you follow the interesting Threads...! :D

OK, yes indeed, you are right, there are lots of differences between the Display on the Mozilla Add-ons Archive and the Display after "proper" js-Beautifying like I posted some time ago. (I notice btw some ugly Quote of mine where I use "jfBeautified", I'm going to correct it..., I used once as well "jsBeautiful", but I left it, as I realize that yesterday I was trying to locate this current Thread again and I used "jsBeautiful(ed)" (instead of "jsBeautify([y/i]ed)"!) (again) as a Search-Term...! Oups!)

So OK, the Display on the Mozilla Add-on Archived is not completely jsBeautified like on http://jsbeautifier.org/ but it is still readable, or at least much more than the whole .js Script on 1 Line...

>>> Stg else, you once posted/started an interesting Thread on the EVENT Mode, I still owe you a Reply on that one, but it takes some time, because I need to find several References and related Threads, and I never find the time to do it...!

>>>

JFC_TAG:
jsBeautifier, js-Beautifier, jsBeautify, js-Beautify, jsBeautified, js-Beautified, jsBeautifuler, js-Beautifuler, jsBeautifuled, js-Beautifuled, Mozilla_Archive, Decompile, Decompile_Script, Decompile_iMacros...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Firefox

Who is online

Users browsing this forum: No registered users and 18 guests

-->