美女时钟
偶然在一个网站上面看到了美女时钟这个东西,觉得挺好玩的,非常养眼。发现图片来自搜道,Google了一下,美女时钟已经流行一段时间了,相对来说搜道的较为知名。可惜它没有开放官方API模块来供其他网站调用,但是它提供了两个API地址,可以提供一些数据,利
偶然在一个网站上面看到了美女时钟这个东西,觉得挺好玩的,非常养眼。发现图片来自搜道,Google了一下,美女时钟已经流行一段时间了,相对来说搜道的较为知名。可惜它没有开放官方API模块来供其他网站调用,但是它提供了两个API地址,可以提供一些数据,利用这些数据我们可以自己来做美女时钟模块。
本站演示:http://loosky.net/clock
文章、代码摘自:arayzou
1、获取图片地址
搜道提供的当前时间的美女时钟API为: http://www.sodao.com/ShowTime/gt
当前时间的下一分钟的API为:http://www.sodao.com/ShowTime/gt1
由于不能直接用ajax来请求搜道的数据,因为涉及到跨域问题,因此需要在本站用PHP来请求搜道的数据并提供给ajax使用。
分别建立clock.php
和clock_gt1.php
,clock.php
代码如下:
<?php function postIt($url) { $result=file_get_contents($url); return $result; } $url="http://www.sodao.com/ShowTime/gt"; print_r(postIt($url));
clock_gt1.php
代码如下:
<?php function postIt($url) { $result=file_get_contents($url); return $result; } $url="http://www.sodao.com/ShowTime/gt1";
解决思路:
在第一次打开页面的时候做两个请求,分别请求当前时间的图片和下一分钟的图片,当前时间的图片立刻添加到模块当中,下一分钟的图片地址先存储到模块的data-nextimg中,然后在每一分钟的0秒替换下一分钟的图片然后再一次请求下一分钟的图片地址替换模块的data-nextimg,这样就能保证图片更换的速度了。
2、代码实现
在适当的地方添加html代码:
JS代码:
$(document).ready(function(){ if($('.mmclock').length>0){ $('.mmclock').hide(); getMMimg(); getMMimg_gt(); setInterval("secCanvas()", 100); setInterval("setmmimg()", 1000); } }); function getMMimg(){ $.ajax({ url: '/demo/clock.php', error:function(item){ console.log('加载图片失败'); }, success: function(item){ var json = eval(item); var src = json[0].path; if (src) { $(".mmclock").show(); $(".mmclock").attr("href", src); $(".mmclock .mmclock_img").attr("src", src); } } }); } function getMMimg_gt(){ $.ajax({ url: '/demo/clock_gt1.php', error:function(mminfo){ console.log('加载图片失败'); }, success: function(mminfo){ var mminfo = eval(mminfo); mmsrc = mminfo[0].path; $('.mmclock').attr('data-nextimg',mmsrc); } }); } function secCanvas(){ var myDate = new Date(); var sec = myDate.getSeconds(); var secDeg = (sec-1)*10 + Math.floor(myDate.getMilliseconds()/100); var cSec = $("#canvas_seconds").get(0); var ctx = cSec.getContext("2d"); ctx.clearRect(0, 0, cSec.width, cSec.height); ctx.beginPath(); ctx.strokeStyle = "#06c"; ctx.arc(25,25,12.5, deg(0), deg(0.6*secDeg)); ctx.lineWidth = 25; ctx.stroke(); function deg(deg) { return (Math.PI/180)*deg - (Math.PI/180)*90 } } function setmmimg(){ var myDate = new Date(); var sec = myDate.getSeconds(); $('.seconds_block').text(sec); if(sec===0){ $(".mmclock").attr("href", $('.mmclock').attr('data-nextimg')); $(".mmclock .mmclock_img").attr("src", $('.mmclock').attr('data-nextimg')); getMMimg_gt(); } }
注:在该代码之前必须先引入jQuery文件
CSS代码:
.mmclock{ width: 100%; max-width:281px; padding:3px; border:1px solid #ddd; -moz-box-sizing:border-box; -ms-box-sizing:border-box; box-sizing:border-box; position: relative; display: block; } .mmclock .mmclock_sec{ width: 50px; height: 50px; position: absolute; left: 5px; top: 5px; } .mmclock .mmclock_sec .seconds_block{ height: 50px; width: 50px; line-height: 50px; text-align: center; position: absolute; top: 0; left: 0; font-size: 20px; font-family: Arial; color: #fff; opacity:0.9; } .mmclock .mmclock_sec canvas{ opacity:0.5; background: rgba(0,0,0,0.5); border-radius: 25px; } .mmclock .mmclock_img{ width: 100%; display: block; }
OK,大功告成!
本站演示:http://loosky.net/clock
原文地址:美女时钟, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

Websites for learning C language: 1. C Language Chinese Website; 2. Rookie Tutorial; 3. C Language Forum; 4. C Language Empire; 5. Script House; 6. Tianji.com; 7. Red and Black Alliance; 8, 51 Self-study network; 9. Likou; 10. C Programming. Detailed introduction: 1. C language Chinese website, which is a website dedicated to providing C language learning materials for beginners. It is rich in content, including basic grammar, pointers, arrays, functions, structures and other modules; 2. Rookie tutorials, This is a comprehensive programming learning website and more.

Do you frequently visit the same website at about the same time every day? This can lead to spending a lot of time with multiple browser tabs open and cluttering the browser while performing daily tasks. Well, how about opening it without having to launch the browser manually? It's very simple and doesn't require you to download any third-party apps, as shown below. How do I set up Task Scheduler to open a website? Press the key, type Task Scheduler in the search box, and then click Open. Windows On the right sidebar, click on the Create Basic Task option. In the Name field, enter the name of the website you want to open and click Next. Next, under Triggers, click Time Frequency and click Next. Select how long you want the event to repeat and click Next. Select enable

Standby is a lock screen mode that activates when the iPhone is plugged into the charger and oriented in horizontal (or landscape) orientation. It consists of three different screens, one of which is displayed full screen time. Read on to learn how to change the style of your clock. StandBy's third screen displays times and dates in various themes that you can swipe vertically. Some themes also display additional information, such as temperature or next alarm. If you hold down any clock, you can switch between different themes, including Digital, Analog, World, Solar, and Floating. Float displays the time in large bubble numbers in customizable colors, Solar has a more standard font with a sun flare design in different colors, and World displays the world by highlighting

In macOS Sonoma and Safari 17, you can turn websites into "web apps," which can sit in your Mac's dock and be accessed like any other app without opening a browser. Read on to learn how it works. Thanks to a new option in Apple's Safari browser, it's now possible to turn any website on the internet you frequently visit into a standalone "web app" that lives in your Mac's dock and is ready for you to access at any time. The web app works with Mission Control and Stage Manager like any app, and can also be opened via Launchpad or SpotlightSearch. How to turn any website into
![How to turn off alarms on iPhone [2023]](https://img.php.cn/upload/article/000/465/014/169259550735100.png?x-oss-process=image/resize,m_fill,h_207,w_330)
Since the advent of smartphones, they have undoubtedly replaced alarm clocks. If you own an iPhone, you can use the Clock app to easily set as many alarms for multiple occasions throughout the day. The app lets you configure the alarm time, the tone, how often it repeats, and whether you want to delay them using the Snooze option. If you want to turn off the alarm you have set, the following post should help you disable and delete regular alarms and wake-up alarms on your iPhone. How to Turn Off a Regular Alarm on iPhone By default, when you add an alarm on the Clock app or ask Siri to add an alarm for you, you're actually creating a regular alarm. You can create as many alarm clocks on your iPhone as you like and put them

Apple offers a new lock screen mode in iOS 17 called Standby Mode, which activates when your iPhone is plugged into a charger (wired or wireless) and placed on a stand in landscape orientation. This mode will show more information at a glance than the standard lock screen by showing the clock, weather data, calendar, and some widgets. After enabling this feature in settings, your iPhone will automatically enter standby mode when placed in landscape orientation while charging. How to change standby colors in iOS 17 Standby mode offers a set of three pages (Widgets, Photos, and Clock) that you can switch back and forth by swiping on the screen. Of these pages, only the Clock screen lets you customize the colors displayed on the screen so you can

To solve the problem of Python website access speed, use database optimization methods such as indexing and caching. In the process of developing and maintaining Python websites, we often encounter the problem of slow website access speed. In order to improve the response speed of the website, we can use some database optimization methods, such as indexing and caching. This article will introduce how to use these methods to solve Python website access speed problems, and provide corresponding code examples for reference. 1. Use indexes to optimize database queries. Indexes are a fast search structure for data in the database, which can greatly
