Subversion Repositories wimsdev

Rev

Rev 16699 | Blame | Compare with Previous | Last modification | View Log | RSS feed

!set anstype=yes
!set anstyle=symtext
!set ans_require=dynapi3

!if $wims_read_parm=def
  !exit
!endif

!! test if style tag is already set in DOM (if multiple instance of same anstype)
!if $compose_css!=set
  <style>
    !read anstype/compose.css
  </style>
  !set compose_css=set
!endif

!bound inputsize between integer 1 and 40 default 10
!if $inputsize<=5
  !distribute item '<p class=\"center\">' +,+ '</p>' into ct1,ct2
!else
  !reset ct1,ct2
!endif
!set linkword=!getopt linkword in $(replyoption$i)
!default linkword=$ $
!if $linkword issametext empty
  !set linkword=
!endif
!set oef_answer_option$i=$linkword
!set inputsize=$[$inputsize*10]
!set lenlimit=40
!set imgs=$(replygood$i)
!set imgs=!translate internal | to , in $imgs
!set imgs=!rows2lines $imgs
!set atest=!line 1 of $imgs
!if ?analyze iswordof $atest
  !set imgs=!line 2 to -1 of $imgs
!endif

!set imgs=!lines2items $imgs
!set imgs=!singlespace $imgs
!set imgs=!nonempty items $imgs
!set imgs=!listuniq $imgs
!if shuffle notwordof $(replyoption$i)
  !set imgs=!sort nocase items $imgs
!else
  !set imgs=!shuffle $imgs
!endif
!set imgcnt=!itemcnt $imgs
!set imgl=!items2lines $imgs
!set imgarr=!replace internal " by \" in $imgl
!set imgarr=!replace internal ' by \' in $imgarr
!set imgarr=!replace internal $\
$ by ',' in '$imgarr'
!set Imgarr=!replace internal \ by \\ in $imgl
!set Imgarr=!replace internal " by \" in $Imgarr
!set Imgarr=!replace internal ' by \' in $Imgarr
!set Imgarr=!replace internal $\
$ by ',' in '$Imgarr'
!set wims_ins_alt=none
!set z=C$i

!read js/dynapi3.phtml
<script>
/*<![CDATA[*/
 var $(z)_imgcnt=0;
 $(z)_imgs=new Array($imgarr);
 $(z)_Imgs=new Array($Imgarr);
 $(z)_strs=new Array($lenlimit+1);
 $(z)_Strs=new Array($lenlimit+1);
 $(z)_strs[0]='';
 $(z)_Strs[0]='';
 var lyr$i;

dynapi.onLoad(function() {
  lyr$i=new DynLayer();
  lyr$i.setAnchor({topA:'tarea$i',leftA:'tarea$i',stretchH:'90%',stretchV:$inputsize});
  lyr$i.setClass('compose_filler');
  //lyr$i.setHTML('');
  dynapi.document.addChild(lyr$i);
});

/* add the element of index t to the filler zone */
function $(z)_addone(e, t) {
  e.preventDefault();
  if(t<0 || $(z)_imgcnt>=$lenlimit) return;
  if($(z)_imgcnt>0) {
    $(z)_strs[$(z)_imgcnt+1]=$(z)_strs[$(z)_imgcnt]+'$linkword'+$(z)_imgs[t];
    $(z)_Strs[$(z)_imgcnt+1]=$(z)_Strs[$(z)_imgcnt]+' '+$(z)_Imgs[t];
  }
  else {
    $(z)_strs[$(z)_imgcnt+1]=$(z)_imgs[t];
    $(z)_Strs[$(z)_imgcnt+1]=$(z)_Imgs[t];
  }
  $(z)_imgcnt++; $(z)_lockdata();
}

/* Remove the last added item */
function $(z)_backone(e) {
  e.preventDefault();
  if($(z)_imgcnt<1) return;
  $(z)_imgcnt--; $(z)_lockdata();
}

/* Remove all items */
function $(z)_cleanall(e) {
  e.preventDefault();
  if($(z)_imgcnt<1) return;
  $(z)_imgcnt=0; $(z)_lockdata();
}

/* append content of clicked item to the filled zone and the reply input */
function $(z)_lockdata() {
  lyr$i.setHTML($ct1 $(z)_strs[$(z)_imgcnt] $ct2);
  document.forms['replyform'].reply$i.value=$(z)_Strs[$(z)_imgcnt];
}
/*]]>*/
</script>

!reset wims_ins_alt
!if $wims_read_parm!=noprompt
  <tr><td>
  !if $module_language=fr
    Cliquez sur les objets ci-dessous pour composer votre réponse.
    !goto cont
  !endif
  !if $module_language=nl
    Klik voor het antwoord op de onderstaande objecten
    !goto cont
  !endif

  Click on the objects below to compose your reply.
  :cont
!endif
!if $wims_read_parm!=noprompt and $(replyname$i) notsametext
  <p><label for="reply$i">$(replyname$i)</label></p>
!endif

<div class="wimscenter">
  <img id="tarea$i" style="height:$[$inputsize]px;width:90%;" src="gifs/transparent.gif" alt="transparent">
</div>

<div class="compose_items">
  !set instex_color=blue
  !for i_=1 to $imgcnt
    !set src=!item $i_ of $imgs
    <a class="wims_label" href="#tarea$i" onclick="$(z)_addone(event, $i_-1)">$src</a>&nbsp;
  !next i_
  !set instex_color=black

  !set style_=height:20px;vertical-align:middle;
  <a href="#tarea$i" onclick="$(z)_backone(event)"  title="remove last item"><img style="$style_" src="gifs/arrows/left3.32.gif" alt="left arrow"></a>
  <a href="#tarea$i" onclick="$(z)_cleanall(event)" title="remove all items"><img style="$style_" src="gifs/reset.gif" alt="reset"></a>
</div>

<input type="hidden" name="reply$i" value="">

!if $wims_read_parm!=noprompt
  </td></tr>
!endif