diff --git a/package.json b/package.json index 5b62aa2..f6b450d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "2.4.6", + "version": "2.4.7", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": { diff --git a/web/css/page.css b/web/css/page.css index e98eadf..cb03805 100644 --- a/web/css/page.css +++ b/web/css/page.css @@ -77,7 +77,7 @@ } .mainTableWrapper .col_time{ - width: 160px; + width: 140px; } .mainTableWrapper tr.row_odd{ @@ -93,13 +93,11 @@ background: #CCC; } -.resHeader{ - width: 400px; -} - -.resBody textarea{ - width: 400px; - height: 280px; +.resBody .resBodyContent{ + min-width: 200px; + padding: 10px; + border: 1px solid #99baca; + background: #f5fbfe; } .subTitle{ diff --git a/web/detail.html b/web/detail.html new file mode 100644 index 0000000..952e93c --- /dev/null +++ b/web/detail.html @@ -0,0 +1,62 @@ + + + + Anyproxy + + + + + + + +
+ + + + + + diff --git a/web/detail.js b/web/detail.js new file mode 100644 index 0000000..0dc5c7a --- /dev/null +++ b/web/detail.js @@ -0,0 +1,67 @@ +define("./detail",['$', 'gallery/underscore/1.6.0/underscore.js'],function(require,exports,module){ + var _ = require("gallery/underscore/1.6.0/underscore.js"), + $ = require("$"); + + var tpl = ""+ + '
'+ + '

request

'+ + '
'+ + ' '+ + '
'+ + '
'+ + ''+ + '
'+ + '

request body

'+ + '
'+ + '

<%= reqBody %>

'+ + '
'+ + '
'+ + ''+ + ' <% if(statusCode) { %>'+ + '
'+ + '

response header

'+ + '
'+ + ' '+ + '
'+ + '
'+ + ''+ + '
'+ + '

response body

'+ + '
'+ + '
'+ + // '
'+ + // ' '+ + // '
'+ + '
'+ + '
'+ + ' <% } %>'; + + function render(data,cb){ + var $baseTpl = $(_.template(tpl, data)); + + if(data.statusCode){ //if finished + $.ajax({ + url : "/body?id=" + data._id, + headers : { + anyproxy_web_req : true + }, + type : "GET", + success : function(data){ + $(".J_responseBody", $baseTpl).html(data); + cb($baseTpl); + } + }); + }else{ + cb($baseTpl); + } + } + + exports.render = render; +}); \ No newline at end of file diff --git a/web/index.html b/web/index.html index e6914f1..1cd6792 100644 --- a/web/index.html +++ b/web/index.html @@ -9,6 +9,7 @@ +

Anyproxy

Clear Logs(Ctrl+X) @@ -36,6 +37,7 @@
+ + + - - - + diff --git a/web/page.js b/web/list.js similarity index 78% rename from web/page.js rename to web/list.js index 42a7ebb..77be929 100644 --- a/web/page.js +++ b/web/list.js @@ -7,9 +7,11 @@ seajs.config({ } }); -seajs.use(['$','Underscore' ,'Backbone'], function($, _, Backbone) { +seajs.use(['$', 'Underscore', 'Backbone',"./detail"], function($, _, Backbone,Detail) { Backbone.$ = $; + var isInApp = window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.list; + $(function(){ //record detail @@ -37,30 +39,12 @@ seajs.use(['$','Underscore' ,'Backbone'], function($, _, Backbone) { self.hideDetail(); }); - self.addMask = function(){ - - } - self.showDetail = function(data){ - var tpl = _.template($("#detail_tpl").html() , data); - - $(".J_recordDetailOverlayContent",$detailEl).html(tpl); - $detailEl.show(); - $mask.show(); - - if(data.statusCode){ //if finished - $.ajax({ - url:"/body?id=" + data._id, - headers:{ - anyproxy_web_req : true - }, - type : "GET", - success:function(data){ - $(".J_responseBody", $detailEl).html(data); - } - }); - - } + Detail.render(data,function(tpl){ + $(".J_recordDetailOverlayContent",$detailEl).html(tpl); + $detailEl.show(); + $mask.show(); + }); }; self.hideDetail = function(){ @@ -106,7 +90,11 @@ seajs.use(['$','Underscore' ,'Backbone'], function($, _, Backbone) { e.stopPropagation(); var self = this; var detailData = self.model.toJSON(); - self.detailPanel.showDetail(detailData); + if(!isInApp){ + self.detailPanel.showDetail(detailData); + }else{ + window.webkit.messageHandlers.list.postMessage(JSON.stringify(detailData)) + } } }, render: function(){ @@ -186,7 +174,7 @@ seajs.use(['$','Underscore' ,'Backbone'], function($, _, Backbone) { var data = JSON.parse(event.data); var reqDate = new Date(data.startTime); - data.startTimeStr = reqDate.toLocaleDateString()+ " " + reqDate.toLocaleTimeString(); + data.startTimeStr = reqDate.toLocaleTimeString() + ""; var previous; if(previous = recList.get(data.id)){ @@ -250,4 +238,19 @@ seajs.use(['$','Underscore' ,'Backbone'], function($, _, Backbone) { })(); + // Date.prototype.Format = function (fmt) { + // var o = { + // "M+": this.getMonth() + 1, //月份 + // "d+": this.getDate(), //日 + // "h+": this.getHours(), //小时 + // "m+": this.getMinutes(), //分 + // "s+": this.getSeconds(), //秒 + // "q+": Math.floor((this.getMonth() + 3) / 3), //季度 + // "S": this.getMilliseconds() //毫秒 + // }; + // if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); + // for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + // return fmt; + // } + }); \ No newline at end of file