1mcWeb.postlogin = new function () { 2 3 this.events = { 4 }; 5 6 this.vm = function (id) { 7 var self = this; 8 this.id = "#" + id; 9 this.conditionVM = new mcWeb.conditions.vm(self.id); 10 this.conditionsStatus = { 11 isFunctionalConditionAccepted: ko.observable(false), 12 acceptDocuments: ko.observableArray([]), 13 usageArea: 1 14 }; 15 this.successLoginResult = null; 16 this.lightboxCloseSubToken = null; 17 this.isStoring = ko.observable(false); 18 19 this.responseCounter = 0; 20 this.expectedResponses = 0; 21 this.initialAcceptChange = true; 22 this.conditionsStored = ko.observable(false); 23 this.conditionsStoringSuccessfull = ko.observable(false); 24 this.reminderText = ko.observable(""); 25 this.checkReminder = ko.observable(false); 26 this.reminderNextTime = null; 27 28 this.EDMAcceptDoc = null; 29 30 self.conditionsService = new WebApiService("Conditions"); 31 32 this.load = function (data, settings) { 33 if (settings) { 34 if(settings.successLoginResult) 35 self.successLoginResult = settings.successLoginResult; 36 } 37 if (null !== self.successLoginResult) { 38 self.reminderText(self.successLoginResult.Reminder.ReminderText); 39 self.reminderNextTime = self.successLoginResult.Reminder.NextReminderDate; 40 this.checkReminder.subscribe(function (newValue) { 41 if(newValue) 42 window.StorageService.localStorage.setItem('nextPostLoginConditionReminder', self.successLoginResult.Reminder.NextReminderDate); 43 else 44 window.StorageService.localStorage.setItem('nextPostLoginConditionReminder', null); 45 }); 46 } 47 self.conditionVM.id = "#postloginConditions"; 48 PubSub.publish(mcWeb.lightbox.events.modifyOptions, { backdrop: 'static' }); 49 self.lightboxCloseSubToken = PubSub.subscribe(mcWeb.lightbox.events.onHideLightbox, function () { 50 if (!self.isStoring()) { 51 PubSub.unsubscribe(self.lightboxCloseSubToken); 52 self.goPostLogin(); 53 } 54 }); 55 self.conditionVM.load(data, { usageArea: self.conditionsStatus.usageArea, forUnknownUser: false, isInLightbox: true, status: self.conditionsStatus, accordionstyleCollapse: false }); 56 PubSub.publish(mcWeb.lightbox.events.onHideSpinicon); 57 58 PubSub.subscribe(mcWeb.conditions.events.onAcceptChange, function (evt, conditionStatus) { 59 if (self.conditionsStatus.usageArea == conditionStatus.usageArea) { 60 self.conditionsStoringSuccessfull(false); 61 if (self.initialAcceptChange) { 62 self.conditionsStored(true); 63 self.initialAcceptChange = false;
64 self.conditionVM.expandAll(); 65 } else { 66 self.isStoring(true); 67 self.conditionsStored(false); 68 self.storeAcceptDocs(); 69 } 70 } 71 }); 72 73 74 }; 75 76 77 this.storeAcceptDocs = function () { 78 if (self.conditionsStatus.acceptDocuments !== undefined && self.conditionsStatus.acceptDocuments != null && self.conditionsStatus.acceptDocuments().length > 0) { 79 self.responseCounter = 0; 80 self.expectedResponses = self.conditionsStatus.acceptDocuments().length; 81 82 var userEmail = mcWeb.currentUser.getUser(); 83 84 for (i = 0; i < self.conditionsStatus.acceptDocuments().length; i++) { 85 var doc = self.conditionsStatus.acceptDocuments()[i]; 86 if (doc !== null) { 87 88 var acceptStatus = doc.Accepted; 89 90 if (! acceptStatus && doc.storedAcceptanceStatus == acceptStatus) { 91 //we only store Accept = true 92 self.responseCounter++; 93 continue; 94 } 95 96 var myParams = { 97 Accept: acceptStatus, 98 DocUsageId: doc.DocUsageID, 99 RevDataId: doc.RevDataID, 100 AvsAdresseID: null, 101 DomainId: null, 102 EmailAddress: userEmail, 103 ReferenceString: doc.FunctionReferenceString 104 }; 105 self.conditionsService.PostAction("RegisterTermAcceptance", myParams).then(function (result) { 106 self.isStoring(false); 107 if (result) { 108 if (result.RetCode == 0) { 109 self.responseCounter++; 110 for (i = 0; i < self.conditionsStatus.acceptDocuments().length; i++) { 111 var updatedDoc = self.conditionsStatus.acceptDocuments()[i]; 112 if (result.DocumentRevisionDataId == updatedDoc.RevDataID) 113 updatedDoc.storedAcceptanceStatus = updatedDoc.Accepted; 114 } 115 } 116 } else { 117 console.log("Something went wrong when registering acceptance. " + result); 118 } 119 console.log("expectedResponses:" + self.expectedResponses + ", responseCounter:" + self.responseCounter); 120 if (self.expectedResponses === self.responseCounter) { 121 self.conditionsStored(true); 122 self.conditionsStoringSuccessfull(true); 123 124 } 125 }); 126 } 127 } 128 129 130 } 131 132 133 134 // self.goPostLogin(); 135 }; 136 137 this.closeDialog = function () { 138 if (self.conditionsStored() != true) 139 { 140 if (!confirm("Endringene er ikke lagret. Fortsette uten å lagre?")) 141 return; 142 } 143 self.goPostLogin(); 144 145 146 }; 147 148 this.goPostLogin = function () { 149 mcWeb.login.postViewingConditions(self.successLoginResult); 150 } 151 152 }; 153};
vendor: 2 bytes, line 154
154
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.