Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
annnhan committed Jan 1, 2014
1 parent 49083ab commit 6cf3bb7
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 89 deletions.
76 changes: 74 additions & 2 deletions ReResSetting.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,84 @@
[
{
"req":"^https?:\\/\\/.*test\.com",
"req":"^https?:\\/\\/.*test.com",
"res":"http://qunar.com",
"type":"dir",
"checked":false
},
{
"req":".*hanan\.com",
"req":".*hanan.com",
"res":"http://cssha.com",
"type":"file",
"checked":true
},
{
"req":"^https?:\\/\\/.*test.com",
"res":"http://qunar.com",
"type":"dir",
"checked":false
},
{
"req":".*hanan.com",
"res":"http://cssha.com",
"type":"file",
"checked":true
},
{
"req":"^https?:\\/\\/.*test.com",
"res":"http://qunar.com",
"type":"dir",
"checked":false
},
{
"req":".*hanan.com",
"res":"http://cssha.com",
"type":"file",
"checked":true
},
{
"req":"^https?:\\/\\/.*test.com",
"res":"http://qunar.com",
"type":"dir",
"checked":false
},
{
"req":".*hanan.com",
"res":"http://cssha.com",
"type":"file",
"checked":true
},
{
"req":"^https?:\\/\\/.*test.com",
"res":"http://qunar.com",
"type":"dir",
"checked":false
},
{
"req":".*hanan.com",
"res":"http://cssha.com",
"type":"file",
"checked":true
},
{
"req":"^https?:\\/\\/.*test.com",
"res":"http://qunar.com",
"type":"dir",
"checked":false
},
{
"req":".*hanan.com",
"res":"http://cssha.com",
"type":"file",
"checked":true
},
{
"req":"^https?:\\/\\/.*test.com",
"res":"http://qunar.com",
"type":"dir",
"checked":false
},
{
"req":".*hanan.com",
"res":"http://cssha.com",
"type":"file",
"checked":true
Expand Down
24 changes: 16 additions & 8 deletions css/options.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
body {
min-width: 100%;
padding-top: 10px;
overflow: hidden;
text-overflow: ellipsis;
}
.top {
position: static!important;
padding-top: 8px;
margin-bottom: 0px!important;
color: #999999;
}
.fr {
float: right;
margin-right: 10px;
}
.table {
margin-top: 10px;
}
.table thead {
font-weight: bold;
}
.btnBox {
position: relative;
}
.btnBox .file {
position: absolute;
width: 54px;
height: 34px;
top: 0px;
left: 0px;
opacity: 0;
overflow: hidden;
position: relative;
}
.btnBox .file input {
position: absolute;
width: 54px;
width: 67px;
height: 994px;
bottom: 0px;
right: 0px;
opacity: 0;
cursor: pointer;
}
tr {
Expand Down
25 changes: 17 additions & 8 deletions css/options.less
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
@mainWith: 100%;
body {
min-width: @mainWith;
padding-top: 10px;
overflow: hidden;
text-overflow: ellipsis;
}
.top {
position: static!important;
padding-top: 8px;
margin-bottom: 0px!important;
color: #999999;
}
.fr {
float: right;
margin-right: 10px;
}
.table {
thead {
font-weight: bold;
}
margin-top: 10px;
}
.btnBox {

position: relative;
.file{
position: absolute;
width: 54px;
height: 34px;
top: 0px;
left: 0px;
opacity: 0;
overflow: hidden;
position: relative;
input {
position: absolute;
width: 54px;
width: 67px;
height: 994px;
bottom: 0px;
right: 0px;
opacity: 0;
cursor: pointer;
}
}
Expand Down
25 changes: 8 additions & 17 deletions css/popup.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
body {
max-width: 300px;
padding-top: 10px;
padding-top: 15px;
overflow: hidden;
text-overflow: ellipsis;
}
Expand All @@ -9,26 +9,17 @@ body {
max-width: 270px;
margin-top: 10px;
overflow: hidden;
margin-bottom: 10px!important;
}
.container {
padding-right: 10px!important;
padding-left: 10px!important;
}
.btnBox {
position: relative;
}
.btnBox .file {
position: absolute;
width: 54px;
height: 34px;
top: 0px;
left: 0px;
opacity: 0;
overflow: hidden;
}
.btnBox .file input {
position: absolute;
width: 54px;
height: 994px;
bottom: 0px;
right: 0px;
cursor: pointer;
.btnBox .btn {
margin: 0 3px;
}
td {
overflow: hidden;
Expand Down
25 changes: 8 additions & 17 deletions css/popup.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@mainWith: 300px;
body {
max-width: @mainWith;
padding-top: 10px;
padding-top: 15px;
overflow: hidden;
text-overflow: ellipsis;
}
Expand All @@ -10,25 +10,16 @@ body {
max-width: @mainWith - 30px;
margin-top: 10px;
overflow: hidden;
margin-bottom: 10px!important;
}
.container {
padding-right: 10px!important;
padding-left: 10px!important;
}
.btnBox {
position: relative;
.file{
position: absolute;
width: 54px;
height: 34px;
top: 0px;
left: 0px;
opacity: 0;
overflow: hidden;
input {
position: absolute;
width: 54px;
height: 994px;
bottom: 0px;
right: 0px;
cursor: pointer;
}
.btn {
margin: 0 3px;
}
}
td {
Expand Down
24 changes: 14 additions & 10 deletions js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ reres.controller('mapListCtrl', function($scope) {

//当前编辑的规则
$scope.curRule = {
req: '^https?:\\/\\/.*',
res: 'http://',
req: '.*reqtest\\.com',
res: 'http://restest\\.com',
type: 'file',
checked: true
}
Expand Down Expand Up @@ -53,8 +53,8 @@ reres.controller('mapListCtrl', function($scope) {
$scope.addRule = function () {
if ($scope.editDisplay === 'none') {
$scope.curRule = {
req: '^https?:\\/\\/.*',
res: 'http://',
req: '.*reqtest\\.com',
res: 'http://restest\\.com',
type: 'file',
checked: true
};
Expand Down Expand Up @@ -128,13 +128,17 @@ reres.controller('mapListCtrl', function($scope) {
var reader = new FileReader();
reader.readAsText(resultFile);
reader.onload = function (e) {
var data = JSON.parse(this.result);
$scope.maps.length = 0;
for (var i = 0, len = data.length; i < len; i++) {
$scope.maps.push(data[i]);
try {
var data = JSON.parse(this.result);
$scope.maps.length = 0;
for (var i = 0, len = data.length; i < len; i++) {
$scope.maps.push(data[i]);
}
saveData();
location.reload();
} catch (e) {
alert("导入失败,请检查文件格式是否正确");
}
saveData();
location.reload();
};
}
}
Expand Down
24 changes: 12 additions & 12 deletions js/popup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
var reres = angular.module('reres', []);

reres.controller('mapListCtrl', function($scope) {
reres.controller('mapListCtrl', function ($scope) {
var bg = chrome.extension.getBackgroundPage();

//保存规则数据到localStorage
Expand All @@ -11,8 +11,8 @@ reres.controller('mapListCtrl', function($scope) {

//当前编辑的规则
$scope.curRule = {
req: '^https?:\\/\\/.*',
res: 'http://',
req: '.*reqtest\\.com',
res: 'http://restest\\.com',
type: 'file',
checked: true
}
Expand All @@ -22,8 +22,8 @@ reres.controller('mapListCtrl', function($scope) {
//编辑框显示状态
$scope.editDisplay = 'none';

//添加按钮显示状态
$scope.addBtnDisplay = 'block';
//按钮框显示状态
// $scope.btnDisplay = 'block';

//编辑框保存按钮文本
$scope.editType = '添加';
Expand All @@ -34,13 +34,13 @@ reres.controller('mapListCtrl', function($scope) {
//隐藏编辑框
$scope.hideEditBox = function () {
$scope.editDisplay = 'none';
$scope.addBtnDisplay = 'block';
// $scope.btnDisplay = 'block';
}

//显示编辑框
$scope.showEditBox = function () {
$scope.editDisplay = 'block';
$scope.addBtnDisplay = 'none';
// $scope.btnDisplay = 'none';
}

//验证输入合法性
Expand All @@ -51,7 +51,7 @@ reres.controller('mapListCtrl', function($scope) {
}
try {
new RegExp($scope.curRule.req)
} catch (e){
} catch (e) {
$scope.inputError = 'req正则格式错误';
return false;
}
Expand All @@ -62,8 +62,8 @@ reres.controller('mapListCtrl', function($scope) {
// 点击添加按钮
$scope.addRule = function () {
$scope.curRule = {
req: '^https?:\\/\\/.*',
res: 'http://',
req: '.*reqtest\\.com',
res: 'http://restest\\.com',
type: 'file',
checked: true
};
Expand All @@ -80,7 +80,7 @@ reres.controller('mapListCtrl', function($scope) {

//编辑后保存
$scope.saveRule = function () {
if ( $scope.virify() ) {
if ($scope.virify()) {
if ($scope.editType === '添加') {
$scope.maps.push($scope.curRule);
} else {
Expand All @@ -93,7 +93,7 @@ reres.controller('mapListCtrl', function($scope) {

//删除规则
$scope.removeUrl = function (rule) {
for (var i = 0, len = $scope.maps.length; i< len; i++) {
for (var i = 0, len = $scope.maps.length; i < len; i++) {
if ($scope.maps[i] === rule) {
$scope.maps.splice(i, 1);
}
Expand Down
Loading

0 comments on commit 6cf3bb7

Please sign in to comment.