Files
mythoughts/masks/write.html
2015-08-24 23:03:22 +02:00

176 lines
6.4 KiB
HTML
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div id="write">
<div id="write_feedback"></div>
<div id="nav">
<a class="fa fa-prev"></a>
<span class="page_nb">1</span>
<A class="fa fa-next"></a>
</div>
<textarea id="editor"></textarea>
</div>
<script type="text/javascript">
var sText = //'<p>David na pas fait grand chose, il a juste créé un embryon de programme. Mais ce programme sest développé lui-même. Comme lordinateur de David nétait pas suffisant, il a utilisé le réseau pour sinstaller sur les autres ordinateurs. Il a grandi alors de manière exponentielle et le voilà : Prélude. Connecté à tout les ordinateurs et capable de leur donner les ordres quil veut.</p>'
//+'<p>Il sort de son lit, les yeux dans un brouillard Londonien, avance jusqu\'à la salle de bain dont la baignoire a été remplie cinq minutes avant par l\'ordinateur de la maison, et va directement prendre un bain. Un bain moussant comme tout les matins. Un bain bien chaud. Et comme il est trop grand pour sa baignoire, ses pieds dépassent. Quelques minutes plus tard, il sendort. Aucun risque de noyade.</p>'
//+'<p>« Prélude mavait dit quil désirait connaître lamour. Les ordinateurs nont pas de sentiments et lamour nest que sentiments. Il y a bien lamour physique, mais sans les sentiments, cela ressemble davantage à un instinct de reproduction quà de lamour. Un ordinateur na pas ce besoin de reproduction. Et pourquoi mavoir choisi ? »</p>'
//+'<p>« Oui, mais rien dexceptionnel. » David essai de se rappeler si dans la lancé de sa jeunesse fougueuse, il naurait pas installé une bombe logique sur les ordinateurs de larmée, mais il ne se rappelait pas avoir fait une telle bêtise. Planter tout le système informatique de la base aurait été trop grave de conséquences.</p>'
'<p>So, I\'m there, wondering about myself and my future - such a luxury by the way - when suddenly, someone approaches. mid-40s i\'d say, elegant cold women, the kind you\'ve learned not to talk to, to eventually avoid feeling repressed, or bad for yourself, or both.</p>'
+'<p>Anyhow, it would seem that in this particular situation, the choice wasn\'t given to me to decide whether or not to talk to that precise women. She seats down next to me and engage a conversation. \'How is it you\'re here today?\' I\'m already regretting not having gone away when i still had the chance.</p>'
+'<p>\'Hello to you too\' I say, still willing to show some manhood, even though I already know this women crushes manhood by pairs as a breakfast ritual.'
+'<p>In-extremist, I manage to babble some excuses about a rigorous lunch break time and leave the premises.</p>';
oMyThoughts.pageInit = function(asHash, bFirstPage)
{
self.vars('counter', 0);
self.vars('id', 0);
self.vars('default_text', '<p><br></p>');
self.vars('working', false);
self.vars('prec_displayed', 0);
self.vars('prec_content', 0);
self.vars('page', $('.page_nb').text());
$('#editor')
.jqte({
br: false,
center: false,
color: false,
fsize: false,
format: false,
indent: false,
link: false,
left: false,
outdent: false,
placeholder: "It all started here",
remove:false,
right:false,
rule:false,
source:false,
sub:false,
sup:false,
title:false,
unlink:false,
change: function(){
//First run
if(!self.vars('editor'))
{
self.vars('max_height', $('.jqte').height());
self.vars('editor', $('.jqte_editor'));
self.vars('editor').css('height', '100%');
self.vars('editor').css('min-height', self.vars('editor').height());
self.vars('editor').css('height', 'auto');
}
//Fixing "empty" content
var sContent = self.vars('editor').html();
if(sContent=='<br>' || sContent=='') $('#editor').jqteVal(self.vars('default_text'));
if(self.vars('counter')%100==0)
{
//Saving
save(sContent);
}
//Adjust book behaviour
if(!self.vars('working')) checkPageBook();
self.vars('counter', self.vars('counter')+1);
}
})
.jqteVal(sText);
//.jqteVal(self.vars('default_text'));
$('.jqte_tool_4')
.attr('title', 'Bold (Ctrl+B)');
$('.jqte_tool_5')
.attr('title', 'Italic (Ctrl+I)');
$('.jqte_tool_6')
.attr('title', 'Underline (Ctrl+U)');
$('.jqte_tool_7')
.attr('title', 'Numbered List (Ctrl+.)');
$('.jqte_tool_8')
.attr('title', 'List (Ctrl+,)');
$('.jqte_tool_16')
.attr('title', 'Strike through (Ctrl+K)')
.insertAfter($('.jqte_tool_6'));
$('.fa-prev').click(function(){moveToPage(-1);});
$('.fa-next').click(function(){moveToPage(1);});
};
oMyThoughts.onFeedback = function(sType, sMsg)
{
var $Feedback = $('#write_feedback');
$Feedback
.stop()
.fadeOut($Feedback.is(':empty')?0:'fast', function(){
$(this)
.empty()
.append($('<span>', {'class':sType}).text(sMsg))
.fadeIn('fast');
});
};
oMyThoughts.onQuitPage = function()
{
save();
return true;
};
function save(sContent)
{
if(sContent != self.vars('default_text'))
{
oMyThoughts.onFeedback('info', 'Saving...');
getInfo
(
'update',
function(asData)
{
self.vars('id', asData.id_thought);
oMyThoughts.onFeedback('notice', 'Saved ('+asData.led.substr(11, 5)+')');
},
{content:sContent, id:self.vars('id')},
function(sError)
{
oMyThoughts.onFeedback('error', 'Not saved! Un error occured: '+sError);
},
'POST'
);
}
}
function checkPageBook()
{
self.vars('working', true);
var iEm = $(1).toPx();
iEm = iEm.substr(0, iEm.length - 2);
$Editor = self.vars('editor');
//Content Height
var iContentHeight = $Editor.height();
//Calculates what should be displayed
iDisplayedHeight = iContentHeight % self.vars('max_height');
console.log(iContentHeight+'%'+self.vars('max_height')+'='+iDisplayedHeight);
//Navigation
var iNewPage = Math.ceil(iContentHeight / self.vars('max_height'));
moveToPage(iNewPage);
self.vars('prec_displayed', iDisplayedHeight);
self.vars('prec_content', iContentHeight);
self.vars('working', false);
}
function moveToPage(iNewPage)
{
if(iNewPage!=self.vars('page'))
{
self.vars('page', iNewPage);
console.log('moving to page '+self.vars('page'));
$('.page_nb').text(self.vars('page'));
self.vars('editor').css('top', (self.vars('page') - 1)*self.vars('max_height')*-1);
}
}
</script>