Difference between revisions of "Template:NEU China B"

Line 1: Line 1:
 
<html>
 
<html>
<script>
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
$(document).ready(function () {
 
 
$("#HQ_page").attr('id', '');
 
 
 
//highlight current page on the menu
 
highlight_current_page_menu();
 
 
//accessing submenus
 
$(".menu_item").click(function () {
 
$(".submenu_control_icon", this).toggleClass("open");
 
$(this).next(".submenu").fadeToggle(400);
 
});
 
 
//mobile menu access
 
$(".igem_2018_team_mobile_bar").click(function () {
 
$(this).next().toggleClass("displaying_menu");
 
});
 
 
});
 
 
 
function highlight_current_page_menu() {
 
 
var page_url = "https://2018.igem.org/";
 
page_url = page_url + wgPageName;
 
$("a[href$='" + page_url + "']").children().addClass("current_page");
 
 
//if the page is in a submenu, open the submenu and make the appropiate changes
 
if ($(".current_page").hasClass("submenu_item")) {
 
 
$(".current_page").parent().parent().fadeToggle(400);
 
$(".current_page").parent().parent().prev().addClass("current_page");
 
$(".menu_item.current_page > .submenu_control_icon").toggleClass("open");
 
 
}
 
}
 
 
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
</script>
 
  
  
Line 686: Line 642:
 
</div>
 
</div>
 
<div class="container" style="margin-top: 20px">
 
<div class="container" style="margin-top: 20px">
 +
 +
<canvas id="base_page" width="800" height="400" style="">
 +
您的浏览器不支持 HTML5 canvas 标签。
 +
</canvas>
 +
<script>
 +
var width = 800;
 +
var height = 400;
 +
 +
var c = document.getElementById("base_page");
 +
 +
$("#base_page").attr("width", c.parentElement.clientWidth);
 +
 +
var ctx = c.getContext("2d");
 +
that = ctx;
 +
var i = 0;
 +
var pi = Math.PI;
 +
var basex = c.width / 2;
 +
var basey = c.height / 2;
 +
width = c.width;
 +
height = c.height;
 +
var imgx;
 +
var imgy;
 +
 +
var w1 = "https://static.igem.org/mediawiki/2018/a/a8/T--NEU_China_B--w1.png";
 +
var w2 = "https://static.igem.org/mediawiki/2018/f/f9/T--NEU_China_B--w2.png";
 +
var w3 = "https://static.igem.org/mediawiki/2018/2/27/T--NEU_China_B--w3.png";
 +
var w4 = "https://static.igem.org/mediawiki/2018/9/96/T--NEU_China_B--w4.png";
 +
var w5 = "https://static.igem.org/mediawiki/2018/7/7a/T--NEU_China_B--w5.png";
 +
var w6 = "https://static.igem.org/mediawiki/2018/6/66/T--NEU_China_B--w6.png";
 +
 +
var img1 = new Image();
 +
var img2 = new Image();
 +
var img3 = new Image();
 +
var img4 = new Image();
 +
var img5 = new Image();
 +
var img6 = new Image();
 +
img1.src = w1;
 +
var during = 40;
 +
var t1 = 0;
 +
var base_t1 = 0;
 +
var t2 = 0;
 +
var base_t2 = base_t1 + during;
 +
var t3 = 0;
 +
var base_t3 = base_t2 + during;
 +
var t4 = 0;
 +
var base_t4 = base_t3 + during;
 +
var t5 = 0;
 +
var base_t5 = base_t4 + during;
 +
var t6 = 0;
 +
var base_t6 = base_t5 + during;
 +
 +
var x_e = 300;
 +
var y_e = 150;
 +
 +
var tipsWarpper = {};
 +
 +
 +
function redraw() {
 +
ctx.clearRect(0, 0, width, height);
 +
 +
var i = 0;
 +
ctx.beginPath();
 +
var x = x_e * Math.cos(0 * 180 * 2) + basex;
 +
var y = y_e * Math.sin(0 * 180 * 4) + basey;
 +
ctx.moveTo(x, y);
 +
for (i = 0; i < 0.05; i += 0.00001) {
 +
var x = x_e * Math.cos(i * 180 * 2) + basex;
 +
var y = y_e * Math.sin(i * 180 * 4) + basey;
 +
ctx.lineTo(x, y);
 +
}
 +
ctx.strokeStyle = '#FAF0E6';
 +
ctx.lineWidth = 3;
 +
ctx.stroke();
 +
ctx.closePath();
 +
 +
}
 +
 +
function draw(x, y, r) {
 +
ctx.beginPath();
 +
ctx.arc(x, y, r, 0, Math.PI * 2, true);
 +
ctx.fillStyle = "red";
 +
ctx.fill();
 +
ctx.closePath();
 +
}
 +
function drawTips(x, y, w, h, msg) {
 +
// ctx.beginPath();
 +
// ctx.rect(x, y, w, h);
 +
// ctx.fillStyle = 'white';
 +
// ctx.fill();
 +
// ctx.closePath();
 +
ctx.beginPath();
 +
ctx.font = 'italic 40pt Calibri';
 +
ctx.fillStyle = 'yellow';
 +
ctx.fillText(msg, x, y);
 +
ctx.fill();
 +
ctx.closePath();
 +
}
 +
 +
function drawImg(imgWarpper, x, y) {
 +
var img = imgWarpper.img;
 +
var drawWidth = img.width / 4;
 +
var drawHeight = img.height / 4;
 +
var imx = x - drawWidth / 2;
 +
var imy = y - drawHeight / 2
 +
imgWarpper.x = imx;
 +
imgWarpper.y = imy;
 +
ctx.drawImage(img, imx, imy, drawWidth, drawHeight);
 +
}
 +
 +
var imgWarpper1 = {};
 +
var imgWarpper2 = {};
 +
var imgWarpper3 = {};
 +
var imgWarpper4 = {};
 +
var imgWarpper5 = {};
 +
var imgWarpper6 = {};
 +
 +
imgWarpper1.img = img1;
 +
imgWarpper2.img = img2;
 +
imgWarpper3.img = img3;
 +
imgWarpper4.img = img4;
 +
imgWarpper5.img = img5;
 +
imgWarpper6.img = img6;
 +
 +
img1.onload = function () {
 +
img2.src = w2;
 +
img2.onload = function () {
 +
img3.src = w3;
 +
img3.onload = function () {
 +
img4.src = w4;
 +
img4.onload = function () {
 +
img5.src = w5;
 +
img5.onload = function () {
 +
console.log("finish");
 +
img6.src = w6;
 +
img6.onload = function () {
 +
var timer = setInterval(function () {
 +
redraw();
 +
i += 0.00001;
 +
 +
t1 = i + base_t1;
 +
t2 = i + base_t2;
 +
t3 = i + base_t3;
 +
t4 = i + base_t4;
 +
t5 = i + base_t5;
 +
t6 = i + base_t6;
 +
 +
var img1_x = x_e * Math.cos(t1 * 180 * 2) + basex;
 +
var img1_y = y_e * Math.sin(t1 * 180 * 4) + basey;
 +
 +
drawImg(imgWarpper1, img1_x, img1_y);
 +
 +
var img2_x = x_e * Math.cos(t2 * 180 * 2) + basex;
 +
var img2_y = y_e * Math.sin(t2 * 180 * 4) + basey;
 +
imgWarpper2.x = img2_x;
 +
imgWarpper2.y = img2_y;
 +
// imgWarpper2.w = i
 +
drawImg(imgWarpper2, img2_x, img2_y);
 +
 +
 +
var img3_x = x_e * Math.cos(t3 * 180 * 2) + basex;
 +
var img3_y = y_e * Math.sin(t3 * 180 * 4) + basey;
 +
drawImg(imgWarpper3, img3_x, img3_y);
 +
 +
var img4_x = x_e * Math.cos(t4 * 180 * 2) + basex;
 +
var img4_y = y_e * Math.sin(t4 * 180 * 4) + basey;
 +
drawImg(imgWarpper4, img4_x, img4_y);
 +
 +
 +
var img5_x = x_e * Math.cos(t5 * 180 * 2) + basex;
 +
var img5_y = y_e * Math.sin(t5 * 180 * 4) + basey;
 +
drawImg(imgWarpper5, img5_x, img5_y);
 +
 +
 +
var img6_x = x_e * Math.cos(t6 * 180 * 2) + basex;
 +
var img6_y = y_e * Math.sin(t6 * 180 * 4) + basey;
 +
drawImg(imgWarpper6, img6_x, img6_y);
 +
console.log(tipsWarpper.valid)
 +
if (tipsWarpper.valid == true)
 +
drawTips(tipsWarpper.x, tipsWarpper.y, 100, 100, tipsWarpper.msg);
 +
// if (y > 400) {
 +
// clearInterval(timer);
 +
// }
 +
}, 50);
 +
 +
}
 +
}
 +
}
 +
}
 +
}
 +
}
 +
 +
function contains(imgWarpper, x, y) {
 +
var img = imgWarpper.img;
 +
var rect = {};
 +
var drawWidth = img.width / 4;
 +
var drawHeight = img.height / 4;
 +
rect.x = imgWarpper.x;
 +
rect.y = imgWarpper.y;;
 +
rect.x2 = drawWidth + rect.x;
 +
rect.y2 = drawHeight + rect.y;
 +
if (rect.x < x)
 +
if (rect.x2 > x)
 +
if (rect.y < y)
 +
if (rect.y2 > y)
 +
return true;
 +
return false;
 +
}
 +
 +
c.addEventListener('click', function (event) {
 +
var x = event.clientX - c.getBoundingClientRect().left;
 +
var y = event.clientY - c.getBoundingClientRect().top;
 +
// console.log(x, y);
 +
if (contains(imgWarpper1, x, y)) {
 +
console.log("img 1");
 +
window.location.href = 'https://2018.igem.org/Team:NEU_China_B/background';
 +
}
 +
else if (contains(imgWarpper2, x, y)) {
 +
console.log("img 2");
 +
window.location.href = 'https://2018.igem.org/Team:NEU_China_B/Basic_Part';
 +
}
 +
else if (contains(imgWarpper3, x, y)) {
 +
console.log("img3");
 +
window.location.href = 'https://2018.igem.org/Team:NEU_China_B/Team';
 +
}
 +
else if (contains(imgWarpper4, x, y)) {
 +
console.log("img4");
 +
window.location.href = 'https://2018.igem.org/Team:NEU_China_B/InterLab';
 +
}
 +
else if (contains(imgWarpper5, x, y)) {
 +
console.log("img5");
 +
window.location.href = 'https://2018.igem.org/Team:NEU_China_B/Human_Practices';
 +
}
 +
else if (contains(imgWarpper6, x, y)) {
 +
window.location.href = 'https://2018.igem.org/Team:NEU_China_B/Human_Practices';
 +
}
 +
});
 +
c.onmousemove = function (event) {
 +
var x = event.clientX - c.getBoundingClientRect().left;
 +
var y = event.clientY - c.getBoundingClientRect().top;
 +
if (contains(imgWarpper1, x, y)) {
 +
tipsWarpper.x = x;
 +
tipsWarpper.y = y;
 +
tipsWarpper.valid = true;
 +
tipsWarpper.msg = "Background";
 +
}
 +
else if (contains(imgWarpper2, x, y)) {
 +
console.log("img 2");
 +
tipsWarpper.x = x;
 +
tipsWarpper.y = y;
 +
tipsWarpper.valid = true;
 +
tipsWarpper.msg = "Basic Part";
 +
}
 +
else if (contains(imgWarpper3, x, y)) {
 +
console.log("img3");
 +
tipsWarpper.valid = true;
 +
tipsWarpper.x = x;
 +
tipsWarpper.y = y;
 +
tipsWarpper.msg = "Team";
 +
}
 +
else if (contains(imgWarpper4, x, y)) {
 +
console.log("img4");
 +
tipsWarpper.x = x;
 +
tipsWarpper.y = y;
 +
tipsWarpper.msg = "InterLab";
 +
tipsWarpper.valid = true;
 +
}
 +
else if (contains(imgWarpper5, x, y)) {
 +
console.log("img5");
 +
tipsWarpper.x = x;
 +
tipsWarpper.y = y;
 +
tipsWarpper.msg = "Human_Practices";
 +
tipsWarpper.valid = true;
 +
}
 +
else if (contains(imgWarpper6, x, y)) {
 +
tipsWarpper.x = x;
 +
tipsWarpper.y = y;
 +
tipsWarpper.msg = "??????";
 +
tipsWarpper.valid = true;
 +
}
 +
else {
 +
console.log("six");
 +
tipsWarpper.valid = false;
 +
}
 +
}
 +
</script>

Revision as of 12:15, 17 October 2018

Title Page Title

您的浏览器不支持 HTML5 canvas 标签。