<commit_before>Cards.module('Set.Details', function(Details, App) {
	Details.NewCardView = Backbone.Marionette.ItemView.extend({
		template: "#set-details-newcard",
		events: {
			"click .btn-success": "saveCard",
			"click .btn.cancel": "cancel",
			"click .btn-pictureSearch": "pictureSearch",
			"keyup input": "keyupInput",
			"focus input": "focusInput"
		},
		ui: {
			saveBtn: ".btn-success",
			cancelBtn: ".btn.cancel",
			picSearchFrontbtn: "#set-details-newcard-btn-pic-front-seach",
			pictureSearchModal: "#pictureSearchModal"
		},
		cancel: function(ev) {
			history.back();
		},
		saveCard: function(ev) {
			this.ui.saveBtn.button('loading');

			var setId = this.model.get('id');
			var setName = this.model.get('name');

			var card = new Cards.Entities.Card({
				front: {
					text: $("#front-textarea").val(),
					text_plain: $("#front-textarea").val().replace(/(<([^>]+)>)/ig,""),
					picture: $("#set-details-newcard-input-pic-front-search").val() || null,
					video: null
				},
				back: {
					text: $("#back-textarea").val(),
					text_plain: $("#back-textarea").val().replace(/(<([^>]+)>)/ig,""),
					picture: $("#set-details-newcard-input-pic-back-search").val() || null,
					video: null
				},
				setId: setId
			});

			if(card.isValid()) {
				card.save({}, {
					success: function(model, response) {
						Cards.trigger("set:details", setId);
					},
					error: function(model, error) {
						this.ui.saveBtn.button('reset');
						alert("something went wrong");
					}
				});
			} else {
				alert('not valid');
				this.ui.saveBtn.button('reset');
			}
		},
		pictureSearch: function(ev) {
			ev.preventDefault();
			var that = this;

			var searchInput = $(ev.target).parent().prev();
			var searchString = searchInput.val();

			console.log("searching for", searchString);

			
			/*var loadSearch = function() {
				console.log("search loaded");
			}
			<commit_msg>fix for newcard: back to correct view<commit_after>Cards.module('Set.Details', function(Details, App) {
	Details.NewCardView = Backbone.Marionette.ItemView.extend({
		template: "#set-details-newcard",
		events: {
			"click .btn-success": "saveCard",
			"click .btn.cancel": "cancel",
			"click .btn-pictureSearch": "pictureSearch",
			"keyup input": "keyupInput",
			"focus input": "focusInput"
		},
		ui: {
			saveBtn: ".btn-success",
			cancelBtn: ".btn.cancel",
			picSearchFrontbtn: "#set-details-newcard-btn-pic-front-seach",
			pictureSearchModal: "#pictureSearchModal"
		},
		cancel: function(ev) {
			history.back();
		},
		saveCard: function(ev) {
			this.ui.saveBtn.button('loading');

			var setId = this.model.get('id');
			var setName = this.model.get('name');

			var card = new Cards.Entities.Card({
				front: {
					text: $("#front-textarea").val(),
					text_plain: $("#front-textarea").val().replace(/(<([^>]+)>)/ig,""),
					picture: $("#set-details-newcard-input-pic-front-search").val() || null,
					video: null
				},
				back: {
					text: $("#back-textarea").val(),
					text_plain: $("#back-textarea").val().replace(/(<([^>]+)>)/ig,""),
					picture: $("#set-details-newcard-input-pic-back-search").val() || null,
					video: null
				},
				setId: setId
			});

			if(card.isValid()) {
				card.save({}, {
					success: function(model, response) {
						history.back();
					},
					error: function(model, error) {
						this.ui.saveBtn.button('reset');
						alert("something went wrong");
					}
				});
			} else {
				alert('not valid');
				this.ui.saveBtn.button('reset');
			}
		},
		pictureSearch: function(ev) {
			ev.preventDefault();
			var that = this;

			var searchInput = $(ev.target).parent().prev();
			var searchString = searchInput.val();

			console.log("searching for", searchString);

			
			/*var loadSearch = function() {
				console.log("search loaded");
			}
			
{'fraction_non_alphanumeric': 0.20396970488378166, 'fraction_numerical': 0.0, 'mean_word_length': 3.2180616740088106, 'pattern_counts': {'":': 10, '<': 7, '<?xml version=': 0, '>': 11, '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': '931461', 'n_tokens_mistral': 1599, 'n_tokens_neox': 1265, 'n_words': 221}