<commit_before>var serviceURL = 'com/cfsilence/service/TestServiceRemote.cfc?_cf_nodebug=true';


// our base object - which all others shall extend
var Entity = Class.extend({
	init: function(){
		this.__type__ = '';  // used for "rehydration" on the cf side
    },
	commit : function() {
		for ( var prop in this ){
			if( this.hasOwnProperty( prop ) && this[prop].hasOwnProperty('commit') ){
					this[prop].commit()
			}
		}
	},
	reset : function() {
		for ( var prop in this ){
			if( this.hasOwnProperty( prop ) && this[prop].hasOwnProperty('reset') ){
				this[prop].reset();
			}
		}
	}
});

/*
 * Model
 */

var Artist = Entity.extend({
	init : function( artistId, art, firstName, lastName, address, city, state, postalCode, email, phone, fax, thePassword ){
		this.artistId = ko.protectedObservable( artistId );
		this.art = ko.observableArray( art );  // doth this need protection? probably not, since it's an array of entities who already are protected.
		this.firstName = ko.protectedObservable( firstName );
		this.lastName = ko.protectedObservable( lastName );
		this.address = ko.protectedObservable( address );
		this.city = ko.protectedObservable( city );
		this.state = ko.protectedObservable( state );
		this.postalCode = ko.protectedObservable( postalCode );
		this.email = ko.protectedObservable( email );
		this.phone = ko.protectedObservable( phone );
		this.fax = ko.protectedObservable( fax );
		this.thePassword = ko.protectedObservable( thePassword );
		this.fullName = ko.computed(function(){ return this.firstName() + ' ' + this.lastName(); }, this);
	}
});

var Art = Entity.extend({
	init : function( artId, artist, artName, description, price, largeImage, media, isSold ){
		this.artId = ko.protectedObservable( artId );
		this.artist = ko.protectedObservable( artist );
		this.artName = ko.protectedObservable( artName );
		this.description = ko.protectedObservable( description );
		this.price = ko.protectedObservable( price );
		this.largeImage = ko.protectedObservable( largeImage );
		this.media = ko.protectedObservable( media );
		this.isSold = ko.protectedObservable( isSold );
	}
});

var Media = Entity.extend({
	init : function( mediaId, mediaType ){
		this.mediaId = ko.protectedObservable( mediaId );
		this.mediaType = ko.protectedObservable( mediaType );
	}
});

/*
 * Service Delegate
 *
 * Abstracts out-of-browser dependencies.  In this case,
 * we're hiding the fact that we use the Amplify framework for easy local storage.
 */
var GalleryService = function () {
    this.loadArtists = function(  ) {
        $.ajax(
			{
				url: serviceURL + '&method=getArtists&returnFormat=JSON',
				success: function(data, textStatus, jqXHR){
					fury.publish( 'artists.loaded', data );
				},
				error: function(e){
					console.log(e)
				}
			}
    	);
    }
}

var GalleryController = function(){
	fury.inject( this, "galleryPresentationModel", "pm", function() { 
	} );
	
	/* Service injection */
    fury.inject( this, "galleryService", "service", function() { });
	
	fury.subscribe( "artist.cancelSave", this, function( data ) {
		// reject the changes so our model isn't dirty
		this.pm.selectedArtist().reset();
		// hide the window
		$('#editArtContainer').modal('hide');
	});
	
	fury.subscribe( "artist.saveRequested", this, function( data ) {
		// validate it
		console.log( ko.toJSON( data.data.selectedArtist() ))
		console.log( JSON.stringify( data.data.selectedArtist() ) )
		console.log( data.data.selectedArtist() )
		console.log( ko.dataFor( this.pm.selectedArtist() )  )
		console.log( JSON.stringify( ko.dataFor( this.pm.selectedArtist() ) ) )
		
		// commit it to the model
		this.pm.selectedArtist().commit();
		
		// save it
		$.ajax(
			{
				type: 'POST',
				url: serviceURL + '&method=saveArtist&returnFormat=JSON',
				data: { artist : ko.toJSON( this.pm.selectedArtist() ) } ,
				success: function(d, textStatus, jqXHR){
					// hide the window
					$('#editArtContainer').modal('hide');
				},
				error: function(e){
					console.log(e)
				}
			}
    	);
		
		
	});
	
	fury.subscribe( "artist.select", this, function( content ) {<commit_msg>remove log stmts<commit_after>var serviceURL = 'com/cfsilence/service/TestServiceRemote.cfc?_cf_nodebug=true';


// our base object - which all others shall extend
var Entity = Class.extend({
	init: function(){
		this.__type__ = '';  // used for "rehydration" on the cf side
    },
	commit : function() {
		for ( var prop in this ){
			if( this.hasOwnProperty( prop ) && this[prop].hasOwnProperty('commit') ){
					this[prop].commit()
			}
		}
	},
	reset : function() {
		for ( var prop in this ){
			if( this.hasOwnProperty( prop ) && this[prop].hasOwnProperty('reset') ){
				this[prop].reset();
			}
		}
	}
});

/*
 * Model
 */

var Artist = Entity.extend({
	init : function( artistId, art, firstName, lastName, address, city, state, postalCode, email, phone, fax, thePassword ){
		this.artistId = ko.protectedObservable( artistId );
		this.art = ko.observableArray( art );  // doth this need protection? probably not, since it's an array of entities who already are protected.
		this.firstName = ko.protectedObservable( firstName );
		this.lastName = ko.protectedObservable( lastName );
		this.address = ko.protectedObservable( address );
		this.city = ko.protectedObservable( city );
		this.state = ko.protectedObservable( state );
		this.postalCode = ko.protectedObservable( postalCode );
		this.email = ko.protectedObservable( email );
		this.phone = ko.protectedObservable( phone );
		this.fax = ko.protectedObservable( fax );
		this.thePassword = ko.protectedObservable( thePassword );
		this.fullName = ko.computed(function(){ return this.firstName() + ' ' + this.lastName(); }, this);
	}
});

var Art = Entity.extend({
	init : function( artId, artist, artName, description, price, largeImage, media, isSold ){
		this.artId = ko.protectedObservable( artId );
		this.artist = ko.protectedObservable( artist );
		this.artName = ko.protectedObservable( artName );
		this.description = ko.protectedObservable( description );
		this.price = ko.protectedObservable( price );
		this.largeImage = ko.protectedObservable( largeImage );
		this.media = ko.protectedObservable( media );
		this.isSold = ko.protectedObservable( isSold );
	}
});

var Media = Entity.extend({
	init : function( mediaId, mediaType ){
		this.mediaId = ko.protectedObservable( mediaId );
		this.mediaType = ko.protectedObservable( mediaType );
	}
});

/*
 * Service Delegate
 *
 * Abstracts out-of-browser dependencies.  In this case,
 * we're hiding the fact that we use the Amplify framework for easy local storage.
 */
var GalleryService = function () {
    this.loadArtists = function(  ) {
        $.ajax(
			{
				url: serviceURL + '&method=getArtists&returnFormat=JSON',
				success: function(data, textStatus, jqXHR){
					fury.publish( 'artists.loaded', data );
				},
				error: function(e){
					console.log(e)
				}
			}
    	);
    }
}

var GalleryController = function(){
	fury.inject( this, "galleryPresentationModel", "pm", function() { 
	} );
	
	/* Service injection */
    fury.inject( this, "galleryService", "service", function() { });
	
	fury.subscribe( "artist.cancelSave", this, function( data ) {
		// reject the changes so our model isn't dirty
		this.pm.selectedArtist().reset();
		// hide the window
		$('#editArtContainer').modal('hide');
	});
	
	fury.subscribe( "artist.saveRequested", this, function( data ) {
		// todo: validate it
		
		// commit it to the model
		this.pm.selectedArtist().commit();
		
		// save it
		$.ajax(
			{
				type: 'POST',
				url: serviceURL + '&method=saveArtist&returnFormat=JSON',
				data: { artist : ko.toJSON( this.pm.selectedArtist() ) } ,
				success: function(d, textStatus, jqXHR){
					// hide the window
					$('#editArtContainer').modal('hide');
				},
				error: function(e){
					console.log(e)
				}
			}
    	);
		
		
	});
	
	fury.subscribe( "artist.select", this, function( content ) {
{'fraction_non_alphanumeric': 0.14718451483157366, 'fraction_numerical': 0.0, 'mean_word_length': 3.6181079512478234, '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': '7528445', 'n_tokens_mistral': 2801, 'n_tokens_neox': 2507, 'n_words': 596}