diff --git a/js/devel/legacy.js b/js/devel/legacy.js index 15453ea..d0a2cf2 100644 --- a/js/devel/legacy.js +++ b/js/devel/legacy.js @@ -41,10 +41,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' {text: "Send"} ]; - $scope.setting_msgLimit = 100; - $scope.setting_enableNotifications = 1; - $scope.setting_contactOrder = 'lastmsg'; - $scope.setting_contactOrderReverse = true; + $scope.vsettings = SmsSettings; $scope.contacts = []; $scope.messages = []; @@ -68,25 +65,22 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' }; $scope.setMessageLimit = function () { - if ($scope.setting_msgLimit === null || $scope.setting_msgLimit === undefined) { - return; - } - $.post($scope.generateUrl('/set/msglimit'), {'limit': $scope.setting_msgLimit}); + $.post($scope.generateUrl('/set/msglimit'), {'limit': SmsSettings.messageLimit}); }; $scope.setNotificationSetting = function () { - if ($scope.setting_enableNotifications < 0 || $scope.setting_enableNotifications > 2) { - $scope.setting_enableNotifications = 0; - return; - } - $.post($scope.generateUrl('/set/notification_state'), {'notification': $scope.setting_enableNotifications}); + $.post($scope.generateUrl('/set/notification_state'), + { + 'notification': SmsSettings.enableNotifications ? 1 : 0 + } + ); }; $scope.setContactOrderSetting = function () { $.post($scope.generateUrl('/set/contact_order'), { - 'attribute': $scope.setting_contactOrder, - 'reverse': $scope.setting_contactOrderReverse + 'attribute': SmsSettings.contactOrderBy, + 'reverse': SmsSettings.reverseContactOrder } ); }; @@ -334,10 +328,10 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' $('select[name=setting_contact_order]').val(jsondata["contact_order"]); $('input[name=setting_contact_order_reverse]').val(toBool(jsondata["contact_order_reverse"])); - $scope.setting_msgLimit = parseInt(jsondata["message_limit"]); - $scope.setting_enableNotifications = jsondata["notification_state"]; - $scope.setting_contactOrder = jsondata["contact_order"]; - $scope.setting_contactOrderReverse = toBool(jsondata["contact_order_reverse"]); + SmsSettings.messageLimit = parseInt(jsondata["message_limit"]); + SmsSettings.enableNotifications = parseInt(jsondata["notification_state"]) !== 0; + SmsSettings.contactOrderBy = jsondata["contact_order"]; + SmsSettings.reverseContactOrder = toBool(jsondata["contact_order_reverse"]); } }); }; @@ -426,7 +420,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' }; $scope.desktopNotify = function (msg) { - if ($scope.setting_enableNotifications === 0) { + if (!SmsSettings.enableNotifications) { return; } diff --git a/js/devel/settings.js b/js/devel/settings.js new file mode 100644 index 0000000..967ccad --- /dev/null +++ b/js/devel/settings.js @@ -0,0 +1,16 @@ +/** + * Nextcloud - Phone Sync + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Loic Blot + * @copyright Loic Blot 2014-2017 + */ + +var SmsSettings = { + messageLimit: 100, + enableNotifications: true, + contactOrderBy: 'lastmsg', + reverseContactOrder: true +}; \ No newline at end of file diff --git a/templates/main.php b/templates/main.php index 2c61223..6a6840e 100644 --- a/templates/main.php +++ b/templates/main.php @@ -12,7 +12,7 @@ use \OCA\OcSms\Lib\CountryCodes;