whistle 2.9.7 → 2.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/plugin.js +43 -17
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +1 -1
- package/index.d.ts +1 -0
- package/lib/config.js +11 -7
- package/lib/https/index.js +43 -67
- package/lib/init.js +1 -20
- package/lib/plugins/get-plugins-sync.js +9 -5
- package/lib/plugins/get-plugins.js +5 -6
- package/lib/plugins/index.js +0 -1
- package/lib/plugins/module-paths.js +3 -4
- package/lib/upgrade.js +2 -2
- package/lib/util/index.js +51 -0
- package/package.json +1 -1
package/bin/plugin.js
CHANGED
|
@@ -7,19 +7,22 @@ var getWhistlePath = require('../lib/util/common').getWhistlePath;
|
|
|
7
7
|
|
|
8
8
|
var CMD_SUFFIX = process.platform === 'win32' ? '.cmd' : '';
|
|
9
9
|
var WHISTLE_PLUGIN_RE = /^((?:@[\w-]+\/)?whistle\.[a-z\d_-]+)(?:\@([\w.^~*-]*))?$/;
|
|
10
|
-
var PLUGIN_PATH = path.join(getWhistlePath(), 'plugins');
|
|
11
10
|
var CUSTOM_PLUGIN_PATH = path.join(getWhistlePath(), 'custom_plugins');
|
|
12
11
|
var PACKAGE_JSON = '{"repository":"https://github.com/avwo/whistle","license":"MIT"}';
|
|
13
12
|
var LICENSE = 'Copyright (c) 2019 avwo';
|
|
14
13
|
var RESP_URL = 'https://github.com/avwo/whistle';
|
|
14
|
+
var REMOTE_URL_RE = /^\s*((?:git[+@]|github:|https?:\/\/)[^\s]+\/whistle\.[a-z\d_-]+(?:\.git)?)\s*$/i;
|
|
15
15
|
|
|
16
16
|
function getInstallPath(name, dir) {
|
|
17
17
|
return path.join(dir || CUSTOM_PLUGIN_PATH, name);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function getPlugins(argv) {
|
|
20
|
+
function getPlugins(argv, isInstall) {
|
|
21
21
|
return argv.filter(function(name) {
|
|
22
|
-
|
|
22
|
+
if (WHISTLE_PLUGIN_RE.test(name)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return isInstall && REMOTE_URL_RE.test(name);
|
|
23
26
|
});
|
|
24
27
|
}
|
|
25
28
|
|
|
@@ -29,11 +32,6 @@ function removeDir(installPath) {
|
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
function removeOldPlugin(name) {
|
|
33
|
-
removeDir(path.join(PLUGIN_PATH, 'node_modules', name));
|
|
34
|
-
removeDir(path.join(PLUGIN_PATH, 'node_modules', getTempName(name)));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
35
|
function getTempName(name) {
|
|
38
36
|
if (name.indexOf('/') === -1) {
|
|
39
37
|
return '.' + name;
|
|
@@ -59,11 +57,28 @@ function getInstallDir(argv) {
|
|
|
59
57
|
return result;
|
|
60
58
|
}
|
|
61
59
|
|
|
60
|
+
function getPluginNameFormDeps(deps) {
|
|
61
|
+
var keys = Object.keys(deps);
|
|
62
|
+
for (var i = 0, len = keys.length; i < len; i++) {
|
|
63
|
+
if (WHISTLE_PLUGIN_RE.test(keys[i])) {
|
|
64
|
+
return RegExp.$1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getPkgName(name) {
|
|
70
|
+
if (/[/\\](whistle\.[a-z\d_-]+)(?:\.git)?$/.test(name)) {
|
|
71
|
+
return RegExp.$1;
|
|
72
|
+
}
|
|
73
|
+
return name;
|
|
74
|
+
}
|
|
75
|
+
|
|
62
76
|
function install(cmd, name, argv, ver, pluginsCache, callback) {
|
|
63
|
-
|
|
64
|
-
var
|
|
77
|
+
var result = getInstallDir(argv.slice());
|
|
78
|
+
var isPkg = WHISTLE_PLUGIN_RE.test(name);
|
|
79
|
+
var pkgName = isPkg ? name : getPkgName(name);
|
|
80
|
+
var installPath = getInstallPath(getTempName(pkgName), result.dir);
|
|
65
81
|
argv = result.argv;
|
|
66
|
-
var installPath = getInstallPath(getTempName(name), result.dir);
|
|
67
82
|
fse.ensureDirSync(installPath);
|
|
68
83
|
fse.emptyDirSync(installPath);
|
|
69
84
|
var pkgJson = PACKAGE_JSON;
|
|
@@ -74,7 +89,7 @@ function install(cmd, name, argv, ver, pluginsCache, callback) {
|
|
|
74
89
|
fs.writeFileSync(path.join(installPath, 'LICENSE'), LICENSE);
|
|
75
90
|
fs.writeFileSync(path.join(installPath, 'README.md'), RESP_URL);
|
|
76
91
|
argv.unshift('install', name);
|
|
77
|
-
pluginsCache[
|
|
92
|
+
pluginsCache[pkgName] = 1;
|
|
78
93
|
cp.spawn(cmd, argv, {
|
|
79
94
|
stdio: 'inherit',
|
|
80
95
|
cwd: installPath
|
|
@@ -83,11 +98,22 @@ function install(cmd, name, argv, ver, pluginsCache, callback) {
|
|
|
83
98
|
removeDir(installPath);
|
|
84
99
|
callback();
|
|
85
100
|
} else {
|
|
101
|
+
if (!isPkg) {
|
|
102
|
+
var deps = fse.readJsonSync(path.join(installPath, 'package.json')).dependencies;
|
|
103
|
+
name = deps && getPluginNameFormDeps(deps);
|
|
104
|
+
}
|
|
105
|
+
if (!name) {
|
|
106
|
+
try {
|
|
107
|
+
removeDir(installPath);
|
|
108
|
+
} catch (e) {}
|
|
109
|
+
return callback();
|
|
110
|
+
}
|
|
86
111
|
var realPath = getInstallPath(name, result.dir);
|
|
87
112
|
removeDir(realPath);
|
|
88
113
|
try {
|
|
89
114
|
fs.renameSync(installPath, realPath);
|
|
90
115
|
} catch (e) {
|
|
116
|
+
fse.ensureDirSync(realPath);
|
|
91
117
|
fse.copySync(installPath, realPath);
|
|
92
118
|
try {
|
|
93
119
|
removeDir(installPath);
|
|
@@ -125,7 +151,8 @@ function installPlugins(cmd, plugins, argv, pluginsCache, deep) {
|
|
|
125
151
|
var list = pkg.whistleConfig && (pkg.whistleConfig.peerPluginList || pkg.whistleConfig.peerPlugins);
|
|
126
152
|
if (Array.isArray(list) && list.length < 16) {
|
|
127
153
|
list.forEach(function(name) {
|
|
128
|
-
|
|
154
|
+
name = typeof name === 'string' ? name.trim() : null;
|
|
155
|
+
if (name && (WHISTLE_PLUGIN_RE.test(name) || REMOTE_URL_RE.test(name))) {
|
|
129
156
|
name = RegExp.$1;
|
|
130
157
|
if (peerPlugins.indexOf(name) === -1) {
|
|
131
158
|
peerPlugins.push(name);
|
|
@@ -142,11 +169,11 @@ function installPlugins(cmd, plugins, argv, pluginsCache, deep) {
|
|
|
142
169
|
}
|
|
143
170
|
};
|
|
144
171
|
plugins.forEach(function(name) {
|
|
145
|
-
|
|
172
|
+
var isPkg = WHISTLE_PLUGIN_RE.test(name);
|
|
173
|
+
if (isPkg || REMOTE_URL_RE.test(name)) {
|
|
146
174
|
++count;
|
|
147
175
|
name = RegExp.$1;
|
|
148
176
|
var ver = RegExp.$2;
|
|
149
|
-
removeOldPlugin(name);
|
|
150
177
|
install(cmd, name, argv, ver, pluginsCache, callback);
|
|
151
178
|
}
|
|
152
179
|
});
|
|
@@ -155,7 +182,7 @@ function installPlugins(cmd, plugins, argv, pluginsCache, deep) {
|
|
|
155
182
|
exports.getWhistlePath = getWhistlePath;
|
|
156
183
|
|
|
157
184
|
exports.install = function(cmd, argv) {
|
|
158
|
-
var plugins = getPlugins(argv);
|
|
185
|
+
var plugins = getPlugins(argv, true);
|
|
159
186
|
if (!plugins.length) {
|
|
160
187
|
return;
|
|
161
188
|
}
|
|
@@ -174,7 +201,6 @@ exports.uninstall = function(plugins) {
|
|
|
174
201
|
getPlugins(plugins).forEach(function(name) {
|
|
175
202
|
if (WHISTLE_PLUGIN_RE.test(name)) {
|
|
176
203
|
name = RegExp.$1;
|
|
177
|
-
!result.dir && removeOldPlugin(name);
|
|
178
204
|
removeDir(getInstallPath(name, result.dir));
|
|
179
205
|
}
|
|
180
206
|
});
|
|
@@ -99,5 +99,5 @@ result:t,type:i(t.req.headers),method:t.req.method,tabName:"Request"},r=p.getBod
|
|
|
99
99
|
*/
|
|
100
100
|
if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(e){"use strict";var t=e.fn.jquery.split(" ")[0].split(".");if(t[0]<2&&t[1]<9||1==t[0]&&9==t[1]&&t[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(e){"use strict";function t(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var n in t)if(void 0!==e.style[n])return{end:t[n]};return!1}e.fn.emulateTransitionEnd=function(t){var n=!1,r=this;e(this).one("bsTransitionEnd",function(){n=!0});var o=function(){n||e(r).trigger(e.support.transition.end)};return setTimeout(o,t),this},e(function(){e.support.transition=t(),e.support.transition&&(e.event.special.bsTransitionEnd={bindType:e.support.transition.end,delegateType:e.support.transition.end,handle:function(t){return e(t.target).is(this)?t.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(e){"use strict";function t(t){return this.each(function(){var n=e(this),o=n.data("bs.alert");o||n.data("bs.alert",o=new r(this)),"string"==typeof t&&o[t].call(n)})}var n='[data-dismiss="alert"]',r=function(t){e(t).on("click",n,this.close)};r.VERSION="3.3.5",r.TRANSITION_DURATION=150,r.prototype.close=function(t){function n(){a.detach().trigger("closed.bs.alert").remove()}var o=e(this),i=o.attr("data-target");i||(i=o.attr("href"),i=i&&i.replace(/.*(?=#[^\s]*$)/,""));var a=e(i);t&&t.preventDefault(),a.length||(a=o.closest(".alert")),a.trigger(t=e.Event("close.bs.alert")),t.isDefaultPrevented()||(a.removeClass("in"),e.support.transition&&a.hasClass("fade")?a.one("bsTransitionEnd",n).emulateTransitionEnd(r.TRANSITION_DURATION):n())};var o=e.fn.alert;e.fn.alert=t,e.fn.alert.Constructor=r,e.fn.alert.noConflict=function(){return e.fn.alert=o,this},e(document).on("click.bs.alert.data-api",n,r.prototype.close)}(jQuery),+function(e){"use strict";function t(t){return this.each(function(){var r=e(this),o=r.data("bs.button"),i="object"==typeof t&&t;o||r.data("bs.button",o=new n(this,i)),"toggle"==t?o.toggle():t&&o.setState(t)})}var n=function(t,r){this.$element=e(t),this.options=e.extend({},n.DEFAULTS,r),this.isLoading=!1};n.VERSION="3.3.5",n.DEFAULTS={loadingText:"loading..."},n.prototype.setState=function(t){var n="disabled",r=this.$element,o=r.is("input")?"val":"html",i=r.data();t+="Text",null==i.resetText&&r.data("resetText",r[o]()),setTimeout(e.proxy(function(){r[o](null==i[t]?this.options[t]:i[t]),"loadingText"==t?(this.isLoading=!0,r.addClass(n).attr(n,n)):this.isLoading&&(this.isLoading=!1,r.removeClass(n).removeAttr(n))},this),0)},n.prototype.toggle=function(){var e=!0,t=this.$element.closest('[data-toggle="buttons"]');if(t.length){var n=this.$element.find("input");"radio"==n.prop("type")?(n.prop("checked")&&(e=!1),t.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==n.prop("type")&&(n.prop("checked")!==this.$element.hasClass("active")&&(e=!1),this.$element.toggleClass("active")),n.prop("checked",this.$element.hasClass("active")),e&&n.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var r=e.fn.button;e.fn.button=t,e.fn.button.Constructor=n,e.fn.button.noConflict=function(){return e.fn.button=r,this},e(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(n){var r=e(n.target);r.hasClass("btn")||(r=r.closest(".btn")),t.call(r,"toggle"),e(n.target).is('input[type="radio"]')||e(n.target).is('input[type="checkbox"]')||n.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(t){e(t.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(t.type))})}(jQuery),+function(e){"use strict";function t(t){return this.each(function(){var r=e(this),o=r.data("bs.carousel"),i=e.extend({},n.DEFAULTS,r.data(),"object"==typeof t&&t),a="string"==typeof t?t:i.slide;o||r.data("bs.carousel",o=new n(this,i)),"number"==typeof t?o.to(t):a?o[a]():i.interval&&o.pause().cycle()})}var n=function(t,n){this.$element=e(t),this.$indicators=this.$element.find(".carousel-indicators"),this.options=n,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",e.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",e.proxy(this.pause,this)).on("mouseleave.bs.carousel",e.proxy(this.cycle,this))};n.VERSION="3.3.5",n.TRANSITION_DURATION=600,n.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},n.prototype.keydown=function(e){if(!/input|textarea/i.test(e.target.tagName)){switch(e.which){case 37:this.prev();break;case 39:this.next();break;default:return}e.preventDefault()}},n.prototype.cycle=function(t){return t||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},n.prototype.getItemIndex=function(e){return this.$items=e.parent().children(".item"),this.$items.index(e||this.$active)},n.prototype.getItemForDirection=function(e,t){var n=this.getItemIndex(t),r="prev"==e&&0===n||"next"==e&&n==this.$items.length-1;if(r&&!this.options.wrap)return t;var o="prev"==e?-1:1,i=(n+o)%this.$items.length;return this.$items.eq(i)},n.prototype.to=function(e){var t=this,n=this.getItemIndex(this.$active=this.$element.find(".item.active"));return e>this.$items.length-1||0>e?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){t.to(e)}):n==e?this.pause().cycle():this.slide(e>n?"next":"prev",this.$items.eq(e))},n.prototype.pause=function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition&&(this.$element.trigger(e.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},n.prototype.next=function(){return this.sliding?void 0:this.slide("next")},n.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},n.prototype.slide=function(t,r){var o=this.$element.find(".item.active"),i=r||this.getItemForDirection(t,o),a=this.interval,s="next"==t?"left":"right",l=this;if(i.hasClass("active"))return this.sliding=!1;var c=i[0],u=e.Event("slide.bs.carousel",{relatedTarget:c,direction:s});if(this.$element.trigger(u),!u.isDefaultPrevented()){if(this.sliding=!0,a&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var d=e(this.$indicators.children()[this.getItemIndex(i)]);d&&d.addClass("active")}var p=e.Event("slid.bs.carousel",{relatedTarget:c,direction:s});return e.support.transition&&this.$element.hasClass("slide")?(i.addClass(t),i[0].offsetWidth,o.addClass(s),i.addClass(s),o.one("bsTransitionEnd",function(){i.removeClass([t,s].join(" ")).addClass("active"),o.removeClass(["active",s].join(" ")),l.sliding=!1,setTimeout(function(){l.$element.trigger(p)},0)}).emulateTransitionEnd(n.TRANSITION_DURATION)):(o.removeClass("active"),i.addClass("active"),this.sliding=!1,this.$element.trigger(p)),a&&this.cycle(),this}};var r=e.fn.carousel;e.fn.carousel=t,e.fn.carousel.Constructor=n,e.fn.carousel.noConflict=function(){return e.fn.carousel=r,this};var o=function(n){var r,o=e(this),i=e(o.attr("data-target")||(r=o.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,""));if(i.hasClass("carousel")){var a=e.extend({},i.data(),o.data()),s=o.attr("data-slide-to");s&&(a.interval=!1),t.call(i,a),s&&i.data("bs.carousel").to(s),n.preventDefault()}};e(document).on("click.bs.carousel.data-api","[data-slide]",o).on("click.bs.carousel.data-api","[data-slide-to]",o),e(window).on("load",function(){e('[data-ride="carousel"]').each(function(){var n=e(this);t.call(n,n.data())})})}(jQuery),+function(e){"use strict";function t(t){var n,r=t.attr("data-target")||(n=t.attr("href"))&&n.replace(/.*(?=#[^\s]+$)/,"");return e(r)}function n(t){return this.each(function(){var n=e(this),o=n.data("bs.collapse"),i=e.extend({},r.DEFAULTS,n.data(),"object"==typeof t&&t);!o&&i.toggle&&/show|hide/.test(t)&&(i.toggle=!1),o||n.data("bs.collapse",o=new r(this,i)),"string"==typeof t&&o[t]()})}var r=function(t,n){this.$element=e(t),this.options=e.extend({},r.DEFAULTS,n),this.$trigger=e('[data-toggle="collapse"][href="#'+t.id+'"],[data-toggle="collapse"][data-target="#'+t.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};r.VERSION="3.3.5",r.TRANSITION_DURATION=350,r.DEFAULTS={toggle:!0},r.prototype.dimension=function(){var e=this.$element.hasClass("width");return e?"width":"height"},r.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var t,o=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(o&&o.length&&(t=o.data("bs.collapse"),t&&t.transitioning))){var i=e.Event("show.bs.collapse");if(this.$element.trigger(i),!i.isDefaultPrevented()){o&&o.length&&(n.call(o,"hide"),t||o.data("bs.collapse",null));var a=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[a](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var s=function(){this.$element.removeClass("collapsing").addClass("collapse in")[a](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!e.support.transition)return s.call(this);var l=e.camelCase(["scroll",a].join("-"));this.$element.one("bsTransitionEnd",e.proxy(s,this)).emulateTransitionEnd(r.TRANSITION_DURATION)[a](this.$element[0][l])}}}},r.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var t=e.Event("hide.bs.collapse");if(this.$element.trigger(t),!t.isDefaultPrevented()){var n=this.dimension();this.$element[n](this.$element[n]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var o=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return e.support.transition?void this.$element[n](0).one("bsTransitionEnd",e.proxy(o,this)).emulateTransitionEnd(r.TRANSITION_DURATION):o.call(this)}}},r.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},r.prototype.getParent=function(){return e(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(e.proxy(function(n,r){var o=e(r);this.addAriaAndCollapsedClass(t(o),o)},this)).end()},r.prototype.addAriaAndCollapsedClass=function(e,t){var n=e.hasClass("in");e.attr("aria-expanded",n),t.toggleClass("collapsed",!n).attr("aria-expanded",n)};var o=e.fn.collapse;e.fn.collapse=n,e.fn.collapse.Constructor=r,e.fn.collapse.noConflict=function(){return e.fn.collapse=o,this},e(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(r){var o=e(this);o.attr("data-target")||r.preventDefault();var i=t(o),a=i.data("bs.collapse"),s=a?"toggle":o.data();n.call(i,s)})}(jQuery),+function(e){"use strict";function t(t){var n=t.attr("data-target");n||(n=t.attr("href"),n=n&&/#[A-Za-z]/.test(n)&&n.replace(/.*(?=#[^\s]*$)/,""));var r=n&&e(n);return r&&r.length?r:t.parent()}function n(n){n&&3===n.which||(e(o).remove(),e(i).each(function(){var r=e(this),o=t(r),i={relatedTarget:this};o.hasClass("open")&&(n&&"click"==n.type&&/input|textarea/i.test(n.target.tagName)&&e.contains(o[0],n.target)||(o.trigger(n=e.Event("hide.bs.dropdown",i)),n.isDefaultPrevented()||(r.attr("aria-expanded","false"),o.removeClass("open").trigger("hidden.bs.dropdown",i))))}))}function r(t){return this.each(function(){var n=e(this),r=n.data("bs.dropdown");r||n.data("bs.dropdown",r=new a(this)),"string"==typeof t&&r[t].call(n)})}var o=".dropdown-backdrop",i='[data-toggle="dropdown"]',a=function(t){e(t).on("click.bs.dropdown",this.toggle)};a.VERSION="3.3.5",a.prototype.toggle=function(r){var o=e(this);if(!o.is(".disabled, :disabled")){var i=t(o),a=i.hasClass("open");if(n(),!a){"ontouchstart"in document.documentElement&&!i.closest(".navbar-nav").length&&e(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(e(this)).on("click",n);var s={relatedTarget:this};if(i.trigger(r=e.Event("show.bs.dropdown",s)),r.isDefaultPrevented())return;o.trigger("focus").attr("aria-expanded","true"),i.toggleClass("open").trigger("shown.bs.dropdown",s)}return!1}},a.prototype.keydown=function(n){if(/(38|40|27|32)/.test(n.which)&&!/input|textarea/i.test(n.target.tagName)){var r=e(this);if(n.preventDefault(),n.stopPropagation(),!r.is(".disabled, :disabled")){var o=t(r),a=o.hasClass("open");if(!a&&27!=n.which||a&&27==n.which)return 27==n.which&&o.find(i).trigger("focus"),r.trigger("click");var s=" li:not(.disabled):visible a",l=o.find(".dropdown-menu"+s);if(l.length){var c=l.index(n.target);38==n.which&&c>0&&c--,40==n.which&&c<l.length-1&&c++,~c||(c=0),l.eq(c).trigger("focus")}}}};var s=e.fn.dropdown;e.fn.dropdown=r,e.fn.dropdown.Constructor=a,e.fn.dropdown.noConflict=function(){return e.fn.dropdown=s,this},e(document).on("click.bs.dropdown.data-api",n).on("click.bs.dropdown.data-api",".dropdown form",function(e){e.stopPropagation()}).on("click.bs.dropdown.data-api",i,a.prototype.toggle).on("keydown.bs.dropdown.data-api",i,a.prototype.keydown).on("keydown.bs.dropdown.data-api",".dropdown-menu",a.prototype.keydown)}(jQuery),+function(e){"use strict";function t(t,r){return this.each(function(){var o=e(this),i=o.data("bs.modal"),a=e.extend({},n.DEFAULTS,o.data(),"object"==typeof t&&t);i||o.data("bs.modal",i=new n(this,a)),"string"==typeof t?i[t](r):a.show&&i.show(r)})}var n=function(t,n){this.options=n,this.$body=e(document.body),this.$element=e(t),this.$dialog=this.$element.find(".modal-dialog"),this.$backdrop=null,this.isShown=null,this.originalBodyPad=null,this.scrollbarWidth=0,this.ignoreBackdropClick=!1,this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,e.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};n.VERSION="3.3.5",n.TRANSITION_DURATION=300,n.BACKDROP_TRANSITION_DURATION=150,n.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},n.prototype.toggle=function(e){return this.isShown?this.hide():this.show(e)},n.prototype.show=function(t){var r=this,o=e.Event("show.bs.modal",{relatedTarget:t});this.$element.trigger(o),this.isShown||o.isDefaultPrevented()||(this.isShown=!0,this.checkScrollbar(),this.setScrollbar(),this.$body.addClass("modal-open"),this.escape(),this.resize(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',e.proxy(this.hide,this)),this.$dialog.on("mousedown.dismiss.bs.modal",function(){r.$element.one("mouseup.dismiss.bs.modal",function(t){e(t.target).is(r.$element)&&(r.ignoreBackdropClick=!0)})}),this.backdrop(function(){var o=e.support.transition&&r.$element.hasClass("fade");r.$element.parent().length||r.$element.appendTo(r.$body),r.$element.show().scrollTop(0),r.adjustDialog(),o&&r.$element[0].offsetWidth,r.$element.addClass("in"),r.enforceFocus();var i=e.Event("shown.bs.modal",{relatedTarget:t});o?r.$dialog.one("bsTransitionEnd",function(){r.$element.trigger("focus").trigger(i)}).emulateTransitionEnd(n.TRANSITION_DURATION):r.$element.trigger("focus").trigger(i)}))},n.prototype.hide=function(t){t&&t.preventDefault(),t=e.Event("hide.bs.modal"),this.$element.trigger(t),this.isShown&&!t.isDefaultPrevented()&&(this.isShown=!1,this.escape(),this.resize(),e(document).off("focusin.bs.modal"),this.$element.removeClass("in").off("click.dismiss.bs.modal").off("mouseup.dismiss.bs.modal"),this.$dialog.off("mousedown.dismiss.bs.modal"),e.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",e.proxy(this.hideModal,this)).emulateTransitionEnd(n.TRANSITION_DURATION):this.hideModal())},n.prototype.enforceFocus=function(){e(document).off("focusin.bs.modal").on("focusin.bs.modal",e.proxy(function(e){this.$element[0]===e.target||this.$element.has(e.target).length||this.$element.trigger("focus")},this))},n.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keydown.dismiss.bs.modal",e.proxy(function(e){27==e.which&&this.hide()},this)):this.isShown||this.$element.off("keydown.dismiss.bs.modal")},n.prototype.resize=function(){this.isShown?e(window).on("resize.bs.modal",e.proxy(this.handleUpdate,this)):e(window).off("resize.bs.modal")},n.prototype.hideModal=function(){var e=this;this.$element.hide(),this.backdrop(function(){e.$body.removeClass("modal-open"),e.resetAdjustments(),e.resetScrollbar(),e.$element.trigger("hidden.bs.modal")})},n.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},n.prototype.backdrop=function(t){var r=this,o=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var i=e.support.transition&&o;if(this.$backdrop=e(document.createElement("div")).addClass("modal-backdrop "+o).appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",e.proxy(function(e){return this.ignoreBackdropClick?void(this.ignoreBackdropClick=!1):void(e.target===e.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus():this.hide()))},this)),i&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!t)return;i?this.$backdrop.one("bsTransitionEnd",t).emulateTransitionEnd(n.BACKDROP_TRANSITION_DURATION):t()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var a=function(){r.removeBackdrop(),t&&t()};e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",a).emulateTransitionEnd(n.BACKDROP_TRANSITION_DURATION):a()}else t&&t()},n.prototype.handleUpdate=function(){this.adjustDialog()},n.prototype.adjustDialog=function(){var e=this.$element[0].scrollHeight>document.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&e?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!e?this.scrollbarWidth:""})},n.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},n.prototype.checkScrollbar=function(){var e=window.innerWidth;if(!e){var t=document.documentElement.getBoundingClientRect();e=t.right-Math.abs(t.left)}this.bodyIsOverflowing=document.body.clientWidth<e,this.scrollbarWidth=this.measureScrollbar()},n.prototype.setScrollbar=function(){var e=parseInt(this.$body.css("padding-right")||0,10);this.originalBodyPad=document.body.style.paddingRight||"",this.bodyIsOverflowing&&this.$body.css("padding-right",e+this.scrollbarWidth)},n.prototype.resetScrollbar=function(){this.$body.css("padding-right",this.originalBodyPad)},n.prototype.measureScrollbar=function(){var e=document.createElement("div");e.className="modal-scrollbar-measure",this.$body.append(e);var t=e.offsetWidth-e.clientWidth;return this.$body[0].removeChild(e),t};var r=e.fn.modal;e.fn.modal=t,e.fn.modal.Constructor=n,e.fn.modal.noConflict=function(){return e.fn.modal=r,this},e(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(n){var r=e(this),o=r.attr("href"),i=e(r.attr("data-target")||o&&o.replace(/.*(?=#[^\s]+$)/,"")),a=i.data("bs.modal")?"toggle":e.extend({remote:!/#/.test(o)&&o},i.data(),r.data());r.is("a")&&n.preventDefault(),i.one("show.bs.modal",function(e){e.isDefaultPrevented()||i.one("hidden.bs.modal",function(){r.is(":visible")&&r.trigger("focus")})}),t.call(i,a,this)})}(jQuery),+function(e){"use strict";function t(t){return this.each(function(){var r=e(this),o=r.data("bs.tooltip"),i="object"==typeof t&&t;(o||!/destroy|hide/.test(t))&&(o||r.data("bs.tooltip",o=new n(this,i)),"string"==typeof t&&o[t]())})}var n=function(e,t){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.inState=null,this.init("tooltip",e,t)};n.VERSION="3.3.5",n.TRANSITION_DURATION=150,n.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},n.prototype.init=function(t,n,r){if(this.enabled=!0,this.type=t,this.$element=e(n),this.options=this.getOptions(r),this.$viewport=this.options.viewport&&e(e.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var o=this.options.trigger.split(" "),i=o.length;i--;){var a=o[i];if("click"==a)this.$element.on("click."+this.type,this.options.selector,e.proxy(this.toggle,this));else if("manual"!=a){var s="hover"==a?"mouseenter":"focusin",l="hover"==a?"mouseleave":"focusout";this.$element.on(s+"."+this.type,this.options.selector,e.proxy(this.enter,this)),this.$element.on(l+"."+this.type,this.options.selector,e.proxy(this.leave,this))}}this.options.selector?this._options=e.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},n.prototype.getDefaults=function(){return n.DEFAULTS},n.prototype.getOptions=function(t){return t=e.extend({},this.getDefaults(),this.$element.data(),t),t.delay&&"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),t},n.prototype.getDelegateOptions=function(){var t={},n=this.getDefaults();return this._options&&e.each(this._options,function(e,r){n[e]!=r&&(t[e]=r)}),t},n.prototype.enter=function(t){var n=t instanceof this.constructor?t:e(t.currentTarget).data("bs."+this.type);return n||(n=new this.constructor(t.currentTarget,this.getDelegateOptions()),e(t.currentTarget).data("bs."+this.type,n)),t instanceof e.Event&&(n.inState["focusin"==t.type?"focus":"hover"]=!0),n.tip().hasClass("in")||"in"==n.hoverState?void(n.hoverState="in"):(clearTimeout(n.timeout),n.hoverState="in",n.options.delay&&n.options.delay.show?void(n.timeout=setTimeout(function(){"in"==n.hoverState&&n.show()},n.options.delay.show)):n.show())},n.prototype.isInStateTrue=function(){for(var e in this.inState)if(this.inState[e])return!0;return!1},n.prototype.leave=function(t){var n=t instanceof this.constructor?t:e(t.currentTarget).data("bs."+this.type);return n||(n=new this.constructor(t.currentTarget,this.getDelegateOptions()),e(t.currentTarget).data("bs."+this.type,n)),t instanceof e.Event&&(n.inState["focusout"==t.type?"focus":"hover"]=!1),n.isInStateTrue()?void 0:(clearTimeout(n.timeout),n.hoverState="out",n.options.delay&&n.options.delay.hide?void(n.timeout=setTimeout(function(){"out"==n.hoverState&&n.hide()},n.options.delay.hide)):n.hide())},n.prototype.show=function(){var t=e.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(t);var r=e.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(t.isDefaultPrevented()||!r)return;var o=this,i=this.tip(),a=this.getUID(this.type);this.setContent(),i.attr("id",a),this.$element.attr("aria-describedby",a),this.options.animation&&i.addClass("fade");var s="function"==typeof this.options.placement?this.options.placement.call(this,i[0],this.$element[0]):this.options.placement,l=/\s?auto?\s?/i,c=l.test(s);c&&(s=s.replace(l,"")||"top"),i.detach().css({top:0,left:0,display:"block"}).addClass(s).data("bs."+this.type,this),this.options.container?i.appendTo(this.options.container):i.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var u=this.getPosition(),d=i[0].offsetWidth,p=i[0].offsetHeight;if(c){var g=s,h=this.getPosition(this.$viewport);s="bottom"==s&&u.bottom+p>h.bottom?"top":"top"==s&&u.top-p<h.top?"bottom":"right"==s&&u.right+d>h.width?"left":"left"==s&&u.left-d<h.left?"right":s,i.removeClass(g).addClass(s)}var f=this.getCalculatedOffset(s,u,d,p);this.applyPlacement(f,s);var m=function(){var e=o.hoverState;o.$element.trigger("shown.bs."+o.type),o.hoverState=null,"out"==e&&o.leave(o)};e.support.transition&&this.$tip.hasClass("fade")?i.one("bsTransitionEnd",m).emulateTransitionEnd(n.TRANSITION_DURATION):m()}},n.prototype.applyPlacement=function(t,n){var r=this.tip(),o=r[0].offsetWidth,i=r[0].offsetHeight,a=parseInt(r.css("margin-top"),10),s=parseInt(r.css("margin-left"),10);isNaN(a)&&(a=0),isNaN(s)&&(s=0),t.top+=a,t.left+=s,e.offset.setOffset(r[0],e.extend({using:function(e){r.css({top:Math.round(e.top),left:Math.round(e.left)})}},t),0),r.addClass("in");var l=r[0].offsetWidth,c=r[0].offsetHeight;"top"==n&&c!=i&&(t.top=t.top+i-c);var u=this.getViewportAdjustedDelta(n,t,l,c);u.left?t.left+=u.left:t.top+=u.top;var d=/top|bottom/.test(n),p=d?2*u.left-o+l:2*u.top-i+c,g=d?"offsetWidth":"offsetHeight";r.offset(t),this.replaceArrow(p,r[0][g],d)},n.prototype.replaceArrow=function(e,t,n){this.arrow().css(n?"left":"top",50*(1-e/t)+"%").css(n?"top":"left","")},n.prototype.setContent=function(){var e=this.tip(),t=this.getTitle();e.find(".tooltip-inner")[this.options.html?"html":"text"](t),e.removeClass("fade in top bottom left right")},n.prototype.hide=function(t){function r(){"in"!=o.hoverState&&i.detach(),o.$element.removeAttr("aria-describedby").trigger("hidden.bs."+o.type),t&&t()}var o=this,i=e(this.$tip),a=e.Event("hide.bs."+this.type);return this.$element.trigger(a),a.isDefaultPrevented()?void 0:(i.removeClass("in"),e.support.transition&&i.hasClass("fade")?i.one("bsTransitionEnd",r).emulateTransitionEnd(n.TRANSITION_DURATION):r(),this.hoverState=null,this)},n.prototype.fixTitle=function(){var e=this.$element;(e.attr("title")||"string"!=typeof e.attr("data-original-title"))&&e.attr("data-original-title",e.attr("title")||"").attr("title","")},n.prototype.hasContent=function(){return this.getTitle()},n.prototype.getPosition=function(t){t=t||this.$element;var n=t[0],r="BODY"==n.tagName,o=n.getBoundingClientRect();null==o.width&&(o=e.extend({},o,{width:o.right-o.left,height:o.bottom-o.top}));var i=r?{top:0,left:0}:t.offset(),a={scroll:r?document.documentElement.scrollTop||document.body.scrollTop:t.scrollTop()},s=r?{width:e(window).width(),height:e(window).height()}:null;return e.extend({},o,a,s,i)},n.prototype.getCalculatedOffset=function(e,t,n,r){return"bottom"==e?{top:t.top+t.height,left:t.left+t.width/2-n/2}:"top"==e?{top:t.top-r,left:t.left+t.width/2-n/2}:"left"==e?{top:t.top+t.height/2-r/2,left:t.left-n}:{top:t.top+t.height/2-r/2,left:t.left+t.width}},n.prototype.getViewportAdjustedDelta=function(e,t,n,r){var o={top:0,left:0};if(!this.$viewport)return o;var i=this.options.viewport&&this.options.viewport.padding||0,a=this.getPosition(this.$viewport);if(/right|left/.test(e)){var s=t.top-i-a.scroll,l=t.top+i-a.scroll+r;s<a.top?o.top=a.top-s:l>a.top+a.height&&(o.top=a.top+a.height-l)}else{var c=t.left-i,u=t.left+i+n;c<a.left?o.left=a.left-c:u>a.right&&(o.left=a.left+a.width-u)}return o},n.prototype.getTitle=function(){var e,t=this.$element,n=this.options;return e=t.attr("data-original-title")||("function"==typeof n.title?n.title.call(t[0]):n.title)},n.prototype.getUID=function(e){do e+=~~(1e6*Math.random());while(document.getElementById(e));return e},n.prototype.tip=function(){if(!this.$tip&&(this.$tip=e(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},n.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},n.prototype.enable=function(){this.enabled=!0},n.prototype.disable=function(){this.enabled=!1},n.prototype.toggleEnabled=function(){this.enabled=!this.enabled},n.prototype.toggle=function(t){var n=this;t&&(n=e(t.currentTarget).data("bs."+this.type),n||(n=new this.constructor(t.currentTarget,this.getDelegateOptions()),e(t.currentTarget).data("bs."+this.type,n))),t?(n.inState.click=!n.inState.click,n.isInStateTrue()?n.enter(n):n.leave(n)):n.tip().hasClass("in")?n.leave(n):n.enter(n)},n.prototype.destroy=function(){var e=this;clearTimeout(this.timeout),this.hide(function(){e.$element.off("."+e.type).removeData("bs."+e.type),e.$tip&&e.$tip.detach(),e.$tip=null,e.$arrow=null,e.$viewport=null})};var r=e.fn.tooltip;e.fn.tooltip=t,e.fn.tooltip.Constructor=n,e.fn.tooltip.noConflict=function(){return e.fn.tooltip=r,this}}(jQuery),+function(e){"use strict";function t(t){return this.each(function(){var r=e(this),o=r.data("bs.popover"),i="object"==typeof t&&t;(o||!/destroy|hide/.test(t))&&(o||r.data("bs.popover",o=new n(this,i)),"string"==typeof t&&o[t]())})}var n=function(e,t){this.init("popover",e,t)};if(!e.fn.tooltip)throw new Error("Popover requires tooltip.js");n.VERSION="3.3.5",n.DEFAULTS=e.extend({},e.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),n.prototype=e.extend({},e.fn.tooltip.Constructor.prototype),n.prototype.constructor=n,n.prototype.getDefaults=function(){return n.DEFAULTS},n.prototype.setContent=function(){var e=this.tip(),t=this.getTitle(),n=this.getContent();e.find(".popover-title")[this.options.html?"html":"text"](t),e.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof n?"html":"append":"text"](n),e.removeClass("fade top bottom left right in"),e.find(".popover-title").html()||e.find(".popover-title").hide()},n.prototype.hasContent=function(){return this.getTitle()||this.getContent()},n.prototype.getContent=function(){var e=this.$element,t=this.options;return e.attr("data-content")||("function"==typeof t.content?t.content.call(e[0]):t.content)},n.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var r=e.fn.popover;e.fn.popover=t,e.fn.popover.Constructor=n,e.fn.popover.noConflict=function(){return e.fn.popover=r,this}}(jQuery),+function(e){"use strict";function t(n,r){this.$body=e(document.body),this.$scrollElement=e(e(n).is(document.body)?window:n),this.options=e.extend({},t.DEFAULTS,r),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",e.proxy(this.process,this)),this.refresh(),this.process()}function n(n){return this.each(function(){var r=e(this),o=r.data("bs.scrollspy"),i="object"==typeof n&&n;o||r.data("bs.scrollspy",o=new t(this,i)),"string"==typeof n&&o[n]()})}t.VERSION="3.3.5",t.DEFAULTS={offset:10},t.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},t.prototype.refresh=function(){var t=this,n="offset",r=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),e.isWindow(this.$scrollElement[0])||(n="position",r=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var t=e(this),o=t.data("target")||t.attr("href"),i=/^#./.test(o)&&e(o);return i&&i.length&&i.is(":visible")&&[[i[n]().top+r,o]]||null}).sort(function(e,t){return e[0]-t[0]}).each(function(){t.offsets.push(this[0]),t.targets.push(this[1])})},t.prototype.process=function(){var e,t=this.$scrollElement.scrollTop()+this.options.offset,n=this.getScrollHeight(),r=this.options.offset+n-this.$scrollElement.height(),o=this.offsets,i=this.targets,a=this.activeTarget;if(this.scrollHeight!=n&&this.refresh(),t>=r)return a!=(e=i[i.length-1])&&this.activate(e);if(a&&t<o[0])return this.activeTarget=null,this.clear();for(e=o.length;e--;)a!=i[e]&&t>=o[e]&&(void 0===o[e+1]||t<o[e+1])&&this.activate(i[e])},t.prototype.activate=function(t){this.activeTarget=t,this.clear();var n=this.selector+'[data-target="'+t+'"],'+this.selector+'[href="'+t+'"]',r=e(n).parents("li").addClass("active");r.parent(".dropdown-menu").length&&(r=r.closest("li.dropdown").addClass("active")),
|
|
101
101
|
r.trigger("activate.bs.scrollspy")},t.prototype.clear=function(){e(this.selector).parentsUntil(this.options.target,".active").removeClass("active")};var r=e.fn.scrollspy;e.fn.scrollspy=n,e.fn.scrollspy.Constructor=t,e.fn.scrollspy.noConflict=function(){return e.fn.scrollspy=r,this},e(window).on("load.bs.scrollspy.data-api",function(){e('[data-spy="scroll"]').each(function(){var t=e(this);n.call(t,t.data())})})}(jQuery),+function(e){"use strict";function t(t){return this.each(function(){var r=e(this),o=r.data("bs.tab");o||r.data("bs.tab",o=new n(this)),"string"==typeof t&&o[t]()})}var n=function(t){this.element=e(t)};n.VERSION="3.3.5",n.TRANSITION_DURATION=150,n.prototype.show=function(){var t=this.element,n=t.closest("ul:not(.dropdown-menu)"),r=t.data("target");if(r||(r=t.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,"")),!t.parent("li").hasClass("active")){var o=n.find(".active:last a"),i=e.Event("hide.bs.tab",{relatedTarget:t[0]}),a=e.Event("show.bs.tab",{relatedTarget:o[0]});if(o.trigger(i),t.trigger(a),!a.isDefaultPrevented()&&!i.isDefaultPrevented()){var s=e(r);this.activate(t.closest("li"),n),this.activate(s,s.parent(),function(){o.trigger({type:"hidden.bs.tab",relatedTarget:t[0]}),t.trigger({type:"shown.bs.tab",relatedTarget:o[0]})})}}},n.prototype.activate=function(t,r,o){function i(){a.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),t.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),s?(t[0].offsetWidth,t.addClass("in")):t.removeClass("fade"),t.parent(".dropdown-menu").length&&t.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),o&&o()}var a=r.find("> .active"),s=o&&e.support.transition&&(a.length&&a.hasClass("fade")||!!r.find("> .fade").length);a.length&&s?a.one("bsTransitionEnd",i).emulateTransitionEnd(n.TRANSITION_DURATION):i(),a.removeClass("in")};var r=e.fn.tab;e.fn.tab=t,e.fn.tab.Constructor=n,e.fn.tab.noConflict=function(){return e.fn.tab=r,this};var o=function(n){n.preventDefault(),t.call(e(this),"show")};e(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',o).on("click.bs.tab.data-api",'[data-toggle="pill"]',o)}(jQuery),+function(e){"use strict";function t(t){return this.each(function(){var r=e(this),o=r.data("bs.affix"),i="object"==typeof t&&t;o||r.data("bs.affix",o=new n(this,i)),"string"==typeof t&&o[t]()})}var n=function(t,r){this.options=e.extend({},n.DEFAULTS,r),this.$target=e(this.options.target).on("scroll.bs.affix.data-api",e.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",e.proxy(this.checkPositionWithEventLoop,this)),this.$element=e(t),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};n.VERSION="3.3.5",n.RESET="affix affix-top affix-bottom",n.DEFAULTS={offset:0,target:window},n.prototype.getState=function(e,t,n,r){var o=this.$target.scrollTop(),i=this.$element.offset(),a=this.$target.height();if(null!=n&&"top"==this.affixed)return n>o?"top":!1;if("bottom"==this.affixed)return null!=n?o+this.unpin<=i.top?!1:"bottom":e-r>=o+a?!1:"bottom";var s=null==this.affixed,l=s?o:i.top,c=s?a:t;return null!=n&&n>=o?"top":null!=r&&l+c>=e-r?"bottom":!1},n.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(n.RESET).addClass("affix");var e=this.$target.scrollTop(),t=this.$element.offset();return this.pinnedOffset=t.top-e},n.prototype.checkPositionWithEventLoop=function(){setTimeout(e.proxy(this.checkPosition,this),1)},n.prototype.checkPosition=function(){if(this.$element.is(":visible")){var t=this.$element.height(),r=this.options.offset,o=r.top,i=r.bottom,a=Math.max(e(document).height(),e(document.body).height());"object"!=typeof r&&(i=o=r),"function"==typeof o&&(o=r.top(this.$element)),"function"==typeof i&&(i=r.bottom(this.$element));var s=this.getState(a,t,o,i);if(this.affixed!=s){null!=this.unpin&&this.$element.css("top","");var l="affix"+(s?"-"+s:""),c=e.Event(l+".bs.affix");if(this.$element.trigger(c),c.isDefaultPrevented())return;this.affixed=s,this.unpin="bottom"==s?this.getPinnedOffset():null,this.$element.removeClass(n.RESET).addClass(l).trigger(l.replace("affix","affixed")+".bs.affix")}"bottom"==s&&this.$element.offset({top:a-t-i})}};var r=e.fn.affix;e.fn.affix=t,e.fn.affix.Constructor=n,e.fn.affix.noConflict=function(){return e.fn.affix=r,this},e(window).on("load",function(){e('[data-spy="affix"]').each(function(){var n=e(this),r=n.data();r.offset=r.offset||{},null!=r.offsetBottom&&(r.offset.bottom=r.offsetBottom),null!=r.offsetTop&&(r.offset.top=r.offsetTop),t.call(n,r)})})}(jQuery)},function(e,t,n){"use strict";function r(){if(!a){var e=['<h5><strong>Uptime:</strong> <span id="whistleUptime">-</span></h5>','<h5><strong>All Requests:</strong> <span id="whistleAllRequests">-</span></h5>','<h5><strong>All QPS:</strong> <span id="whistleAllQps">-</span></h5>','<h5><strong>Requests:</strong> <span id="whistleRequests">-</span></h5>','<h5><strong>QPS:</strong> <span id="whistleQps">-</span></h5>','<h5><strong>CPU:</strong> <span id="whistleCpu">-</span></h5>','<h5><strong>Memory:</strong> <span id="whistleMemory">-</span></h5>'];a=i('<div class="modal fade w-online-dialog"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button><div class="w-online-dialog-ctn"></div><div class="w-online-dialog-info">'+e.join("")+'</div><a class="w-online-view-dns">View custom DNS servers</a></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button></div></div></div></div>').appendTo(document.body)}return a}function o(e){return e.map(function(e){return" "+e})}n(187),n(592);var i=window.jQuery=n(5);n(590);var a,s=n(6),l=n(39),c=n(293),u=n(281),d=n(199),p=n(594),g=s.createClass({displayName:"Online",getInitialState:function(){return{}},componentWillMount:function(){var e=this,t=!0,n=i(document.body);u.on("serverInfo",function(r){e.updateServerInfo(r),r&&e.checkServerChanged(r);var o=!!r;o!==t&&(t=o,t?n.removeClass("w-offline-status"):n.addClass("w-offline-status")),e.setState({server:r})})},checkServerChanged:function(e){e.mac=e.mac||"",void 0===this.macAddr?(this.macAddr=e.mac,this.serverPort=e.port,this.version=e.version,this.baseDir=e.baseDir,this.networkMode=e.networkMode,this.pluginsMode=e.pluginsMode,this.rulesMode=e.rulesMode,this.multiEnv=e.multiEnv,this.rulesOnlyMode=e.rulesOnlyMode):this.version!==e.version||this.baseDir!==e.baseDir||this.rulesOnlyMode!==e.rulesOnlyMode||this.networkMode!==e.networkMode||this.pluginsMode!==e.pluginsMode||this.rulesMode!==e.rulesMode||this.multiEnv!==e.multiEnv?this.refs.confirmReload.show():this.refs.confirmReload.hide()},showServerInfo:function(){this.state.server&&(this.updateServerInfo(this.state.server),a.modal("show"))},updateServerInfo:function(e){if(e){this.state.server=e;var t=[],n=d.escape(e.username);n&&t.push("<h5><strong>Username:</strong> "+n+"</h5>");var o=d.escape(e.host);o&&t.push("<h5><strong>Host:</strong> "+o+"</h5>"),e.pid&&t.push("<h5><strong>PID:</strong> "+e.pid+"</h5>"),e.nodeVersion&&t.push("<h5><strong>Node:</strong> "+e.nodeVersion+"</h5>"),e.version&&t.push("<h5><strong>Whistle:</strong> v"+e.version+"</h5>");var i=e.realPort||e.port;if(i){var s=e.bip;t.push("<h5><strong>Port:</strong> "+(s?s+":"+i:i)+"</h5>")}e.socksPort&&t.push("<h5><strong>SOCKS Port:</strong> "+e.socksPort+"</h5>"),e.httpPort&&t.push("<h5><strong>HTTP Port:</strong> "+e.httpPort+"</h5>"),e.httpsPort&&t.push("<h5><strong>HTTPS Port:</strong> "+e.httpsPort+"</h5>"),e.ipv4.length&&(t.push("<h5><strong>IPv4:</strong></h5>"),t.push("<p>"+e.ipv4.join("<br/>")+"</p>")),e.ipv6.length&&(t.push("<h5><strong>IPv6:</strong></h5>"),t.push("<p>"+e.ipv6.join("<br/>")+"</p>"));var l=r().find(".w-online-dialog-ctn").html(t.join(""));if(l.find("h5:first").attr("title",e.host),!this._initProxyInfo){this._initProxyInfo=!0;var c,p=!0,g=a.find(".w-online-view-dns"),h=!0,f=this;g.on("click",function(){f.refs.dnsDialog.show(u.getServerInfo())});var m=function(e){e&&e.dns?h&&(h=!1,g.show()):h||(h=!0,g.hide())};m(e),setInterval(function(){var e=u.getServerInfo(),t=e&&e.pInfo;if(m(e),!t)return void(p&&(p=!0,a.find(".w-online-dialog-info").hide()));p&&(p=!1,a.find(".w-online-dialog-info").show());var n=a.find("#whistleRequests"),r=a.find("#whistleAllRequests"),o=a.find("#whistleCpu"),i=a.find("#whistleMemory"),s=a.find("#whistleUptime"),l=a.find("#whistleQps"),g=a.find("#whistleAllQps");s.text(d.formatTime(t.uptime)),s.parent().attr("title",t.uptime),n.parent().attr("title","HTTP[S]: "+t.httpRequests+" (Total: "+t.totalHttpRequests+")\nWS[S]: "+t.wsRequests+" (Total: "+t.totalWsRequests+")\nTUNNEL: "+t.tunnelRequests+" (Total: "+t.totalTunnelRequests+")"),r.parent().attr("title","HTTP[S]: "+t.allHttpRequests+" (Total: "+t.totalAllHttpRequests+")\nWS[S]: "+t.allWsRequests+" (Total: "+t.totalAllWsRequests+")\nTUNNEL: "+t.tunnelRequests+" (Total: "+t.totalTunnelRequests+")"),i.parent().attr("title",Object.keys(t.memUsage).map(function(e){return e+": "+t.memUsage[e]}).join("\n")),l.parent().attr("title",["HTTP[s]: "+d.getQps(t.httpQps),"WS[S]: "+d.getQps(t.wsQps),"TUNNEL: "+d.getQps(t.tunnelQps)].join("\n")),g.parent().attr("title",["HTTP[s]: "+d.getQps(t.allHttpQps),"WS[S]: "+d.getQps(t.allWsQps),"TUNNEL: "+d.getQps(t.tunnelQps)].join("\n"));var h=t.httpRequests+t.wsRequests+t.tunnelRequests,f=t.allHttpRequests+t.allWsRequests+t.tunnelRequests,A=t.totalHttpRequests+t.totalWsRequests+t.totalTunnelRequests,M=t.totalAllHttpRequests+t.totalAllWsRequests+t.totalTunnelRequests;if(t.totalCount=h,t.allCount=A,t.totalUICount=f,t.allUICount=M,c&&c.pInfo){var w=c.pInfo;t.memUsage.rss!==w.memUsage.rss&&i.text(d.getSize(t.memUsage.rss)+" (Max: "+d.getSize(t.maxRss)+")"),(h!==w.totalCount||A!==w.allCount)&&n.text(h+" (Total: "+A+")"),(f!==w.totalUICount||M!==w.allUICount)&&r.text(f+" (Total: "+M+")"),t.cpuPercent!==w.cpuPercent&&o.text(t.cpuPercent+" (Max: "+t.maxCpu+")"),t.totalQps!==w.totalQps&&l.text(d.getQps(t.totalQps)+" (Max: "+d.getQps(t.maxQps)+")"),t.totalAllQps!==w.totalAllQps&&g.text(d.getQps(t.totalAllQps)+" (Max: "+d.getQps(t.maxAllQps)+")")}else n.text(h+" (Total: "+A+")"),r.text(f+" (Total: "+M+")"),o.text(t.cpuPercent+" (Max: "+t.maxCpu+")"),i.text(d.getSize(t.memUsage.rss)+" (Max: "+d.getSize(t.maxRss)+")"),l.text(d.getQps(t.totalQps)+" (Max: "+d.getQps(t.maxQps)+")"),g.text(d.getQps(t.totalAllQps)+" (Max: "+d.getQps(t.maxAllQps)+")");c=e},1e3)}}},reload:function(){location.reload()},getTitle:function(e){if(e){var t=[];e.host&&t.push("Host: "+e.host),e.pid&&t.push("PID: "+e.pid);var n=e.realPort||e.port;n&&t.push("Port: "+n),e.socksPort&&t.push("SOCKS Port: "+e.socksPort),e.httpPort&&t.push("HTTP Port: "+e.httpPort),e.httpsPort&&t.push("HTTPS Port: "+e.httpsPort),e.ipv4.length&&(t.push("IPv4:"),t.push.apply(t,o(e.ipv4))),e.ipv6.length&&(t.push("IPv6:"),t.push.apply(t,o(e.ipv6)));var r=e.pInfo;return r&&(t.push("Uptime: "+d.formatTime(r.uptime)),t.push("All Requests: "+(r.allHttpRequests+r.allWsRequests+r.tunnelRequests+" (Total: "+(r.totalAllHttpRequests+r.totalAllWsRequests+r.totalTunnelRequests)+")")),t.push("Requests: "+(r.httpRequests+r.wsRequests+r.tunnelRequests+" (Total: "+(r.totalHttpRequests+r.totalWsRequests+r.totalTunnelRequests)+")")),r.cpuPercent&&t.push("CPU: "+r.cpuPercent),t.push("Memory: "+d.getSize(r.memUsage.rss)),t.push("QPS: "+d.getQps(r.totalQps)),t.push("All QPS: "+d.getQps(r.totalAllQps))),e.dns&&t.push("Use custom DNS servers"),t.join("\n")}},setTitle:function(){var e=u.getServerInfo()||this.state.server;l.findDOMNode(this.refs.onlineMenu).title=this.getTitle(e)},render:function(){var e=this.state.server;return s.createElement("a",{ref:"onlineMenu",draggable:"false",onMouseEnter:this.setTitle,className:"w-online-menu w-online"+(e?"":" w-offline"),onClick:this.showServerInfo},s.createElement("span",{className:"glyphicon glyphicon-stats"}),e?"Online":"Offline",e&&e.dns?s.createElement("span",null,e.doh?"(DOH)":e.r6?"(IPv6)":"(IPv4)"):null,s.createElement(c,{ref:"confirmReload",wstyle:"w-confirm-reload-dialog w-confirm-reload-global"},s.createElement("div",{className:"modal-body w-confirm-reload"},s.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},s.createElement("span",{"aria-hidden":"true"},"×")),"The proxy has been modified.",s.createElement("br",null),"Do you want to reload this page."),s.createElement("div",{className:"modal-footer"},s.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Cancel"),s.createElement("button",{type:"button",className:"btn btn-primary",onClick:this.reload},"Reload"))),s.createElement(p,{ref:"dnsDialog"}))}});e.exports=g},function(e,t,n){var r=n(593);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-online-dialog .modal-dialog{width:20pc}.w-online-dialog-info,.w-online-view-dns{display:none}.w-online-dialog-ctn h5{padding:5px 0;margin:0;text-overflow:ellipsis;max-width:100%;white-space:nowrap;overflow:hidden}.w-online-dialog-ctn p{margin:-23px 0 5px 36px}.w-confirm-reload-dialog{z-index:1000000000}.w-confirm-reload-global{z-index:1000000001}.w-confirm-reload-dialog .modal-dialog{width:280px}.w-confirm-reload-dialog .w-confirm-reload{font-weight:700;line-height:1.8;padding:10px 20px}.w-confim-reload-note{color:red;margin:0}.w-online-menu>span{margin-left:5px;font-size:13px}.w-dns-servers-dialog{z-index:1100}.w-dns-servers-dialog pre{font-size:14px;font-weight:700}.w-dns-servers-dialog .modal-dialog{width:420px}.w-tips-dialog .modal-dialog{width:35pc!important}#appearanceMode{display:inline-block;width:150px;margin-left:10px;height:2pc;font-size:13px;font-weight:400}",""])},function(e,t,n){"use strict";n(187);var r=n(6),o=n(293),i=r.createClass({displayName:"DNSDialog",getInitialState:function(){return{servers:""}},show:function(e){if(e&&e.dns){this._hideDialog=!1;var t=e.dns;e.doh||(t=e.dns.split(",").map(function(e,t){return"DNS Server"+(t+1)+": "+e}).join("\n")),this.setState({ipv6:e.r6,useDefault:e.df,servers:t,doh:e.doh}),this.refs.dnsServersDialog.show()}},hide:function(){this.refs.dnsServersDialog.hide(),this._hideDialog=!0},shouldComponentUpdate:function(){return this._hideDialog===!1},render:function(){var e,t=this.state;return e=t.doh?"Resolve IP address from follow URL:":"Resolve "+(t.ipv6?"IPv6":"IPv4")+" address from follow DNS servers"+(t.useDefault?" first":"")+":",r.createElement(o,{ref:"dnsServersDialog",wstyle:"w-dns-servers-dialog"},r.createElement("div",{className:"modal-header"},e,r.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},r.createElement("span",{"aria-hidden":"true"},"×"))),r.createElement("pre",{className:"modal-body"},t.servers),r.createElement("div",{className:"modal-footer"},r.createElement("button",{type:"button","data-dismiss":"modal",className:"btn btn-primary w-copy-text-with-tips","data-clipboard-text":t.servers},"Copy"),r.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")))}});e.exports=i},function(e,t,n){"use strict";n(187),n(596);var r=n(6),o=r.createClass({displayName:"EditorSettings",render:function(){return r.createElement("div",{className:"w-editor-settings"},r.createElement("p",null,r.createElement("label",null,r.createElement("span",{className:"w-label"},"Theme:"),r.createElement("select",{value:this.props.theme,onChange:this.props.onThemeChange,className:"form-control"},r.createElement("option",{value:"default"},"default"),r.createElement("option",{value:"ambiance"},"ambiance"),r.createElement("option",{value:"blackboard"},"blackboard"),r.createElement("option",{value:"cobalt"},"cobalt"),r.createElement("option",{value:"eclipse"},"eclipse"),r.createElement("option",{value:"elegant"},"elegant"),r.createElement("option",{value:"erlang-dark"},"erlang-dark"),r.createElement("option",{value:"lesser-dark"},"lesser-dark"),r.createElement("option",{value:"midnight"},"midnight"),r.createElement("option",{value:"monokai"},"monokai"),r.createElement("option",{value:"neat"},"neat"),r.createElement("option",{value:"night"},"night"),r.createElement("option",{value:"rubyblue"},"rubyblue"),r.createElement("option",{value:"solarized dark"},"solarized dark"),r.createElement("option",{value:"solarized light"},"solarized light"),r.createElement("option",{value:"twilight"},"twilight"),r.createElement("option",{value:"vibrant-ink"},"vibrant-ink"),r.createElement("option",{value:"xq-dark"},"xq-dark"),r.createElement("option",{value:"xq-light"},"xq-light")))),r.createElement("p",null,r.createElement("label",null,r.createElement("span",{className:"w-label"},"Font size:"),r.createElement("select",{value:this.props.fontSize,onChange:this.props.onFontSizeChange,className:"form-control"},r.createElement("option",{value:"13px"},"13px"),r.createElement("option",{value:"14px"},"14px"),r.createElement("option",{value:"16px"},"16px"),r.createElement("option",{value:"18px"},"18px"),r.createElement("option",{value:"20px"},"20px"),r.createElement("option",{value:"22px"},"22px"),r.createElement("option",{value:"24px"},"24px"),r.createElement("option",{value:"26px"},"26px"),r.createElement("option",{value:"28px"},"28px"),r.createElement("option",{value:"30px"},"30px"),r.createElement("option",{value:"32px"},"32px"),r.createElement("option",{value:"34px"},"34px"),r.createElement("option",{value:"36px"},"36px")))),r.createElement("p",{className:"w-editor-settings-box"},r.createElement("label",null,r.createElement("input",{checked:this.props.lineNumbers,onChange:this.props.onLineNumberChange,type:"checkbox"})," ","Show line number")),r.createElement("p",{className:"w-editor-settings-box"},r.createElement("label",null,r.createElement("input",{checked:this.props.lineWrapping,onChange:this.props.onLineWrappingChange,type:"checkbox"})," ","Auto line wrapping")))}});e.exports=o},function(e,t,n){var r=n(597);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-editor-settings label,.w-editor-settings-box label{font-weight:400;white-space:nowrap}.w-editor-settings label .w-label{display:inline-block;width:60px;text-align:right;margin-right:5px}.w-editor-settings select{width:186px}.w-rules-settings-dialog .w-editor-settings select{width:260px}.w-editor-settings-box{padding-left:65px;margin:10px!important}.w-editor-settings .form-control{display:inline-block;margin-left:5px}.w-editor-settings p{margin:5px}",""])},function(e,t,n){"use strict";var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};n(187),n(599);var o=n(5),i=n(6),a=n(39),s=n(283),l=n(293),c=n(342),u=n(281),d=n(280),p=n(199),g=n(284),h=i.createClass({displayName:"Settings",getInitialState:function(){var e=c.getDragger();return e.onDrop=e.onDrop.bind(this),o.extend(this.getNetworkSettings(),{dragger:e})},getNetworkSettings:function(){return o.extend(u.getFilterText(),{columns:c.getAllColumns()})},onColumnsResort:function(){d.trigger("onColumnsChanged"),this.setState({columns:c.getAllColumns()})},resetColumns:function(){c.reset(),this.onColumnsResort()},componentDidMount:function(){var e=this;d.on("toggleTreeView",function(){e.setState({})})},onNetworkSettingsChange:function(e){var t=e.target,n=t.getAttribute("data-name");if(n&&"path"!==n){if("viewOwn"===n)return u.setOnlyViewOwnData(t.checked),this.setState({}),void d.trigger("filterChanged");if("treeView"===n)return void d.trigger("switchTreeView");if("disabledHNR"===n)return g.set("disabledHNR",t.checked?"":"1"),this.setState({});var r,o,i=this.state;switch(n){case"filter":i.disabledFilterText=!t.checked,r=!0;break;case"excludeFilter":i.disabledExcludeText=!t.checked,r=!0;break;case"filterText":r=!0,i.filterText=t.value;break;case"excludeText":r=!0,i.excludeText=t.value;break;case"networkColumns":o=!0;break;default:c.setSelected(n,t.checked),o=!0}r?(u.setFilterText(i),d.trigger("filterChanged")):o&&d.trigger("onColumnsChanged"),this.setState(i)}},onFilterKeyDown:function(e){(e.ctrlKey||e.metaKey)&&88==e.keyCode&&e.stopPropagation()},onRowsChange:function(e){s.setMaxRows(e.target.value)},showDialog:function(){var e=this.getNetworkSettings();this.setState(e),this.refs.networkSettingsDialog.show()},hideDialog:function(){this.refs.networkSettingsDialog.hide()},editCustomCol:function(e){e.preventDefault();var t=this;t.refs.editCustomColumn.show();var n=e.target.getAttribute("data-name");t.setState({name:n,value:u[n.toLowerCase()],nameChanged:!1},function(){setTimeout(function(){var e=a.findDOMNode(t.refs.newColumnName);e.select(),e.focus()},360)})},onNameChange:function(e){var t=e.target.value;this.setState({value:t.trim(),nameChanged:!0})},changeName:function(){var e=this,t=e.state,n=t.name,r=t.value;u.setCustomColumn({name:n,value:r},function(t,o){return t?(e.refs.editCustomColumn.hide(),u[n.toLowerCase()]=r,e.setState({}),void d.trigger("onColumnTitleChange")):void p.showSystemError(o)})},render:function(){var e=this,t=e.state,n=t.columns,o="1"===g.get("isTreeView");return i.createElement(l,{ref:"networkSettingsDialog",wstyle:"w-network-settings-dialog"},i.createElement("div",{onChange:e.onNetworkSettingsChange,className:"modal-body"},i.createElement("button",{type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},i.createElement("span",{"aria-hidden":"true"},"×")),i.createElement("fieldset",{className:"network-settings-filter"},i.createElement("legend",null,i.createElement("label",null,i.createElement("input",{checked:!t.disabledExcludeText,"data-name":"excludeFilter",type:"checkbox"}),"Exclude Filter"),i.createElement("a",{className:"w-help-menu",title:"Click here to learn how to use the filter",href:"https://avwo.github.io/whistle/webui/filter.html",target:"_blank"},i.createElement("span",{className:"glyphicon glyphicon-question-sign"}))),i.createElement("textarea",{disabled:t.disabledExcludeText,onKeyDown:e.onFilterKeyDown,value:t.excludeText,"data-name":"excludeText",placeholder:"type filter text",maxLength:u.MAX_EXCLUDE_LEN})),i.createElement("fieldset",{className:"network-settings-filter"},i.createElement("legend",null,i.createElement("label",null,i.createElement("input",{checked:!t.disabledFilterText,"data-name":"filter",type:"checkbox"}),"Include Filter"),i.createElement("a",{className:"w-help-menu",title:"Click here to learn how to use the filter",href:"https://avwo.github.io/whistle/webui/filter.html",target:"_blank"},i.createElement("span",{className:"glyphicon glyphicon-question-sign"}))),i.createElement("textarea",{disabled:t.disabledFilterText,onKeyDown:e.onFilterKeyDown,value:t.filterText,"data-name":"filterText",placeholder:"type filter text",maxLength:u.MAX_INCLUDE_LEN})),i.createElement("fieldset",{className:"network-settings-columns"},i.createElement("legend",null,i.createElement("label",null,"Network Columns"),i.createElement("label",{onClick:e.resetColumns,className:"btn btn-default"},"Reset")),n.map(function(n){var o,a=n.name,s="custom1"===a,l=s||"custom2"===a;return o=l?s?u.custom1:u.custom2:n.title,i.createElement("label",r({},t.dragger,{"data-name":a,draggable:!0,key:a}),i.createElement("input",{disabled:n.locked,checked:!!n.selected||!!n.locked,"data-name":a,type:"checkbox"}),l?i.createElement("span",{title:o,className:"w-network-custom-col"},o):o,l?i.createElement("span",{onClick:e.editCustomCol,"data-name":n.title,title:"Edit "+n.title,className:"glyphicon glyphicon-edit"},s?1:2):void 0)})),i.createElement("label",{className:"w-network-settings-own"},"Max Rows Number:",i.createElement("select",{className:"form-control",onChange:e.onRowsChange,defaultValue:s.getMaxRows()},i.createElement("option",{value:"500"},"500"),i.createElement("option",{value:"1000"},"1000"),i.createElement("option",{value:"1500"},"1500"),i.createElement("option",{value:"2000"},"2000"),i.createElement("option",{value:"2500"},"2500"),i.createElement("option",{value:"3000"},"3000"))),i.createElement("label",{className:"w-network-settings-own"},i.createElement("input",{checked:u.isOnlyViewOwnData(),"data-name":"viewOwn",type:"checkbox"}),"Only view the requests of own computer (IP: ",u.clientIp,")"),i.createElement("label",{className:"w-network-settings-own"},i.createElement("input",{checked:o,"data-name":"treeView",type:"checkbox"}),i.createElement("span",{className:"glyphicon glyphicon-tree-conifer",style:{marginRight:2}}),"Show Tree View (Ctrl[Command] + B)"),o?i.createElement("br",null):null,o?i.createElement("label",{className:"w-network-settings-own"},i.createElement("input",{checked:"1"!==g.get("disabledHNR"),"data-name":"disabledHNR",type:"checkbox"}),"Highlight new requests"):null),i.createElement("div",{className:"modal-footer"},i.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")),i.createElement(l,{ref:"editCustomColumn",wstyle:"w-network-settings-edit"},i.createElement("div",{onChange:e.onNetworkSettingsChange,className:"modal-body"},i.createElement("button",{type:"button",className:"close","data-dismiss":"modal","aria-label":"Close"},i.createElement("span",{"aria-hidden":"true"},"×")),i.createElement("label",null,"New ",t.name," Name:",i.createElement("input",{onChange:this.onNameChange,ref:"newColumnName",value:t.value,className:"form-control",maxLength:"16",placeholder:"Input the new column name"}))),i.createElement("div",{className:"modal-footer"},i.createElement("button",{disabled:!t.nameChanged,onClick:e.changeName,type:"button",className:"btn btn-primary"},"Confirm"),i.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Cancel"))))}});e.exports=h},function(e,t,n){var r=n(600);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-network-settings-dialog fieldset{border:1px solid #ddd;padding-bottom:10px}.w-network-settings-dialog legend{border:none;margin:0 10px;padding:0 10px;width:auto}.w-network-settings-dialog legend label{font-size:13px;width:auto;padding:0}.w-network-settings-dialog label{font-size:13px;font-weight:400;line-height:30px;height:30px;display:inline-block;width:6pc;margin-right:10px;font-weight:700;text-align:right}.network-settings-columns{margin-top:10px}.network-settings-filter{border:none!important}.network-settings-filter legend{margin:0;padding:0}.network-settings-filter legend label{margin-right:5px}.network-settings-filter textarea[disabled]{background:#f5f5f5}.network-settings-columns label{white-space:nowrap;padding-left:10px;margin-left:10px;text-align:left;width:90pt}.network-settings-columns label .glyphicon-edit{margin-left:5px;cursor:pointer}.network-settings-columns label .glyphicon-edit:hover{color:#337ab7}.network-settings-columns .btn{margin-right:0;text-align:center;color:#666;width:72px}.network-settings-columns legend label{margin-left:0}.w-network-settings-dialog .modal-dialog{width:600px}.w-network-settings-dialog input[type=checkbox]{margin-right:5px}.w-network-settings-dialog textarea{width:578px;height:90px;border:1px solid #ddd;overflow:auto;margin:0;padding:5px 10px}.w-network-settings-dialog .w-help-menu{color:#000;font-size:14px}.w-certs-info-dialog .w-help-menu:hover,.w-files-dialog .w-help-menu:hover,.w-https-dialog .w-help-menu:hover,.w-network-settings-dialog .w-help-menu:hover{color:#337ab7}.w-certs-info-dialog .w-help-menu,.w-files-dialog .w-help-menu,.w-https-dialog .w-help-menu{margin-right:5px;color:#000;font-size:14px}.w-network-settings-dialog div input[type=text]{width:436px}.w-network-settings-own{width:auto!important;margin:15px 0 0;white-space:nowrap}.w-network-settings-own select{margin-left:20px;width:10pc;display:inline-block}.w-network-custom-col{display:inline-block;max-width:90px;text-overflow:ellipsis;white-space:nowrap}.network-settings-columns label span{vertical-align:middle;overflow:hidden;font-weight:400}.w-network-settings-edit label{white-space:nowrap}.w-network-settings-edit label .form-control{display:inline-block;margin:0 10px;font-weight:400}.w-network-settings-edit label select{width:150px}.w-network-settings-edit label input{width:330px}.w-network-settings-edit .modal-dialog{width:530px}.network-settings-columns legend .btn-primary{width:auto;margin-right:10px;padding:0 8px;color:#fff;font-weight:400}.w-certs-info-title{margin-bottom:20px}",""])},function(e,t,n){"use strict";function r(e){return function(t,n){var r=e[t],o=e[n];return r._key=t,o._key=n,f.comparePlugin(r,o)}}function o(e){s||(s=setTimeout(function(){s=null},2e3),d.trigger("disableAllPlugins",e))}function i(e){var t=h.getServerInfo().cmdName,n="";return t&&M.test(t)?(t=RegExp.$1+" ",n=" "+RegExp.$2.trim()):t="w2 ",t+(e?"uninstall":"install")+n+" "}function a(e){return e.account?" --account="+e.account:""}n(602);var s,l=n(5),c=n(6),u=n(39),d=n(280),p=n(293),g=n(604),h=n(281),f=n(199),m=n(210),A=n(567),M=/^([\w]{1,12})(\s+-g)?$/;window.getWhistleProxyServerInfo=function(){var e=h.getServerInfo();return e&&l.extend(!0,{},e)};var w=c.createClass({displayName:"Home",componentDidMount:function(){var e=this;e.setUpdateAllBtnState(),d.on("updateAllPlugins",function(t,n){n="reinstallAllPlugins"===n;var o=e.props.data||{},s=o.plugins||{},l={};Object.keys(s).sort(r(s)).map(function(e){var t=s[e];if(!t.isProj&&(n||f.compareVersion(t.latest,t.version))){var r=(t.registry?" --registry="+t.registry:"")+a(t),o=l[r]||[];o.push(t.moduleName),l[r]=o}});var c=Object.keys(l).map(function(e){var t=l[e].join(" ");return i()+t+e}).join("\n\n");c&&e.setState({cmdMsg:c,uninstall:!1},e.showMsgDialog)})},componentDidUpdate:function(){this.setUpdateAllBtnState()},shouldComponentUpdate:function(e){var t=f.getBoolean(this.props.hide);return t!=f.getBoolean(e.hide)||!t},onOpen:function(e){this.props.onOpen&&this.props.onOpen(e),e.preventDefault()},syncData:function(e){var t=this.props.data||"";this.refs.syncDialog.show(e,t.rules,t.values)},showDialog:function(){this.refs.pluginRulesDialog.show()},hideDialog:function(){this.refs.pluginRulesDialog.hide()},showRules:function(e){var t=l(e.target).attr("data-name"),n=this.props.data.plugins[t+":"];n.name=t,this.setState({plugin:n},this.showDialog)},onCmdChange:function(e){this.setState({cmdMsg:e.target.value})},showMsgDialog:function(){this.refs.operatePluginDialog.show()},showUpdate:function(e){var t=l(e.target).attr("data-name"),n=this.props.data.plugins[t+":"],r=n.registry?" --registry="+n.registry:"";this.setState({cmdMsg:i()+n.moduleName+a(n)+r,isSys:n.isSys,uninstall:!1},this.showMsgDialog)},showUninstall:function(e){var t=l(e.target).attr("data-name"),n=this.props.data.plugins[t+":"],r=this.props.data.isWin?"":"sudo ",o=n.isSys,s=o?i(!0):r+"npm uninstall -g ",c=!o&&n.registry?" --registry="+n.registry:"";this.setState({cmdMsg:s+n.moduleName+a(n)+c,isSys:o,uninstall:!0,pluginPath:n.path},this.showMsgDialog)},enableAllPlugins:function(e){var t=this,n=t.props.data||{};!s&&n.disabledAllPlugins&&m.confirm("Do you want to turn on Plugins?",function(t){t&&o(e)})},setUpdateAllBtnState:function(){d.trigger("setUpdateAllBtnState",this.hasNewPlugin)},render:function(){var e=this,t=e.props.data||{},n=t.plugins||[],o=e.state||{},i=o.plugin||{},a=o.cmdMsg,s=Object.keys(n),l=t.disabledPlugins||{},u=t.disabledAllPlugins,d=t.ndp;return e.hasNewPlugin=!1,c.createElement("div",{className:"fill orient-vertical-box w-plugins",style:{display:e.props.hide?"none":""}},c.createElement("div",{className:"w-plugins-headers"},c.createElement("table",{className:"table"},c.createElement("thead",null,c.createElement("tr",null,c.createElement("th",{className:"w-plugins-order"},"#"),c.createElement("th",{className:"w-plugins-active"},"Active"),c.createElement("th",{className:"w-plugins-date"},"Date"),c.createElement("th",{
|
|
102
|
-
className:"w-plugins-name"},"Name"),c.createElement("th",{className:"w-plugins-version"},"Version"),c.createElement("th",{className:"w-plugins-operation"},"Operation"),c.createElement("th",{className:"w-plugins-desc"},"Description"))))),c.createElement("div",{className:"fill w-plugins-list"},c.createElement("table",{className:"table table-hover"},c.createElement("tbody",null,s.length?s.sort(r(n)).map(function(t,r){var o=n[t];t=t.slice(0,-1);var i=!l[t],a=o.pluginHomepage&&!o.openInPlugins,s=o.pluginHomepage||"plugin."+t+"/",p=f.compareVersion(o.latest,o.version);return p&&(p="(New: "+o.latest+")",e.hasNewPlugin=!0),c.createElement("tr",{key:t,className:(!u&&i?"":"w-plugins-disable")+(p?" w-has-new-version":"")},c.createElement("th",{className:"w-plugins-order",onDoubleClick:e.enableAllPlugins},r+1),c.createElement("td",{className:"w-plugins-active",onDoubleClick:e.enableAllPlugins},c.createElement("input",{type:"checkbox",title:d?"Not allowed disable plugins":u?"Disabled":(i?"Disable ":"Enable ")+t,"data-name":t,checked:d||i,disabled:!d&&u,onChange:e.props.onChange,className:d?"w-not-allowed":void 0})),c.createElement("td",{className:"w-plugins-date"},f.toLocaleString(new Date(o.mtime))),c.createElement("td",{className:"w-plugins-name",title:o.moduleName},c.createElement("a",{href:s,target:"_blank","data-name":t,onClick:a?null:e.onOpen},t)),c.createElement("td",{className:"w-plugins-version"},o.homepage?c.createElement("a",{href:o.homepage,target:"_blank"},o.version):o.version,p?o.homepage?c.createElement("a",{className:"w-new-version",href:o.homepage,target:"_blank"},p):c.createElement("span",{className:"w-new-version"},p):void 0),c.createElement("td",{className:"w-plugins-operation"},c.createElement("a",{href:s,target:"_blank","data-name":t,className:"w-plugin-btn",onClick:a?null:e.onOpen},"Option"),o.rules||o._rules||o.resRules?c.createElement("a",{draggable:"false","data-name":t,onClick:e.showRules},"Rules"):c.createElement("span",{className:"disabled"},"Rules"),o.isProj?c.createElement("span",{className:"disabled"},"Update"):c.createElement("a",{draggable:"false",className:"w-plugin-btn w-plugin-update-btn","data-name":t,onClick:e.showUpdate},"Update"),o.isProj?c.createElement("span",{className:"disabled"},"Uninstall"):c.createElement("a",{draggable:"false",className:"w-plugin-btn","data-name":t,onClick:e.showUninstall},"Uninstall"),f.isString(o.rulesUrl)||f.isString(o.valuesUrl)?c.createElement("a",{className:"w-plugin-btn",onClick:function(){e.syncData(o)}},"Sync"):void 0,o.homepage?c.createElement("a",{href:o.homepage,className:"w-plugin-btn",target:"_blank"},"Help"):c.createElement("span",{className:"disabled"},"Help")),c.createElement("td",{className:"w-plugins-desc",title:o.description},o.description))}):c.createElement("tr",null,c.createElement("td",{colSpan:"7",className:"w-empty"},c.createElement("a",{href:"https://github.com/whistle-plugins",target:"_blank"},"Empty")))))),c.createElement(g,{ref:"syncDialog"}),c.createElement(p,{ref:"pluginRulesDialog",wstyle:"w-plugin-rules-dialog"},c.createElement("div",{className:"modal-header"},c.createElement("h4",null,i.name),c.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},c.createElement("span",{"aria-hidden":"true"},"×"))),c.createElement("div",{className:"modal-body"},c.createElement("div",{className:"w-plugin-rules"},i.rules?c.createElement("fieldset",null,c.createElement("legend",null,"rules.txt"),c.createElement("pre",null,i.rules)):null,i._rules?c.createElement("fieldset",null,c.createElement("legend",null,"reqRules.txt (_rules.txt)"),c.createElement("pre",null,i._rules)):null,i.resRules?c.createElement("fieldset",null,c.createElement("legend",null,"resRules.txt"),c.createElement("pre",null,i.resRules)):null)),c.createElement("div",{className:"modal-footer"},c.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close"))),c.createElement(p,{ref:"operatePluginDialog",wstyle:"w-plugin-update-dialog"},c.createElement("div",{className:"modal-body"},c.createElement("h5",null,c.createElement("a",{"data-dismiss":"modal",className:"w-copy-text-with-tips","data-clipboard-text":a},"Copy the following command")," ","to the CLI to execute:"),c.createElement("textarea",{value:a,className:"w-plugin-update-cmd",onChange:this.onCmdChange}),c.createElement("div",{style:{margin:"8px 0 0",color:"red","word-break":"break-all",display:!o.isSys&&o.uninstall?"":"none"}},"If uninstall failed, delete the following directory instead:",c.createElement("a",{className:"w-copy-text-with-tips","data-dismiss":"modal","data-clipboard-text":o.pluginPath,style:{marginLeft:5,cursor:"pointer"}},o.pluginPath))),c.createElement("div",{className:"modal-footer"},c.createElement("button",{type:"button","data-dismiss":"modal",className:"btn btn-primary w-copy-text-with-tips","data-clipboard-text":a},"Copy"),c.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close"))))}}),b=c.createClass({displayName:"Tabs",componentDidMount:function(){function e(){clearTimeout(n),n=setTimeout(t,60)}function t(){if(!r.props.hide){var e=i.offsetHeight;e&&(o.style.width=i.offsetWidth+"px",o.style.height=e+"px")}}var n,r=this,o=u.findDOMNode(r.refs.tabPanel),i=o.parentNode;r._resizeHandler=e,e(),l(window).on("resize",e)},shouldComponentUpdate:function(e,t){return!this.props.hide||!e.hide},componentDidUpdate:function(e,t){e.hide&&!this.props.hide&&this._resizeHandler()},onClose:function(e){this.props.onClose&&this.props.onClose(e),e.stopPropagation()},render:function(){var e=this,t=e.props,n=t.tabs||[],r="Home",i=t.disabledPlugins||{},a=t.disabledAllPlugins,s=t.ndp,l=e.props.active;if(l&&l!=r)for(var u=0,d=n.length;d>u;u++){var p=n[u];if(p.name==l){r=p.name;break}}return c.createElement("div",{className:"w-nav-tabs fill orient-vertical-box",style:{display:e.props.hide?"none":"",paddingTop:a?0:void 0}},a?c.createElement("div",{className:"w-record-status",style:{marginBottom:5}},"All plugins is disabled",c.createElement("button",{className:"btn btn-primary",onClick:o},"Enable")):null,c.createElement("ul",{className:"nav nav-tabs"},c.createElement("li",{className:"w-nav-home-tab"+("Home"==r?" active":""),"data-name":"Home",onClick:e.props.onActive},c.createElement("a",{draggable:"false"},"Home")),n.map(function(t){var n=!s&&(a||i[t.name]);return c.createElement("li",{className:r==t.name?" active":""},c.createElement("a",{"data-name":t.name,title:t.name,onClick:e.props.onActive,draggable:"false",className:n?"w-plugin-tab-disabled":void 0},n?c.createElement("span",{className:"glyphicon glyphicon-ban-circle"}):void 0,t.name,c.createElement("span",{"data-name":t.name,title:"Close",className:"w-close-icon",onClick:e.onClose},"×")))})),c.createElement("div",{className:"fill orient-vertical-box w-nav-tab-panel"},c.createElement("div",{ref:"tabPanel",className:"fill orient-vertical-box"},c.createElement(w,{data:e.props,hide:"Home"!=r,onChange:e.props.onChange,onOpen:e.props.onOpen}),n.map(function(e){return c.createElement(A,{inited:r==e.name},c.createElement("iframe",{style:{display:r==e.name?"":"none"},src:e.url}))}))))}});e.exports=b},function(e,t,n){var r=n(603);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-nav-tabs{padding-top:10px;font-size:13px}.w-nav-tabs>.nav>li>a{padding:5px 20px 5px 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:90pt;position:relative}.w-nav-tabs>.nav>li>a>.w-close-icon{display:block;position:absolute;top:5px;right:5px;color:#999;cursor:pointer}.w-nav-tabs>.nav>li>a>.w-close-icon:hover{color:#000}.w-plugin-tab-disabled{color:#ccc!important}.w-plugin-tab-disabled .glyphicon-ban-circle{vertical-align:text-top;margin-right:3px;color:#ccc!important}.w-nav-tabs iframe{border:none;display:block;background-color:#fff;margin:0;padding:0;width:100%;height:100%}.w-nav-tabs .w-nav-tab-panel,.w-nav-tabs .w-nav-tab-panel>div{overflow:hidden}.w-nav-tabs>.nav>.w-nav-home-tab>a{padding-right:10px!important}.w-plugins td,.w-plugins th{font-size:13px;font-weight:400}.w-plugins-headers{border-bottom:1px solid #ccc;overflow:hidden}.w-plugins-headers .table th{border:none!important;padding:6px;color:#000;background:#fafafa;font-weight:700}.w-plugins-list{overflow-y:auto;overflow-x:hidden;outline:0}.w-plugins-list td,.w-plugins-list th{border-top:none!important;border-bottom:1px solid #ddd;padding:8px 6px!important;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.w-plugins-disable,.w-plugins-disable a,.w-plugins-disable td{color:#aaa}.w-plugins-order{width:50px}.w-plugins-active{width:60px}.w-plugins-list td.w-plugins-active input{margin-left:9pt;vertical-align:text-bottom}.w-plugins-name{width:10pc}.w-plugins-version{width:140px}.w-plugins-list .w-has-new-version .w-plugin-update-btn,.w-plugins-list .w-has-new-version .w-plugins-version .w-new-version,.w-plugins-menu.w-plugin-update-btn{color:#f66!important}.w-plugins-list .w-has-new-version .w-plugins-version span{margin-left:3px}.w-plugins-list .w-has-new-version .w-plugin-update-btn:hover,.w-plugins-list .w-has-new-version .w-plugins-version span:hover,.w-plugins-menu.w-plugin-update-btn:hover{color:#f33!important}.w-plugins-date{width:180px}.w-plugins-operation{width:360px}.w-plugins-operation a,.w-plugins-operation span.disabled{margin-right:20px}.w-plugins-operation a:last-child,.w-plugins-operation span.disabled:last-child{margin-right:0}.w-plugins-operation span.disabled{color:#ccc}.w-plugin-rules-dialog .modal-dialog{width:40pc}.w-plugin-rules-dialog .modal-dialog pre{max-height:220px;overflow:auto;padding:10px}.w-plugin-rules-dialog fieldset{border:1px solid #ddd}.w-plugin-rules-dialog fieldset legend{font-size:13px;padding:0 10px;border:none;width:auto;margin:0 10px;font-weight:700}.w-plugin-rules-dialog fieldset:nth-child(2){margin-top:15px}.w-plugin-rules-dialog .modal-header h4{margin:0}.w-plugin-rules-dialog .modal-header .close{position:absolute;right:10px;top:1pc}.w-plugin-update-dialog .modal-dialog{width:600px}.w-plugin-update-cmd{background:#002240;color:#ddd;padding:15px;margin-top:10px;font-size:14px;display:block;width:578px;height:220px}.w-plugin-btn{color:#337ab7!important}.w-plugin-btn:hover{color:#23527c!important}",""])},function(e,t,n){"use strict";function r(e,t){var n="plugin."+e.substring(8);return 0===t.indexOf(e)||0===t.indexOf(n)?t:n+"/"+t}n(605);var o=n(6),i=n(293),a=n(199),s=n(281),l=n(607),c=o.createClass({displayName:"SyncDialog",getInitialState:function(){return{}},show:function(e,t,n){var r=this;r.rulesModal=t,r.valuesModal=n,a.isString(e.rulesUrl)||(e.rulesUrl=null),a.isString(e.valuesUrl)||(e.valuesUrl=null),r.setState(e,function(){r.refs.syncDialog.show()})},syncRules:function(){var e=this,t=e.state.rulesUrl;if(!e.loadingRules&&a.isString(t)){e.loadingRules=!0;var n=s.createCgi(r(e.state.moduleName,t));n(function(t,n){return e.loadingRules=!1,e.setState({}),t?void e.refs.kvDialog.show(t,e.rulesModal,e.valuesModal):a.showSystemError(n)}),e.setState({})}},syncValues:function(){var e=this,t=e.state.valuesUrl;if(!e.loadingValues&&a.isString(t)){e.loadingValues=!0;var n=s.createCgi(r(e.state.moduleName,t));n(function(t,n){return e.loadingValues=!1,e.setState({}),t?void e.refs.kvDialog.show(t,e.rulesModal,e.valuesModal,!0):a.showSystemError(n)}),e.setState({})}},render:function(){var e=this.state;return o.createElement(i,{ref:"syncDialog",wstyle:"w-sync-dialog"},o.createElement("div",{className:"modal-body"},o.createElement("button",{onClick:this.syncRules,disabled:this.loadingRules||!a.isString(e.rulesUrl),type:"button",className:"btn btn-primary"},o.createElement("span",{className:"glyphicon glyphicon-list"})," ",this.loadingRules?"Loading":"Sync"," Rules"),o.createElement("button",{onClick:this.syncValues,disabled:this.loadingValues||!a.isString(e.valuesUrl),type:"button",className:"btn btn-default"},o.createElement("span",{className:"glyphicon glyphicon-folder-close"})," ",this.loadingValues?"Loading":"Sync"," Values")),o.createElement("div",{className:"modal-footer"},o.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")),o.createElement(l,{ref:"kvDialog"}))}}),u=o.createClass({displayName:"SyncDialogWrap",shouldComponentUpdate:function(){return!1},show:function(e,t,n){this.refs.syncDialog.show(e,t,n)},render:function(){return o.createElement(c,{ref:"syncDialog"})}});e.exports=u},function(e,t,n){var r=n(606);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-sync-dialog .modal-dialog{width:420px}.w-sync-dialog .modal-body .btn{display:block;width:398px;line-height:40px;font-size:18px;margin:10px 0}.w-sync-dialog .modal-body .btn span{margin-right:10px}",""])},function(e,t,n){"use strict";n(187),n(608);var r=n(6),o=n(293),i=n(199),a=n(280),s=n(210),l=r.createClass({displayName:"KVDialog",getInitialState:function(){return{list:[]}},show:function(e,t,n,r){this.isValues=r,this.refs.kvDialog.show(),this._hideDialog=!1,this.setState({list:i.parseImportData(e||"",r?n:t,r)})},hide:function(){this.refs.kvDialog.hide(),this._hideDialog=!0},shouldComponentUpdate:function(){return this._hideDialog===!1},viewContent:function(e){i.openEditor(e.target.title)},confirm:function(){var e,t={},n=this;return n.state.list.forEach(function(n){e=e||n.isConflict,t[n.name]=n.value}),e?void s.confirm("Conflict with existing content, whether to continue to overwrite them?",function(e){e&&a.trigger(n.isValues?"uploadValues":"uploadRules",t)}):a.trigger(n.isValues?"uploadValues":"uploadRules",t)},remove:function(e){var t=this;s.confirm("Are you sure to delete '"+e.name+"'.",function(n){if(n){var r=t.state.list.indexOf(e);-1!==r&&(t.state.list.splice(r,1),t.setState({}))}})},render:function(){var e=this,t=e.state.list||[],n=!t.length;return r.createElement(o,{ref:"kvDialog",wstyle:"w-kv-dialog"},r.createElement("div",{className:"modal-body"},r.createElement("button",{type:"button",className:"close",onClick:e.hide},r.createElement("span",{"aria-hidden":"true"},"×")),r.createElement("table",{className:"table"},r.createElement("thead",null,r.createElement("th",{className:"w-kv-name"},"Name"),r.createElement("th",{className:"w-kv-operation"},"Operation")),r.createElement("tbody",null,n?r.createElement("tr",null,r.createElement("td",{colSpan:"2",className:"w-empty"},"Empty")):t.map(function(t,n){return r.createElement("tr",{className:t.isConflict?"w-kv-conflict":void 0},r.createElement("th",{title:t.name,className:"w-kv-name"},t.name),r.createElement("td",{className:"w-kv-operation"},r.createElement("a",{title:t.value,onClick:e.viewContent},"Content"),r.createElement("a",{"data-name":t.name,onClick:function(){e.remove(t)}},"Delete"),r.createElement("strong",null,t.isConflict?"[Conflict]":"")))})))),r.createElement("div",{className:"modal-footer"},r.createElement("button",{type:"button",className:"btn btn-primary",disabled:n,onClick:this.confirm,"data-dismiss":"modal"},"Confirm"),r.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")))}});e.exports=l},function(e,t,n){var r=n(609);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-kv-dialog .modal-dialog{width:666px}.w-kv-name{width:25pc}.w-kv-operation a:nth-child(2){color:#f66;margin:0 20px}.w-kv-conflict th,.w-kv-operation strong{color:#f66}",""])},function(e,t,n){"use strict";n(187),n(611);var r=n(6),o=n(39),i=n(293),a=r.createClass({displayName:"ListDialog",getInitialState:function(){return{checkedItems:{},selectedCount:0}},onChange:function(e){var t=e.target,n=t.parentNode.title,r=this.state.checkedItems;t.checked?r[n]=1:delete r[n],this.setState({selectedCount:Object.keys(r).length})},onConfirm:function(e){if(!e.target.disabled){this.refs.dialog.hide();var t=o.findDOMNode(this.refs.filename),n=o.findDOMNode(this.refs.exportData),r=-1!==e.target.className.indexOf("btn-warning"),i=r?this.getAllItems():this.state.checkedItems;o.findDOMNode(this.refs.exportName).value=t.value.trim(),o.findDOMNode(this.refs.data).value=JSON.stringify(i),n.submit(),t.value=""}},getAllItems:function(){var e=this.props.list||[],t={};return e.forEach(function(e){t[e]=1}),t},show:function(){var e=this;e.refs.dialog.show(),setTimeout(function(){o.findDOMNode(e.refs.filename).focus()},500)},preventDefault:function(e){e.preventDefault()},render:function(){var e=this,t=e.props.list||[],n=e.state.checkedItems,o=e.state.selectedCount,a=this.props.name;return r.createElement(i,{ref:"dialog",wclassName:" w-list-dialog"},r.createElement("div",{className:"modal-body"},r.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},r.createElement("span",{"aria-hidden":"true"},"×")),r.createElement("p",null,"Filename:",r.createElement("input",{ref:"filename",style:{width:390,display:"inline-block",marginLeft:5},className:"form-control",placeholder:"Input the filename"})),t.map(function(t){return r.createElement("label",{title:t},r.createElement("input",{onChange:e.onChange,type:"checkbox",checked:!!n[t]}),t)})),r.createElement("div",{className:"modal-footer"},r.createElement("div",{className:"w-list-counter"},"Selected: ",o," / ",t.length),r.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Cancel"),r.createElement("button",{type:"button",className:"btn btn-warning",onMouseDown:this.preventDefault,onClick:this.onConfirm},"Export All"),r.createElement("button",{type:"button",className:"btn btn-primary",disabled:!Object.keys(n).length,onMouseDown:this.preventDefault,onClick:this.onConfirm},"Export Selected")),r.createElement("form",{action:"cgi-bin/"+a+"/export",ref:"exportData",style:{display:"none"},target:"downloadTargetFrame"},r.createElement("input",{ref:"exportName",type:"hidden",name:"filename"}),r.createElement("input",{ref:"data",type:"hidden",name:a})))}});e.exports=a},function(e,t,n){var r=n(612);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-list-dialog label{line-height:26px;width:226px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-left:10px}.w-list-dialog label input{margin-right:5px}.w-list-dialog{width:500px}.w-list-dialog .modal-footer{position:relative}.w-list-counter{position:absolute;left:10px;top:15px}",""])},function(e,t,n){"use strict";var r=n(6),o=n(281),i=n(280),a=r.createClass({displayName:"FilterBtn",getInitialState:function(){return{hasFilterText:!!o.filterIsEnabled()}},componentDidMount:function(){var e=this;i.on("filterChanged",function(){var t=!!o.filterIsEnabled();t!==e.state.hasFilterText&&e.setState({hasFilterText:!!o.filterIsEnabled()})})},render:function(){var e=this.props.hide,t=this.props.isNetwork,n=t&&this.state.hasFilterText?" w-menu-enable":"";return r.createElement("a",{onClick:this.props.onClick,className:"w-settings-menu"+n,style:{display:e?"none":""},draggable:"false"},r.createElement("span",{className:"glyphicon glyphicon-cog"}),"Settings")}});e.exports=a},function(e,t,n){"use strict";function r(e){e.select(),e.focus()}function o(e,t){d.error(e),t.select(),t.focus()}function i(e){return e.map(function(e){return e.date=c.toLocaleString(new Date(e.date)),e})}n(187),n(615);var a=n(6),s=n(39),l=n(293),c=n(199),u=n(280),d=n(207),p=n(281),g=n(210),h=20971520,f=60,m=a.createClass({displayName:"FilesDialog",getInitialState:function(){return{files:i(p.getUploadFiles())}},updateFiles:function(e){e&&this.setState({files:i(e)})},show:function(){this.refs.filesDialog.show()},hide:function(){this.refs.filesDialog.hide()},showNameInput:function(){if(this.checkCount()){var e=this.refs;e.filenameDialog.show();var t=s.findDOMNode(e.filename);t.value=this.params.name||"",setTimeout(function(){r(t)},500),this.setState({})}},componentDidMount:function(){var e=this;u.on("uploadFile",function(t,n){e.submit(n)}),u.on("showFilenameInput",function(t,n){e.params=n,e.showNameInput()}),u.on("download",function(t,n){e.startDownload(n)})},checkParams:function(){var e=s.findDOMNode(this.refs.filename),t=e.value.trim();return t?t.length>f?void o("The filename length cannot exceed 60.",e):/[\\/:*?"<>|\s]/.test(t)?void o('The filename cannot contain \\/:*?"<>| and spaces.',e):(this.params.name=t,!0):void o("The filename cannot be empty.",e)},checkCount:function(){var e=this.state.files;return e.length>=f?(this.show(),setTimeout(function(){g.alert("The number of uploaded files cannot exceed 60,\ndelete the unnecessary files first.")},10),!1):!0},onConfirm:function(){if(!this.pending&&this.checkParams()&&this.checkCount()){var e=this;e.pending=!0;var t=e.params.name;p.values.checkFile({name:t,count:e.state.files.length},function(n,r){if(e.pending=!1,!n)return c.showSystemError(r);if(e.updateFiles(n.files),n.isMax)return g.alert("The number of uploaded files cannot exceed 60,\ndelete the unnecessary files first.");var o=function(t){t&&(e.pending=!0,p.values.upload(JSON.stringify(e.params),function(t,n){return e.pending=!1,t?0!==t.ec?g.alert(t.em):(e.params="",e.refs.filenameDialog.hide(),e.updateFiles(t.files),void e.show()):c.showSystemError(n)},{contentType:"application/json",processData:!1}))};return n.exists?void g.confirm("The name `"+t+"` already exists, whether to overwrite it?",o):o(!0)})}},startDownload:function(e){s.findDOMNode(this.refs.name).value=e.name,s.findDOMNode(this.refs.headers).value=e.headers||"",s.findDOMNode(this.refs.content).value=e.base64||"",s.findDOMNode(this.refs.downloadForm).submit()},download:function(e){this.checkParams()&&this.startDownload(this.params)},submit:function(e){if(!e.size)return g.alert("The file size cannot be empty.");if(e.size>h)return g.alert("The file size cannot exceed 20m.");var t=this,n={};c.readFileAsBase64(e,function(r){n.base64=r,s.findDOMNode(t.refs.file).value="",n.name=(e.name||"").replace(/[\\/:*?"<>|\s]/g,""),t.params=n,t.showNameInput()})},uploadFile:function(){var e=s.findDOMNode(this.refs.uploadFileForm);this.submit(new FormData(e).get("file"))},selectFile:function(){this.checkCount()&&s.findDOMNode(this.refs.file).click()},remove:function(e){var t=e.target.getAttribute("data-name"),n=this;g.confirm("Are you sure to delete '"+t+"'.",function(e){e&&p.values.removeFile({name:t},function(e,t){return e?0!==e.ec?g.alert(e.em):void n.updateFiles(e.files):c.showSystemError(t)})})},downloadFile:function(e){var t=e.target.getAttribute("data-name");window.open("cgi-bin/values/download?name="+encodeURIComponent(t))},render:function(){var e=this,t=(e.params||"").title,n=e.state.files;return a.createElement(l,{wstyle:"w-files-dialog",ref:"filesDialog"},a.createElement("div",{className:"modal-body"},a.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},a.createElement("span",{"aria-hidden":"true"},"×")),a.createElement("h4",null,a.createElement("a",{className:"w-help-menu",title:"Click here to see help",href:"https://avwo.github.io/whistle/webui/files.html",target:"_blank"},a.createElement("span",{className:"glyphicon glyphicon-question-sign"})),"System Files"),a.createElement("button",{className:"w-files-upload-btn",onClick:e.selectFile},a.createElement("span",{className:"glyphicon glyphicon-arrow-up"}),"Drop file here or click to browse (size <= 20m)"),a.createElement("table",{className:"table",style:{display:n.length?void 0:"none"}},a.createElement("thead",null,a.createElement("th",{className:"w-files-order"},"#"),a.createElement("th",{className:"w-files-date"},"Date"),a.createElement("th",{className:"w-files-path"},"Path"),a.createElement("th",{className:"w-files-operation"},"Operation")),a.createElement("tbody",null,n.map(function(t,n){var r="/$whistle/"+t.name;return a.createElement("tr",{key:t.name},a.createElement("th",{className:"w-files-order"},n+1),a.createElement("td",{className:"w-files-date"},t.date),a.createElement("td",{className:"w-files-path"},r),a.createElement("td",{className:"w-files-operation"},a.createElement("a",{className:"w-copy-text-with-tips","data-clipboard-text":r},"Copy path"),a.createElement("a",{"data-name":t.name,onClick:e.downloadFile},"Download"),a.createElement("a",{"data-name":t.name,onClick:e.remove},"Delete")))})))),a.createElement("div",{className:"modal-footer"},a.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")),a.createElement("form",{ref:"uploadFileForm",encType:"multipart/form-data",style:{display:"none"}},a.createElement("input",{ref:"file",onChange:this.uploadFile,name:"file",type:"file"})),a.createElement(l,{ref:"filenameDialog",wstyle:"w-files-info-dialog"},a.createElement("div",{className:"modal-header"},t||"Modify the filename",a.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},a.createElement("span",{"aria-hidden":"true"},"×"))),a.createElement("div",{className:"modal-body"},a.createElement("label",{className:"w-files-name"},"Name:",a.createElement("input",{ref:"filename",maxLength:"60",placeholder:"Input the filename",type:"text",className:"form-control"}))),a.createElement("div",{className:"modal-footer"},a.createElement("button",{type:"button",className:"btn btn-default",onClick:this.download},"Download"),a.createElement("button",{type:"button",className:"btn btn-primary",onClick:this.onConfirm},"Confirm"),a.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close"))),a.createElement("form",{ref:"downloadForm",action:"cgi-bin/download",style:{display:"none"},method:"post",target:"downloadTargetFrame"},a.createElement("input",{ref:"name",name:"filename",type:"hidden"}),a.createElement("input",{ref:"type",name:"type",type:"hidden",value:"rawBase64"}),a.createElement("input",{ref:"headers",name:"headers",type:"hidden"}),a.createElement("input",{ref:"content",name:"content",type:"hidden"})))}}),A=a.createClass({displayName:"FilesDialogWrap",show:function(e){this.refs.filesDialog.show(e)},hide:function(){this.refs.filesDialog.hide()},shouldComponentUpdate:function(){return!1},render:function(){return a.createElement(m,{ref:"filesDialog"})}});e.exports=A},function(e,t,n){var r=n(616);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-files-dialog .modal-dialog{width:900px}.w-files-dialog h4{margin-top:10px}.w-files-upload-btn{border:1px solid #ccc;border-radius:5px;display:block;background:#fff;line-height:60px;text-align:center;margin:20px 0;color:#aaa;font-size:1pc;width:55pc;font-weight:400}.w-files-upload-btn:hover{color:#aaa}.w-files-upload-btn span{font-size:24px;vertical-align:sub;margin-right:10px}.w-files-order{width:36px}.w-files-date{width:205px}.w-files-path{word-break:break-all;word-wrap:break-word}.w-files-operation{width:15pc}.w-files-operation a{margin-right:15px;display:inline-block;white-space:nowrap}.w-files-operation a:last-child{color:#f66}.w-files-operation a:last-child:hover{color:red}.w-files-name{display:block;margin:20px 0;white-space:nowrap}.w-files-info-dialog .modal-dialog{width:45pc}.w-files-name input{display:inline-block;width:620px;margin-left:20px;font-weight:400}.w-files-save-in{padding-bottom:10px}.w-files-save-in label{margin-right:20px;font-weight:400}label:first-child{font-weight:700}.w-files-save-in input{margin-right:5px}.w-files-save-in label:last-child{margin-left:20px}.w-files-info-dialog .modal-header{font-weight:700}.w-files-dialog thead th{padding:8px}",""])},function(e,t,n){"use strict";var r=n(6),o=n(280),i=r.createClass({displayName:"UpdateAllBtn",getInitialState:function(){return{disabled:!0}},componentDidMount:function(){var e=this;o.on("setUpdateAllBtnState",function(t,n){e.setState({disabled:!n})})},updateAllPlugins:function(){!this.state.disabled&&o.trigger("updateAllPlugins")},render:function(){var e=this.state.disabled||this.props.hide;return r.createElement("a",{onClick:this.updateAllPlugins,className:"w-plugins-menu w-plugin-update-btn"+(e?" hide":""),draggable:"false"},r.createElement("span",{className:"glyphicon glyphicon-refresh"}),"UpdateAll")}});e.exports=i},function(e,t,n){"use strict";function r(e,t){var n=new FileReader;n.readAsText(e),n.onload=function(){t(n.result)}}n(187),n(619);var o=n(6),i=n(39),a=n(199),s=n(293),l=n(621),c=n(210),u=n(281),d=n(207),p={color:"#5bbd72"},g=131072,h=o.createClass({displayName:"HistoryData",getInitialState:function(){return{list:[]}},show:function(e,t){var n,r=[];this._certsDir=this._certsDir||t,Object.keys(e).forEach(function(t){var i,a=e[t],s=new Date(a.notBefore),l=new Date(a.notAfter),c="",u=Date.now();s.getTime()>u?(i=!0,c="Invalid"):l.getTime()<u&&(i=!0,c="Expired");var d={dir:a.dir,filename:t,domain:a.dnsName,mtime:a.mtime,validity:s.toLocaleString()+" ~ "+l.toLocaleString(),status:c||o.createElement("span",{className:"glyphicon glyphicon-ok",style:p}),isInvalid:i};"root"===t?(d.displayName="root (Root CA)",n=d,d.readOnly=!0):("z"===t[0]&&"/"===t[1]&&(d.displayName=t.substring(2),d.readOnly=!0),r.push(d))}),r.sort(function(e,t){return e.readOnly?t.readOnly?0:-1:t.readOnly?1:a.compare(t.mtime,e.mtime)}),n&&r.unshift(n),this.refs.certsInfoDialog.show(),this._hideDialog=!1,this.setState({list:r})},hide:function(){this.refs.certsInfoDialog.hide(),this._hideDialog=!0},showRemoveTips:function(e){var t=(e.dir||"").replace(/\\/g,"/");t=t+(/\/$/.test(t)?"":"/")+e.filename;var n=t+".crt",r=t+".key";this.refs.tipsDialog.show({title:"Delete the following files and restart whistle:",tips:r+"\n"+n,dir:e.dir})},handleCgi:function(e,t){return e?void this.show(e):a.showSystemError(t)},removeCert:function(e){var t=this;c.confirm("Are you sure to delete '"+e.filename+"'.",function(n){n&&u.certs.remove({filename:e.filename},t.handleCgi)})},shouldComponentUpdate:function(){return this._hideDialog===!1},formatFiles:function(e){for(var t,n=0,r=e.length;r>n;n++){var o=e[n];if(o.size>g||!(o.size>0))return void d.error("The uploaded certificate size cannot exceed 128K.");var i=o.name;if(!/\.(crt|key)/.test(i))return void d.error("Only files with .key or .crt suffixes are supported.");var a=RegExp.$1;if(i=i.slice(0,-4),!i||i.length>128)return void d.error("The file name cannot be empty and the length cannot exceed 128.");t=t||{};var s=t[i]||{};s["key"==a?"key":"cert"]=o,t[i]=s}if(t){var l;return Object.keys(t).forEach(function(e){var n=t[e];n.key&&n.cert&&(l=l||{},l[e]=n)}),l}},handleChange:function(e){var t=this,n=i.findDOMNode(t.refs.uploadCerts),o=n.files&&t.formatFiles(n.files);if(n.value="",o){if(o.root){var a=t._certsDir||"~/.WhistleAppData/custom_certs";c.alert("Root CA cannot be uploaded by UI.\nYou must manually upload to follow directory and restart Whistle:\n"+a),delete o.root}var s=function(){u.certs.upload(JSON.stringify(o),t.handleCgi)},l=Object.keys(o),d=2*l.length;l.map(function(e){var t=o[e];r(t.key,function(e){t.key=e,0===--d&&s()}),r(t.cert,function(e){t.cert=e,0===--d&&s()})})}},showUpload:function(){i.findDOMNode(this.refs.uploadCerts).click()},render:function(){var e=this,t=e.state.list||[];return o.createElement(s,{ref:"certsInfoDialog",wstyle:"w-certs-info-dialog"},o.createElement("div",{className:"modal-body"},o.createElement("button",{type:"button",className:"close",onClick:e.hide},o.createElement("span",{"aria-hidden":"true"},"×")),o.createElement("h4",{className:"w-certs-info-title"},o.createElement("a",{className:"w-help-menu",title:"Click here to see help",href:"https://avwo.github.io/whistle/custom-certs.html",target:"_blank"},o.createElement("span",{className:"glyphicon glyphicon-question-sign"})),"Custom Certs"),o.createElement("table",{className:"table"},o.createElement("thead",null,o.createElement("th",{className:"w-certs-info-order"},"#"),o.createElement("th",{className:"w-certs-info-filename"},"Filename"),o.createElement("th",{className:"w-certs-info-domain"},"DNS Name"),o.createElement("th",{className:"w-certs-info-validity"
|
|
102
|
+
className:"w-plugins-name"},"Name"),c.createElement("th",{className:"w-plugins-version"},"Version"),c.createElement("th",{className:"w-plugins-operation"},"Operation"),c.createElement("th",{className:"w-plugins-desc"},"Description"))))),c.createElement("div",{className:"fill w-plugins-list"},c.createElement("table",{className:"table table-hover"},c.createElement("tbody",null,s.length?s.sort(r(n)).map(function(t,r){var o=n[t];t=t.slice(0,-1);var i=!l[t],a=o.pluginHomepage&&!o.openInPlugins,s=o.pluginHomepage||"plugin."+t+"/",p=f.compareVersion(o.latest,o.version);return p&&(p="(New: "+o.latest+")",e.hasNewPlugin=!0),c.createElement("tr",{key:t,className:(!u&&i?"":"w-plugins-disable")+(p?" w-has-new-version":"")},c.createElement("th",{className:"w-plugins-order",onDoubleClick:e.enableAllPlugins},r+1),c.createElement("td",{className:"w-plugins-active",onDoubleClick:e.enableAllPlugins},c.createElement("input",{type:"checkbox",title:d?"Not allowed disable plugins":u?"Disabled":(i?"Disable ":"Enable ")+t,"data-name":t,checked:d||i,disabled:!d&&u,onChange:e.props.onChange,className:d?"w-not-allowed":void 0})),c.createElement("td",{className:"w-plugins-date"},f.toLocaleString(new Date(o.mtime))),c.createElement("td",{className:"w-plugins-name",title:o.moduleName},c.createElement("a",{href:s,target:"_blank","data-name":t,onClick:a?null:e.onOpen},t)),c.createElement("td",{className:"w-plugins-version"},o.homepage?c.createElement("a",{href:o.homepage,target:"_blank"},o.version):o.version,p?o.homepage?c.createElement("a",{className:"w-new-version",href:o.homepage,target:"_blank"},p):c.createElement("span",{className:"w-new-version"},p):void 0),c.createElement("td",{className:"w-plugins-operation"},c.createElement("a",{href:s,target:"_blank","data-name":t,className:"w-plugin-btn",onClick:a?null:e.onOpen},"Option"),o.rules||o._rules||o.resRules?c.createElement("a",{draggable:"false","data-name":t,onClick:e.showRules},"Rules"):c.createElement("span",{className:"disabled"},"Rules"),o.isProj?c.createElement("span",{className:"disabled"},"Update"):c.createElement("a",{draggable:"false",className:"w-plugin-btn w-plugin-update-btn","data-name":t,onClick:e.showUpdate},"Update"),o.isProj||o.notUn?c.createElement("span",{className:"disabled"},"Uninstall"):c.createElement("a",{draggable:"false",className:"w-plugin-btn","data-name":t,onClick:e.showUninstall},"Uninstall"),f.isString(o.rulesUrl)||f.isString(o.valuesUrl)?c.createElement("a",{className:"w-plugin-btn",onClick:function(){e.syncData(o)}},"Sync"):void 0,o.homepage?c.createElement("a",{href:o.homepage,className:"w-plugin-btn",target:"_blank"},"Help"):c.createElement("span",{className:"disabled"},"Help")),c.createElement("td",{className:"w-plugins-desc",title:o.description},o.description))}):c.createElement("tr",null,c.createElement("td",{colSpan:"7",className:"w-empty"},c.createElement("a",{href:"https://github.com/whistle-plugins",target:"_blank"},"Empty")))))),c.createElement(g,{ref:"syncDialog"}),c.createElement(p,{ref:"pluginRulesDialog",wstyle:"w-plugin-rules-dialog"},c.createElement("div",{className:"modal-header"},c.createElement("h4",null,i.name),c.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},c.createElement("span",{"aria-hidden":"true"},"×"))),c.createElement("div",{className:"modal-body"},c.createElement("div",{className:"w-plugin-rules"},i.rules?c.createElement("fieldset",null,c.createElement("legend",null,"rules.txt"),c.createElement("pre",null,i.rules)):null,i._rules?c.createElement("fieldset",null,c.createElement("legend",null,"reqRules.txt (_rules.txt)"),c.createElement("pre",null,i._rules)):null,i.resRules?c.createElement("fieldset",null,c.createElement("legend",null,"resRules.txt"),c.createElement("pre",null,i.resRules)):null)),c.createElement("div",{className:"modal-footer"},c.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close"))),c.createElement(p,{ref:"operatePluginDialog",wstyle:"w-plugin-update-dialog"},c.createElement("div",{className:"modal-body"},c.createElement("h5",null,c.createElement("a",{"data-dismiss":"modal",className:"w-copy-text-with-tips","data-clipboard-text":a},"Copy the following command")," ","to the CLI to execute:"),c.createElement("textarea",{value:a,className:"w-plugin-update-cmd",onChange:this.onCmdChange}),c.createElement("div",{style:{margin:"8px 0 0",color:"red","word-break":"break-all",display:!o.isSys&&o.uninstall?"":"none"}},"If uninstall failed, delete the following directory instead:",c.createElement("a",{className:"w-copy-text-with-tips","data-dismiss":"modal","data-clipboard-text":o.pluginPath,style:{marginLeft:5,cursor:"pointer"}},o.pluginPath))),c.createElement("div",{className:"modal-footer"},c.createElement("button",{type:"button","data-dismiss":"modal",className:"btn btn-primary w-copy-text-with-tips","data-clipboard-text":a},"Copy"),c.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close"))))}}),b=c.createClass({displayName:"Tabs",componentDidMount:function(){function e(){clearTimeout(n),n=setTimeout(t,60)}function t(){if(!r.props.hide){var e=i.offsetHeight;e&&(o.style.width=i.offsetWidth+"px",o.style.height=e+"px")}}var n,r=this,o=u.findDOMNode(r.refs.tabPanel),i=o.parentNode;r._resizeHandler=e,e(),l(window).on("resize",e)},shouldComponentUpdate:function(e,t){return!this.props.hide||!e.hide},componentDidUpdate:function(e,t){e.hide&&!this.props.hide&&this._resizeHandler()},onClose:function(e){this.props.onClose&&this.props.onClose(e),e.stopPropagation()},render:function(){var e=this,t=e.props,n=t.tabs||[],r="Home",i=t.disabledPlugins||{},a=t.disabledAllPlugins,s=t.ndp,l=e.props.active;if(l&&l!=r)for(var u=0,d=n.length;d>u;u++){var p=n[u];if(p.name==l){r=p.name;break}}return c.createElement("div",{className:"w-nav-tabs fill orient-vertical-box",style:{display:e.props.hide?"none":"",paddingTop:a?0:void 0}},a?c.createElement("div",{className:"w-record-status",style:{marginBottom:5}},"All plugins is disabled",c.createElement("button",{className:"btn btn-primary",onClick:o},"Enable")):null,c.createElement("ul",{className:"nav nav-tabs"},c.createElement("li",{className:"w-nav-home-tab"+("Home"==r?" active":""),"data-name":"Home",onClick:e.props.onActive},c.createElement("a",{draggable:"false"},"Home")),n.map(function(t){var n=!s&&(a||i[t.name]);return c.createElement("li",{className:r==t.name?" active":""},c.createElement("a",{"data-name":t.name,title:t.name,onClick:e.props.onActive,draggable:"false",className:n?"w-plugin-tab-disabled":void 0},n?c.createElement("span",{className:"glyphicon glyphicon-ban-circle"}):void 0,t.name,c.createElement("span",{"data-name":t.name,title:"Close",className:"w-close-icon",onClick:e.onClose},"×")))})),c.createElement("div",{className:"fill orient-vertical-box w-nav-tab-panel"},c.createElement("div",{ref:"tabPanel",className:"fill orient-vertical-box"},c.createElement(w,{data:e.props,hide:"Home"!=r,onChange:e.props.onChange,onOpen:e.props.onOpen}),n.map(function(e){return c.createElement(A,{inited:r==e.name},c.createElement("iframe",{style:{display:r==e.name?"":"none"},src:e.url}))}))))}});e.exports=b},function(e,t,n){var r=n(603);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-nav-tabs{padding-top:10px;font-size:13px}.w-nav-tabs>.nav>li>a{padding:5px 20px 5px 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:90pt;position:relative}.w-nav-tabs>.nav>li>a>.w-close-icon{display:block;position:absolute;top:5px;right:5px;color:#999;cursor:pointer}.w-nav-tabs>.nav>li>a>.w-close-icon:hover{color:#000}.w-plugin-tab-disabled{color:#ccc!important}.w-plugin-tab-disabled .glyphicon-ban-circle{vertical-align:text-top;margin-right:3px;color:#ccc!important}.w-nav-tabs iframe{border:none;display:block;background-color:#fff;margin:0;padding:0;width:100%;height:100%}.w-nav-tabs .w-nav-tab-panel,.w-nav-tabs .w-nav-tab-panel>div{overflow:hidden}.w-nav-tabs>.nav>.w-nav-home-tab>a{padding-right:10px!important}.w-plugins td,.w-plugins th{font-size:13px;font-weight:400}.w-plugins-headers{border-bottom:1px solid #ccc;overflow:hidden}.w-plugins-headers .table th{border:none!important;padding:6px;color:#000;background:#fafafa;font-weight:700}.w-plugins-list{overflow-y:auto;overflow-x:hidden;outline:0}.w-plugins-list td,.w-plugins-list th{border-top:none!important;border-bottom:1px solid #ddd;padding:8px 6px!important;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.w-plugins-disable,.w-plugins-disable a,.w-plugins-disable td{color:#aaa}.w-plugins-order{width:50px}.w-plugins-active{width:60px}.w-plugins-list td.w-plugins-active input{margin-left:9pt;vertical-align:text-bottom}.w-plugins-name{width:10pc}.w-plugins-version{width:140px}.w-plugins-list .w-has-new-version .w-plugin-update-btn,.w-plugins-list .w-has-new-version .w-plugins-version .w-new-version,.w-plugins-menu.w-plugin-update-btn{color:#f66!important}.w-plugins-list .w-has-new-version .w-plugins-version span{margin-left:3px}.w-plugins-list .w-has-new-version .w-plugin-update-btn:hover,.w-plugins-list .w-has-new-version .w-plugins-version span:hover,.w-plugins-menu.w-plugin-update-btn:hover{color:#f33!important}.w-plugins-date{width:180px}.w-plugins-operation{width:360px}.w-plugins-operation a,.w-plugins-operation span.disabled{margin-right:20px}.w-plugins-operation a:last-child,.w-plugins-operation span.disabled:last-child{margin-right:0}.w-plugins-operation span.disabled{color:#ccc}.w-plugin-rules-dialog .modal-dialog{width:40pc}.w-plugin-rules-dialog .modal-dialog pre{max-height:220px;overflow:auto;padding:10px}.w-plugin-rules-dialog fieldset{border:1px solid #ddd}.w-plugin-rules-dialog fieldset legend{font-size:13px;padding:0 10px;border:none;width:auto;margin:0 10px;font-weight:700}.w-plugin-rules-dialog fieldset:nth-child(2){margin-top:15px}.w-plugin-rules-dialog .modal-header h4{margin:0}.w-plugin-rules-dialog .modal-header .close{position:absolute;right:10px;top:1pc}.w-plugin-update-dialog .modal-dialog{width:600px}.w-plugin-update-cmd{background:#002240;color:#ddd;padding:15px;margin-top:10px;font-size:14px;display:block;width:578px;height:220px}.w-plugin-btn{color:#337ab7!important}.w-plugin-btn:hover{color:#23527c!important}",""])},function(e,t,n){"use strict";function r(e,t){var n="plugin."+e.substring(8);return 0===t.indexOf(e)||0===t.indexOf(n)?t:n+"/"+t}n(605);var o=n(6),i=n(293),a=n(199),s=n(281),l=n(607),c=o.createClass({displayName:"SyncDialog",getInitialState:function(){return{}},show:function(e,t,n){var r=this;r.rulesModal=t,r.valuesModal=n,a.isString(e.rulesUrl)||(e.rulesUrl=null),a.isString(e.valuesUrl)||(e.valuesUrl=null),r.setState(e,function(){r.refs.syncDialog.show()})},syncRules:function(){var e=this,t=e.state.rulesUrl;if(!e.loadingRules&&a.isString(t)){e.loadingRules=!0;var n=s.createCgi(r(e.state.moduleName,t));n(function(t,n){return e.loadingRules=!1,e.setState({}),t?void e.refs.kvDialog.show(t,e.rulesModal,e.valuesModal):a.showSystemError(n)}),e.setState({})}},syncValues:function(){var e=this,t=e.state.valuesUrl;if(!e.loadingValues&&a.isString(t)){e.loadingValues=!0;var n=s.createCgi(r(e.state.moduleName,t));n(function(t,n){return e.loadingValues=!1,e.setState({}),t?void e.refs.kvDialog.show(t,e.rulesModal,e.valuesModal,!0):a.showSystemError(n)}),e.setState({})}},render:function(){var e=this.state;return o.createElement(i,{ref:"syncDialog",wstyle:"w-sync-dialog"},o.createElement("div",{className:"modal-body"},o.createElement("button",{onClick:this.syncRules,disabled:this.loadingRules||!a.isString(e.rulesUrl),type:"button",className:"btn btn-primary"},o.createElement("span",{className:"glyphicon glyphicon-list"})," ",this.loadingRules?"Loading":"Sync"," Rules"),o.createElement("button",{onClick:this.syncValues,disabled:this.loadingValues||!a.isString(e.valuesUrl),type:"button",className:"btn btn-default"},o.createElement("span",{className:"glyphicon glyphicon-folder-close"})," ",this.loadingValues?"Loading":"Sync"," Values")),o.createElement("div",{className:"modal-footer"},o.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")),o.createElement(l,{ref:"kvDialog"}))}}),u=o.createClass({displayName:"SyncDialogWrap",shouldComponentUpdate:function(){return!1},show:function(e,t,n){this.refs.syncDialog.show(e,t,n)},render:function(){return o.createElement(c,{ref:"syncDialog"})}});e.exports=u},function(e,t,n){var r=n(606);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-sync-dialog .modal-dialog{width:420px}.w-sync-dialog .modal-body .btn{display:block;width:398px;line-height:40px;font-size:18px;margin:10px 0}.w-sync-dialog .modal-body .btn span{margin-right:10px}",""])},function(e,t,n){"use strict";n(187),n(608);var r=n(6),o=n(293),i=n(199),a=n(280),s=n(210),l=r.createClass({displayName:"KVDialog",getInitialState:function(){return{list:[]}},show:function(e,t,n,r){this.isValues=r,this.refs.kvDialog.show(),this._hideDialog=!1,this.setState({list:i.parseImportData(e||"",r?n:t,r)})},hide:function(){this.refs.kvDialog.hide(),this._hideDialog=!0},shouldComponentUpdate:function(){return this._hideDialog===!1},viewContent:function(e){i.openEditor(e.target.title)},confirm:function(){var e,t={},n=this;return n.state.list.forEach(function(n){e=e||n.isConflict,t[n.name]=n.value}),e?void s.confirm("Conflict with existing content, whether to continue to overwrite them?",function(e){e&&a.trigger(n.isValues?"uploadValues":"uploadRules",t)}):a.trigger(n.isValues?"uploadValues":"uploadRules",t)},remove:function(e){var t=this;s.confirm("Are you sure to delete '"+e.name+"'.",function(n){if(n){var r=t.state.list.indexOf(e);-1!==r&&(t.state.list.splice(r,1),t.setState({}))}})},render:function(){var e=this,t=e.state.list||[],n=!t.length;return r.createElement(o,{ref:"kvDialog",wstyle:"w-kv-dialog"},r.createElement("div",{className:"modal-body"},r.createElement("button",{type:"button",className:"close",onClick:e.hide},r.createElement("span",{"aria-hidden":"true"},"×")),r.createElement("table",{className:"table"},r.createElement("thead",null,r.createElement("th",{className:"w-kv-name"},"Name"),r.createElement("th",{className:"w-kv-operation"},"Operation")),r.createElement("tbody",null,n?r.createElement("tr",null,r.createElement("td",{colSpan:"2",className:"w-empty"},"Empty")):t.map(function(t,n){return r.createElement("tr",{className:t.isConflict?"w-kv-conflict":void 0},r.createElement("th",{title:t.name,className:"w-kv-name"},t.name),r.createElement("td",{className:"w-kv-operation"},r.createElement("a",{title:t.value,onClick:e.viewContent},"Content"),r.createElement("a",{"data-name":t.name,onClick:function(){e.remove(t)}},"Delete"),r.createElement("strong",null,t.isConflict?"[Conflict]":"")))})))),r.createElement("div",{className:"modal-footer"},r.createElement("button",{type:"button",className:"btn btn-primary",disabled:n,onClick:this.confirm,"data-dismiss":"modal"},"Confirm"),r.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")))}});e.exports=l},function(e,t,n){var r=n(609);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-kv-dialog .modal-dialog{width:666px}.w-kv-name{width:25pc}.w-kv-operation a:nth-child(2){color:#f66;margin:0 20px}.w-kv-conflict th,.w-kv-operation strong{color:#f66}",""])},function(e,t,n){"use strict";n(187),n(611);var r=n(6),o=n(39),i=n(293),a=r.createClass({displayName:"ListDialog",getInitialState:function(){return{checkedItems:{},selectedCount:0}},onChange:function(e){var t=e.target,n=t.parentNode.title,r=this.state.checkedItems;t.checked?r[n]=1:delete r[n],this.setState({selectedCount:Object.keys(r).length})},onConfirm:function(e){if(!e.target.disabled){this.refs.dialog.hide();var t=o.findDOMNode(this.refs.filename),n=o.findDOMNode(this.refs.exportData),r=-1!==e.target.className.indexOf("btn-warning"),i=r?this.getAllItems():this.state.checkedItems;o.findDOMNode(this.refs.exportName).value=t.value.trim(),o.findDOMNode(this.refs.data).value=JSON.stringify(i),n.submit(),t.value=""}},getAllItems:function(){var e=this.props.list||[],t={};return e.forEach(function(e){t[e]=1}),t},show:function(){var e=this;e.refs.dialog.show(),setTimeout(function(){o.findDOMNode(e.refs.filename).focus()},500)},preventDefault:function(e){e.preventDefault()},render:function(){var e=this,t=e.props.list||[],n=e.state.checkedItems,o=e.state.selectedCount,a=this.props.name;return r.createElement(i,{ref:"dialog",wclassName:" w-list-dialog"},r.createElement("div",{className:"modal-body"},r.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},r.createElement("span",{"aria-hidden":"true"},"×")),r.createElement("p",null,"Filename:",r.createElement("input",{ref:"filename",style:{width:390,display:"inline-block",marginLeft:5},className:"form-control",placeholder:"Input the filename"})),t.map(function(t){return r.createElement("label",{title:t},r.createElement("input",{onChange:e.onChange,type:"checkbox",checked:!!n[t]}),t)})),r.createElement("div",{className:"modal-footer"},r.createElement("div",{className:"w-list-counter"},"Selected: ",o," / ",t.length),r.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Cancel"),r.createElement("button",{type:"button",className:"btn btn-warning",onMouseDown:this.preventDefault,onClick:this.onConfirm},"Export All"),r.createElement("button",{type:"button",className:"btn btn-primary",disabled:!Object.keys(n).length,onMouseDown:this.preventDefault,onClick:this.onConfirm},"Export Selected")),r.createElement("form",{action:"cgi-bin/"+a+"/export",ref:"exportData",style:{display:"none"},target:"downloadTargetFrame"},r.createElement("input",{ref:"exportName",type:"hidden",name:"filename"}),r.createElement("input",{ref:"data",type:"hidden",name:a})))}});e.exports=a},function(e,t,n){var r=n(612);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-list-dialog label{line-height:26px;width:226px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-left:10px}.w-list-dialog label input{margin-right:5px}.w-list-dialog{width:500px}.w-list-dialog .modal-footer{position:relative}.w-list-counter{position:absolute;left:10px;top:15px}",""])},function(e,t,n){"use strict";var r=n(6),o=n(281),i=n(280),a=r.createClass({displayName:"FilterBtn",getInitialState:function(){return{hasFilterText:!!o.filterIsEnabled()}},componentDidMount:function(){var e=this;i.on("filterChanged",function(){var t=!!o.filterIsEnabled();t!==e.state.hasFilterText&&e.setState({hasFilterText:!!o.filterIsEnabled()})})},render:function(){var e=this.props.hide,t=this.props.isNetwork,n=t&&this.state.hasFilterText?" w-menu-enable":"";return r.createElement("a",{onClick:this.props.onClick,className:"w-settings-menu"+n,style:{display:e?"none":""},draggable:"false"},r.createElement("span",{className:"glyphicon glyphicon-cog"}),"Settings")}});e.exports=a},function(e,t,n){"use strict";function r(e){e.select(),e.focus()}function o(e,t){d.error(e),t.select(),t.focus()}function i(e){return e.map(function(e){return e.date=c.toLocaleString(new Date(e.date)),e})}n(187),n(615);var a=n(6),s=n(39),l=n(293),c=n(199),u=n(280),d=n(207),p=n(281),g=n(210),h=20971520,f=60,m=a.createClass({displayName:"FilesDialog",getInitialState:function(){return{files:i(p.getUploadFiles())}},updateFiles:function(e){e&&this.setState({files:i(e)})},show:function(){this.refs.filesDialog.show()},hide:function(){this.refs.filesDialog.hide()},showNameInput:function(){if(this.checkCount()){var e=this.refs;e.filenameDialog.show();var t=s.findDOMNode(e.filename);t.value=this.params.name||"",setTimeout(function(){r(t)},500),this.setState({})}},componentDidMount:function(){var e=this;u.on("uploadFile",function(t,n){e.submit(n)}),u.on("showFilenameInput",function(t,n){e.params=n,e.showNameInput()}),u.on("download",function(t,n){e.startDownload(n)})},checkParams:function(){var e=s.findDOMNode(this.refs.filename),t=e.value.trim();return t?t.length>f?void o("The filename length cannot exceed 60.",e):/[\\/:*?"<>|\s]/.test(t)?void o('The filename cannot contain \\/:*?"<>| and spaces.',e):(this.params.name=t,!0):void o("The filename cannot be empty.",e)},checkCount:function(){var e=this.state.files;return e.length>=f?(this.show(),setTimeout(function(){g.alert("The number of uploaded files cannot exceed 60,\ndelete the unnecessary files first.")},10),!1):!0},onConfirm:function(){if(!this.pending&&this.checkParams()&&this.checkCount()){var e=this;e.pending=!0;var t=e.params.name;p.values.checkFile({name:t,count:e.state.files.length},function(n,r){if(e.pending=!1,!n)return c.showSystemError(r);if(e.updateFiles(n.files),n.isMax)return g.alert("The number of uploaded files cannot exceed 60,\ndelete the unnecessary files first.");var o=function(t){t&&(e.pending=!0,p.values.upload(JSON.stringify(e.params),function(t,n){return e.pending=!1,t?0!==t.ec?g.alert(t.em):(e.params="",e.refs.filenameDialog.hide(),e.updateFiles(t.files),void e.show()):c.showSystemError(n)},{contentType:"application/json",processData:!1}))};return n.exists?void g.confirm("The name `"+t+"` already exists, whether to overwrite it?",o):o(!0)})}},startDownload:function(e){s.findDOMNode(this.refs.name).value=e.name,s.findDOMNode(this.refs.headers).value=e.headers||"",s.findDOMNode(this.refs.content).value=e.base64||"",s.findDOMNode(this.refs.downloadForm).submit()},download:function(e){this.checkParams()&&this.startDownload(this.params)},submit:function(e){if(!e.size)return g.alert("The file size cannot be empty.");if(e.size>h)return g.alert("The file size cannot exceed 20m.");var t=this,n={};c.readFileAsBase64(e,function(r){n.base64=r,s.findDOMNode(t.refs.file).value="",n.name=(e.name||"").replace(/[\\/:*?"<>|\s]/g,""),t.params=n,t.showNameInput()})},uploadFile:function(){var e=s.findDOMNode(this.refs.uploadFileForm);this.submit(new FormData(e).get("file"))},selectFile:function(){this.checkCount()&&s.findDOMNode(this.refs.file).click()},remove:function(e){var t=e.target.getAttribute("data-name"),n=this;g.confirm("Are you sure to delete '"+t+"'.",function(e){e&&p.values.removeFile({name:t},function(e,t){return e?0!==e.ec?g.alert(e.em):void n.updateFiles(e.files):c.showSystemError(t)})})},downloadFile:function(e){var t=e.target.getAttribute("data-name");window.open("cgi-bin/values/download?name="+encodeURIComponent(t))},render:function(){var e=this,t=(e.params||"").title,n=e.state.files;return a.createElement(l,{wstyle:"w-files-dialog",ref:"filesDialog"},a.createElement("div",{className:"modal-body"},a.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},a.createElement("span",{"aria-hidden":"true"},"×")),a.createElement("h4",null,a.createElement("a",{className:"w-help-menu",title:"Click here to see help",href:"https://avwo.github.io/whistle/webui/files.html",target:"_blank"},a.createElement("span",{className:"glyphicon glyphicon-question-sign"})),"System Files"),a.createElement("button",{className:"w-files-upload-btn",onClick:e.selectFile},a.createElement("span",{className:"glyphicon glyphicon-arrow-up"}),"Drop file here or click to browse (size <= 20m)"),a.createElement("table",{className:"table",style:{display:n.length?void 0:"none"}},a.createElement("thead",null,a.createElement("th",{className:"w-files-order"},"#"),a.createElement("th",{className:"w-files-date"},"Date"),a.createElement("th",{className:"w-files-path"},"Path"),a.createElement("th",{className:"w-files-operation"},"Operation")),a.createElement("tbody",null,n.map(function(t,n){var r="/$whistle/"+t.name;return a.createElement("tr",{key:t.name},a.createElement("th",{className:"w-files-order"},n+1),a.createElement("td",{className:"w-files-date"},t.date),a.createElement("td",{className:"w-files-path"},r),a.createElement("td",{className:"w-files-operation"},a.createElement("a",{className:"w-copy-text-with-tips","data-clipboard-text":r},"Copy path"),a.createElement("a",{"data-name":t.name,onClick:e.downloadFile},"Download"),a.createElement("a",{"data-name":t.name,onClick:e.remove},"Delete")))})))),a.createElement("div",{className:"modal-footer"},a.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")),a.createElement("form",{ref:"uploadFileForm",encType:"multipart/form-data",style:{display:"none"}},a.createElement("input",{ref:"file",onChange:this.uploadFile,name:"file",type:"file"})),a.createElement(l,{ref:"filenameDialog",wstyle:"w-files-info-dialog"},a.createElement("div",{className:"modal-header"},t||"Modify the filename",a.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},a.createElement("span",{"aria-hidden":"true"},"×"))),a.createElement("div",{className:"modal-body"},a.createElement("label",{className:"w-files-name"},"Name:",a.createElement("input",{ref:"filename",maxLength:"60",placeholder:"Input the filename",type:"text",className:"form-control"}))),a.createElement("div",{className:"modal-footer"},a.createElement("button",{type:"button",className:"btn btn-default",onClick:this.download},"Download"),a.createElement("button",{type:"button",className:"btn btn-primary",onClick:this.onConfirm},"Confirm"),a.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close"))),a.createElement("form",{ref:"downloadForm",action:"cgi-bin/download",style:{display:"none"},method:"post",target:"downloadTargetFrame"},a.createElement("input",{ref:"name",name:"filename",type:"hidden"}),a.createElement("input",{ref:"type",name:"type",type:"hidden",value:"rawBase64"}),a.createElement("input",{ref:"headers",name:"headers",type:"hidden"}),a.createElement("input",{ref:"content",name:"content",type:"hidden"})))}}),A=a.createClass({displayName:"FilesDialogWrap",show:function(e){this.refs.filesDialog.show(e)},hide:function(){this.refs.filesDialog.hide()},shouldComponentUpdate:function(){return!1},render:function(){return a.createElement(m,{ref:"filesDialog"})}});e.exports=A},function(e,t,n){var r=n(616);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-files-dialog .modal-dialog{width:900px}.w-files-dialog h4{margin-top:10px}.w-files-upload-btn{border:1px solid #ccc;border-radius:5px;display:block;background:#fff;line-height:60px;text-align:center;margin:20px 0;color:#aaa;font-size:1pc;width:55pc;font-weight:400}.w-files-upload-btn:hover{color:#aaa}.w-files-upload-btn span{font-size:24px;vertical-align:sub;margin-right:10px}.w-files-order{width:36px}.w-files-date{width:205px}.w-files-path{word-break:break-all;word-wrap:break-word}.w-files-operation{width:15pc}.w-files-operation a{margin-right:15px;display:inline-block;white-space:nowrap}.w-files-operation a:last-child{color:#f66}.w-files-operation a:last-child:hover{color:red}.w-files-name{display:block;margin:20px 0;white-space:nowrap}.w-files-info-dialog .modal-dialog{width:45pc}.w-files-name input{display:inline-block;width:620px;margin-left:20px;font-weight:400}.w-files-save-in{padding-bottom:10px}.w-files-save-in label{margin-right:20px;font-weight:400}label:first-child{font-weight:700}.w-files-save-in input{margin-right:5px}.w-files-save-in label:last-child{margin-left:20px}.w-files-info-dialog .modal-header{font-weight:700}.w-files-dialog thead th{padding:8px}",""])},function(e,t,n){"use strict";var r=n(6),o=n(280),i=r.createClass({displayName:"UpdateAllBtn",getInitialState:function(){return{disabled:!0}},componentDidMount:function(){var e=this;o.on("setUpdateAllBtnState",function(t,n){e.setState({disabled:!n})})},updateAllPlugins:function(){!this.state.disabled&&o.trigger("updateAllPlugins")},render:function(){var e=this.state.disabled||this.props.hide;return r.createElement("a",{onClick:this.updateAllPlugins,className:"w-plugins-menu w-plugin-update-btn"+(e?" hide":""),draggable:"false"},r.createElement("span",{className:"glyphicon glyphicon-refresh"}),"UpdateAll")}});e.exports=i},function(e,t,n){"use strict";function r(e,t){var n=new FileReader;n.readAsText(e),n.onload=function(){t(n.result)}}n(187),n(619);var o=n(6),i=n(39),a=n(199),s=n(293),l=n(621),c=n(210),u=n(281),d=n(207),p={color:"#5bbd72"},g=131072,h=o.createClass({displayName:"HistoryData",getInitialState:function(){return{list:[]}},show:function(e,t){var n,r=[];this._certsDir=this._certsDir||t,Object.keys(e).forEach(function(t){var i,a=e[t],s=new Date(a.notBefore),l=new Date(a.notAfter),c="",u=Date.now();s.getTime()>u?(i=!0,c="Invalid"):l.getTime()<u&&(i=!0,c="Expired");var d={dir:a.dir,filename:t,domain:a.dnsName,mtime:a.mtime,validity:s.toLocaleString()+" ~ "+l.toLocaleString(),status:c||o.createElement("span",{className:"glyphicon glyphicon-ok",style:p}),isInvalid:i};"root"===t?(d.displayName="root (Root CA)",n=d,d.readOnly=!0):("z"===t[0]&&"/"===t[1]&&(d.displayName=t.substring(2),d.readOnly=!0),r.push(d))}),r.sort(function(e,t){return e.readOnly?t.readOnly?0:-1:t.readOnly?1:a.compare(t.mtime,e.mtime)}),n&&r.unshift(n),this.refs.certsInfoDialog.show(),this._hideDialog=!1,this.setState({list:r})},hide:function(){this.refs.certsInfoDialog.hide(),this._hideDialog=!0},showRemoveTips:function(e){var t=(e.dir||"").replace(/\\/g,"/");t=t+(/\/$/.test(t)?"":"/")+e.filename;var n=t+".crt",r=t+".key";this.refs.tipsDialog.show({title:"Delete the following files and restart whistle:",tips:r+"\n"+n,dir:e.dir})},handleCgi:function(e,t){return e?void this.show(e):a.showSystemError(t)},removeCert:function(e){var t=this;c.confirm("Are you sure to delete '"+e.filename+"'.",function(n){n&&u.certs.remove({filename:e.filename},t.handleCgi)})},shouldComponentUpdate:function(){return this._hideDialog===!1},formatFiles:function(e){for(var t,n=0,r=e.length;r>n;n++){var o=e[n];if(o.size>g||!(o.size>0))return void d.error("The uploaded certificate size cannot exceed 128K.");var i=o.name;if(!/\.(crt|key)/.test(i))return void d.error("Only files with .key or .crt suffixes are supported.");var a=RegExp.$1;if(i=i.slice(0,-4),!i||i.length>128)return void d.error("The file name cannot be empty and the length cannot exceed 128.");t=t||{};var s=t[i]||{};s["key"==a?"key":"cert"]=o,t[i]=s}if(t){var l;return Object.keys(t).forEach(function(e){var n=t[e];n.key&&n.cert&&(l=l||{},l[e]=n)}),l}},handleChange:function(e){var t=this,n=i.findDOMNode(t.refs.uploadCerts),o=n.files&&t.formatFiles(n.files);if(n.value="",o){if(o.root){var a=t._certsDir||"~/.WhistleAppData/custom_certs";c.alert("Root CA cannot be uploaded by UI.\nYou must manually upload to follow directory and restart Whistle:\n"+a),delete o.root}var s=function(){u.certs.upload(JSON.stringify(o),t.handleCgi)},l=Object.keys(o),d=2*l.length;l.map(function(e){var t=o[e];r(t.key,function(e){t.key=e,0===--d&&s()}),r(t.cert,function(e){t.cert=e,0===--d&&s()})})}},showUpload:function(){i.findDOMNode(this.refs.uploadCerts).click()},render:function(){var e=this,t=e.state.list||[];return o.createElement(s,{ref:"certsInfoDialog",wstyle:"w-certs-info-dialog"},o.createElement("div",{className:"modal-body"},o.createElement("button",{type:"button",className:"close",onClick:e.hide},o.createElement("span",{"aria-hidden":"true"},"×")),o.createElement("h4",{className:"w-certs-info-title"},o.createElement("a",{className:"w-help-menu",title:"Click here to see help",href:"https://avwo.github.io/whistle/custom-certs.html",target:"_blank"},o.createElement("span",{className:"glyphicon glyphicon-question-sign"})),"Custom Certs"),o.createElement("table",{className:"table"},o.createElement("thead",null,o.createElement("th",{className:"w-certs-info-order"},"#"),o.createElement("th",{className:"w-certs-info-filename"},"Filename"),o.createElement("th",{className:"w-certs-info-domain"},"DNS Name"),o.createElement("th",{className:"w-certs-info-validity"
|
|
103
103
|
},"Validity"),o.createElement("th",{className:"w-certs-info-status"},"Status")),o.createElement("tbody",null,t.length?t.map(function(t,n){return o.createElement("tr",{className:t.isInvalid?"w-cert-invalid":void 0},o.createElement("th",{className:"w-certs-info-order"},n+1),o.createElement("td",{className:"w-certs-info-filename",title:t.filename},t.readOnly?o.createElement("span",{className:"glyphicon glyphicon-lock"}):void 0,t.displayName||t.filename,o.createElement("br",null),o.createElement("a",{className:"w-delete",onClick:function(){t.readOnly?e.showRemoveTips(t):e.removeCert(t)},title:"",style:{color:t.readOnly?"#337ab7":void 0}},t.readOnly?"View path":"Delete")),o.createElement("td",{className:"w-certs-info-domain",title:t.domain},t.domain),o.createElement("td",{className:"w-certs-info-validity",title:t.validity},t.validity),o.createElement("td",{className:"w-certs-info-status"},t.status))}):o.createElement("tr",null,o.createElement("td",{colSpan:"5",className:"w-empty"},"Empty"))))),o.createElement("div",{className:"modal-footer"},o.createElement("input",{ref:"uploadCerts",style:{display:"none"},type:"file",accept:".crt,.key",multiple:"multiple",onChange:e.handleChange}),o.createElement("button",{type:"button",style:{display:u.isDiableCustomCerts()?"none":void 0},className:"btn btn-primary",onClick:e.showUpload},"Upload"),o.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")),o.createElement(l,{ref:"tipsDialog"}))}});e.exports=h},function(e,t,n){var r=n(620);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(),t.push([e.id,".w-certs-info-dialog .modal-dialog{width:64pc}.w-certs-info-order{width:50px}.w-certs-info-validity{width:330px}.w-certs-info-status{width:75pt}.w-cert-invalid td,.w-cert-invalid th{color:red}.w-certs-info-filename a{font-size:9pt;cursor:pointer}.w-certs-info-filename .glyphicon-lock{margin-right:5px}.w-certs-info-dialog td{overflow:hidden;text-overflow:ellipsis}.w-certs-info-filename{width:220px}.w-certs-info-dialog td,.w-certs-info-dialog th{vertical-align:middle!important}",""])},function(e,t,n){"use strict";n(187);var r=n(6),o=n(293),i=r.createClass({displayName:"TipsDialog",getInitialState:function(){return{}},show:function(e){this._hideDialog=!1,this.setState(e),this.refs.tipsDialog.show()},hide:function(){this.refs.tipsDialog.hide(),this._hideDialog=!0},shouldComponentUpdate:function(){return this._hideDialog===!1},render:function(){var e=this.state;return r.createElement(o,{ref:"tipsDialog",wstyle:"w-dns-servers-dialog w-tips-dialog"},r.createElement("div",{className:"modal-header"},e.title,r.createElement("button",{type:"button",className:"close","data-dismiss":"modal"},r.createElement("span",{"aria-hidden":"true"},"×"))),r.createElement("pre",{className:"modal-body"},e.tips),r.createElement("div",{className:"modal-footer"},r.createElement("button",{type:"button","data-dismiss":"modal",className:"btn btn-primary w-copy-text-with-tips","data-clipboard-text":e.dir},"Copy directory"),r.createElement("button",{type:"button",className:"btn btn-default","data-dismiss":"modal"},"Close")))}});e.exports=i}]);
|
package/index.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ export interface WhistleOptions {
|
|
|
105
105
|
projectPluginsPath?: string | string[];
|
|
106
106
|
accountPluginsPath?: string | string[];
|
|
107
107
|
customPluginsPath?: string | string[];
|
|
108
|
+
notUninstallPluginPath?: string | string[];
|
|
108
109
|
pluginsPath?: string | string[];
|
|
109
110
|
addonsPath?: string | string[];
|
|
110
111
|
inspect?: boolean;
|
package/lib/config.js
CHANGED
|
@@ -91,7 +91,6 @@ config.PLUGIN_HOOK_NAME_HEADER = 'x-whistle-plugin-hook-name_';
|
|
|
91
91
|
config.CLIENT_ID_HEADER = 'x-whistle-client-id';
|
|
92
92
|
config.COMPOSER_CLIENT_ID_HEADER = 'x-whistle-client-id-' + uid;
|
|
93
93
|
config.TUNNEL_DATA_HEADER = 'x-whistle-tunnel-data';
|
|
94
|
-
config.TEMP_CLIENT_ID_HEADER = 'x-whistle-client-id-' + uid;
|
|
95
94
|
config.TEMP_TUNNEL_DATA_HEADER = 'x-whistle-tunnel-data-' + uid;
|
|
96
95
|
config.SNI_TYPE_HEADER = 'x-whistle-sni-type-' + uid;
|
|
97
96
|
config.ALPN_PROTOCOL_HEADER = 'x-whistle-alpn-protocol';
|
|
@@ -139,7 +138,6 @@ function getDataDir(dirname) {
|
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
config.baseDir = getDataDir();
|
|
142
|
-
config.SYSTEM_PLUGIN_PATH = path.join(getWhistlePath(), 'plugins');
|
|
143
141
|
config.CUSTOM_PLUGIN_PATH = path.join(getWhistlePath(), 'custom_plugins');
|
|
144
142
|
config.CUSTOM_CERTS_DIR = path.resolve(getWhistlePath(), 'custom_certs');
|
|
145
143
|
|
|
@@ -478,16 +476,21 @@ function getHostname(_url) {
|
|
|
478
476
|
return index == -1 ? _url : _url.substring(0, index);
|
|
479
477
|
}
|
|
480
478
|
|
|
481
|
-
function getPaths(paths) {
|
|
479
|
+
function getPaths(paths, isCustom) {
|
|
482
480
|
if (typeof paths === 'string') {
|
|
483
481
|
paths = paths.trim().split(/\s*[|,;]\s*/);
|
|
484
482
|
} else if (!Array.isArray(paths)) {
|
|
485
483
|
return;
|
|
486
484
|
}
|
|
487
|
-
|
|
488
|
-
|
|
485
|
+
var result = [];
|
|
486
|
+
paths.forEach(function (path) {
|
|
487
|
+
if (isCustom && ['self', 'buildin', 'buildIn', 'build-in'].indexOf(path) !== -1) {
|
|
488
|
+
result.push(config.CUSTOM_PLUGIN_PATH);
|
|
489
|
+
} else if (path && typeof path === 'string') {
|
|
490
|
+
result.push(path);
|
|
491
|
+
}
|
|
489
492
|
});
|
|
490
|
-
return
|
|
493
|
+
return result.length ? result : null;
|
|
491
494
|
}
|
|
492
495
|
|
|
493
496
|
function getSecureFilter(newConf) {
|
|
@@ -914,10 +917,11 @@ exports.extend = function (newConf) {
|
|
|
914
917
|
if (typeof secureFilter === 'function') {
|
|
915
918
|
config.secureFilter = secureFilter;
|
|
916
919
|
}
|
|
920
|
+
config.notUninstallPluginPaths = getPaths(newConf.notUninstallPluginPath || newConf.notUninstallPluginPaths);
|
|
917
921
|
config.pluginPaths = getPaths(newConf.pluginPaths || newConf.pluginsPath || newConf.pluginPath);
|
|
918
922
|
config.prePluginsPath = config.projectPluginPaths = getPaths(newConf.projectPluginPaths || newConf.projectPluginsPath || newConf.projectPluginPath);
|
|
919
923
|
config.accountPluginsPath = getPaths(newConf.accountPluginsPath);
|
|
920
|
-
config.customPluginPaths = getPaths(newConf.customPluginPaths || newConf.customPluginsPath || newConf.customPluginPath);
|
|
924
|
+
config.customPluginPaths = getPaths(newConf.customPluginPaths || newConf.customPluginsPath || newConf.customPluginPath, true);
|
|
921
925
|
config.addon = getPaths(newConf.addonsPath || newConf.addonPath || newConf.addon);
|
|
922
926
|
if (config.accountPluginsPath) {
|
|
923
927
|
config.customPluginPaths = config.accountPluginsPath.concat(config.customPluginPaths || []);
|
package/lib/https/index.js
CHANGED
|
@@ -848,6 +848,42 @@ function resolveWebsocket(socket, wss) {
|
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
850
|
|
|
851
|
+
function getTunnelData(socket, clientIp, clientPort, isHttpH2) {
|
|
852
|
+
var enable = socket.enable || '';
|
|
853
|
+
var disable = socket.disable || '';
|
|
854
|
+
var headers = socket.headers;
|
|
855
|
+
var tunnelData = headers[config.TUNNEL_DATA_HEADER];
|
|
856
|
+
var tdKey = config.tdKey;
|
|
857
|
+
if (tdKey && (!tunnelData || config.overTdKey)) {
|
|
858
|
+
tunnelData = headers[tdKey] || tunnelData;
|
|
859
|
+
}
|
|
860
|
+
var tunnelHeaders;
|
|
861
|
+
var tunnelKeys = pluginMgr.getTunnelKeys();
|
|
862
|
+
tunnelKeys.forEach(function (k) {
|
|
863
|
+
var val = headers[k];
|
|
864
|
+
if (val) {
|
|
865
|
+
tunnelHeaders = tunnelHeaders || {};
|
|
866
|
+
tunnelHeaders[k] = val;
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
return {
|
|
870
|
+
clientIp: clientIp,
|
|
871
|
+
clientPort: clientPort,
|
|
872
|
+
remoteAddr: socket._remoteAddr,
|
|
873
|
+
remotePort: socket._remotePort,
|
|
874
|
+
clientId: headers[config.CLIENT_ID_HEADER],
|
|
875
|
+
proxyAuth: disable.tunnelAuthHeader
|
|
876
|
+
? undefined
|
|
877
|
+
: headers['proxy-authorization'],
|
|
878
|
+
tunnelData: tunnelData,
|
|
879
|
+
headers: tunnelHeaders,
|
|
880
|
+
tunnelFirst:
|
|
881
|
+
enable.tunnelHeadersFirst && !disable.tunnelHeadersFirst,
|
|
882
|
+
isHttpH2: isHttpH2,
|
|
883
|
+
sniPlugin: socket.sniPlugin
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
|
|
851
887
|
function addReqInfo(req) {
|
|
852
888
|
var socket = req.socket;
|
|
853
889
|
var remoteData =
|
|
@@ -859,36 +895,10 @@ function addReqInfo(req) {
|
|
|
859
895
|
socket._remoteDataInfo = remoteData;
|
|
860
896
|
headers[config.CLIENT_INFO_HEAD] =
|
|
861
897
|
(remoteData.clientIp || LOCALHOST) +
|
|
862
|
-
',' +
|
|
863
|
-
remoteData.
|
|
864
|
-
',' +
|
|
865
|
-
|
|
866
|
-
',' +
|
|
867
|
-
remoteData.remotePort;
|
|
868
|
-
var tunnelFirst = remoteData.tunnelFirst;
|
|
869
|
-
if (remoteData.clientId) {
|
|
870
|
-
headers[config.CLIENT_ID_HEADER] = remoteData.clientId;
|
|
871
|
-
}
|
|
872
|
-
if (
|
|
873
|
-
remoteData.proxyAuth &&
|
|
874
|
-
(tunnelFirst || !headers['proxy-authorization'])
|
|
875
|
-
) {
|
|
876
|
-
headers['proxy-authorization'] = remoteData.proxyAuth;
|
|
877
|
-
}
|
|
878
|
-
if (remoteData.tunnelData) {
|
|
879
|
-
headers[config.TUNNEL_DATA_HEADER] = remoteData.tunnelData;
|
|
880
|
-
}
|
|
881
|
-
if (remoteData.sniPlugin) {
|
|
882
|
-
headers[config.SNI_PLUGIN_HEADER] = remoteData.sniPlugin;
|
|
883
|
-
}
|
|
884
|
-
var tunnelHeaders = remoteData.headers;
|
|
885
|
-
if (tunnelHeaders) {
|
|
886
|
-
Object.keys(tunnelHeaders).forEach(function (key) {
|
|
887
|
-
if (tunnelFirst || !headers[key]) {
|
|
888
|
-
headers[key] = tunnelHeaders[key];
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
|
-
}
|
|
898
|
+
',' + remoteData.clientPort +
|
|
899
|
+
',' + remoteData.remoteAddr +
|
|
900
|
+
',' + remoteData.remotePort;
|
|
901
|
+
util.setTunnelHeaders(headers, remoteData);
|
|
892
902
|
}
|
|
893
903
|
if (!req.isHttpH2) {
|
|
894
904
|
headers[config.HTTPS_FIELD] = 1;
|
|
@@ -1054,13 +1064,9 @@ function addClientInfo(socket, chunk, statusLine, clientIp, clientPort) {
|
|
|
1054
1064
|
socket._remoteAddr +
|
|
1055
1065
|
',' +
|
|
1056
1066
|
socket._remotePort;
|
|
1057
|
-
var
|
|
1058
|
-
if (clientId) {
|
|
1059
|
-
statusLine += '\r\n' + config.TEMP_CLIENT_ID_HEADER + ': ' + clientId;
|
|
1060
|
-
}
|
|
1061
|
-
var tunnelData = socket.headers[config.TUNNEL_DATA_HEADER];
|
|
1067
|
+
var tunnelData = getTunnelData(socket, clientIp, clientPort);
|
|
1062
1068
|
if (tunnelData) {
|
|
1063
|
-
statusLine += '\r\n' + config.TEMP_TUNNEL_DATA_HEADER + ': ' + tunnelData;
|
|
1069
|
+
statusLine += '\r\n' + config.TEMP_TUNNEL_DATA_HEADER + ': ' + encodeURIComponent(JSON.stringify(tunnelData));
|
|
1064
1070
|
}
|
|
1065
1071
|
return Buffer.concat([Buffer.from(statusLine), chunk]);
|
|
1066
1072
|
}
|
|
@@ -1170,39 +1176,9 @@ module.exports = function (socket, next, isWebPort) {
|
|
|
1170
1176
|
if (err || socket._hasError) {
|
|
1171
1177
|
return destroy(err);
|
|
1172
1178
|
}
|
|
1173
|
-
var headers = socket.headers;
|
|
1174
|
-
var tunnelData = headers[config.TUNNEL_DATA_HEADER];
|
|
1175
|
-
var tdKey = config.tdKey;
|
|
1176
|
-
if (tdKey && (!tunnelData || config.overTdKey)) {
|
|
1177
|
-
tunnelData = headers[tdKey] || tunnelData;
|
|
1178
|
-
}
|
|
1179
|
-
var tunnelHeaders;
|
|
1180
|
-
var tunnelKeys = pluginMgr.getTunnelKeys();
|
|
1181
|
-
tunnelKeys.forEach(function (k) {
|
|
1182
|
-
var val = headers[k];
|
|
1183
|
-
if (val) {
|
|
1184
|
-
tunnelHeaders = tunnelHeaders || {};
|
|
1185
|
-
tunnelHeaders[k] = val;
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
1179
|
tunnelTmplData.set(
|
|
1189
1180
|
reqSocket.localPort + ':' + reqSocket.remotePort,
|
|
1190
|
-
|
|
1191
|
-
clientIp: clientIp,
|
|
1192
|
-
clientPort: clientPort,
|
|
1193
|
-
remoteAddr: socket._remoteAddr,
|
|
1194
|
-
remotePort: socket._remotePort,
|
|
1195
|
-
clientId: headers[config.CLIENT_ID_HEADER],
|
|
1196
|
-
proxyAuth: disable.tunnelAuthHeader
|
|
1197
|
-
? undefined
|
|
1198
|
-
: headers['proxy-authorization'],
|
|
1199
|
-
tunnelData: tunnelData,
|
|
1200
|
-
headers: tunnelHeaders,
|
|
1201
|
-
tunnelFirst:
|
|
1202
|
-
enable.tunnelHeadersFirst && !disable.tunnelHeadersFirst,
|
|
1203
|
-
isHttpH2: isHttpH2,
|
|
1204
|
-
sniPlugin: socket.sniPlugin
|
|
1205
|
-
}
|
|
1181
|
+
getTunnelData(socket, clientIp, clientPort, isHttpH2)
|
|
1206
1182
|
);
|
|
1207
1183
|
receiveData = function (data) {
|
|
1208
1184
|
clearTimeout(authTimer);
|
package/lib/init.js
CHANGED
|
@@ -82,14 +82,6 @@ function addErrorEvents(req, res) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
function addTunnelData(socket, headers, key, tempKey) {
|
|
86
|
-
var value = socket[key] || headers[tempKey];
|
|
87
|
-
if (value) {
|
|
88
|
-
delete headers[tempKey];
|
|
89
|
-
socket[key] = headers[key] = value;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
85
|
function addTransforms(req, res) {
|
|
94
86
|
var reqIconvPipeStream, resIconvPipeStream, svrRes, initedResTransform;
|
|
95
87
|
|
|
@@ -211,18 +203,7 @@ module.exports = function (req, res, next) {
|
|
|
211
203
|
if (!req.isHttps && HTTPS_RE.test(req.url)) {
|
|
212
204
|
req.isHttps = true;
|
|
213
205
|
}
|
|
214
|
-
addTunnelData(
|
|
215
|
-
socket,
|
|
216
|
-
headers,
|
|
217
|
-
config.TEMP_CLIENT_ID_HEADER,
|
|
218
|
-
config.TEMP_CLIENT_ID_HEADER
|
|
219
|
-
);
|
|
220
|
-
addTunnelData(
|
|
221
|
-
socket,
|
|
222
|
-
headers,
|
|
223
|
-
config.TUNNEL_DATA_HEADER,
|
|
224
|
-
config.TEMP_TUNNEL_DATA_HEADER
|
|
225
|
-
);
|
|
206
|
+
util.addTunnelData(socket, headers);
|
|
226
207
|
var alpn = headers[config.ALPN_PROTOCOL_HEADER];
|
|
227
208
|
if (alpn) {
|
|
228
209
|
if (alpn === 'httpH2') {
|
|
@@ -6,9 +6,9 @@ var pluginUtil = require('./util');
|
|
|
6
6
|
var mp = require('./module-paths');
|
|
7
7
|
var config = require('../config');
|
|
8
8
|
|
|
9
|
-
var systemPluginPath = config.systemPluginPath;
|
|
10
9
|
var CUSTOM_PLUGIN_PATH = config.CUSTOM_PLUGIN_PATH;
|
|
11
10
|
var customPluginPaths = config.customPluginPaths || [];
|
|
11
|
+
var notUninstallPluginPaths = config.notUninstallPluginPaths || [];
|
|
12
12
|
var projectPluginPaths = config.projectPluginPaths || [];
|
|
13
13
|
var accountPluginsPath = config.accountPluginsPath || [];
|
|
14
14
|
var paths = mp.getPaths();
|
|
@@ -17,9 +17,9 @@ function readPluginModulesSync(dir, plugins) {
|
|
|
17
17
|
plugins = plugins || {};
|
|
18
18
|
var isAccount = accountPluginsPath.indexOf(dir) !== -1;
|
|
19
19
|
var account = isAccount ? config.account : undefined;
|
|
20
|
-
var
|
|
21
|
-
var isSys = isCustom || systemPluginPath === dir;
|
|
20
|
+
var isSys = isAccount || CUSTOM_PLUGIN_PATH === dir || customPluginPaths.indexOf(dir) !== -1;
|
|
22
21
|
var isProj = projectPluginPaths.indexOf(dir) !== -1;
|
|
22
|
+
var notUn = notUninstallPluginPaths.indexOf(dir) !== -1;
|
|
23
23
|
|
|
24
24
|
try {
|
|
25
25
|
var list = fs.readdirSync(dir).filter(function (name) {
|
|
@@ -33,7 +33,7 @@ function readPluginModulesSync(dir, plugins) {
|
|
|
33
33
|
var org = name;
|
|
34
34
|
fs.readdirSync(_dir).forEach(function (name) {
|
|
35
35
|
if (!plugins[name] && pluginUtil.isWhistleModule(name)) {
|
|
36
|
-
var root =
|
|
36
|
+
var root = isSys
|
|
37
37
|
? path.join(_dir, name, 'node_modules', org, name)
|
|
38
38
|
: path.join(_dir, name);
|
|
39
39
|
if (fs.existsSync(path.join(root, 'package.json'))) {
|
|
@@ -41,6 +41,7 @@ function readPluginModulesSync(dir, plugins) {
|
|
|
41
41
|
root: root,
|
|
42
42
|
account: account,
|
|
43
43
|
isSys: isSys,
|
|
44
|
+
notUn: notUn,
|
|
44
45
|
isProj: isProj
|
|
45
46
|
};
|
|
46
47
|
}
|
|
@@ -53,7 +54,7 @@ function readPluginModulesSync(dir, plugins) {
|
|
|
53
54
|
|
|
54
55
|
list.forEach(function (name) {
|
|
55
56
|
if (!plugins[name]) {
|
|
56
|
-
var root =
|
|
57
|
+
var root = isSys
|
|
57
58
|
? path.join(dir, name, 'node_modules', name)
|
|
58
59
|
: path.join(dir, name);
|
|
59
60
|
if (fs.existsSync(path.join(root, 'package.json'))) {
|
|
@@ -61,6 +62,7 @@ function readPluginModulesSync(dir, plugins) {
|
|
|
61
62
|
root: root,
|
|
62
63
|
account: account,
|
|
63
64
|
isSys: isSys,
|
|
65
|
+
notUn: notUn,
|
|
64
66
|
isProj: isProj
|
|
65
67
|
};
|
|
66
68
|
}
|
|
@@ -87,6 +89,7 @@ module.exports = function () {
|
|
|
87
89
|
var account = dir.account;
|
|
88
90
|
var isSys = dir.isSys;
|
|
89
91
|
var isProj = dir.isProj;
|
|
92
|
+
var notUn = dir.notUn;
|
|
90
93
|
dir = dir.root;
|
|
91
94
|
try {
|
|
92
95
|
var pkgPath = path.join(dir, 'package.json');
|
|
@@ -100,6 +103,7 @@ module.exports = function () {
|
|
|
100
103
|
account: account,
|
|
101
104
|
isSys: isSys,
|
|
102
105
|
isProj: isProj,
|
|
106
|
+
notUn: notUn,
|
|
103
107
|
moduleName: pkg.name,
|
|
104
108
|
enableAuthUI: !!conf.enableAuthUI,
|
|
105
109
|
inheritAuth: !!conf.inheritAuth,
|
|
@@ -4,9 +4,9 @@ var util = require('./util');
|
|
|
4
4
|
var mp = require('./module-paths');
|
|
5
5
|
var config = require('../config');
|
|
6
6
|
|
|
7
|
-
var systemPluginPath = config.systemPluginPath;
|
|
8
7
|
var CUSTOM_PLUGIN_PATH = config.CUSTOM_PLUGIN_PATH;
|
|
9
8
|
var customPluginPaths = config.customPluginPaths || [];
|
|
9
|
+
var notUninstallPluginPaths = config.notUninstallPluginPaths || [];
|
|
10
10
|
var projectPluginPaths = config.projectPluginPaths || [];
|
|
11
11
|
var accountPluginsPath = config.accountPluginsPath || [];
|
|
12
12
|
|
|
@@ -127,11 +127,9 @@ module.exports = function (callback) {
|
|
|
127
127
|
var loadPlugins = function (dir, cb) {
|
|
128
128
|
var isAccount = accountPluginsPath.indexOf(dir) !== -1;
|
|
129
129
|
var account = isAccount ? config.account : undefined;
|
|
130
|
-
var
|
|
131
|
-
var isSys =
|
|
132
|
-
isCustom ||
|
|
133
|
-
systemPluginPath === dir;
|
|
130
|
+
var isSys = isAccount || CUSTOM_PLUGIN_PATH === dir || customPluginPaths.indexOf(dir) !== -1;
|
|
134
131
|
var isProj = projectPluginPaths.indexOf(dir) !== -1;
|
|
132
|
+
var notUn = notUninstallPluginPaths.indexOf(dir) !== -1;
|
|
135
133
|
readPluginModules(
|
|
136
134
|
dir,
|
|
137
135
|
function () {
|
|
@@ -144,6 +142,7 @@ module.exports = function (callback) {
|
|
|
144
142
|
account: account,
|
|
145
143
|
isSys: isSys,
|
|
146
144
|
isProj: isProj,
|
|
145
|
+
notUn: notUn,
|
|
147
146
|
path: obj.root,
|
|
148
147
|
mtime: obj.mtime
|
|
149
148
|
};
|
|
@@ -151,7 +150,7 @@ module.exports = function (callback) {
|
|
|
151
150
|
cb();
|
|
152
151
|
},
|
|
153
152
|
plugins,
|
|
154
|
-
|
|
153
|
+
isSys
|
|
155
154
|
);
|
|
156
155
|
};
|
|
157
156
|
var index = 0;
|
package/lib/plugins/index.js
CHANGED
|
@@ -17,8 +17,6 @@ var prePlugins = (config.prePluginsPath || []).map(resolvePath);
|
|
|
17
17
|
var addon = (config.addon || []).map(resolvePath);
|
|
18
18
|
addon = addon.concat(addon.map(formatPath));
|
|
19
19
|
|
|
20
|
-
config.systemPluginPath = formatPath(config.SYSTEM_PLUGIN_PATH);
|
|
21
|
-
|
|
22
20
|
function addDebugPaths(plugins) {
|
|
23
21
|
if (config.debugMode) {
|
|
24
22
|
var cwd = process.cwd();
|
|
@@ -79,8 +77,9 @@ pluginsPath = formatPath(env.WHISTLE_PLUGINS_PATH);
|
|
|
79
77
|
if (pluginsPath && paths.indexOf(pluginsPath) == -1) {
|
|
80
78
|
paths.unshift(pluginsPath);
|
|
81
79
|
}
|
|
82
|
-
|
|
83
|
-
paths.unshift(config.CUSTOM_PLUGIN_PATH
|
|
80
|
+
if (!config.customPluginPaths || !config.customPluginPaths.length) {
|
|
81
|
+
paths.unshift(config.CUSTOM_PLUGIN_PATH);
|
|
82
|
+
}
|
|
84
83
|
paths = addon.concat(paths);
|
|
85
84
|
addDebugPaths(paths);
|
|
86
85
|
|
package/lib/upgrade.js
CHANGED
|
@@ -98,9 +98,9 @@ function upgradeHandler(req, socket) {
|
|
|
98
98
|
--util.proc.allWsRequests;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
util.onSocketEnd(socket, destroy);
|
|
102
|
-
|
|
103
101
|
var headers = req.headers;
|
|
102
|
+
util.onSocketEnd(socket, destroy);
|
|
103
|
+
util.addTunnelData(socket, headers);
|
|
104
104
|
socket._clientId = util.getComposerClientId(headers);
|
|
105
105
|
var getBuffer = function (method, newHeaders, path) {
|
|
106
106
|
var rawData = [
|
package/lib/util/index.js
CHANGED
|
@@ -3505,3 +3505,54 @@ exports.filterWeakRule = function (req) {
|
|
|
3505
3505
|
exports.setPluginMgr = function(p) {
|
|
3506
3506
|
pluginMgr = p;
|
|
3507
3507
|
};
|
|
3508
|
+
|
|
3509
|
+
|
|
3510
|
+
function setTunnelHeaders(headers, remoteData) {
|
|
3511
|
+
var tunnelFirst = remoteData.tunnelFirst;
|
|
3512
|
+
if (remoteData.clientId) {
|
|
3513
|
+
headers[config.CLIENT_ID_HEADER] = remoteData.clientId;
|
|
3514
|
+
}
|
|
3515
|
+
if (
|
|
3516
|
+
remoteData.proxyAuth &&
|
|
3517
|
+
(tunnelFirst || !headers['proxy-authorization'])
|
|
3518
|
+
) {
|
|
3519
|
+
headers['proxy-authorization'] = remoteData.proxyAuth;
|
|
3520
|
+
}
|
|
3521
|
+
if (remoteData.tunnelData) {
|
|
3522
|
+
headers[config.TUNNEL_DATA_HEADER] = remoteData.tunnelData;
|
|
3523
|
+
}
|
|
3524
|
+
if (remoteData.sniPlugin) {
|
|
3525
|
+
headers[config.SNI_PLUGIN_HEADER] = remoteData.sniPlugin;
|
|
3526
|
+
}
|
|
3527
|
+
var tunnelHeaders = remoteData.headers;
|
|
3528
|
+
if (tunnelHeaders) {
|
|
3529
|
+
Object.keys(tunnelHeaders).forEach(function (key) {
|
|
3530
|
+
if (tunnelFirst || !headers[key]) {
|
|
3531
|
+
headers[key] = tunnelHeaders[key];
|
|
3532
|
+
}
|
|
3533
|
+
});
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3536
|
+
|
|
3537
|
+
exports.setTunnelHeaders = setTunnelHeaders;
|
|
3538
|
+
|
|
3539
|
+
var tunnelDataKey = config.TUNNEL_DATA_HEADER;
|
|
3540
|
+
var tmplDataKey = config.TEMP_TUNNEL_DATA_HEADER;
|
|
3541
|
+
|
|
3542
|
+
exports.addTunnelData = function(socket, headers) {
|
|
3543
|
+
var data = socket[tunnelDataKey];
|
|
3544
|
+
if (!data) {
|
|
3545
|
+
data = headers[tmplDataKey];
|
|
3546
|
+
if (data) {
|
|
3547
|
+
delete headers[tmplDataKey];
|
|
3548
|
+
try {
|
|
3549
|
+
data = decodeURIComponent(data);
|
|
3550
|
+
data = JSON.parse(data);
|
|
3551
|
+
socket[tunnelDataKey] = data;
|
|
3552
|
+
} catch(e) {
|
|
3553
|
+
return;
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
data && setTunnelHeaders(headers, data);
|
|
3558
|
+
};
|