Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello world extension in vanilla JS and with access to WebSQL #2

Open
phrrngtn opened this issue Jun 12, 2015 · 5 comments
Open

Hello world extension in vanilla JS and with access to WebSQL #2

phrrngtn opened this issue Jun 12, 2015 · 5 comments

Comments

@phrrngtn
Copy link
Owner

http://ahoj.io/chrome-extensions-and-web-sql-practical-experience

@phrrngtn
Copy link
Owner Author

some nice-looking code in https://rickosborne.org/html5-dbstorage-sudoku/ ... much better than any other JavaScript I have seen.

http://www.slideshare.net/casden/inbrowser-storage-and-me

@phrrngtn
Copy link
Owner Author

Found a site that generated one for me. Metaprogramming at its best!

http://extensionizr.com/!#{"modules":["hidden-mode","with-bg","with-persistent-bg","no-options","no-override"],"boolean_perms":[],"match_ptrns":[]}

Added it to whitelist. Packed it from Chrome. Dragged and dropped the packed extension onto the chrome://extensions page

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallWhitelist

Was unable to get the --load-extension command-line switch to work for me.

@phrrngtn
Copy link
Owner Author

Some JS snippets that demonstrate opening a database and running some transactions against it.

    /*
     * Constructor code begins here.
     */
    if(!window.openDatabase) {
        alert("Your browser does not appear to support the openDatabase call from the HTML5 Database Storage API.");
        return null;
    } // if not openDatabase
    db = openDatabase(dbName, DB_VERSION, DB_TITLE, DB_BYTES);
    if(!db) {
        alert("The browser rejected the request to open the database.");
        return null;
    } //
    /**
     * Return the values that are written (known) on the game board.
     * Rows and columns are converted to 0-base (0-8) from the 1-base (1-9) stored in the database.
     * 
     * @param {Function} doneCallback   Next step once the values have been fetched.
     */
    function getKnowns (doneCallback) {
        db.transaction(function(tx) {
            tx.executeSql("SELECT row, col, box, term FROM rs_cells;", [], function(tx, r) {
                var knowns = [];
                for(var i = 0; i < r.rows.length; i++) {
                    var rec = r.rows.item(i);
                    knowns.push({ row: rec.row - 1, col: rec.col - 1, box: rec.box, term: rec.term });
                } // for i
                doneCallback(knowns);
            }, sqlFailed);
        }); // transaction
    } // getKnowns

@phrrngtn
Copy link
Owner Author

This may be less relevant now that an embedded browser in an Excel CTP seems feasible.

@phrrngtn
Copy link
Owner Author

I don't know how much of the extension API is implemented by CEF. Is it feasible to take code that is written to run as an extension and run it in an embedded Qt application? This is of relevance for using 3rd party tools such as TableCapture "headless" (i.e. not using the UI provided by the extension but instead calling into the extraction code directly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant