Skip to content
Browse files

Merge branch 'master' of github.com:yfann/ImgCollector

Conflicts:
	contentscript.js
  • Loading branch information...
2 parents ddc895c + f819cc5 commit 7f8d6f59fd4eb2b96e6a49460c4ed6ec02873068 Fan Yu committed
Showing with 30 additions and 8 deletions.
  1. +30 −8 contentscript.js
View
38 contentscript.js
@@ -1,9 +1,31 @@
console.log("content script loaded");
-//$("img").css("border", "5px solid orange");
-function addborder(event) {
- $(this).css("border", "5px solid orange");
-}
-function removeborder(event) {
- $(this).css("border", "");
-}
-$("img").hover(addborder, removeborder);
+ var imges = [];
+ imges.contains = function (arr) {
+ for (var i = 0; i < this.length; i++) {
+ if (this[i] == arr)
+ return true;
+ }
+ return false;
+ }
+
+ function addborder(event) {
+ $(this).css("border", "5px solid orange");
+ }
+ function removeborder(event) {
+ if (!imges.contains(this)) {
+ $(this).css("border", "");
+ }
+ }
+ $("img").hover(addborder, removeborder);
+
+ $("img").bind("click", function (event) {
+ if (!imges.contains(this)) {
+ imges.push(this);
+ $(this).css("border", "5px solid orange");
+ }
+ else {
+ imges.splice($.inArray(this, imges), 1);
+ $(this).css("border", "");
+ }
+ });
+

0 comments on commit 7f8d6f5

Please sign in to comment.
Something went wrong with that request. Please try again.