<commit_before>(function () {
    'use strict';

var website = openerp.website;

if (typeof QWeb2 !== "undefined")
website.add_template_file('/website/static/src/xml/website.tour.xml');

if (website.EditorBar)
website.EditorBar.include({
    tours: [],
    start: function () {
        var self = this;
        var menu = $('#help-menu');
        _.each(this.tours, function (tour) {
            var $menuItem = $($.parseHTML('<li><a href="#">'+tour.name+'</a></li>'));
            $menuItem.click(function () {
                tour.reset();
                tour.run();
            });
            menu.append($menuItem);
        });
        return this._super();
    },
    registerTour: function (tour) {
        website.Tour.add(tour);
        this.tours.push(tour);
    }
});


/////////////////////////////////////////////////


/* jQuery selector to match exact text inside an element
 *  :containsExact()     - case insensitive
 *  :containsExactCase() - case sensitive
 *  :containsRegex()     - set by user ( use: $(el).find(':containsRegex(/(red|blue|yellow)/gi)') )
 */
$.extend($.expr[':'],{
    containsExact: function(a,i,m){
        return $.trim(a.innerHTML.toLowerCase()) === m[3].toLowerCase();
    },
    containsExactCase: function(a,i,m){
        return $.trim(a.innerHTML) === m[3];
    },
    // Note all escaped characters need to be double escaped
    // inside of the containsRegex, so "\(" needs to be "\\("
    containsRegex: function(a,i,m){
        var regreg =  /^\/((?:\\\/|[^\/])+)\/([mig]{0,3})$/,
        reg = regreg.exec(m[3]);
        return reg ? new RegExp(reg[1], reg[2]).test($.trim(a.innerHTML)) : false;
    }
});
$.ajaxSetup({
    beforeSend:function(){
        $.ajaxBusy = ($.ajaxBusy|0) + 1;
    },
    complete:function(){
        $.ajaxBusy--;
    }
});

website.Tour = openerp.Class.extend({
    steps: [],
    defaultDelay: 50, //ms
    defaultOverLaps: 5000, //ms
    localStorage: window.localStorage,
    init: function () {},

    run: function (automatic) {
        this.reset();

        for (var k in this.localStorage) {
            if (!k.indexOf("tour-") && k.indexOf("-test") > -1) return;
        }

        website.Tour.busy = true;

        this.localStorage.setItem("tour-"+this.id+"-test-automatic", automatic);
        this.automatic = automatic;

        if (this.path) {
            // redirect to begin of the tour in function of the language
            if (!this.testUrl(this.path+"(#.*)?$")) {
                var path = this.path.split('#');
                window.location.href = "/"+this.getLang()+path[0] + "#tutorial."+this.id+"=true&" + path.slice(1, path.length).join("#");
                return;
            }
        }

        var self = this;
        this.localStorage.setItem("tour-"+this.id+"-test", 0);
        website.Tour.waitReady.call(this, function () {self._running();});
    },
    running: function () {<commit_msg>[FIX] website: don't set tour as automatic when reload page<commit_after>(function () {
    'use strict';

var website = openerp.website;

if (typeof QWeb2 !== "undefined")
website.add_template_file('/website/static/src/xml/website.tour.xml');

if (website.EditorBar)
website.EditorBar.include({
    tours: [],
    start: function () {
        var self = this;
        var menu = $('#help-menu');
        _.each(this.tours, function (tour) {
            var $menuItem = $($.parseHTML('<li><a href="#">'+tour.name+'</a></li>'));
            $menuItem.click(function () {
                tour.reset();
                tour.run();
            });
            menu.append($menuItem);
        });
        return this._super();
    },
    registerTour: function (tour) {
        website.Tour.add(tour);
        this.tours.push(tour);
    }
});


/////////////////////////////////////////////////


/* jQuery selector to match exact text inside an element
 *  :containsExact()     - case insensitive
 *  :containsExactCase() - case sensitive
 *  :containsRegex()     - set by user ( use: $(el).find(':containsRegex(/(red|blue|yellow)/gi)') )
 */
$.extend($.expr[':'],{
    containsExact: function(a,i,m){
        return $.trim(a.innerHTML.toLowerCase()) === m[3].toLowerCase();
    },
    containsExactCase: function(a,i,m){
        return $.trim(a.innerHTML) === m[3];
    },
    // Note all escaped characters need to be double escaped
    // inside of the containsRegex, so "\(" needs to be "\\("
    containsRegex: function(a,i,m){
        var regreg =  /^\/((?:\\\/|[^\/])+)\/([mig]{0,3})$/,
        reg = regreg.exec(m[3]);
        return reg ? new RegExp(reg[1], reg[2]).test($.trim(a.innerHTML)) : false;
    }
});
$.ajaxSetup({
    beforeSend:function(){
        $.ajaxBusy = ($.ajaxBusy|0) + 1;
    },
    complete:function(){
        $.ajaxBusy--;
    }
});

website.Tour = openerp.Class.extend({
    steps: [],
    defaultDelay: 50, //ms
    defaultOverLaps: 5000, //ms
    localStorage: window.localStorage,
    init: function () {},

    run: function (automatic) {
        this.reset();

        for (var k in this.localStorage) {
            if (!k.indexOf("tour-") && k.indexOf("-test") > -1) return;
        }

        website.Tour.busy = true;

        if (automatic) {
            this.localStorage.setItem("tour-"+this.id+"-test-automatic", true);
        } else {
            this.localStorage.removeItem("tour-"+this.id+"-test-automatic");
        }
        this.automatic = automatic;

        if (this.path) {
            // redirect to begin of the tour in function of the language
            if (!this.testUrl(this.path+"(#.*)?$")) {
                var path = this.path.split('#');
                window.location.href = "/"+this.getLang()+path[0] + "#tutorial."+this.id+"=true&" + path.slice(1, path.length).join("#");
                return;
            }
        }

        var self = this;
        this.localStorage.setItem("tour-"+this.id+"-test", 0);
        website.Tour.waitReady.call(this, function () {self._running();});
    },
    running: function () {
{'fraction_non_alphanumeric': 0.2045, 'fraction_numerical': 0.006666666666666667, 'mean_word_length': 2.112551867219917, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6709759', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1835, 'n_words': 367}