Sha256: c5a05486190ec2a0f66a63cb27df8c9bdcbadbb5bfabb90dfd583c277f3a8525

Contents?: true

Size: 1.45 KB

Versions: 18

Compression:

Stored size: 1.45 KB

Contents

/*
 01conf.js: javascript for preferences pages of tDiary

 Copyright (C) 2011 by TADA Tadashi <t@tdtds.jp>
 You can redistribute it and/or modify it under GPL2.
 */

$(function(){
	$('#saving')
		.hide()
		.css('text-align', 'center')
		.css('margin-top', '10em');

	$('#conf-form').submit(function(){
		var form = $(this);
		$.ajax({
			type: 'post',
			url: form.attr('action'),
			data: form.serialize() + '&saveconf=OK',
			dataType: 'html',
			beforeSend: function(){
				form.hide();
				$('#saving').show();
			},
			success: function(data){
				if(location.search.match(/conf=(sp|csrf_protection)$/)){
					location.reload();
				} else {
					var result = data.match(/<form id="conf-form"[\s\S]*<\/form>/)[0];
					$('#saving').hide();
					form.empty().append($('div:first', result)).show();
				}
			},
			error: function(){
				$('#saving').hide();
				form.show();
				alert('cannot save!');
			}
		});
		return false;
	});

	/*
	 * old ruby alert
	 */
	$('#alert-old-ruby').on('click', function(){
		var data = 'conf=old_ruby_alert;saveconf=OK';
		var csrf_key = $('#conf-form input[name=csrf_protection_key]').attr('value');
		if (csrf_key){ data += ';csrf_protection_key=' + csrf_key; }

		$.ajax({
			url: $('#conf-form').attr('action'),
			type: 'POST',
			dataType: 'html',
			data: data
		}).done(function(html){
			$('.alert-warn').hide();
		}).fail(function(XMLHttpRequest, textStatus, errorThrown){
			alert('failed saving settings.' + textStatus);
		});
	});
});

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
tdiary-4.0.2.20140201 js/01conf.js
tdiary-4.0.2 js/01conf.js
tdiary-4.0.1.20131102 js/01conf.js
tdiary-4.0.1.20130929 js/01conf.js
tdiary-4.0.1.20130903 js/01conf.js
tdiary-4.0.1 js/01conf.js
tdiary-4.0.0.20130826 js/01conf.js
tdiary-4.0.0 js/01conf.js
tdiary-3.2.2.20130727 js/01conf.js
tdiary-3.2.2.20130722 js/01conf.js
tdiary-3.2.2.20130720 js/01conf.js
tdiary-3.2.2.20130617 js/01conf.js
tdiary-3.2.2.20130614 js/01conf.js
tdiary-3.2.2.20130604 js/01conf.js
tdiary-3.2.2.20130527 js/01conf.js
tdiary-3.2.2.20130518 js/01conf.js
tdiary-3.2.2.20130508 js/01conf.js
tdiary-3.2.2.20130507 js/01conf.js