| Total Complexity | 14 |
| Complexity/F | 2 |
| Lines of Code | 72 |
| Function Count | 7 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | |||
| 2 | (function () { |
||
| 3 | |||
| 4 | /** |
||
| 5 | * @constructor |
||
| 6 | */ |
||
| 7 | function CustomUserSettings() |
||
| 8 | { |
||
| 9 | this.userSkype = ko.observable(''); |
||
| 10 | this.userFacebook = ko.observable(''); |
||
| 11 | |||
| 12 | this.loading = ko.observable(false); |
||
| 13 | this.saving = ko.observable(false); |
||
| 14 | |||
| 15 | this.savingOrLoading = ko.computed(function () { |
||
| 16 | return this.loading() || this.saving(); |
||
| 17 | }, this); |
||
| 18 | } |
||
| 19 | |||
| 20 | CustomUserSettings.prototype.customAjaxSaveData = function () |
||
| 21 | { |
||
| 22 | var self = this; |
||
| 23 | |||
| 24 | if (this.saving()) |
||
| 25 | { |
||
| 26 | return false; |
||
| 27 | } |
||
| 28 | |||
| 29 | this.saving(true); |
||
| 30 | |||
| 31 | window.rl.pluginRemoteRequest(function (sResult, oData) { |
||
| 32 | |||
| 33 | self.saving(false); |
||
| 34 | |||
| 35 | if (window.rl.Enums.StorageResultType.Success === sResult && oData && oData.Result) |
||
| 36 | { |
||
| 37 | // true |
||
| 38 | } |
||
| 39 | else |
||
| 40 | { |
||
| 41 | // false |
||
| 42 | } |
||
| 43 | |||
| 44 | }, 'AjaxSaveCustomUserData', { |
||
| 45 | 'UserSkype': this.userSkype(), |
||
| 46 | 'UserFacebook': this.userFacebook() |
||
| 47 | }); |
||
| 48 | }; |
||
| 49 | |||
| 50 | CustomUserSettings.prototype.onBuild = function () // special function |
||
| 51 | { |
||
| 52 | var self = this; |
||
| 53 | |||
| 54 | this.loading(true); |
||
| 55 | |||
| 56 | window.rl.pluginRemoteRequest(function (sResult, oData) { |
||
| 57 | |||
| 58 | self.loading(false); |
||
| 59 | |||
| 60 | if (window.rl.Enums.StorageResultType.Success === sResult && oData && oData.Result) |
||
| 61 | { |
||
| 62 | self.userSkype(oData.Result.UserSkype || ''); |
||
| 63 | self.userFacebook(oData.Result.UserFacebook || ''); |
||
| 64 | } |
||
| 65 | |||
| 66 | }, 'AjaxGetCustomUserData'); |
||
| 67 | |||
| 68 | }; |
||
| 69 | |||
| 70 | window.rl.addSettingsViewModel(CustomUserSettings, 'PluginCustomSettingsTab', |
||
| 71 | 'SETTINGS_CUSTOM_PLUGIN/TAB_NAME', 'custom'); |
||
| 72 | |||
| 73 | }()); |