<commit_before>/**
 * @fileOverview Main module for restartless addons
 * @author       YUKI "Piro" Hiroshi
 * @version      2
 *
 * @license
 *   The MIT License, Copyright (c) 2010 YUKI "Piro" Hiroshi.
 *   https://github.com/piroor/restartless/blob/master/license.txt
 * @url http://github.com/piroor/restartless
 */

dump('main.js loaded\n');

/**
 * load() works like Components.utils.import(). EXPORTED_SYMBOLS
 * in loaded scripts are exported to the global object of this script.
 */
load('lib/jsdeferred');
load('lib/WindowManager');
load('lib/ToolbarItem');
load('lib/KeyboardShortcut');
load('lib/here');
load('lib/easyTemplate');
// this.import() also available instead of load(), as an alias.
// Note: don't use simply "import()" without the prefix "this.",
// because the keyword "import" will be a reserved word in future.
// https://developer.mozilla.org/en/JavaScript/Strict_mode#Paving_the_way_for_future_ECMAScript_versions
this.import('config');

/**
 * Timer sample.
 */
var timer = require('lib/jstimer'); // CommonJS style require() also available!
timer.setTimeout(function() {
	dump('DELAYED CODE DONE\n');
}, 500);

/**
 * JSDeferred sample.
 */
Deferred.next(function() {
	dump('DEFERRED CODE DONE\n');
});

/**
 * Localized messages sample.
 */
var bundle = require('lib/locale')
				.get(location.href+'/../locale/messages.properties');
dump(bundle.getString('message')+'\n');


/**
 * Sample code for addons around browser windows.
 */
const TYPE_BROWSER = 'navigator:browser';

var global = this;
function handleWindow(aWindow)
{
	var doc = aWindow.document;
	if (doc.documentElement.getAttribute('windowtype') != TYPE_BROWSER)
		return;

	/* sample: hello world */
	var range = doc.createRange();
	range.selectNodeContents(doc.documentElement);
	range.collapse(false);

	var fragment = range.createContextualFragment(here(/*
			<label id="helloworld" value="hello, world!"
				style="background: white; color: blue;"/>
		*/));
	range.insertNode(fragment);

	range.detach();

	/* sample: customizable toolbar button */
	ToolbarItem.create(
		easyTemplate.apply(here(/*
		<toolbarbutton id="restartless-test-button">
			<label value={{ JSON.stringify(bundle.getString('message')) }}/>
		</toolbarbutton>
		*/), global),
		doc.getElementById('nav-bar'),
		{ // options
			onInit : function() {
				Application.console.log('restartless-test-button: inserted ' + this.node);
			},
			onDestroy : function() {
				Application.console.log('restartless-test-button: going to be removed: ' + this.node);
			}
		}
	);

	/* sample: keyboard shortcut */
	KeyboardShortcut.create({<commit_msg>Define handler for the toolbar button<commit_after>/**
 * @fileOverview Main module for restartless addons
 * @author       YUKI "<NAME>
 * @version      2
 *
 * @license
 *   The MIT License, Copyright (c) 2010 YUKI "<NAME>.
 *   https://github.com/piroor/restartless/blob/master/license.txt
 * @url http://github.com/piroor/restartless
 */

dump('main.js loaded\n');

/**
 * load() works like Components.utils.import(). EXPORTED_SYMBOLS
 * in loaded scripts are exported to the global object of this script.
 */
load('lib/jsdeferred');
load('lib/WindowManager');
load('lib/ToolbarItem');
load('lib/KeyboardShortcut');
load('lib/here');
load('lib/easyTemplate');
// this.import() also available instead of load(), as an alias.
// Note: don't use simply "import()" without the prefix "this.",
// because the keyword "import" will be a reserved word in future.
// https://developer.mozilla.org/en/JavaScript/Strict_mode#Paving_the_way_for_future_ECMAScript_versions
this.import('config');

/**
 * Timer sample.
 */
var timer = require('lib/jstimer'); // CommonJS style require() also available!
timer.setTimeout(function() {
	dump('DELAYED CODE DONE\n');
}, 500);

/**
 * JSDeferred sample.
 */
Deferred.next(function() {
	dump('DEFERRED CODE DONE\n');
});

/**
 * Localized messages sample.
 */
var bundle = require('lib/locale')
				.get(location.href+'/../locale/messages.properties');
dump(bundle.getString('message')+'\n');


/**
 * Sample code for addons around browser windows.
 */
const TYPE_BROWSER = 'navigator:browser';

var global = this;
function handleWindow(aWindow)
{
	var doc = aWindow.document;
	if (doc.documentElement.getAttribute('windowtype') != TYPE_BROWSER)
		return;

	/* sample: hello world */
	var range = doc.createRange();
	range.selectNodeContents(doc.documentElement);
	range.collapse(false);

	var fragment = range.createContextualFragment(here(/*
			<label id="helloworld" value="hello, world!"
				style="background: white; color: blue;"/>
		*/));
	range.insertNode(fragment);

	range.detach();

	/* sample: customizable toolbar button */
	ToolbarItem.create(
		easyTemplate.apply(here(/*
		<toolbarbutton id="restartless-test-button" oncommand="alert('hello!');">
			<label value={{ JSON.stringify(bundle.getString('message')) }}/>
		</toolbarbutton>
		*/), global),
		doc.getElementById('nav-bar'),
		{ // options
			onInit : function() {
				Application.console.log('restartless-test-button: inserted ' + this.node);
			},
			onDestroy : function() {
				Application.console.log('restartless-test-button: going to be removed: ' + this.node);
			}
		}
	);

	/* sample: keyboard shortcut */
	KeyboardShortcut.create({
{'fraction_non_alphanumeric': 0.16473494204826145, 'fraction_numerical': 0.0030400912027360822, 'mean_word_length': 4.3225480283114255, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1596866', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1649, 'n_words': 375}