Commit 757e74d1 authored by Claudio Valerio's avatar Claudio Valerio

imported Maxim changes to persist changes

parent 6e181605
......@@ -28,7 +28,16 @@ function checkResponse()
var sentence = "this is\nan example\nsentence";
var sentence = "";
var curSentence = "";
if(window.sankore){
sentence = (sankore.preference("rightOrdPhrases", ""))?sankore.preference("rightOrdPhrases", ""):"this is\nan example\nsentence";
curSentence = (sankore.preference("currentOrdPhrases", ""))?sankore.preference("currentOrdPhrases", ""):"";
} else {
sentence = "this is\nan example\nsentence";
}
var doCheck = true;
// array of dom elements
......@@ -143,8 +152,13 @@ function modeView()
// clean the previous word
$( "#mp_word" ).empty();
var phrases;
// create new set of elements
var phrases = shuffle( createElements( sentence ) );
if(window.sankore && curSentence && !editMode)
phrases = createElements( curSentence );
else
phrases = shuffle( createElements( sentence ) );
for( i in phrases ){
$("#mp_word").append( phrases[i] );
}
......@@ -153,7 +167,9 @@ function modeView()
// the answer, so no update parameter would be needed
$( "#mp_word" ).sortable();
if( !isSankore ){
$( "#mp_word" ).sortable( { update: checkSentence } );
$( "#mp_word" ).sortable( {
update: checkSentence
} );
} else
$( "#mp_word" ).sortable();
......@@ -172,7 +188,9 @@ adjust width or height
*/
function adjust( height )
{
$( "#mp_word" ).animate( {height: height } );
$( "#mp_word" ).animate( {
height: height
} );
// if viewed as a widget, resize the window
if( !isBrowser ){
window.resizeTo( widget.width, height + widget_padding );
......@@ -200,6 +218,19 @@ function modeEdit()
adjust( $( "#mp_word textarea" ).outerHeight() );
}
$(window).mouseout(function(){
if(window.sankore){
var ph = [];
$( "#mp_word .phrase" ).each( function()
{
ph.push( $( this ).text() );
});
sankore.setPreference("currentOrdPhrases", ph.join( "\n" ));
sankore.setPreference("rightOrdPhrases", sentence);
}
});
$(document).ready(function()
{
......
......@@ -28,7 +28,16 @@ function checkResponse()
var word = "a*long*,*long*time*ago*...";
var word = "";
var curWord = "";
if(window.sankore){
word = (sankore.preference("rightOrdWords", ""))?sankore.preference("rightOrdWords", ""):"a*long*,*long*time*ago*...";
curWord = (sankore.preference("currentOrdWords", ""))?sankore.preference("currentOrdWords", ""):"";
} else {
word = "a*long*,*long*time*ago*...";
}
var img = "template/images/horse.png";
var doCheckWord = true;
......@@ -156,7 +165,12 @@ function modeView()
$( "#mp_word" ).empty();
// create new set of letters
var letters = shuffle( createWordLetters( word ) );
var letters;
if(window.sankore && curWord && !editMode)
letters = createWordLetters( curWord );
else
letters = shuffle( createWordLetters( word ) );
for( i in letters ){
$("#mp_word").append( letters[i] );
}
......@@ -164,7 +178,9 @@ function modeView()
// in sankore api there would be a function to check
// the answer, so no update parameter would be needed
if( !isSankore ){
$( "#mp_word" ).sortable( { update: checkWord } );
$( "#mp_word" ).sortable( {
update: checkWord
} );
} else $( "#mp_word" ).sortable();
// adjustWidth
......@@ -200,7 +216,9 @@ adjustWidth
*/
function adjustWidth( width )
{
$( "#ub-widget" ).animate( {width: width } );
$( "#ub-widget" ).animate( {
width: width
} );
// if viewed as a widget, resize the window
if( !isBrowser ){
window.resizeTo( width + widget_padding, widget.height );
......@@ -227,6 +245,17 @@ function modeEdit()
adjustWidth( input_width );
}
$(window).mouseout(function(){
if(window.sankore){
var str = "";
$( "#mp_word .letter" ).each( function(){
str += $(this).text();
});
sankore.setPreference("currentOrdWords", str);
sankore.setPreference("rightOrdWords", word);
}
});
$(document).ready(function()
{
......
......@@ -21,10 +21,17 @@ function createElements( phrase )
$(document).ready(function()
{
var w = new wcontainer( "#ub-widget" );
var sentence = "";
if(window.sankore)
sentence = (sankore.preference("ordSplPhrases", ""))?sankore.preference("ordSplPhrases", ""):"this is a bunch of words which should be split apart";
else
sentence = "this is a bunch of words which should be split apart";
w.maxWidth = 600;
w.setEditContent( '<div class="inputwrap"><textarea class="percent">this is a bunch of words which should be split apart</textarea></div>' );
w.setEditContent( '<div class="inputwrap"><textarea class="percent">' + sentence + '</textarea></div>' );
w.setViewContent( '<div class="upper"><div class="dash fixed">. </div></div>' );
w.setData( "dashWidth", w.elements.container.find( ".dash" ).outerWidth() );
w.setViewContent( '<div class="upper"><div class="dash fixed">M</div></div>' );
......@@ -116,7 +123,10 @@ $(document).ready(function()
h = parseInt( square / w );
}
return { w: w, h: h+dh };
return {
w: w,
h: h+dh
};
};
// editSize
......@@ -161,4 +171,10 @@ $(document).ready(function()
w.modeView();
$(window).mouseout(function(){
if(window.sankore){
sankore.setPreference("ordSplPhrases", w.getData("phrase"));
}
});
});
\ No newline at end of file
......@@ -24,9 +24,16 @@ $(document).ready(function()
{
var w = new wcontainer( "#ub-widget" );
var sentences = "";
if(window.sankore)
sentences = (sankore.preference("ordSplText", ""))?sankore.preference("ordSplText", ""):"hello, this is the first sentence. hi, this is the second sentence. hello again, this is the third sentence. good morning, this is the fifth sentence. hi, sorry, i\'m late, i\'m the fourth sentence.";
else
sentences = "hello, this is the first sentence. hi, this is the second sentence. hello again, this is the third sentence. good morning, this is the fifth sentence. hi, sorry, i\'m late, i\'m the fourth sentence.";
w.maxWidth = 600;
w.setEditContent( '<div class="inputwrap"><textarea class="percent">hello, this is the first sentence. hi, this is the second sentence. hello again, this is the third sentence. good morning, this is the fifth sentence. hi, sorry, i\'m late, i\'m the fourth sentence.</textarea></div>' );
w.setEditContent( '<div class="inputwrap"><textarea class="percent">' + sentences + '</textarea></div>' );
w.setViewContent( '<div class="upper"><div class="dash fixed">. </div></div>' );
w.setData( "dashWidth", w.elements.container.find( ".dash" ).outerWidth() );
w.setViewContent( '<div class="upper"><div class="dash fixed">M</div></div>' );
......@@ -117,7 +124,10 @@ $(document).ready(function()
h = parseInt( square / w );
}
return { w: w, h: h+dh };
return {
w: w,
h: h+dh
};
};
// editSize
......@@ -151,8 +161,6 @@ $(document).ready(function()
}
});
console.log( text );
if( text == this.getData( "text" ) ){
this.elements.containerView.addClass( "answerRight" );
}
......@@ -167,4 +175,10 @@ $(document).ready(function()
w.modeView();
$(window).mouseout(function(){
if(window.sankore){
sankore.setPreference("ordSplText", w.getData( "text" ));
}
});
});
\ No newline at end of file
......@@ -18,8 +18,13 @@ function createWord( word )
$(document).ready(function()
{
var w = new wcontainer( "#ub-widget" );
var words = "";
w.setEditContent( '<div class="inputwrap"><input class="percent" value="so*phis*ti*ca*ted"></div>' );
if(window.sankore)
words = (sankore.preference("ordSplWords", ""))?sankore.preference("ordSplWords", ""):"so*phis*ti*ca*ted";
else
words = "so*phis*ti*ca*ted";
w.setEditContent( '<div class="inputwrap"><input class="percent" value="' + words + '"></div>' );
w.setViewContent( '<span class="upper"><span class="dash fixed">&mdash;</span></span>' );
w.setData( "dashWidth", w.elements.container.find( "span.dash" ).outerWidth() );
w.setViewContent( "" );
......@@ -53,7 +58,10 @@ $(document).ready(function()
});
var dw = winstance.getData( "dashWidth" );
return { w: w+dw, h: h };
return {
w: w+dw,
h: h
};
};
// editSize
......@@ -96,4 +104,10 @@ $(document).ready(function()
w.modeView();
$(window).mouseout(function(){
if(window.sankore){
sankore.setPreference("ordSplWords", w.getData("word"));
}
});
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment