<commit_before>/* 
 * Author: <NAME> 
 * Date: 07.2010
 *
 */

var openZIMformsave = {
    autosave : 900000,
    
    replaceForm: function(data) {
    	openZIMtinyMce.removeEditors();
    	$('#form_data').replaceWith($(data).find('#form_data'));
    	// re-init tiny mces
    	openZIMtinyMce.setup();
    	// re init expanders
    	openZIMExpander.init();
    },
	doSave: function() {
	     var self = this;
      	 $('.form_loader').show();
      
	      // do not do ajax call if there are any
	      // non-empty file inputs
	      if ( self.ajaxError || $.browser.msie || 
		   $("input:file[value|='']").length > 0 )
	    	  return true;

	      self.ajaxError = false;

	      tinyMCE.triggerSave();
	      $.post( $('#ajax_form').attr('action') + '?random=' + Math.random()*99999,
	    		  $('#ajax_form').serializeArray(), function(data) {
	    	  		self.replaceForm(data);
	    	  		$('.form_loader').hide();
	    		  })
	    		  .error(function() {
	    			  self.ajaxError = true;
	    			  $('#ajax_form').submit();
	    		  });

	      return false;
	},

	cancel: function() {
	    if(typeof this.timeoutID == "number") {
	      window.clearTimeout(this.timeoutID);
	      delete this.timeoutID;
	    }
	},

	setTimeout: function() {
	  var self = this;
	  self.cancel();
	  self.timeoutID = window.setTimeout(function(){
		  $('#ajax_form').submit();
	  }, self.autosave);
	},

	setSaveEvent: function(elem){
		elem.keydown(function(event){
			if ((String.fromCharCode(event.which).toLowerCase() == 's' && event.ctrlKey)){
				$('#ajax_form').submit();
				return false;
			}
		});
	},

	setup: function() {
	  var self = this;
	  self.setTimeout();
	  $('#ajax_form').submit(function() {
		self.setTimeout();
		return self.doSave();
	  });

	  // bind ctrl+s to tiny mces
	  tinyMCE.onAddEditor.add(function(mgr,ed) {
		  ed.onInit.add(function(ed) {
			  self.setSaveEvent($(ed.getDoc()));
		  });
	  });<commit_msg>ajaxformsave: add osx keycode<commit_after>/* 
 * Author: <NAME> 
 * Date: 07.2010
 *
 */

var openZIMformsave = {
    autosave : 900000,
    
    replaceForm: function(data) {
    	openZIMtinyMce.removeEditors();
    	$('#form_data').replaceWith($(data).find('#form_data'));
    	// re-init tiny mces
    	openZIMtinyMce.setup();
    	// re init expanders
    	openZIMExpander.init();
    },
	doSave: function() {
	     var self = this;
      	 $('.form_loader').show();
      
	      // do not do ajax call if there are any
	      // non-empty file inputs
	      if ( self.ajaxError || $.browser.msie || 
		   $("input:file[value|='']").length > 0 )
	    	  return true;

	      self.ajaxError = false;

	      tinyMCE.triggerSave();
	      $.post( $('#ajax_form').attr('action') + '?random=' + Math.random()*99999,
	    		  $('#ajax_form').serializeArray(), function(data) {
	    	  		self.replaceForm(data);
	    	  		$('.form_loader').hide();
	    		  })
	    		  .error(function() {
	    			  self.ajaxError = true;
	    			  $('#ajax_form').submit();
	    		  });

	      return false;
	},

	cancel: function() {
	    if(typeof this.timeoutID == "number") {
	      window.clearTimeout(this.timeoutID);
	      delete this.timeoutID;
	    }
	},

	setTimeout: function() {
	  var self = this;
	  self.cancel();
	  self.timeoutID = window.setTimeout(function(){
		  $('#ajax_form').submit();
	  }, self.autosave);
	},

	setSaveEvent: function(elem){
		elem.keydown(function(event){
			if ((String.fromCharCode(event.which).toLowerCase() == 's' && event.ctrlKey) ||
					(event.which == 19)){
				$('#ajax_form').submit();
				return false;
			}
		});
	},

	setup: function() {
	  var self = this;
	  self.setTimeout();
	  $('#ajax_form').submit(function() {
		self.setTimeout();
		return self.doSave();
	  });

	  // bind ctrl+s to tiny mces
	  tinyMCE.onAddEditor.add(function(mgr,ed) {
		  ed.onInit.add(function(ed) {
			  self.setSaveEvent($(ed.getDoc()));
		  });
	  });
{'fraction_non_alphanumeric': 0.18456032719836402, 'fraction_numerical': 0.009713701431492843, 'mean_word_length': 2.5062724014336917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1644215', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1338, 'n_words': 223}