aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Sylvester Johansson <scj@archlinux.us>2009-05-28 15:08:49 +0200
committerGravatar Sylvester Johansson <scj@archlinux.us>2009-05-28 15:08:49 +0200
commit09ae8e31a84ef94e82ccecae2196bad9ba12c538 (patch)
tree082d577dbf51ebac263f9334428357a945a19b00 /examples
parent6e15eb4b1a9bbec813a21fc55eccadddb49fe396 (diff)
Zaba_'s patch, fixing filehandles and removing Switch.pm
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/scripts/formfiller.pl60
-rw-r--r--examples/scripts/linkfollow.js2
2 files changed, 31 insertions, 31 deletions
diff --git a/examples/scripts/formfiller.pl b/examples/scripts/formfiller.pl
index a6e07a0..22f2c0d 100755
--- a/examples/scripts/formfiller.pl
+++ b/examples/scripts/formfiller.pl
@@ -15,11 +15,11 @@
# bind LE = spawn /usr/share/uzbl/examples/scripts/formfiller.pl edit
use strict;
-use Switch;
+use warnings;
my $keydir = $ENV{XDG_CONFIG_HOME} . "/uzbl/forms";
-my ($config,$pid,$xid,$fifo,$socket,$url,$title,$cmd) = @ARGV;
-if($fifo eq "") { die "No fifo"; };
+my ($config,$pid,$xid,$fifoname,$socket,$url,$title,$cmd) = @ARGV;
+if (!defined $fifoname || $fifoname eq "") { die "No fifo"; }
sub domain {
my ($url) = @_;
@@ -41,29 +41,29 @@ my %command;
$command{load} = sub {
my ($domain) = @_;
- my $file = "$keydir/$domain";
- if( -e $file){
- open(FH,$file);
- my (@lines) = <FH>;
- close(FH);
+ my $filename = "$keydir/$domain";
+ if (-e $filename){
+ open(my $file, $filename) or die "Failed to open $filename: $!";
+ my (@lines) = <$file>;
+ close($file);
$|++;
- open(FIFO,">>$fifo");
- print "opened $fifo\n";
+ open(my $fifo, ">>", $fifoname) or die "Failed to open $fifoname: $!";
foreach my $line (@lines) {
- if($line !~ m/^#/){
- my ($type,$name,$value) = ($line =~ /\s*(\w+)\s*\|\s*(.*?)\s*\|\s*(.*?)\s*$/);
- switch ($type) {
- case "" {}
- case "checkbox" { printf FIFO 'act js document.getElementsByName("%s")[0].checked = %s;', $name, $value}
- case "submit" { printf FIFO 'act js function fs (n) {try{n.submit()} catch (e){fs(n.parentNode)}}; fs(document.getElementsByName("%s")[0]);', $name }
- else { printf FIFO 'act js document.getElementsByName("%s")[0].value = "%s";', $name, $value}
- }
-
- print FIFO "\n";
+ next if ($line =~ m/^#/);
+ my ($type,$name,$value) = ($line =~ /^\s*(\w+)\s*\|\s*(.*?)\s*\|\s*(.*?)\s*$/);
+ if ($type eq "checkbox")
+ {
+ printf $fifo 'act js document.getElementsByName("%s")[0].checked = %s;', $name, $value;
+ } elsif ($type eq "submit")
+ {
+ printf $fifo 'act js function fs (n) {try{n.submit()} catch (e){fs(n.parentNode)}}; fs(document.getElementsByName("%s")[0]);', $name;
+ } elsif ($type ne "")
+ {
+ printf $fifo 'act js document.getElementsByName("%s")[0].value = "%s";', $name, $value;
}
+ print $fifo "\n";
}
$|--;
- close(FIFO);
} else {
$command{new}->($domain);
$command{edit}->($domain);
@@ -76,24 +76,24 @@ $command{edit} = sub {
system ($editor, $file);
} else {
$command{new}->($domain);
-}
+ }
};
$command{new} = sub {
my ($domain) = @_;
- my $file = "$keydir/$domain";
- open(FILE,">>$file");
+ my $filename = "$keydir/$domain";
+ open (my $file,">>", $filename) or die "Failed to open $filename: $!";
$|++;
- print FILE "#make sure that there are no extra submits, since it may trigger the wrong one\n";
- printf FILE "#%-10s | %-10s | %s\n", @fields;
- print FILE "#------------------------------\n";
+ print $file "# Make sure that there are no extra submits, since it may trigger the wrong one.\n";
+ printf $file "#%-10s | %-10s | %s\n", @fields;
+ print $file "#------------------------------\n";
my @data = `$downloader $url`;
foreach my $line (@data){
if($line =~ m/<input ([^>].*?)>/i){
- $line =~ s/.*(<input ([^>].*?)>).*/\1/;
- printf FILE " %-10s | %-10s | %s\n", map { my ($r) = $line =~ /.*$_=["'](.*?)["']/;$r } @fields;
+ $line =~ s/.*(<input ([^>].*?)>).*/$1/;
+ printf $file " %-10s | %-10s | %s\n", map { my ($r) = $line =~ /.*$_=["'](.*?)["']/;$r } @fields;
};
};
- close(FILE);
$|--;
};
+
$command{$cmd}->(domain($url));
diff --git a/examples/scripts/linkfollow.js b/examples/scripts/linkfollow.js
index 2b381cc..e77219c 100644
--- a/examples/scripts/linkfollow.js
+++ b/examples/scripts/linkfollow.js
@@ -77,7 +77,7 @@ function Hints(){
}
// the vimperator defaults minus the xhtml elements, since it gave DOM errors
- var hintable = " //*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @role='link'] | //input[not(@type='hidden')] | //a | //area | //iframe | //textarea | //button | //select";
+ var hintable = " //*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @role='link' or @href] | //input[not(@type='hidden')] | //a | //area | //iframe | //textarea | //button | //select";
function Matcher(str){
var numbers = str.replace(/[^\d]/g,"");