Advertisement
genBTC

Franz bugfixed integrationClass.js

Nov 13th, 2016
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. function _classCallCheck(e, t) {
  4.     if(!(e instanceof t)) {
  5.         throw new TypeError('Cannot call a class as a function')
  6.     }
  7. }
  8. var _createClass = function () {
  9.         function e(e, t) {
  10.             for(var i = 0; i < t['length']; i++) {
  11.                 var o = t[i];
  12.                 o['enumerable'] = o['enumerable'] || !1, o['configurable'] = !0, 'value' in o && (o['writable'] = !0), Object['defineProperty'](e, o['key'], o)
  13.             }
  14.         }
  15.         return function (t, i, o) {
  16.             return i && e(t['prototype'], i), o && e(t, o), t
  17.         }
  18.     }(),
  19.     _ = require('underscore'),
  20.     path = require('path'),
  21.     _require = require('electron'),
  22.     ipcRenderer = _require['ipcRenderer'],
  23.     FranzIntegration = function () {
  24.         function e(t, i) {
  25.             if(_classCallCheck(this, e), this['options'] = t || {}, this['model'] = i, this['packageJSON'] = {}, void(0) === this['options']['path']) {
  26.                 throw console['error']('No plugin path specified')
  27.             };
  28.             try {
  29.                 if(this['packageJSON'] = require(path['join'](this['options']['path'], 'package.json')), !this['packageJSON']['config']) {
  30.                     throw console['error']('Integration "' + this['packageJSON']['name'] + '" is missing \'config\'')
  31.                 };
  32.                 _['extend'](this['options'], this['packageJSON']['config'])
  33.             } catch(o) {
  34.                 throw console['error']('Could not load "' + this['options']['path'] + 'package.json"')
  35.             };
  36.             Object['freeze'](this['getConfig']), Object['freeze'](this['getWebview'])
  37.         }
  38.         return _createClass(e, [{
  39.             key: 'getConfig',
  40.             value: function (e) {
  41.                 return void(0) !== e ? this['options'][e] : this['options']
  42.             }
  43.         }, {
  44.             key: 'getURL',
  45.             value: function () {
  46.                 var e = void(0);
  47.                 return e = this['options']['hostedOnly'] ? this['model']['get']('team') : this['options']['hasTeamID'] ? this['options']['serviceURL']['replace']('{teamID}', this['model']['get']('team')) : this['options']['serviceURL']
  48.             }
  49.         }, {
  50.             key: 'validateServer',
  51.             value: function () {
  52.                 return Promise['resolve'](!0)
  53.             }
  54.         }, {
  55.             key: 'getWebview',
  56.             value: function () {
  57.                 if(void(0) === this['model']) {
  58.                     throw console['error']('Model is missing')
  59.                 };
  60.                 var e = {
  61.                         id: 'webview_' + this['model']['get']('id'),
  62.                         "class": 'chatContainer',
  63.                         src: this['getURL'](),
  64.                         preload: './scripts/service/integration.js',
  65.                         partition: 'persist:' + this['options']['service'] + '_' + this['model']['get']('id'),
  66.                         "data-service": this['options']['service'],
  67.                         "data-id": this['model']['get']('id')
  68.                     },
  69.                     t = $('<webview />');
  70.                 var w = this.options.webviewOptions;
  71.                 return Object.keys(e).forEach(function (i) {
  72.                     t.attr(i, e[i]);
  73.                 }), Object.keys(w).forEach(function (i) {
  74.                     t.attr(i, w[i]);
  75.                 }), t;
  76.             }
  77.         }]), e
  78.     }();
  79. module['exports'] = FranzIntegration
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement