2011-07-01 22:56:53 +00:00
|
|
|
|
|
|
|
if {![exists -proc require]} {
|
2011-07-05 18:38:42 +00:00
|
|
|
proc require {args} {{done {}}} {
|
2011-07-01 22:56:53 +00:00
|
|
|
foreach file $args {
|
2011-07-07 22:33:19 +00:00
|
|
|
if {$file ni $done} {
|
2012-05-21 20:23:41 +00:00
|
|
|
uplevel source "/mod/webif/lib/$file"
|
2013-09-07 22:13:03 +00:00
|
|
|
lappend done $file
|
2011-07-05 18:38:42 +00:00
|
|
|
}
|
2011-07-01 22:56:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-09 22:46:15 +00:00
|
|
|
proc httpheader {{type "text/html"} {cache 0} {extra ""}} {{done 0}} {
|
|
|
|
if {$done} return
|
|
|
|
if {!$cache} {
|
2013-02-25 22:31:54 +00:00
|
|
|
puts -nonewline "Content-Type: $type; charset=\"UTF-8\"; no-cache\r\n"
|
2013-02-09 22:46:15 +00:00
|
|
|
puts -nonewline "Expires: -1\r\n"
|
2014-02-21 21:25:33 +00:00
|
|
|
puts -nonewline "Connection: close\r\n"
|
2013-02-09 22:46:15 +00:00
|
|
|
puts -nonewline "Pragma: no-cache\r\n"
|
|
|
|
puts -nonewline "Cache-Control: no-cache\r\n"
|
|
|
|
} else {
|
2013-04-10 21:49:11 +00:00
|
|
|
puts -nonewline "Content-Type: $type; charset=\"UTF-8\"\r\n"
|
2013-02-09 22:46:15 +00:00
|
|
|
}
|
2013-04-10 21:49:11 +00:00
|
|
|
if {$extra ne ""} { puts -nonewline "$extra" }
|
2013-02-09 22:46:15 +00:00
|
|
|
puts -nonewline "\r\n"
|
|
|
|
set done 1
|
|
|
|
}
|
|
|
|
|
2014-02-21 21:25:33 +00:00
|
|
|
set ::_mws_headerdone 0
|
|
|
|
set ::_mws_js {}
|
|
|
|
set ::_mws_css {}
|
2013-02-09 22:46:15 +00:00
|
|
|
proc header {{type "text/html"} {cache 0}} {
|
|
|
|
httpheader $type $cache
|
2012-05-21 20:23:41 +00:00
|
|
|
uplevel source /mod/webif/html/lib/header.jim
|
2014-02-21 21:25:33 +00:00
|
|
|
incr ::_mws_headerdone
|
|
|
|
}
|
|
|
|
|
|
|
|
proc noheader {} {
|
2014-02-23 22:22:07 +00:00
|
|
|
emit_jscss
|
2014-02-21 21:25:33 +00:00
|
|
|
incr ::_mws_headerdone
|
2011-07-01 22:56:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proc footer {} {
|
2012-05-21 20:23:41 +00:00
|
|
|
uplevel source /mod/webif/html/lib/footer.jim
|
2011-07-01 22:56:53 +00:00
|
|
|
}
|
2012-01-22 19:47:47 +00:00
|
|
|
|
2012-10-23 22:51:54 +00:00
|
|
|
proc mheader {} {
|
|
|
|
uplevel source /mod/webif/html/m/lib/header.jim
|
|
|
|
}
|
|
|
|
|
|
|
|
proc mfooter {} {
|
|
|
|
uplevel source /mod/webif/html/m/lib/footer.jim
|
|
|
|
}
|
|
|
|
|
2014-02-21 21:25:33 +00:00
|
|
|
proc _css {file} {
|
|
|
|
if {$::_mws_headerdone} {
|
|
|
|
puts "<link href=\"$file\" rel=stylesheet type=text/css />"
|
|
|
|
} else {
|
|
|
|
lappend ::_mws_css $file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proc _js {file} {
|
|
|
|
if {$::_mws_headerdone} {
|
|
|
|
puts "<script type=text/javascript src=\"$file\"></script>"
|
|
|
|
} else {
|
|
|
|
lappend ::_mws_js $file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-23 22:22:07 +00:00
|
|
|
proc emit_jscss {} {
|
|
|
|
foreach js $::_mws_js { _js $js }
|
|
|
|
foreach css $::_mws_css { _css $css }
|
|
|
|
}
|
|
|
|
|
2014-02-21 21:25:33 +00:00
|
|
|
proc jqplugin {args} {{done {}}} {
|
|
|
|
foreach name $args {
|
|
|
|
if {$name in $done} continue
|
2013-09-07 22:13:03 +00:00
|
|
|
lappend done $name
|
2014-02-21 21:25:33 +00:00
|
|
|
set dir "/mod/webif/html/lib/jquery.plugin/$name"
|
|
|
|
if {![file isdirectory $dir]} {
|
|
|
|
error "Unknown JQ Plugin - '$name'"
|
|
|
|
}
|
|
|
|
foreach file [glob -nocomplain "$dir/*.js"] {
|
2013-07-30 20:07:13 +00:00
|
|
|
set file [join [lrange [split $file /] 4 end] /]
|
2014-02-21 21:25:33 +00:00
|
|
|
_js "/$file"
|
2013-07-30 20:07:13 +00:00
|
|
|
}
|
2014-02-21 21:25:33 +00:00
|
|
|
foreach file [glob -nocomplain "$dir/*.css"] {
|
2013-07-30 20:07:13 +00:00
|
|
|
set file [join [lrange [split $file /] 4 end] /]
|
2014-02-21 21:25:33 +00:00
|
|
|
_css "/$file"
|
2013-07-30 20:07:13 +00:00
|
|
|
}
|
2014-02-21 21:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proc jscss {{js ""} {css ""}} {
|
|
|
|
foreach j $js { _js $j }
|
|
|
|
foreach c $css { _css $c }
|
2013-07-30 20:07:13 +00:00
|
|
|
}
|
|
|
|
|
2013-11-26 21:47:58 +00:00
|
|
|
require fileops overrides
|
2011-07-01 22:56:53 +00:00
|
|
|
}
|
|
|
|
|