<commit_before>/*
 * Class representing the Jetpack only 
 * Prepare the editor, save, update
 */
var Jetpack = new Class({
	Extends: Capability,
	type: 'jetpack',
	options: {
		description_el: {element: 'jetpack_description'},
		try_in_browser_el: 'try_in_browser',
		// try_in_browser_url: ''
	},
	/*
	 * Method: initialize
	 * @attribute object options: 
	 * 	
	 * initialize Version and inside of that chosen FDEditor
	 * assign actions to the buttons
	 */
	initialize: function(options) {
		this.setOptions(options);
		if (!this.options.version.manifest) {
			this.options.version.manifest = this.generateInitialManifest();
			// TODO: REFACTOR: this is actually a hack!
			$('version_manifest').set('text', this.options.version.manifest);
		}
		this.parent(this.options);
	},
	
	listenToEvents: function() {
		this.parent();
		// one may try even not edited data
		var try_in_browser_el = $(this.options.try_in_browser_el)
		if (try_in_browser_el) {
			try_in_browser_el.addEvent('click', function(e) {
				e.stop();
				this.try_in_browser();
			}.bind(this));
		}
	},
	/*
	 * Method: try_in_browser
	 * Prepare Capability using saved content and install temporary in the browser
	 */
	try_in_browser: function() {
		var data = this.getFullData();
		//fd.warning.alert('Not implemented','try_in_browser');
		new Request.JSON({
			url: this.options.try_in_browser_url,
			method: 'post',
			data: data,
			onSuccess: function(response) {
				if (response.stderr) {
					fd.error.alert('Error',response.stderr);
					$log(response);
					return;
				}
				fd.message.alert('Debug','XPI created - sending data to Fd addon');
				// now call the add-on
				console.log(response);
				this.install_xpi(response.get_xpi_url);
			}.bind(this)
		}).send();
	},
	install_xpi: function(url) {
		$log(url)
	},
	/*
	 * Method: initializeVersion
	 * assigns JetVersion to this.version
	 */
	initializeVersion: function() {
		this.version = new JetVersion(this.options.version);
	},
	/*
	 * Method: updateFromDOM
	 * get all jetpack editable fields from DOM and set parameters in model
	 */
	updateFromDOM: function() {
		this.parent();
	},
	getManifestData: function() {
		return {
			name: this.options.slug,
			fullName: this.options.name,
			description: this.options.description,
			author: this.options.creator
		}
	},
	generateManifest: function() {<commit_msg>collaborating with the FD add on<commit_after>/*
 * Class representing the Jetpack only 
 * Prepare the editor, save, update
 */
var Jetpack = new Class({
	Extends: Capability,
	type: 'jetpack',
	options: {
		description_el: {element: 'jetpack_description'},
		try_in_browser_el: 'try_in_browser',
		// try_in_browser_url: ''
	},
	/*
	 * Method: initialize
	 * @attribute object options: 
	 * 	
	 * initialize Version and inside of that chosen FDEditor
	 * assign actions to the buttons
	 */
	initialize: function(options) {
		this.setOptions(options);
		if (!this.options.version.manifest) {
			this.options.version.manifest = this.generateInitialManifest();
			// TODO: REFACTOR: this is actually a hack!
			$('version_manifest').set('text', this.options.version.manifest);
		}
		this.parent(this.options);
	},
	
	listenToEvents: function() {
		this.parent();
		// one may try even not edited data
		var try_in_browser_el = $(this.options.try_in_browser_el)
		if (try_in_browser_el) {
			try_in_browser_el.addEvent('click', function(e) {
				e.stop();
				this.try_in_browser();
			}.bind(this));
		}
	},
	/*
	 * Method: try_in_browser
	 * Prepare Capability using saved content and install temporary in the browser
	 */
	try_in_browser: function() {
		var data = this.getFullData();
		//fd.warning.alert('Not implemented','try_in_browser');
		new Request.JSON({
			url: this.options.try_in_browser_url,
			method: 'post',
			data: data,
			onSuccess: function(response) {
				if (response.stderr) {
					fd.error.alert('Error',response.stderr);
					return;
				}
				fd.message.alert('Debug','XPI created - sending data to FD addon');
				// now call the add-on
				this.install_xpi(response.get_xpi_url);
			}.bind(this)
		}).send();
	},
	install_xpi: function(url) {
		install(url)
	},
	/*
	 * Method: initializeVersion
	 * assigns JetVersion to this.version
	 */
	initializeVersion: function() {
		this.version = new JetVersion(this.options.version);
	},
	/*
	 * Method: updateFromDOM
	 * get all jetpack editable fields from DOM and set parameters in model
	 */
	updateFromDOM: function() {
		this.parent();
	},
	getManifestData: function() {
		return {
			name: this.options.slug,
			fullName: this.options.name,
			description: this.options.description,
			author: this.options.creator
		}
	},
	generateManifest: function() {
{'fraction_non_alphanumeric': 0.13436967632027258, 'fraction_numerical': 0.0, 'mean_word_length': 3.7253521126760565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '5277047', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1520, 'n_words': 353}