2 * App to drive the base page.
7 angular.module('egWorkstationAdmin',
8 ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod'])
10 .config(['$routeProvider','$locationProvider','$compileProvider',
11 function($routeProvider , $locationProvider , $compileProvider) {
13 $locationProvider.html5Mode(true);
14 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|mailto|blob):/);
15 var resolver = {delay : function(egStartup) {return egStartup.go()}};
17 $routeProvider.when('/admin/workstation/workstations', {
18 templateUrl: './admin/workstation/t_workstations',
19 controller: 'WSRegCtrl',
23 $routeProvider.when('/admin/workstation/print/config', {
24 templateUrl: './admin/workstation/t_print_config',
25 controller: 'PrintConfigCtrl',
29 $routeProvider.when('/admin/workstation/print/templates', {
30 templateUrl: './admin/workstation/t_print_templates',
31 controller: 'PrintTemplatesCtrl',
35 $routeProvider.when('/admin/workstation/stored_prefs', {
36 templateUrl: './admin/workstation/t_stored_prefs',
37 controller: 'StoredPrefsCtrl',
41 $routeProvider.when('/admin/workstation/hatch', {
42 templateUrl: './admin/workstation/t_hatch',
43 controller: 'HatchCtrl',
48 $routeProvider.otherwise({
49 templateUrl : './admin/workstation/t_splash',
50 controller : 'SplashCtrl',
55 .config(['ngToastProvider', function(ngToastProvider) {
56 ngToastProvider.configure({
57 verticalPosition: 'bottom',
62 .factory('workstationSvc',
63 ['$q','$timeout','$location','egCore','egConfirmDialog',
64 function($q , $timeout , $location , egCore , egConfirmDialog) {
68 service.get_all = function() {
69 return egCore.hatch.getItem('eg.workstation.all')
70 .then(function(all) { return all || [] });
73 service.get_default = function() {
74 return egCore.hatch.getItem('eg.workstation.default');
77 service.set_default = function(name) {
78 return egCore.hatch.setItem('eg.workstation.default', name);
81 service.register_workstation = function(base_name, name, org_id) {
82 return service.register_ws_api(base_name, name, org_id)
83 .then(function(ws_id) {
84 return service.track_new_ws(ws_id, name, org_id);
88 service.register_ws_api =
89 function(base_name, name, org_id, override, deferred) {
90 if (!deferred) deferred = $q.defer();
92 var method = 'open-ils.actor.workstation.register';
93 if (override) method += '.override';
96 'open-ils.actor', method, egCore.auth.token(), name, org_id)
98 .then(function(resp) {
100 if (evt = egCore.evt.parse(resp)) {
101 console.log('register returned ' + evt.toString());
103 if (evt.textcode == 'WORKSTATION_NAME_EXISTS' && !override) {
105 egConfirmDialog.open(
106 egCore.strings.WS_EXISTS, base_name, {
108 service.register_ws_api(
109 base_name, name, org_id, true, deferred)
111 cancel : function() {
118 alert(evt.toString());
122 console.log('Resolving register promise with: ' + resp);
123 deferred.resolve(resp);
127 return deferred.promise;
130 service.track_new_ws = function(ws_id, ws_name, owning_lib) {
131 console.log('Tracking newly created WS with ID ' + ws_id);
132 var new_ws = {id : ws_id, name : ws_name, owning_lib : owning_lib};
134 return service.get_all()
135 .then(function(all) {
137 return egCore.hatch.setItem('eg.workstation.all', all)
138 .then(function() { return new_ws });
142 // Remove all traces of the workstation locally.
143 // This does not remove the WS from the server.
144 service.remove_workstation = function(name) {
145 console.debug('Removing workstation: ' + name);
147 return egCore.hatch.getItem('eg.workstation.all')
149 // remove from list of all workstations
150 .then(function(all) {
152 var keep = all.filter(function(ws) {return ws.name != name});
153 return egCore.hatch.setItem('eg.workstation.all', keep)
157 return service.get_default()
159 }).then(function(def) {
161 console.debug('Removing default workstation: ' + name);
162 return egCore.hatch.removeItem('eg.workstation.default');
171 .controller('SplashCtrl',
172 ['$scope','$window','$location','egCore','egConfirmDialog',
173 function($scope , $window , $location , egCore , egConfirmDialog) {
175 egCore.hatch.getItem('eg.audio.disable').then(function(val) {
176 $scope.disable_sound = val;
179 egCore.hatch.getItem('eg.search.search_lib').then(function(val) {
180 $scope.search_lib = egCore.org.get(val);
182 $scope.handle_search_lib_changed = function(org) {
183 egCore.hatch.setItem('eg.search.search_lib', org.id());
186 egCore.hatch.getItem('eg.search.pref_lib').then(function(val) {
187 $scope.pref_lib = egCore.org.get(val);
189 $scope.handle_pref_lib_changed = function(org) {
190 egCore.hatch.setItem('eg.search.pref_lib', org.id());
193 $scope.adv_pane = 'advanced'; // default value if not explicitly set
194 egCore.hatch.getItem('eg.search.adv_pane').then(function(val) {
195 $scope.adv_pane = val;
197 $scope.$watch('adv_pane', function(newVal, oldVal) {
198 if (typeof newVal != 'undefined' && newVal != oldVal) {
199 egCore.hatch.setItem('eg.search.adv_pane', newVal);
203 $scope.apply_sound = function() {
204 if ($scope.disable_sound) {
205 egCore.hatch.setItem('eg.audio.disable', true);
207 egCore.hatch.removeItem('eg.audio.disable');
211 $scope.test_audio = function(sound) {
212 egCore.audio.play(sound);
217 .controller('PrintConfigCtrl',
219 function($scope , egCore) {
221 $scope.printConfig = {};
222 $scope.setContext = function(ctx) {
223 $scope.context = ctx;
224 $scope.isTestView = false;
226 $scope.setContext('default');
228 $scope.setContentType = function(type) { $scope.contentType = type }
229 $scope.setContentType('text/plain');
231 $scope.useHatchPrinting = function() {
232 return egCore.hatch.usePrinting();
235 $scope.hatchIsOpen = function() {
236 return egCore.hatch.hatchAvailable;
239 $scope.getPrinterByAttr = function(attr, value) {
241 angular.forEach($scope.printers, function(p) {
242 if (p[attr] == value) printer = p;
247 $scope.resetPrinterSettings = function(context) {
248 $scope.printConfig[context] = {
250 printer : $scope.defaultPrinter ? $scope.defaultPrinter.name : null,
257 $scope.savePrinterSettings = function(context) {
258 return egCore.hatch.setPrintConfig(
259 context, $scope.printConfig[context]);
262 $scope.printerConfString = function() {
263 if ($scope.printConfigError) return $scope.printConfigError;
264 if (!$scope.printConfig) return;
265 if (!$scope.printConfig[$scope.context]) return;
266 return JSON.stringify(
267 $scope.printConfig[$scope.context], undefined, 2);
270 function loadPrinterOptions(name) {
271 egCore.hatch.getPrinterOptions(name).then(
272 function(options) {$scope.printerOptions = options});
275 $scope.setPrinter = function(name) {
276 $scope.printConfig[$scope.context].printer = name;
277 loadPrinterOptions(name);
280 $scope.testPrint = function(withDialog) {
281 if ($scope.contentType == 'text/plain') {
283 context : $scope.context,
284 content_type : $scope.contentType,
285 content : $scope.textPrintContent,
286 show_dialog : withDialog
290 context : $scope.context,
291 content_type : $scope.contentType,
292 content : $scope.htmlPrintContent,
294 value1 : 'Value One',
295 value2 : 'Value Two',
296 date_value : '2015-02-04T14:04:34-0400'
298 show_dialog : withDialog
303 // Load startup data....
304 // Don't bother talking to Hatch if it's not there.
305 if (!egCore.hatch.hatchAvailable) return;
307 // fetch info on all remote printers
308 egCore.hatch.getPrinters()
309 .then(function(printers) {
310 $scope.printers = printers;
312 var def = $scope.getPrinterByAttr('is-default', true);
313 if (!def && printers.length) def = printers[0];
316 $scope.defaultPrinter = def;
317 loadPrinterOptions(def.name);
321 ['default','receipt','label','mail','offline'],
323 egCore.hatch.getPrintConfig(ctx).then(function(conf) {
325 $scope.printConfig[ctx] = conf;
327 $scope.resetPrinterSettings(ctx);
336 .controller('PrintTemplatesCtrl',
337 ['$scope','$q','egCore','ngToast',
338 function($scope , $q , egCore , ngToast) {
341 template_name : 'bills_current',
342 template_output : '',
343 template_context : 'default'
346 // print preview scope data
347 // TODO: consider moving the template-specific bits directly
348 // into the templates or storing template- specific script files
349 // alongside the templates.
350 // NOTE: A lot of this data can be shared across templates.
353 first_given_name : 'Slow',
354 second_given_name : 'Joe',
355 family_name : 'Jones',
358 barcode : '30393830393'
361 balance_owed : 4, // This is currently how these values are returned to the client
362 total_billed : '5.00',
365 expire_date : '2020-12-31',
371 street1 : '123 Apple Rd',
380 title : 'Traveling Pants!!',
381 author : 'Jane Jones',
386 barcode : '33434322323',
391 'title' : 'Test Title'
396 name : 'General Collection'
398 // flattened versions for item status template
399 // TODO - make this go away
400 'call_number.label' : '636.8 JON',
401 'call_number.record.simple_record.title' : 'Test Title',
402 'location.name' : 'General Colleciton'
407 phone_notify : '111-222-3333',
408 sms_notify : '111-222-3333',
409 email_notify : 'user@example.org',
410 request_time : new Date().toISOString(),
412 shelf_expire_time : new Date().toISOString()
419 holds_address : seed_addr
424 holds_address : seed_addr
426 source_send_time : new Date().toISOString(),
427 target_copy : seed_copy
430 $scope.preview_scope = {
435 xact_start : new Date().toISOString(),
437 xact_type : 'circulation',
438 last_billing_type : 'Overdue materials',
440 last_payment_note : 'Test Note 1',
441 last_payment_type : 'cash_payment',
447 xact_start : new Date().toISOString(),
449 xact_type : 'circulation',
450 last_billing_type : 'Overdue materials',
452 last_payment_note : 'Test Note 2',
453 last_payment_type : 'credit_payment',
461 copies : [ seed_copy ],
465 due_date : new Date().toISOString(),
468 target_copy : seed_copy,
469 copy_barcode : seed_copy.barcode,
470 call_number : seed_copy.call_number,
471 title : seed_record.title
478 due_date : new Date().toISOString(),
483 title : seed_record.title,
484 author : seed_record.author
498 title : seed_record.title
502 previous_balance : 8.45,
503 payment_total : 2.00,
504 payment_applied : 2.00,
508 payment_type : 'cash_payment',
509 payment_note : 'Here is a payment note',
511 create_date : new Date().toISOString(),
512 title : 'Test Note Title',
514 value : 'This patron is super nice!'
517 transit : seed_transit,
518 transits : [ seed_transit ],
519 title : seed_record.title,
520 author : seed_record.author,
523 dest_location : egCore.idl.toHash(egCore.org.get(egCore.auth.user().ws_ou())),
524 dest_address : seed_addr,
528 hold : one_hold, title : 'Some Title 1', author : 'Some Author 1',
529 volume : { label : '646.4 SOM' }, copy : seed_copy,
530 part : { label : 'v. 1' },
531 patron_barcode : 'S52802662',
532 patron_alias : 'XYZ', patron_last : 'Smith', patron_first : 'Jane',
533 status_string : 'Ready for Pickup'
536 hold : one_hold, title : 'Some Title 2', author : 'Some Author 2',
537 volume : { label : '646.4 SOM' }, copy : seed_copy,
538 part : { label : 'v. 1' },
539 patron_barcode : 'S52802662',
540 patron_alias : 'XYZ', patron_last : 'Smith', patron_first : 'Jane',
541 status_string : 'Ready for Pickup'
544 hold : one_hold, title : 'Some Title 3', author : 'Some Author 3',
545 volume : { label : '646.4 SOM' }, copy : seed_copy,
546 part : { label : 'v. 1' },
547 patron_barcode : 'S52802662',
548 patron_alias : 'XYZ', patron_last : 'Smith', patron_first : 'Jane',
549 status_string : 'Canceled'
554 $scope.preview_scope.payments = [
555 {amount : 1.00, xact : $scope.preview_scope.transactions[0]},
556 {amount : 1.00, xact : $scope.preview_scope.transactions[1]}
558 $scope.preview_scope.payments[0].xact.title = 'Hali Bote Azikaban de tao fan';
559 $scope.preview_scope.payments[0].xact.copy_barcode = '334343434';
560 $scope.preview_scope.payments[1].xact.title = seed_record.title;
561 $scope.preview_scope.payments[1].xact.copy_barcode = seed_copy.barcode;
563 // today, staff, current_location, etc.
564 egCore.print.fleshPrintScope($scope.preview_scope);
566 $scope.template_changed = function() {
567 $scope.print.load_failed = false;
568 egCore.print.getPrintTemplate($scope.print.template_name)
571 $scope.print.template_content = html;
572 console.log('set template content');
575 $scope.print.template_content = '';
576 $scope.print.load_failed = true;
579 egCore.print.getPrintTemplateContext($scope.print.template_name)
580 .then(function(template_context) {
581 $scope.print.template_context = template_context;
585 $scope.reset_to_default = function() {
586 egCore.print.removePrintTemplate(
587 $scope.print.template_name
589 egCore.print.removePrintTemplateContext(
590 $scope.print.template_name
592 $scope.template_changed();
595 $scope.save_locally = function() {
596 egCore.print.storePrintTemplate(
597 $scope.print.template_name,
598 $scope.print.template_content
600 egCore.print.storePrintTemplateContext(
601 $scope.print.template_name,
602 $scope.print.template_context
606 $scope.exportable_templates = function() {
609 var deferred = $q.defer();
611 egCore.hatch.getKeys('eg.print.template').then(function(keys) {
612 angular.forEach(keys, function(key) {
613 if (key.match(/^eg\.print\.template\./)) {
614 promises.push(egCore.hatch.getItem(key).then(function(value) {
615 templates[key.replace('eg.print.template.', '')] = value;
618 promises.push(egCore.hatch.getItem(key).then(function(value) {
619 contexts[key.replace('eg.print.template_context.', '')] = value;
623 $q.all(promises).then(function() {
624 if (Object.keys(templates).length) {
626 templates: templates,
630 ngToast.warning(egCore.strings.PRINT_TEMPLATES_FAIL_EXPORT);
635 return deferred.promise;
638 $scope.imported_print_templates = { data : '' };
639 $scope.$watch('imported_print_templates.data', function(newVal, oldVal) {
640 if (newVal && newVal != oldVal) {
642 var data = JSON.parse(newVal);
643 angular.forEach(data.templates, function(template_content, template_name) {
644 egCore.print.storePrintTemplate(template_name, template_content);
646 angular.forEach(data.contexts, function(template_context, template_name) {
647 egCore.print.storePrintTemplateContext(template_name, template_context);
649 $scope.template_changed(); // refresh
650 ngToast.create(egCore.strings.PRINT_TEMPLATES_SUCCESS_IMPORT);
652 ngToast.warning(egCore.strings.PRINT_TEMPLATES_FAIL_IMPORT);
657 $scope.template_changed(); // load the default
661 .directive('egPrintTemplateOutput', ['$compile',function($compile) {
662 return function(scope, element, attrs) {
665 return scope.$eval(attrs.content);
668 // create an isolate scope and copy the print context
669 // data into the new scope.
670 // TODO: see also print security concerns in egHatch
671 var result = element.html(value);
672 var context = scope.$eval(attrs.context);
673 var print_scope = scope.$new(true);
674 angular.forEach(context, function(val, key) {
675 print_scope[key] = val;
677 $compile(element.contents())(print_scope);
683 .controller('StoredPrefsCtrl',
684 ['$scope','$q','egCore','egConfirmDialog',
685 function($scope , $q , egCore , egConfirmDialog) {
686 console.log('StoredPrefsCtrl');
688 $scope.setContext = function(ctx) {
689 $scope.context = ctx;
691 $scope.setContext('local');
693 // grab the edit perm
694 $scope.userHasDeletePerm = false;
695 egCore.perm.hasPermHere('ADMIN_WORKSTATION')
696 .then(function(bool) { $scope.userHasDeletePerm = bool });
700 function refreshKeys() {
701 $scope.keys = {local : [], remote : []};
703 if (egCore.hatch.hatchAvailable) {
704 egCore.hatch.getRemoteKeys().then(
705 function(keys) { $scope.keys.remote = keys.sort() })
708 // local calls are non-async
709 $scope.keys.local = egCore.hatch.getLocalKeys();
713 $scope.selectKey = function(key) {
714 $scope.currentKey = key;
715 $scope.currentKeyContent = null;
717 if ($scope.context == 'local') {
718 $scope.currentKeyContent = egCore.hatch.getLocalItem(key);
720 egCore.hatch.getRemoteItem(key)
721 .then(function(content) {
722 $scope.currentKeyContent = content
727 $scope.getCurrentKeyContent = function() {
728 return JSON.stringify($scope.currentKeyContent, null, 2);
731 $scope.removeKey = function(key) {
732 egConfirmDialog.open(
733 egCore.strings.PREFS_REMOVE_KEY_CONFIRM, '',
736 if ($scope.context == 'local') {
737 egCore.hatch.removeLocalItem(key);
740 egCore.hatch.removeItem(key)
741 .then(function() { refreshKeys() });
744 cancel : function() {} // user canceled, nothing to do
750 .controller('WSRegCtrl',
751 ['$scope','$q','$window','$location','egCore','egAlertDialog','workstationSvc',
752 function($scope , $q , $window , $location , egCore , egAlertDialog , workstationSvc) {
754 var all_workstations = [];
755 var reg_perm_orgs = [];
757 $scope.page_loaded = false;
758 $scope.contextOrg = egCore.org.get(egCore.auth.user().ws_ou());
759 $scope.wsOrgChanged = function(org) { $scope.contextOrg = org; }
761 console.log('set context org to ' + $scope.contextOrg);
763 // fetch workstation reg perms
764 egCore.perm.hasPermAt('REGISTER_WORKSTATION', true)
765 .then(function(orgList) {
766 reg_perm_orgs = orgList;
768 // hide orgs in the context org selector where this login
769 // does not have the reg_ws perm or the org can't have users
770 $scope.wsOrgHidden = function(id) {
771 return reg_perm_orgs.indexOf(id) == -1
772 || $scope.cant_have_users(id);
775 // fetch the locally stored workstation data
777 return workstationSvc.get_all()
779 }).then(function(all) {
780 all_workstations = all || [];
781 $scope.workstations =
782 all_workstations.map(function(w) { return w.name });
783 return workstationSvc.get_default()
785 // fetch the default workstation
786 }).then(function(def) {
787 $scope.defaultWS = def;
788 $scope.activeWS = $scope.selectedWS = egCore.auth.workstation() || def;
790 // Handle any URL commands.
792 var remove = $location.search().remove;
794 console.log('Removing WS via URL request: ' + remove);
795 return $scope.remove_ws(remove).then(
796 function() { $scope.page_loaded = true; });
798 $scope.page_loaded = true;
801 $scope.get_ws_label = function(ws) {
802 return ws == $scope.defaultWS ?
803 egCore.strings.$replace(egCore.strings.DEFAULT_WS_LABEL, {ws:ws}) : ws;
806 $scope.set_default_ws = function(name) {
807 delete $scope.removing_ws;
808 $scope.defaultWS = name;
809 workstationSvc.set_default(name);
812 $scope.cant_have_users =
813 function (id) { return !egCore.org.CanHaveUsers(id); };
814 $scope.cant_have_volumes =
815 function (id) { return !egCore.org.CanHaveVolumes(id); };
817 // Log out and return to login page with selected WS
818 $scope.use_now = function() {
819 egCore.auth.logout();
820 $window.location.href = $location
822 .search({ws : $scope.selectedWS})
826 $scope.can_delete_ws = function(name) {
827 var ws = all_workstations.filter(
828 function(ws) { return ws.name == name })[0];
829 return ws && reg_perm_orgs.indexOf(ws.owning_lib) != -1;
832 $scope.remove_ws = function(remove_me) {
833 $scope.removing_ws = remove_me;
835 // Perm is used to disable Remove button in UI, but have to check
836 // again here in case we're removing a WS based on URL params.
837 if (!$scope.can_delete_ws(remove_me)) return $q.when();
839 $scope.is_removing = true;
840 return workstationSvc.remove_workstation(remove_me)
843 all_workstations = all_workstations.filter(
844 function(ws) { return ws.name != remove_me });
846 $scope.workstations = $scope.workstations.filter(
847 function(ws) { return ws != remove_me });
849 if ($scope.selectedWS == remove_me)
850 $scope.selectedWS = $scope.workstations[0];
852 if ($scope.defaultWS == remove_me)
853 $scope.defaultWS = '';
855 $scope.is_removing = false;
859 $scope.register_ws = function() {
860 delete $scope.removing_ws;
863 $scope.contextOrg.shortname() + '-' + $scope.newWSName;
865 if ($scope.workstations.indexOf(full_name) > -1) {
866 // avoid duplicate local registrations
867 return egAlertDialog.open(egCore.strings.WS_USED);
870 $scope.is_registering = true;
871 workstationSvc.register_workstation(
872 $scope.newWSName, full_name,
873 $scope.contextOrg.id()
875 ).then(function(new_ws) {
876 $scope.workstations.push(new_ws.name);
877 all_workstations.push(new_ws);
878 $scope.is_registering = false;
880 if (!$scope.selectedWS) {
881 $scope.selectedWS = new_ws.name;
883 if (!$scope.defaultWS) {
884 return $scope.set_default_ws(new_ws.name);
886 $scope.newWSName = '';
888 $scope.is_registering = false;
893 .controller('HatchCtrl',
894 ['$scope','egCore','ngToast',
895 function($scope , egCore , ngToast) {
896 var hatch = egCore.hatch; // convenience
898 $scope.hatch_available = hatch.hatchAvailable;
899 $scope.hatch_printing = hatch.usePrinting();
900 $scope.hatch_settings = hatch.useSettings();
901 $scope.hatch_offline = hatch.useOffline();
903 // Apply Hatch settings as changes occur in the UI.
905 $scope.$watch('hatch_printing', function(newval) {
906 if (typeof newval != 'boolean') return;
907 hatch.setLocalItem('eg.hatch.enable.printing', newval);
910 $scope.$watch('hatch_settings', function(newval) {
911 if (typeof newval != 'boolean') return;
912 hatch.setLocalItem('eg.hatch.enable.settings', newval);
915 $scope.$watch('hatch_offline', function(newval) {
916 if (typeof newval != 'boolean') return;
917 hatch.setLocalItem('eg.hatch.enable.offline', newval);
920 $scope.copy_to_hatch = function() {
921 hatch.copySettingsToHatch().then(
923 ngToast.create(egCore.strings.HATCH_SETTINGS_MIGRATION_SUCCESS)},
925 ngToast.warning(egCore.strings.HATCH_SETTINGS_MIGRATION_FAILURE)}
929 $scope.copy_to_local = function() {
930 hatch.copySettingsToLocal().then(
932 ngToast.create(egCore.strings.HATCH_SETTINGS_MIGRATION_SUCCESS)},
934 ngToast.warning(egCore.strings.HATCH_SETTINGS_MIGRATION_FAILURE)}
941 * Home of the Latency tester
943 .controller('testsCtrl', ['$scope', '$location', 'egCore', function($scope, $location, egCore) {
944 $scope.hostname = $location.host();
947 $scope.clearTestData = function(){
952 $scope.isTesting = false;
953 $scope.avrg = 0; // avrg latency
954 $scope.canCopyCommand = document.queryCommandSupported('copy');
956 // initially fetch first 10 (gets a decent average)
958 function calcAverage(){
960 if ($scope.tests.length == 0) return 0;
962 if ($scope.tests.length == 1) return $scope.tests[0].l;
965 angular.forEach($scope.tests, function(t){
969 return sum / $scope.tests.length;
973 $scope.isTesting = true;
975 return egCore.net.request(
976 "open-ils.pcrud", "opensrf.system.echo", "ping"
977 ).then(function(resp){
979 var latency = t2 - t;
980 $scope.tests.push({t: new Date(t), l: latency});
981 console.log("Start: " + t + " and end: " + t2);
982 console.log("Latency: " + latency);
985 $scope.avrg = calcAverage();
987 $scope.isTesting = false;
991 $scope.testLatency = function(){
994 ping(); // just ping once after the initial ten
997 .then($scope.testLatency)
1000 $scope.tests.shift(); // toss first result
1001 $scope.avrg = calcAverage();
1007 $scope.copyTests = function(){
1009 var lNode = document.querySelector('#pingData');
1010 var r = document.createRange();
1011 r.selectNode(lNode);
1012 var sel = window.getSelection();
1013 sel.removeAllRanges();
1015 document.execCommand('copy');