<commit_before>﻿/// <reference path="../elements.d.ts" />

namespace DefaultLinkElement {
	export const defaultLinkProperties: {
		href: string;
		defaultName: string;
		searchEngine: boolean;
	} = {
		searchEngine: {
			type: Boolean,
			notify: true,
			value: false
		},
		href: {
			type: String,
			notify: true
		},
		defaultName: {
			type: String,
			notify: true
		}
	} as any;

	export class DL {
		static is: string = 'default-link';

		static properties = defaultLinkProperties;

		static onClick(this: DefaultLink) {
			const link = this.href;
			const name = this.$.input.value;
			const script =
				`var query;
	var url = "${link}";
	if (crmAPI.getSelection()) {
		query = crmAPI.getSelection();
	} else {
		query = window.prompt(\'Please enter a search query\');
	}
	if (query) {
		window.open(url.replace(/%s/g,query), \'_blank\');
	}`;

			let newItem;
			if (this.searchEngine !== undefined) {
				newItem = window.app.templates.getDefaultScriptNode({
					id: window.app.generateItemId(),
					name: name,
					value: {
						script: script
					}
				});
			} else {
				newItem = window.app.templates.getDefaultLinkNode({
					id: window.app.generateItemId(),
					name: name,
					value: [
						{
							url: link,<commit_msg>is a bit more lenient in searchEngine property truthyness<commit_after>﻿/// <reference path="../elements.d.ts" />

namespace DefaultLinkElement {
	export const defaultLinkProperties: {
		href: string;
		defaultName: string;
		searchEngine: boolean;
	} = {
		searchEngine: {
			type: Boolean,
			notify: true,
			value: false
		},
		href: {
			type: String,
			notify: true
		},
		defaultName: {
			type: String,
			notify: true
		}
	} as any;

	export class DL {
		static is: string = 'default-link';

		static properties = defaultLinkProperties;

		static onClick(this: DefaultLink) {
			const link = this.href;
			const name = this.$.input.value;
			const script =
				`var query;
	var url = "${link}";
	if (crmAPI.getSelection()) {
		query = crmAPI.getSelection();
	} else {
		query = window.prompt(\'Please enter a search query\');
	}
	if (query) {
		window.open(url.replace(/%s/g,query), \'_blank\');
	}`;

			let newItem;
			if (this.searchEngine) {
				newItem = window.app.templates.getDefaultScriptNode({
					id: window.app.generateItemId(),
					name: name,
					value: {
						script: script
					}
				});
			} else {
				newItem = window.app.templates.getDefaultLinkNode({
					id: window.app.generateItemId(),
					name: name,
					value: [
						{
							url: link,
{'fraction_non_alphanumeric': 0.14178515007898895, 'fraction_numerical': 0.0, 'mean_word_length': 2.832072617246596, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '964014', 'n_tokens_mistral': 1037, 'n_tokens_neox': 839, 'n_words': 202}