[freeside-commits] branch FREESIDE_3_BRANCH updated. b85a720cb3605855f685c8af1dce98c7b1658b4b
Mark Wells
mark at 420.am
Thu Jan 15 20:35:55 PST 2015
The branch, FREESIDE_3_BRANCH has been updated
via b85a720cb3605855f685c8af1dce98c7b1658b4b (commit)
from 1cf55d0a0ccb48142608e67653f86e3c294e4561 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b85a720cb3605855f685c8af1dce98c7b1658b4b
Author: Mark Wells <mark at freeside.biz>
Date: Thu Jan 15 20:35:24 2015 -0800
MAC address copying hack for view/ pages, #25599
diff --git a/httemplate/elements/mac_addr.html b/httemplate/elements/mac_addr.html
new file mode 100644
index 0000000..1d867f5
--- /dev/null
+++ b/httemplate/elements/mac_addr.html
@@ -0,0 +1,53 @@
+% if (!$init) {
+% if ($clipboard_hack) {
+<& init_overlib.html &>
+<script>
+<&| /elements/onload.js &>
+ var transform_text = function(str) {
+ var regexp = new RegExp('.*(..):(..):(..):(..):(..):(..).*');
+ return str.replace(regexp, '$1$2$3$4$5$6');
+ }
+ var span_onclick = function() {
+ var input = document.createElement('INPUT');
+ // IE8 doesn't support textContent
+ var str = this.textContent || this.innerText || '';
+ input.value = transform_text(str);
+ input.style.position = 'absolute';
+ input.style.top = '0px';
+ input.style.left = '0px';
+ input.onblur = function() { input.parentNode.removeChild(input) }
+ this.appendChild(input);
+ input.select();
+ }
+ // set this on any ".mac_addr" object in the doc
+
+ // IE8 doesn't support getElementsByClassName
+ var els = document.getElementsByTagName('span');
+ for (var i = 0; i < els.length; i++) {
+ if (els[i].className = 'mac_addr') {
+ els[i].id = 'span_mac_addr' + i;
+ els[i].onclick = span_onclick;
+ }
+ }
+</&>
+</SCRIPT>
+<style type="text/css">
+.mac_addr {
+ border-bottom: 1px dotted blue;
+ color: blue;
+ position: relative;
+}
+</style>
+% } # if $clipboard_hack
+% $init++;
+% }
+%# the only part to be included in every instance
+<SPAN CLASS="mac_addr"><% $value |h %></SPAN>
+<%shared>
+my $init = 0;
+</%shared>
+<%init>
+my $clipboard_hack =
+ $FS::CurrentUser::CurrentUser->option('enable_mask_clipboard_hack');
+my $value = shift; # no other params
+</%init>
diff --git a/httemplate/view/elements/svc_Common.html b/httemplate/view/elements/svc_Common.html
index 501fea0..7d21e76 100644
--- a/httemplate/view/elements/svc_Common.html
+++ b/httemplate/view/elements/svc_Common.html
@@ -222,6 +222,7 @@ my $format_field = sub {
$field = $f;
$type = 'text';
}
+ warn "$field\t$type\t$value\n";
my $columndef = $part_svc->part_svc_column($field);
# skip fields that are fixed and empty
@@ -273,8 +274,10 @@ my $format_field = sub {
$value = time2str("$date_format %H:%M",$value)
} elsif ( $type eq 'checkbox' ) {
$value = $value eq 'Y' ? emt('Yes') : emt('No');
- } elsif ( $type eq 'mac_addr' and $value =~ /\w/) {
- $value .= ' ('. (Net::MAC::Vendor::lookup($value))->[0]. ')'
+ } elsif ( $type =~ /(input-)?mac_addr/ and $value =~ /\w/) {
+ my $vendor = Net::MAC::Vendor::lookup($value)->[0];
+ $value .= " ($vendor)" if $vendor;
+ $value = $m->scomp('/elements/mac_addr.html', $value);
}
# 'link' option
-----------------------------------------------------------------------
Summary of changes:
httemplate/elements/mac_addr.html | 53 ++++++++++++++++++++++++++++++
httemplate/view/elements/svc_Common.html | 7 ++--
2 files changed, 58 insertions(+), 2 deletions(-)
create mode 100644 httemplate/elements/mac_addr.html
More information about the freeside-commits
mailing list