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 @@
% endfor
<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 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>
</table>
......
// CRITICAL TODO: Namespace
var files=["",
var ${ id }files=["",
%for t in items:
${t[1]['content']} ,
%endfor
""
];
var functions=["",
var ${ id }functions=["",
%for t in items:
function(){ ${t[1]['js']} },
%endfor
""];
var loc;
var ${ id }loc;
function goto(i) {
$('#content').html(files[i]);
functions[i]()
loc=i;
function ${ id }goto(i) {
$('#content').html(${ id }files[i]);
${ id }functions[i]()
${ id }loc=i;
}
function setup_click(i) {
$('#tt_'+i).click(function(eo) { goto(i);});
function ${ id }setup_click(i) {
$('#tt_'+i).click(function(eo) { ${ id }goto(i);});
}
function next() {
loc=loc+1;
if(loc> ${ len(items) } ) loc=${ len(items) };
goto(loc);
function ${ id }next() {
${ id }loc=${ id }loc+1;
if(${ id }loc> ${ len(items) } ) ${ id }loc=${ len(items) };
${ id }goto(${ id }loc);
}
function prev() {
loc=loc-1;
if(loc<1) loc=1;
goto(loc);
function ${ id }prev() {
${ id }loc=${ id }loc-1;
if(${ id }loc<1) ${ id }loc=1;
${ id }goto(${ id }loc);
}
$(function() {
var i;
for(i=1; i<11; i++) {
setup_click(i);
${ id }setup_click(i);
}
$('#next').click(function(eo) { next();});
$('#prev').click(function(eo) { prev();});
goto(1);
$('#${ id }next').click(function(eo) { ${ id }next();});
$('#${ id }prev').click(function(eo) { ${ id }prev();});
${ 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