| Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Include/JS.pm |
| Statements | Executed 17 statements in 2.36ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 86µs | 352µs | RTP::Webmerge::Include::JS::BEGIN@8 |
| 1 | 1 | 1 | 74µs | 74µs | RTP::Webmerge::Include::JS::BEGIN@18.18 |
| 1 | 1 | 1 | 60µs | 301µs | RTP::Webmerge::Include::JS::BEGIN@26 |
| 1 | 1 | 1 | 56µs | 88µs | RTP::Webmerge::Include::JS::BEGIN@10 |
| 1 | 1 | 1 | 55µs | 589µs | RTP::Webmerge::Include::JS::BEGIN@25 |
| 1 | 1 | 1 | 53µs | 141µs | RTP::Webmerge::Include::JS::BEGIN@9 |
| 1 | 1 | 1 | 29µs | 29µs | RTP::Webmerge::Include::JS::BEGIN@21 |
| 1 | 1 | 1 | 22µs | 22µs | RTP::Webmerge::Include::JS::BEGIN@18 |
| 1 | 1 | 1 | 22µs | 22µs | RTP::Webmerge::Include::JS::BEGIN@15 |
| 0 | 0 | 0 | 0s | 0s | RTP::Webmerge::Include::JS::includeJS |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | ################################################################################################### | ||||
| 2 | # Copyright 2013 by Marcel Greter | ||||
| 3 | # This file is part of Webmerge (GPL3) | ||||
| 4 | ################################################################################################### | ||||
| 5 | package RTP::Webmerge::Include::JS; | ||||
| 6 | ################################################################################################### | ||||
| 7 | |||||
| 8 | 2 | 161µs | 2 | 618µs | # spent 352µs (86+266) within RTP::Webmerge::Include::JS::BEGIN@8 which was called:
# once (86µs+266µs) by RTP::Webmerge::Merge::JS::BEGIN@70 at line 8 # spent 352µs making 1 call to RTP::Webmerge::Include::JS::BEGIN@8
# spent 266µs making 1 call to Exporter::import |
| 9 | 2 | 158µs | 2 | 228µs | # spent 141µs (53+88) within RTP::Webmerge::Include::JS::BEGIN@9 which was called:
# once (53µs+88µs) by RTP::Webmerge::Merge::JS::BEGIN@70 at line 9 # spent 141µs making 1 call to RTP::Webmerge::Include::JS::BEGIN@9
# spent 88µs making 1 call to strict::import |
| 10 | 2 | 192µs | 2 | 121µs | # spent 88µs (56+33) within RTP::Webmerge::Include::JS::BEGIN@10 which was called:
# once (56µs+33µs) by RTP::Webmerge::Merge::JS::BEGIN@70 at line 10 # spent 88µs making 1 call to RTP::Webmerge::Include::JS::BEGIN@10
# spent 33µs making 1 call to warnings::import |
| 11 | |||||
| 12 | ################################################################################################### | ||||
| 13 | |||||
| 14 | # define our version string | ||||
| 15 | 1 | 143µs | 1 | 22µs | # spent 22µs within RTP::Webmerge::Include::JS::BEGIN@15 which was called:
# once (22µs+0s) by RTP::Webmerge::Merge::JS::BEGIN@70 at line 15 # spent 22µs making 1 call to RTP::Webmerge::Include::JS::BEGIN@15 |
| 16 | |||||
| 17 | # load exporter and inherit from it | ||||
| 18 | 3 | 399µs | 2 | 96µs | BEGIN { use Exporter qw(); our @ISA = qw(Exporter) } # spent 74µs making 1 call to RTP::Webmerge::Include::JS::BEGIN@18.18
# spent 22µs making 1 call to RTP::Webmerge::Include::JS::BEGIN@18 |
| 19 | |||||
| 20 | # define our functions to be exported | ||||
| 21 | 1 | 167µs | 1 | 29µs | # spent 29µs within RTP::Webmerge::Include::JS::BEGIN@21 which was called:
# once (29µs+0s) by RTP::Webmerge::Merge::JS::BEGIN@70 at line 21 # spent 29µs making 1 call to RTP::Webmerge::Include::JS::BEGIN@21 |
| 22 | |||||
| 23 | ################################################################################################### | ||||
| 24 | |||||
| 25 | 2 | 180µs | 2 | 1.12ms | # spent 589µs (55+534) within RTP::Webmerge::Include::JS::BEGIN@25 which was called:
# once (55µs+534µs) by RTP::Webmerge::Merge::JS::BEGIN@70 at line 25 # spent 589µs making 1 call to RTP::Webmerge::Include::JS::BEGIN@25
# spent 534µs making 1 call to Exporter::import |
| 26 | 2 | 931µs | 2 | 543µs | # spent 301µs (60+242) within RTP::Webmerge::Include::JS::BEGIN@26 which was called:
# once (60µs+242µs) by RTP::Webmerge::Merge::JS::BEGIN@70 at line 26 # spent 301µs making 1 call to RTP::Webmerge::Include::JS::BEGIN@26
# spent 242µs making 1 call to Exporter::import |
| 27 | |||||
| 28 | ################################################################################################### | ||||
| 29 | |||||
| 30 | # js function for header include | ||||
| 31 | # you can overwrite and control all bits by defining your own | ||||
| 32 | # javascript functions before including the generated dev file | ||||
| 33 | #************************************************************************************************** | ||||
| 34 | 1 | 14µs | our $js_dev_header = | ||
| 35 | ' | ||||
| 36 | // create namespace for webmerge if not yet defined | ||||
| 37 | if (typeof webmerge == \'undefined\') window.webmerge = {}; | ||||
| 38 | |||||
| 39 | // define default JS loader function, overwrite with | ||||
| 40 | // other defered JS loaders like head.hs or requireJS | ||||
| 41 | if (typeof webmerge.loadJS != \'function\') | ||||
| 42 | { | ||||
| 43 | webmerge.loadJS = function (src) | ||||
| 44 | { | ||||
| 45 | document.write(\'<script src="\' + src + \'"></script>\'); | ||||
| 46 | } | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | // include a JS file (rewrite url if configured to) | ||||
| 50 | // then call the loadJS function to import the code | ||||
| 51 | if (typeof webmerge.includeJS != \'function\') | ||||
| 52 | { | ||||
| 53 | webmerge.includeJS = function (src) | ||||
| 54 | { | ||||
| 55 | // check if we have a custom webroot | ||||
| 56 | if (webmerge.webroot) src = [webmerge.webroot, src].join(\'/\'); | ||||
| 57 | // check if we have a custom url rewriter | ||||
| 58 | if (webmerge.rewriteJS) src = webmerge.rewriteJS(src); | ||||
| 59 | // call the importer function, which | ||||
| 60 | // can be overwritten by a custom loader | ||||
| 61 | webmerge.loadJS.call(this, src); | ||||
| 62 | } | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | '; | ||||
| 66 | |||||
| 67 | ################################################################################################### | ||||
| 68 | |||||
| 69 | # called via array map | ||||
| 70 | #************************************************************************************************** | ||||
| 71 | sub includeJS | ||||
| 72 | { | ||||
| 73 | |||||
| 74 | # get passed variables | ||||
| 75 | my ($config) = @_; | ||||
| 76 | |||||
| 77 | # magick map variable | ||||
| 78 | my $data = $_; | ||||
| 79 | |||||
| 80 | # define the template for the script includes | ||||
| 81 | my $js_include_tmpl = 'webmerge.includeJS(\'%s\');' . "\n"; | ||||
| 82 | |||||
| 83 | # get a unique path with added fingerprint (query or directory) | ||||
| 84 | my $path = fingerprint($config, 'dev', $data->{'local_path'}, $data->{'org'}); | ||||
| 85 | |||||
| 86 | # return the script include string | ||||
| 87 | return sprintf($js_include_tmpl, exportURI($path, $webroot, 1)); | ||||
| 88 | |||||
| 89 | } | ||||
| 90 | # EO includeJS | ||||
| 91 | |||||
| 92 | ################################################################################################### | ||||
| 93 | ################################################################################################### | ||||
| 94 | 1 | 15µs | 1; |