Commit 5385a024 by Piotr Mitros

Sequence is now namespaced

parent 0a075b5e
$(function() {
$('#check_${ id }').click(function() {
var submit_data={};
$.each($("[id^=input_${ id }_]"), function(index,value){
submit_data[value.id]=value.value;
});
if($('#check_${ id }').attr('value') == 'Check') {
$.getJSON('/modx/problem/${ id }/problem_check',
submit_data,
function(json) {
for(p in json) {
if(json[p]=='correct')
$("#status_"+p).attr("class", "ui-icon ui-icon-check");
if(json[p]=='incorrect')
$("#status_"+p).attr("class", "ui-icon ui-icon-close");
$('#check_${ id }').attr("value", "Reset");
}
});
} else /* if 'Reset' */ {
// Possible cleanup: Move from getJSON to just load
$.getJSON('/modx/problem/${ id }/problem_reset', {'id':'${ id }'}, function(json) {
$('#main_${ id }').html(json);
});
}
});
});
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
% endfor % endfor
<td></td></tr> <td></td></tr>
<tr><td align=center valign=center><div id="prev"><span class="ui-icon ui-icon-circle-triangle-w" onclick="pause();"></span></div></td> <tr><td align=center valign=center><div id="${ id }prev"><span class="ui-icon ui-icon-circle-triangle-w"></span></div></td>
<td colspan=10><div id="content"></div></td> <td colspan=10><div id="content"></div></td>
<td align=center valign=center><div id="next"><span class="ui-icon ui-icon-circle-triangle-e" onclick="pause();">&nbsp;</span></div></td> <td align=center valign=center><div id="${ id }next"><span class="ui-icon ui-icon-circle-triangle-e">&nbsp;</span></div></td>
</tr> </tr>
<tr></tr> <tr></tr>
</table> </table>
......
// CRITICAL TODO: Namespace // CRITICAL TODO: Namespace
var files=["", var ${ id }files=["",
%for t in items: %for t in items:
${t[1]['content']} , ${t[1]['content']} ,
%endfor %endfor
"" ""
]; ];
var functions=["", var ${ id }functions=["",
%for t in items: %for t in items:
function(){ ${t[1]['js']} }, function(){ ${t[1]['js']} },
%endfor %endfor
""]; ""];
var loc; var ${ id }loc;
function goto(i) { function ${ id }goto(i) {
$('#content').html(files[i]); $('#content').html(${ id }files[i]);
functions[i]() ${ id }functions[i]()
loc=i; ${ id }loc=i;
} }
function setup_click(i) { function ${ id }setup_click(i) {
$('#tt_'+i).click(function(eo) { goto(i);}); $('#tt_'+i).click(function(eo) { ${ id }goto(i);});
} }
function next() { function ${ id }next() {
loc=loc+1; ${ id }loc=${ id }loc+1;
if(loc> ${ len(items) } ) loc=${ len(items) }; if(${ id }loc> ${ len(items) } ) ${ id }loc=${ len(items) };
goto(loc); ${ id }goto(${ id }loc);
} }
function prev() { function ${ id }prev() {
loc=loc-1; ${ id }loc=${ id }loc-1;
if(loc<1) loc=1; if(${ id }loc<1) ${ id }loc=1;
goto(loc); ${ id }goto(${ id }loc);
} }
$(function() { $(function() {
var i; var i;
for(i=1; i<11; i++) { for(i=1; i<11; i++) {
setup_click(i); ${ id }setup_click(i);
} }
$('#next').click(function(eo) { next();}); $('#${ id }next').click(function(eo) { ${ id }next();});
$('#prev').click(function(eo) { prev();}); $('#${ id }prev').click(function(eo) { ${ id }prev();});
goto(1); ${ id }goto(1);
}); });
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