rsanchez
2015-09-24 94c288b4f8d353c44b64e40c0863c7fce6782293
securis/src/main/webapp/js/licenses.js
....@@ -724,7 +724,10 @@
724724 email: true
725725 }
726726 $scope.maxlength = {
727
+ activation_code: 36,
727728 code: 50,
729
+ full_name: 100,
730
+ email: 100,
728731 request_data: 500,
729732 comments: 1024
730733 }
....@@ -787,7 +790,8 @@
787790 $scope.isNew = true;
788791 $scope.showForm = true;
789792 $scope.license = {
790
- pack_id: $scope.currentPack.id
793
+ pack_id: $scope.currentPack.id,
794
+ activation_code: $scope.createUUID()
791795 }
792796 Packs.nextliccode($scope.currentPack.id, function(data) {
793797 console.log('New code: ' + data);
....@@ -797,12 +801,26 @@
797801 $('#licenseForm * #email').focus();
798802 }, 0);
799803 }
804
+ $scope.createUUID = function () {
805
+ // http://www.ietf.org/rfc/rfc4122.txt
806
+ var s = new Array(36);
807
+ var hexDigits = "0123456789abcdef";
808
+ for (var i = 0; i < 36; i++) {
809
+ s[i] = hexDigits.substr(Math.random() * 0x10 | 0, 1);
810
+ }
811
+ s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
812
+ s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
813
+ s[8] = s[13] = s[18] = s[23] = "-";
800814
815
+ var uuid = s.join("");
816
+ return uuid;
817
+ }
801818 $scope.editLicense = function(selectedlicense) {
802819 $scope.isNew = false;
803820 $scope.showForm = true;
804821 $scope.license = selectedlicense;
805822 $scope.license.status_name = Licenses.getStatusName($scope.license.status);
823
+ $scope.license.activation_code = $scope.license.activation_code || $scope.createUUID();
806824
807825 setTimeout(function() {
808826 $('#licenseForm * #code').focus();