| .. | .. |
|---|
| 724 | 724 | email: true |
|---|
| 725 | 725 | } |
|---|
| 726 | 726 | $scope.maxlength = { |
|---|
| 727 | + activation_code: 36, |
|---|
| 727 | 728 | code: 50, |
|---|
| 729 | + full_name: 100, |
|---|
| 730 | + email: 100, |
|---|
| 728 | 731 | request_data: 500, |
|---|
| 729 | 732 | comments: 1024 |
|---|
| 730 | 733 | } |
|---|
| .. | .. |
|---|
| 787 | 790 | $scope.isNew = true; |
|---|
| 788 | 791 | $scope.showForm = true; |
|---|
| 789 | 792 | $scope.license = { |
|---|
| 790 | | - pack_id: $scope.currentPack.id |
|---|
| 793 | + pack_id: $scope.currentPack.id, |
|---|
| 794 | + activation_code: $scope.createUUID() |
|---|
| 791 | 795 | } |
|---|
| 792 | 796 | Packs.nextliccode($scope.currentPack.id, function(data) { |
|---|
| 793 | 797 | console.log('New code: ' + data); |
|---|
| .. | .. |
|---|
| 797 | 801 | $('#licenseForm * #email').focus(); |
|---|
| 798 | 802 | }, 0); |
|---|
| 799 | 803 | } |
|---|
| 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] = "-"; |
|---|
| 800 | 814 | |
|---|
| 815 | + var uuid = s.join(""); |
|---|
| 816 | + return uuid; |
|---|
| 817 | + } |
|---|
| 801 | 818 | $scope.editLicense = function(selectedlicense) { |
|---|
| 802 | 819 | $scope.isNew = false; |
|---|
| 803 | 820 | $scope.showForm = true; |
|---|
| 804 | 821 | $scope.license = selectedlicense; |
|---|
| 805 | 822 | $scope.license.status_name = Licenses.getStatusName($scope.license.status); |
|---|
| 823 | + $scope.license.activation_code = $scope.license.activation_code || $scope.createUUID(); |
|---|
| 806 | 824 | |
|---|
| 807 | 825 | setTimeout(function() { |
|---|
| 808 | 826 | $('#licenseForm * #code').focus(); |
|---|