1 min

Splitscreen.js

var MINI = require('minified');
var $ = MINI.$, $$ = MINI.$$, EE = MINI.EE;

$(function() {
$('#moveButton').on('click', function() {
$('#text_preview').animate({$$fade: 0}, 500); // fade out
$('#tx_input').animate({$$fade: 1}, 500); // fade in
$('#col_right').set('$', '+col -singlecol');
$('#col_left').set('$', '+singlecol -col');
$('#col_right').set({$float: 'right'} );
$('#col_right').set({$position: 'relative'} );
document.getElementById('tx_input').focus();
});

$('#resetButton').on('click', function() {
$('#tx_input').animate({$$fade: 1}, 500); // fade in
$('#text_preview').animate({$$fade: 1}, 500); // fade in
$('#col_left').set('$', '+col -singlecol');
$('#col_right').set('$', '+col -singlecol');
$('#col_right').set({$float: 'right'} );
$('#col_right').set({$position: 'relative'} );
document.getElementById('tx_input').focus();
});

$('#previewButton').on('click', function() {
var col_type = $('#col_left').get('@class');

// alert($('#parulaform').get('@action'));
var action = $('#splitscreenaction').get('@value');
var cgiapp = $('#splitscreencgiapp').get('@value');

if ( col_type === "singlecol" ) {
$('#col_left').set('$', '+col -singlecol');
$('#tx_input').animate({$$fade: 0}, 500); // fade out
$('#col_right').set('$', '+singlecol -col');
$('#col_right').set({$float: 'left'} );
$('#col_right').set({$position: 'absolute'} );
$('#text_preview').animate({$$fade: 1}, 500); // fade in
}

var markup = $$('#tx_input').value;
markup=escape(markup);
// $.request('post', 'http://jothut.com/cgi-bin/d16augjunco.pl/addarticle', {article: markup, sb: 'Preview', formtype: 'ajax'})
$.request('post', cgiapp + '/' + action , {article: markup, sb: 'Preview', formtype: 'ajax'})
.then(function(response) {
$('#text_preview').set('innerHTML', response);
})
.error(function(status, statusText, responseText) {
$('#text_preview').fill('response could not be completed.');
});
});

$('#saveButton').on('click', function() {
var col_type = $('#col_left').get('@class');

var action = $('#splitscreenaction').get('@value');
var cgiapp = $('#splitscreencgiapp').get('@value');

// $('#text_preview').animate({$$fade: 1}, 500); // fade in
// $('#col_left').set('$', '+col -singlecol');

var markup = $$('#tx_input').value;
markup=escape(markup);
// $.request('post', 'http://jothut.com/cgi-bin/d16augjunco.pl/addarticle', {article: markup, sb: 'Save', formtype: 'ajax'})
$.request('post', cgiapp + '/' + action, {article: markup, sb: 'Save', formtype: 'ajax'})
.then(function(response) {
$('#text_preview').set('innerHTML', response);
var regex = /^Error: /;
if ( regex.test(response) ) {
$('#text_preview').animate({$$fade: 1}, 500); // fade in
$('#col_left').set('$', '+col -singlecol');
} else {
$('#saveposttext').set({$color: '#fff'});
setTimeout(function() {$('#saveposttext').set({$color: '#120a8f'})}, 2000);
}
})
.error(function(status, statusText, responseText) {
$('#text_preview').fill('response could not be completed.');
});
});
});

From JR's : articles
264 words - 3647 chars - 1 min read
created on
updated on - #
source - versions



A     A     A     A     A

© 2013-2017 JotHut - Online notebook

current date: May 10, 2025 - 3:56 p.m. EDT