Tacoen's shared code-snipsets
image/jpeg image/gif image/png image/x-icon application/x-shockwave-flashIn squid.conf
acl images-mime rep_mime_type -i "/etc/squid3/data/cached-mime.txt" cache allow images-mime
sub CreateLST {
my ($tpl_file,$output)=@_; my $spl;
my $tpl = uc(tacoenf::load_as_string($tpl_file));
$tpl =~ s/\%pause(.*)\%/&pause($1,$sn)/gie;
$tpl =~ s/\%(.*)\%/"-1\t".$file{uc($1)}/gie;
$tpl = &removeblank($tpl);
my $ntpl = @ntpl = split(/\n/,$tpl);
my $str = $ntpl."\n".$tpl."\n";
tacoenf::save_file($output,$str,0);
if ($debug) {
print $tpl_file." -> ".$output."\n";
print "-"x60; print "\n";
print $str;
print "-"x60; print "\n\n";
}
}
sub CreateSEQ {
my ($tpl_file,$output)=@_; my $sn=0; my $str;
my @ntpl = tacoenf::load_as_array($tpl_file);
foreach $tpl(@ntpl) {
$tpl =~ s/\%time\%/"file$sn=.time\nlength$n=-1\n"/gie;
$tpl =~ s/\%pause(.*)\%/&seqpause($1,$sn)/gie;
$tpl =~ s/\%(.*)\%/"file$sn=".$file{uc($1)}."\nlength$n=-1\n"/gie;
$str .=$tpl; $sn++;
}
$str = &removeblank(&removeblank($str));
$strn = "\n[playlist]\n\n".$str."\nNumberofentries=".$sn."\nnextindex=0\n";
tacoenf::save_file($output,$strn,0);
if ($debug) {
print $tpl_file." -> ".$output."\n";
print "-"x60; print "\n";
print $strn;
print "-"x60; print "\n\n";
}
}
sub removeblank {
my $str = shift;
$str =~ s/-1\t\n/\n/gi;
$str =~ s/\n\n/\n/gi;
$str =~ s/^[\s]//gi;
$str =~ s/[\s]$//gi;
return $str;
}
sub seqpause {
my ($p,$n) = @_; my $pa = $p*1000;
return "file$n=$p.pause\nlength=$pa\n";
}
sub pause {
my $p = shift; my $pa = $p*1000;
return "$pa\t$p.pause";
}
sub IniLoad {
# my %ini = &IniLoad("/where/is/file.ini");
# print $ini{"section:field"};
my $file=shift; my %ini; my @INI = &tacoenf::load_as_array($file);
for $l(@INI) {
$l=tacoenf::notrail($l);
if ($l=~/^\[(.*)\]/) {
$vsection = $l; $vsection =~ s/^\[(.*)\]$/$1/ie;
}
next if ($l eq "");
next if ($l=~/^\[(.*)\]/);
my $value=$vkey=$l;
$vkey =~ s/(.*)\=(.*)/$1/gie; $vkey=tacoenf::trim($vkey);
$value=~ s/(.*)\=(.*)/$2/gie; $value=tacoenf::trim($value);
$ini{"$vsection:$vkey"} = $value;
}
return %ini
}
#A Shortcut
sub IniRead {
my($file,$section,$key)=@_;
my %ini = &IniLoad("where/is/file.ini");
return $ini{"$section:$key"};
}
require tacoen.pm
function getElementsByClassName(searchClass, node, tag)
{
var classElements = new Array();
if (node == null)
{
node = document;
}
if (tag == null)
{
tag = '*';
}
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
for (var i = 0, j = 0; i < elsLen; i++)
{
if (pattern.test(els[i].className))
{
classElements[j] = els[i];
j++;
}
}
return classElements;
}Label: Javascript