<commit_before><!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

<script src="/extlib/build/webgme.classes.build.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.js"></script>
<script src="gme-services.js"></script>

<script type="text/javascript">
    var clientLoaded,
            timeout = 5000, // 10 seconds
            waitCounter = 0,
            i,
            success,
            usedClasses = ["Client"],
            interval = 200, // 100 milliseconds interval
            waitForLoadId = setInterval(function () {
                if (window.WebGMEGlobal &&
                        window.WebGMEGlobal.classes) {
                    // TODO: check for all classes that we use
                    clearInterval(waitForLoadId);
                    success = true;

                    for (i = 0; i < usedClasses.length; i += 1) {
                        if (window.WebGMEGlobal.classes.hasOwnProperty(usedClasses[i])) {
                            console.log('WebGME ' + usedClasses[i] + ' is available.');
                        } else {
                            console.error('WebGME ' + usedClasses[i] + ' was not found.');
                            success = false;
                        }
                    }

                    if (success) {
                        console.log('WebGME client library is ready to use.');
                        clientLoaded();
                    }
                } else {
                    console.log('Waiting for WebGME client library to load.');
                    waitCounter += 1;
                    if (waitCounter >= timeout / interval) {
                        clearInterval(waitForLoadId);
                        console.error('WebGME client library was not loaded within a reasonable time. (' + (timeout / 1000) + ' s)');
                    }
                }
            }, interval);

    clientLoaded = function () {
        // main entry point of the app.js
        // once the webgme Client is loaded and ready we can use it.


        var testApp = angular.module('testApp', ['gme.services'])
                .run(function ($q, DataStoreService, ProjectService, BranchService, NodeService) {
                    var context1 = 'my-connection-id',
                        context2 = 'my-conn-id-3',
                        registerForNodeService,
                        setupConnection;


                    registerForNodeService = function (c) {
                        console.log('Registering for node service', c);
                        NodeService.on(c, 'initialize', function () {
                            var contextWithRegion = {
                                db: c,
                                regionId: 'TestRegion'
                            };

                            console.log('NodeService initialize called', c);
                            console.log('Loading node for', contextWithRegion);
                            NodeService.loadNode(contextWithRegion, '')
                                    .then(function (node) {
                                        console.log('Node was loaded', node);
                                        node.onUpdate(function () {
                                            console.log(node.getAttribute('name'), contextWithRegion);
                                        });
                                    });
                        });
                    };

                    setupConnection = function (databaseId) {
                        var deferred = new $q.defer();

                        console.log('Setup connection', databaseId);
                        DataStoreService.connectToDatabase(databaseId, {host: window.location.basename})
                                .then(function () {
                                    console.log('Connection is ready.');

                                    registerForNodeService(databaseId);

                                    console.log('Selecting project Test', databaseId);
                                    return ProjectService.selectProject(databaseId, 'Test');
                                }).then(function () {
                                    console.log('Project ADMEditor is opened.');
                                    console.log('Selecting b1 branch', databaseId);
                                    return BranchService.selectBranch(databaseId, 'b1');
                                }).then(function () {
                                    console.log('b1 branch is selected.', databaseId);
                                    console.log('Selecting master branch', databaseId);
                                    return BranchService.selectBranch(databaseId, 'master');
                                }).then(function () {
                                    console.log('master branch is selected.', databaseId);
                                    deferred.resolve();
                                })
                                .catch(function (reason) {
                                    deferred.reject(reason);
                                });

                        return deferred.promise;
                    };

                    console.log('test app is running.');

                    $q.all([setupConnection(context1), setupConnection(context2)])
                            .then(function () {
                                console.log('Done with loading.');

                                return NodeService.loadNode({db: context1, regionId: 'TestRegion2'}, '');
                            })
                            .then(function (node) {
                                console.log(node);
                                node.onUpdate(function () {
                                    console.log(node.getAttribute('name'), {db: context1, regionId: 'TestRegion2'}, ' - 2nd update implementation');
                                });
                                node.setAttribute('name', 'Root ' + (new Date()).toISOString());
                            })
                            .catch(function (reason) {
                                console.error(reason);
                            });
                });

        angular.bootstrap(document, ['testApp']);

    };

</script>

</body>
</html><commit_msg>Add async. branch change.<commit_after><!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

<script src="/extlib/build/webgme.classes.build.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.js"></script>
<script src="gme-services.js"></script>

<script type="text/javascript">
    var clientLoaded,
            timeout = 5000, // 10 seconds
            waitCounter = 0,
            i,
            success,
            usedClasses = ["Client"],
            interval = 200, // 100 milliseconds interval
            waitForLoadId = setInterval(function () {
                if (window.WebGMEGlobal &&
                        window.WebGMEGlobal.classes) {
                    // TODO: check for all classes that we use
                    clearInterval(waitForLoadId);
                    success = true;

                    for (i = 0; i < usedClasses.length; i += 1) {
                        if (window.WebGMEGlobal.classes.hasOwnProperty(usedClasses[i])) {
                            console.log('WebGME ' + usedClasses[i] + ' is available.');
                        } else {
                            console.error('WebGME ' + usedClasses[i] + ' was not found.');
                            success = false;
                        }
                    }

                    if (success) {
                        console.log('WebGME client library is ready to use.');
                        clientLoaded();
                    }
                } else {
                    console.log('Waiting for WebGME client library to load.');
                    waitCounter += 1;
                    if (waitCounter >= timeout / interval) {
                        clearInterval(waitForLoadId);
                        console.error('WebGME client library was not loaded within a reasonable time. (' + (timeout / 1000) + ' s)');
                    }
                }
            }, interval);

    clientLoaded = function () {
        // main entry point of the app.js
        // once the webgme Client is loaded and ready we can use it.


        var testApp = angular.module('testApp', ['gme.services'])
                .run(function ($q, DataStoreService, ProjectService, BranchService, NodeService) {
                    var context1 = 'my-connection-id',
                        context2 = 'my-conn-id-3',
                        registerForNodeService,
                        setupConnection;


                    registerForNodeService = function (c) {
                        console.log('Registering for node service', c);
                        NodeService.on(c, 'initialize', function () {
                            var contextWithRegion = {
                                db: c,
                                regionId: 'TestRegion'
                            };

                            console.log('NodeService initialize called', c);
                            console.log('Loading node for', contextWithRegion);
                            NodeService.loadNode(contextWithRegion, '')
                                    .then(function (node) {
                                        console.log('Node was loaded', node);
                                        node.onUpdate(function () {
                                            console.log(node.getAttribute('name'), contextWithRegion);
                                        });
                                    });
                        });
                    };

                    setupConnection = function (databaseId) {
                        var deferred = new $q.defer();

                        console.log('Setup connection', databaseId);
                        DataStoreService.connectToDatabase(databaseId, {host: window.location.basename})
                                .then(function () {
                                    console.log('Connection is ready.', databaseId);

                                    registerForNodeService(databaseId);

                                    console.log('Selecting project Test', databaseId);
                                    return ProjectService.selectProject(databaseId, 'Test');
                                }).then(function () {
                                    console.log('Project ADMEditor is opened.');
                                    console.log('Selecting b1 branch', databaseId);
                                    return BranchService.selectBranch(databaseId, 'b1');
                                }).then(function () {
                                    console.log('b1 branch is selected.', databaseId);
                                    console.log('Selecting master branch', databaseId);
                                    return BranchService.selectBranch(databaseId, 'master');
                                }).then(function () {
                                    console.log('master branch is selected.', databaseId);
                                    deferred.resolve();
                                })
                                .catch(function (reason) {
                                    deferred.reject(reason);
                                });

                        return deferred.promise;
                    };

                    console.log('test app is running.');

                    $q.all([setupConnection(context1), setupConnection(context2)])
                            .then(function () {
                                console.log('Done with loading.');

                                return NodeService.loadNode({db: context1, regionId: 'TestRegion2'}, '');
                            })
                            .then(function (node) {
                                console.log(node);
                                node.onUpdate(function () {
                                    console.log(node.getAttribute('name'), {db: context1, regionId: 'TestRegion2'}, ' - 2nd update implementation');
                                });
                                node.setAttribute('name', 'Root ' + (new Date()).toISOString());

                                setTimeout(function () {
                                    BranchService.selectBranch(context1, 'b1');
                                }, 500);
                            })
                            .catch(function (reason) {
                                console.error(reason);
                            });
                });

        angular.bootstrap(document, ['testApp']);

    };

</script>

</body>
</html>
{'fraction_non_alphanumeric': 0.10100390834546709, 'fraction_numerical': 0.006207372212430071, 'mean_word_length': 1.003992628992629, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '107024', 'n_tokens_mistral': 2878, 'n_tokens_neox': 2654, 'n_words': 575}