annotate index.pl @ 2:d7dd496a4fa6 boosterpack

[svn r4] actual functionality!
author robert
date Tue, 08 Sep 2009 02:45:26 -0400
parents 477258d09353
children 2e849c856026
rev   line source
robert@0 1 #!C:/strawberry/perl/bin/perl.exe
robert@0 2
robert@2 3 use List::Util qw(first max maxstr min minstr reduce shuffle sum);
robert@2 4 use Storable;
robert@0 5 use CGI::Ajax;
robert@0 6 use CGI;
robert@2 7 use Rule;
robert@2 8 use Filter;
robert@2 9 use Card;
robert@0 10 my $q = new CGI;
robert@0 11
robert@0 12
robert@2 13
robert@2 14 my $refstruct = retrieve 'CARD.perl';
robert@2 15 my @pokes = @$refstruct;
robert@2 16
robert@2 17
robert@2 18
robert@2 19
robert@2 20
robert@2 21 my %hash = ( 'gen_pack' => \&gen_pack, 'change_rules' => \&change_rules);
robert@0 22
robert@0 23
robert@0 24
robert@0 25
robert@0 26
robert@0 27
robert@0 28 my $pjx = CGI::Ajax->new(%hash);
robert@2 29 #$pjx->JSDEBUG(1);
robert@2 30 #$pjx->DEBUG(1);
robert@2 31
robert@0 32 print $pjx->build_html($q,\&gen); # this outputs the html for the page
robert@0 33
robert@0 34
robert@0 35
robert@0 36
robert@0 37
robert@2 38 sub change_rules
robert@2 39 {
robert@2 40 my $currentRuleref = retrieve 'rlm/booster.prefs';
robert@2 41 $currentRule = $$currentRuleref;
robert@2 42 $a = shift;
robert@2 43 $currentRule -> setSets(($a));
robert@2 44 store \$currentRule, 'rlm/booster.prefs';
robert@2 45 return $a;
robert@2 46
robert@2 47
robert@2 48 }
robert@0 49
robert@2 50
robert@2 51
robert@2 52
robert@2 53
robert@2 54
robert@2 55
robert@2 56
robert@2 57
robert@2 58
robert@2 59 sub gen_pack
robert@0 60 {
robert@2 61 sub tag_analyze
robert@2 62 {
robert@2 63
robert@2 64
robert@2 65
robert@2 66 my @sets = $currentRule -> getSets();
robert@2 67 #print ERR @sets;
robert@2 68
robert@2 69 my $card = shift;
robert@2 70
robert@2 71 #print ERR $card->getPix();
robert@2 72 #print ERR "\n";
robert@2 73 return $card -> hasTags(@sets);
robert@2 74
robert@2 75
robert@2 76 }
robert@2 77
robert@2 78 my $currentRuleref = retrieve 'rlm/booster.prefs';
robert@2 79 $currentRule = $$currentRuleref;
robert@2 80
robert@2 81 #print ERR "@pokes";
robert@2 82 @reduced = filter(\&tag_analyze, @pokes);
robert@2 83
robert@2 84 #print ERR "@reduced";
robert@2 85
robert@2 86 for $crd(@reduced)
robert@2 87 {
robert@2 88 #print ERR $crd->getPix();
robert@2 89 $rob = $rob.$crd->getPix();
robert@2 90 $rob = $rob."<br>";
robert@2 91 }
robert@2 92
robert@2 93 #print $rob;
robert@2 94
robert@2 95 #print ERR @reduced;
robert@2 96 #print ERR $rob;
robert@2 97 #print $rob;
robert@2 98 return $rob;
robert@2 99 #close ERR;
robert@2 100
robert@2 101
robert@0 102 };
robert@0 103
robert@0 104
robert@0 105
robert@0 106
robert@0 107
robert@0 108 sub gen
robert@0 109 {
robert@0 110 open FILE, "<index.html";
robert@0 111 return do { local $/; <FILE> };
robert@2 112 };
robert@2 113
robert@2 114 #print "done";
robert@2 115
robert@2 116 #print &change_rules("Fossil");
robert@2 117 #print &gen_pack;