| 1 | package CGI::Lazy::Widget::DomLoader; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use base qw(CGI::Lazy::Widget); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | #---------------------------------------------------------------------------------------- | ||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 10 | 0 | my $class = shift; | |||||||||
| 11 | 0 | my $q = shift; | |||||||||
| 12 | 0 | my $inputvars = shift; | |||||||||
| 13 | |||||||||||
| 14 | 0 | my $vars = {}; | |||||||||
| 15 | |||||||||||
| 16 | 0 | foreach (keys %{$inputvars->{lookups}}) { | |||||||||
| 17 | 0 | $vars->{lookups}->{$_} = $_; | |||||||||
| 18 | 0 | $vars->{lookups}->{$_}->{preload} = 1; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 0 | $vars->{raw} = $inputvars->{raw}; | |||||||||
| 22 | |||||||||||
| 23 | 0 | my $widgetID = $vars->{id}; | |||||||||
| 24 | 0 | return bless {_q => $q, _vars => $vars, _widgetID => $widgetID}, $class; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | #---------------------------------------------------------------------------------------- | ||||||||||
| 28 | 0 | ▶ | sub output { | ||||||||
|
Subroutine
output: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 29 | 0 | my $self = shift; | |||||||||
| 30 | |||||||||||
| 31 | 0 | my $rawObjectJs; | |||||||||
| 32 | |||||||||||
| 33 | 0 | foreach my $rawvar (keys %{$self->vars->{raw};}) { | |||||||||
| 34 | 0 | $rawObjectJs .= "var $rawvar = JSON.parse('".to_json($self->vars->{raw}->{$rawvar})."');\n"; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | $rawObjectJs = $self->q->jswrap($rawObjectJs) if $rawObjectJs; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | |||||||||||
| 39 | 0 | my $output = $self->preloadLookup; | |||||||||
| 40 | 0 | ▶ | $output .= $rawObjectJs if $rawObjectJs; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | |||||||||||
| 42 | 0 | return $output; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 1 | 1 | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||