Subversion Repositories wimsdev

Rev

Rev 13664 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
105 bpr 1
!if $wims_read_parm!=slib_header
13594 bpr 2
  !goto proc
105 bpr 3
!endif
4351 bpr 4
slib_author=Georges, Khaznadar
105 bpr 5
slib_license=GPL
281 bpr 6
 
7
slib_example= MnO4^- + 5 e^- + 8H^+ -> Mn^2+ + 4H2O \
475 georgesk 8
MnO4^- + 5 e^- + 8H^+ -> Mn^2+ + 4H2O, htmlbuttons 3 \
9
MnO4^- + 5 e^- + 8H^+ -> Mn^2+ + 4H2O, htmlbuttons 3,,[extra,redox_extra] \
10
MnO4^- + 5 e^- + 8H^+ -> Mn^2+ + 4H2O, htmlbuttons 2, shuffle,[extra]
3265 bpr 11
slib_require=chemeq
105 bpr 12
!exit
13
 
475 georgesk 14
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15
!! TODO : find a way to accept the experimental "tex" feature
16
!! this example should work but it does not:
17
!! MnO4^- + 5 e^- + 8H^+ -> Mn^2+ + 4H2O, htmlbuttons 2, tex
18
!! it should make nice graphic buttons with TeX rendered formulas
19
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20
 
105 bpr 21
:proc
22
 
475 georgesk 23
!distribute items $wims_read_parm into slib_chem, slib_html, slib_opt, slib_add
24
 
25
slib_add=!declosing $slib_add
26
 
281 bpr 27
!if htmlbuttons isin $slib_html
28
  !distribute words $slib_html into slib_html slib_n
29
!endif
475 georgesk 30
 
31
!if shuffle isin $slib_opt
32
  slib_shuffle=shuffle
33
!else
34
  slib_shuffle=
281 bpr 35
!endif
105 bpr 36
 
475 georgesk 37
!if tex isin $slib_opt
38
  slib_tex=tex
39
!else
40
  slib_tex=
41
!endif
42
 
105 bpr 43
chemeq_option=C
281 bpr 44
slib_c=!exec chemeq $slib_chem
105 bpr 45
!reset chemeq_option
46
 
13664 bpr 47
slib_c=!replace |[^,;]* by $empty in $slib_c
48
slib_c=!replace [0-9]\+[ ] by $empty in $slib_c
281 bpr 49
 
475 georgesk 50
slib_add=!replace redox_extra by H^+_aq,OH^-_aq,H2O,e^- in $slib_add
51
 
52
!if $slib_tex=tex
53
  slib_c=!replace ; by , in $slib_c
54
  slib_c1=
55
  !for slib_component in $slib_c
56
     chemeq_option=l
57
     slib_component_tex=!exec chemeq $slib_component
58
     slib_c1=!append item $slib_component_tex to $slib_c1
59
  !next
60
  slib_c=$slib_c1
61
!endif
62
 
63
slib_add=!replace extra by +,-> in $slib_add
64
 
65
!if $slib_add != $empty
66
  slib_c=$slib_c, $slib_add
67
!endif
68
 
69
 
281 bpr 70
!if $slib_html=htmlbuttons
71
  slib_c=!replace ; by , in $slib_c
72
  slib_c=!listuniq $slib_c
73
  !if $slib_shuffle=shuffle
74
    slib_c=!shuffle $slib_c
75
  !endif
76
  slib_buttons=
475 georgesk 77
  !if $slib_tex=tex
78
    !!!!!!!!!!!!!! this feature should work but it does not !!!!!!!!!!!!!!!!!!
79
    !for slib_component in $slib_c
5787 bpr 80
      slib_buttons=$slib_buttons<input type="button" value="\
475 georgesk 81
!instex $slib_component\
17173 bpr 82
" onclick="appendToInput($slib_n,' $slib_component ')">
475 georgesk 83
    !next slib_component
84
  !else
85
    !for slib_component in $slib_c
17173 bpr 86
      slib_buttons=$slib_buttons<input type="button" value="$slib_component" onclick="appendToInput($slib_n,' $slib_component ')">
475 georgesk 87
    !next slib_component
88
  !endif
281 bpr 89
  slib_out=$slib_buttons
90
!else
91
  slib_out=$slib_c
92
!endif