<commit_before>'use strict';

(function (angular, buildfire) {
  angular.module('smoochChatPluginSettings', ['ui.bootstrap'])
    .controller('SettingsHomeCtrl', ['$scope', 'Buildfire', 'STATUS_CODE', 'TAG_NAMES', 'DataStore', function ($scope, Buildfire, STATUS_CODE, TAG_NAMES, DataStore) {
      var SettingsHome = this;
      SettingsHome.helloWorld = 'Hello World';
      // Smooch.init({appToken: '<KEY>'});
        SettingsHome.masterData = null;
      //Smooch.init({
      //    appToken: '<KEY>',
      //    customText: {
      //        headerText: 'How can we help?',
      //        inputPlaceholder: 'Type a message...',
      //        sendButtonText: 'Send',
      //        introText: 'This is the beginning of your conversation.<br/> Ask us anything!',
      //        settingsText: 'You can leave us your email so that we can get back to you this way.'
      //    }
      //});

      SettingsHome.data = {
        settings: {
          "apiKey": "",
          "headerText": ""
        }
      };

        function isUnchanged(data) {
          return angular.equals(data, SettingsHome.masterData);
        }

        function updateMasterItem(data) {
          SettingsHome.masterData = angular.copy(data);
        }
      /*Init method call, it will bring all the pre saved data*/
      SettingsHome.init = function () {
        SettingsHome.success = function (result) {
          console.info('init success result:', result);
          if (result) {
            SettingsHome.data = result.data;
            if (!SettingsHome.data.settings)
              SettingsHome.data.settings = {};
            updateMasterItem(SettingsHome.data);
          }
        };
        SettingsHome.error = function (err) {
          if (err && err.code !== STATUS_CODE.NOT_FOUND) {
            console.error('Error while getting data', err);
          }
          else if (err && err.code === STATUS_CODE.NOT_FOUND) {
            SettingsHome.saveData(JSON.parse(angular.toJson(SettingsHome.data)), TAG_NAMES.SMOOCH_CHAT_INFO);
          }
        };
        DataStore.get(TAG_NAMES.SMOOCH_CHAT_INFO).then(SettingsHome.success, SettingsHome.error);
      };
      SettingsHome.init();

      SettingsHome.saveData = function (newObj, tag) {
        if (typeof newObj === 'undefined') {
          return;
        }
        SettingsHome.success = function (result) {
          console.info('Saved data result: ', result);
        };
        SettingsHome.error = function (err) {
          console.error('Error while saving data : ', err);
        };
        DataStore.save(newObj, tag).then(SettingsHome.success, SettingsHome.error);
      };
      SettingsHome.saveApi = function () {
        SettingsHome.saveData(JSON.parse(angular.toJson(SettingsHome.data)), TAG_NAMES.SMOOCH_CHAT_INFO);
      };


        /*Save the data on .5 sec delay*/
        var tmrDelay = null;
        var saveDataWithDelay = function (newObj) {
          console.log("///////////",newObj)
          if (newObj) {
            if (isUnchanged(newObj)) {
              return;
            }
            if (tmrDelay) {
              clearTimeout(tmrDelay);
            }
            tmrDelay = setTimeout(function () {
            console.log("insave")
                SettingsHome.saveApi();
            }, 1000);
          }
        };

        /*
         * watch for changes in data and trigger the saveDataWithDelay function on change
         * */

        $scope.$watch(function () {
          return SettingsHome.data;
        }, saveDataWithDelay, true);

      SettingsHome.gotToPage = function(){
        window.open('https://app.smooch.io/signup', '_blank');
      };
    }])
})(window.angular, window.buildfire);<commit_msg>Modified test cases for settings section<commit_after>'use strict';

(function (angular, buildfire) {
  angular.module('smoochChatPluginSettings', ['ui.bootstrap'])
    .controller('SettingsHomeCtrl', ['$scope', 'Buildfire', 'STATUS_CODE', 'TAG_NAMES', 'DataStore', function ($scope, Buildfire, STATUS_CODE, TAG_NAMES, DataStore) {
      var SettingsHome = this;
      SettingsHome.helloWorld = 'Hello World';
      // Smooch.init({appToken: '<KEY>'});
      SettingsHome.masterData = null;
      //Smooch.init({
      //    appToken: '<KEY>',
      //    customText: {
      //        headerText: 'How can we help?',
      //        inputPlaceholder: 'Type a message...',
      //        sendButtonText: 'Send',
      //        introText: 'This is the beginning of your conversation.<br/> Ask us anything!',
      //        settingsText: 'You can leave us your email so that we can get back to you this way.'
      //    }
      //});

      SettingsHome.data = {
        settings: {
          "apiKey": "",
          "headerText": ""
        }
      };

      SettingsHome.isUnchanged = function(data) {
        return angular.equals(data, SettingsHome.masterData);
      };

      SettingsHome.updateMasterItem = function(data) {
        SettingsHome.masterData = angular.copy(data);
      };

      /*Init method call, it will bring all the pre saved data*/
      SettingsHome.init = function () {
        SettingsHome.success = function (result) {
          console.info('init success result:', result);
          if (result) {
            SettingsHome.data = result.data;
            if (!SettingsHome.data.settings)
              SettingsHome.data.settings = {};
            SettingsHome.updateMasterItem(SettingsHome.data);
          }
        };
        SettingsHome.error = function (err) {
          if (err && err.code !== STATUS_CODE.NOT_FOUND) {
            console.error('Error while getting data', err);
          }
          else if (err && err.code === STATUS_CODE.NOT_FOUND) {
            SettingsHome.saveData(JSON.parse(angular.toJson(SettingsHome.data)), TAG_NAMES.SMOOCH_CHAT_INFO);
          }
        };
        DataStore.get(TAG_NAMES.SMOOCH_CHAT_INFO).then(SettingsHome.success, SettingsHome.error);
      };
      SettingsHome.init();

      SettingsHome.saveData = function (newObj, tag) {
        if (typeof newObj === 'undefined') {
          return;
        }
        SettingsHome.success = function (result) {
          console.info('Saved data result: ', result);
        };
        SettingsHome.error = function (err) {
          console.error('Error while saving data : ', err);
        };
        DataStore.save(newObj, tag).then(SettingsHome.success, SettingsHome.error);
      };
      SettingsHome.saveApi = function () {
        SettingsHome.saveData(JSON.parse(angular.toJson(SettingsHome.data)), TAG_NAMES.SMOOCH_CHAT_INFO);
      };


      /*Save the data on .5 sec delay*/
      var tmrDelay = null;
      var saveDataWithDelay = function (newObj) {
        if (newObj) {
          if (SettingsHome.isUnchanged(newObj)) {
            return;
          }
          if (tmrDelay) {
            clearTimeout(tmrDelay);
          }
          tmrDelay = setTimeout(function () {
            console.log("insave")
            SettingsHome.saveApi();
          }, 1000);
        }
      };

      /*
       * watch for changes in data and trigger the saveDataWithDelay function on change
       * */

      $scope.$watch(function () {
        return SettingsHome.data;
      }, saveDataWithDelay, true);

      SettingsHome.gotToPage = function () {
        window.open('https://app.smooch.io/signup', '_blank');
      };
    }])
})(window.angular, window.buildfire);
{'fraction_non_alphanumeric': 0.1307568004309184, 'fraction_numerical': 0.00134661998384056, 'mean_word_length': 2.0191056910569105, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1423866', 'n_tokens_mistral': 2091, 'n_tokens_neox': 2052, 'n_words': 437}