Skip to content

Commit

Permalink
support responsive layout
Browse files Browse the repository at this point in the history
  • Loading branch information
haoel committed Jul 9, 2018
1 parent 29fede5 commit 6e2eadb
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
51 changes: 50 additions & 1 deletion js/anti-baidu-latest.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,55 @@
.done(function () {
(function ($) {
$(document).ready(function () {
var antiDiv = '<div id="nobaidu_dlg" style="background-color:#fff; border-radius:15px;color:#000;display:none;padding:20px;min-width:450px;min-height:180px;"><img src="https://cdn.jsdelivr.net/gh/haoel/anti-baidu/images/nobaidu.jpg" align="left"><p style="margin-left:200px;margin-top: 20px; line-height: 30px;">检测到你还在使用百度这个搜索引擎,<br>作为一个程序员,这是一种自暴自弃!<br><br></p><p align="center" style="margin-top:20px;"><b><a href="http://coolshell.cn/articles/9308.html">做环保的程序员,从不用百度开始!</a></b></p></div>';
var css='<style type="text/css">'+
' * {'+
' box-sizing: border-box;'+
' }'+
' .anti-baidu-row::after {'+
' content: "";'+
' clear: both;'+
' display: table;'+
' }'+
' [class*="anti-baidu-col-"] {'+
' float: left;'+
' padding: 15px;'+
' }'+
' .anti-baidu-col-1 {width: 8.33%;}'+
' .anti-baidu-col-2 {width: 16.66%;}'+
' .anti-baidu-col-3 {width: 25%;}'+
' .anti-baidu-col-4 {width: 33.33%;}'+
' .anti-baidu-col-5 {width: 41.66%;}'+
' .anti-baidu-col-6 {width: 50%;}'+
' .anti-baidu-col-7 {width: 58.33%;}'+
' .anti-baidu-col-8 {width: 66.66%;}'+
' .anti-baidu-col-9 {width: 75%;}'+
' .anti-baidu-col-10 {width: 83.33%;}'+
' .anti-baidu-col-11 {width: 91.66%;}'+
' .anti-baidu-col-12 {width: 100%;}'+
' @media only screen and (max-width: 768px) {'+
' /* For mobile phones: */'+
' [class*="anti-baidu-col-"] {'+
' width: 100%;'+
' }'+
' }'+
'</style>';

var antiDiv = '<div id="nobaidu_dlg" class="anti-baidu-col-4" style="background-color:#fff; border-radius:15px;color:#000;display:none;padding:20px;min-height:180px;">'+
' <div class="anti-baidu-row">' +
' <div class="anti-baidu-col-5" style="text-align:center;">' +
' <img src="https://cdn.jsdelivr.net/gh/haoel/anti-baidu/images/nobaidu.jpg">'+
' </div>' +
' <div class="anti-baidu-col-7" style="text-align:center;line-height: 30px;padding-top: 35px;">'+
' 检测到你还在使用百度这个搜索引擎<br>作为一个程序员,这是一种自暴自弃'+
' </div>'+
' </div>' +
' <div class="anti-baidu-row">' +
' <div class=anti-baidu-col-12>'+
' <p align="center"><b><a href="http://coolshell.cn/articles/9308.html">做环保的程序员,从不用百度开始!</a></b></p>'+
' </div>'+
' </div>'+
'</div>';
$("head").append(css);
$("body").append(antiDiv);
if (isBaiduReferrer) {
$('#nobaidu_dlg').bPopup();
Expand Down Expand Up @@ -72,3 +120,4 @@
loader();
}
})();

20 changes: 16 additions & 4 deletions test-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,27 @@
<html>
<head>
<title>anti-baidu-test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">


<script type="text/javascript">
var isTest = true;
var TestURL = "http://www.baidu.com/";
</script>
<script type="text/javascript" src="./js/anti-baidu-latest.js" charset="UTF-8"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/haoel/anti-baidu/js/anti-baidu-latest.js" charset="UTF-8"></script>


<script type="text/javascript" src="./js/anti-baidu-latest.js" charset="UTF-8"></script>
</head>
<body>
If you can see the Anti-Baidu popup, it means everything works...
<div class="anti-baidu-row">
<div class="anti-baidu-col-12">
<h2>If you can see the Anti-Baidu popup, it means everything works...</h2>
</div>
</div>
<div class="row">
<div class="anti-baidu-col-4" style="background-color:#c00; ">.anti-baidu-col-4</div>
<div class="anti-baidu-col-4" style="background-color:#0c0; ">.anti-baidu-col-4</div>
<div class="anti-baidu-col-4" style="background-color:#00c; ">.anti-baidu-col-4</div>
</div>

</body>
</html>

0 comments on commit 6e2eadb

Please sign in to comment.