public/js/buttonClick.js
/*
 * Function that is called when the document is ready.
 */
Function that is called when the document is ready.
Function that is called when the document is ready .
function initializePage() {
	$('.selectCategory').click(function(e) {
		if($(this).attr("class") == "selectCategory"){
			console.log("Button is selected " + $(this).attr("value"));
		}
		$(this).toggleClass("selected");
	});
	$('.submitButton').click(function(e) {
		var elements = document.querySelectorAll("input[type=button]");   
		var categories = " ";
		for(var i = 0, len = elements.length; i < len; i++) {   
  			console.log("Button: " +  elements[i].value);
  			console.log(elements[i].className);
  			if(elements[i].className == "selectCategory selected"){
  				categories += elements[i].value + " ";
  			}
		}
		$('.entry').val($('.entry').val() + categories);
		console.log("Current entry is: " + $('.entry').val());
	});
	$('include_form').submit(function(e){
		e.preventDefault();
		console.log('include');
		var new_term = $('#include_terms').val();
		console.log(new_term);
	});
	$('exclude_form').submit(function(e){
		e.preventDefault();
		console.log('exclude');
		var new_term = $('#exclude_terms').val();
		console.log(new_term);
	});
}
function initializePage ( ) { $ ( '.selectCategory' ) . click ( function ( e ) { if ( $ ( this ) . attr ( "class" ) == "selectCategory" ) { console . log ( "Button is selected " + $ ( this ) . attr ( "value" ) ) ; } $ ( this ) . toggleClass ( "selected" ) ; } ) ; $ ( '.submitButton' ) . click ( function ( e ) { var elements = document . querySelectorAll ( "input[type=button]" ) ; var categories = " " ; for ( var i = 0 , len = elements . length ; i < len ; i ++ ) { console . log ( "Button: " + elements [ i ] . value ) ; console . log ( elements [ i ] . className ) ; if ( elements [ i ] . className == "selectCategory selected" ) { categories += elements [ i ] . value + " " ; } } $ ( '.entry' ) . val ( $ ( '.entry' ) . val ( ) + categories ) ; console . log ( "Current entry is: " + $ ( '.entry' ) . val ( ) ) ; } ) ; $ ( 'include_form' ) . submit ( function ( e ) { e . preventDefault ( ) ; console . log ( 'include' ) ; var new_term = $ ( '#include_terms' ) . val ( ) ; console . log ( new_term ) ; } ) ; $ ( 'exclude_form' ) . submit ( function ( e ) { e . preventDefault ( ) ; console . log ( 'exclude' ) ; var new_term = $ ( '#exclude_terms' ) . val ( ) ; console . log ( new_term ) ; } ) ; }
Function that is called when the document is ready.
Function that is called when the document is ready .
//include.push({"term" : new_term}); //exclude.push({"term" : new_term});