Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
IcedWatermelonJuice authored Oct 17, 2022
1 parent 1fd5051 commit 54eb971
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 166 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
* 支持添加自定义JS/CSS
* 添加书签时支持自动获取网站favicon
* 设置页支持检查版本更新(以github版本为标准)
* 搜索栏/书签支持http、https、ftp、file类URL转跳(file类型URL仅支持本地主页)
* 搜索栏/书签支持http、https、ftp、file类URL转跳(file类型URL仅支持本地主页)
# 📝后续计划
* 语音搜索
* 长文本搜索
* 主页书签文件夹
* 自定义默认书签库
# 🌐相关地址
* 在线使用地址(GithubPage可能会被墙):https://icedwatermelonjuice.github.io/HMOSHomePage
* 备用在线地址(国内地址访问较慢):https://gem-hp.rth.app
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<input type="text" class="s-temp" />
</div>
<script src="js/lib/require.js?v=1.25"></script>
<script src="js/lib/ajaxJson.js"></script>
<!-- <script src="js/lib/ajaxJson.js"></script> -->
<script src="js/main.js?v=1.25"></script>
<!-- 不重要的CSS最后加载 -->
<link rel="stylesheet" type="text/css" href="css/lazy.css?v=1.25" />
Expand Down
310 changes: 160 additions & 150 deletions js/lib/ajaxJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,162 +2,172 @@
gitee仓库:https://gitee.com/wangjins/weather_api
开发文档:http://doc.tianqiapi.com/603579
*/
function getWeather(IdKey, city) {
IdKey = IdKey ? IdKey : "appid=23035354&appsecret=8YvlPNrz";
city = city ? "&city=" + city : "";
var url = "https://yiketianqi.com/api?unescape=1&version=v1&" + IdKey + city;
function errorFn(){
var msg="天气api失效或日次数达上限";
console.log(msg);
$('.weather').html(`<h1>${msg}</h1>`);
}
$.ajax({
url: url,
type: "get",
dataType: "json",
success: function(res) {
if(!(res.city&&res.data)){
errorFn();
return false;
define(["jquery"],function($){
return new function (){
function getWeather(IdKey, city) {
IdKey = IdKey ? IdKey : "appid=23035354&appsecret=8YvlPNrz";
city = city ? "&city=" + city : "";
var url = "https://yiketianqi.com/api?unescape=1&version=v1&" + IdKey + city;

function errorFn() {
var msg = "天气api失效或日次数达上限";
console.log(msg);
$('.weather').html(`<h1>${msg}</h1>`);
}
var location = res.city;
var data = res.data[0];
var temp = data.tem;
var air = data.air_level;
var weather = data.wea;
var img = data.wea_img;
var html =
`<div>${temp}</div><div>${weather}</div><div>${location} · ${air.length>1?air:"空气"+air}</div><div class="weather-icon" id="lottie-box" style="background-image: url(img/weather/${data.wea_img}.png);"></div>`;
$('.weather').html(html);
},
error:function(){
errorFn();
$.ajax({
url: url,
type: "get",
dataType: "json",
success: function(res) {
if (!(res.city && res.data)) {
errorFn();
return false;
}
var location = res.city;
var data = res.data[0];
var temp = data.tem;
var air = data.air_level;
var weather = data.wea;
var img = data.wea_img;
var html =
`<div>${temp}</div><div>${weather}</div><div>${location} · ${air.length>1?air:"空气"+air}</div><div class="weather-icon" id="lottie-box" style="background-image: url(img/weather/${data.wea_img}.png);"></div>`;
$('.weather').html(html);
},
error: function() {
errorFn();
}
})
}
})
}

function getWeibo() {
function errorFn(){
var msg="微博api失效或日次数达上限";
console.log(msg);
$('.news-list').html(`<h1>${msg}</h1>`);
}
$.ajax({
url: "https://tenapi.cn/resou/",
type: "get",
dataType: "json",
success: function(res) {
var data = res.list;
if(!data){
errorFn();
return false

function getWeibo() {
function errorFn() {
var msg = "微博api失效或日次数达上限";
console.log(msg);
$('.news-list').html(`<h1>${msg}</h1>`);
}
var html = '';
for (var i = 0; i < 4; i++) {
html +=
'<div class="news-item"><div class="news-item-count">' +
(i + 1) + '</div><div class="news-item-title">' + data[i]
.name +
'</div><div class="news-item-hot">' + data[i].hot +
'</div></div>';
}
$('.news-list').html(html);
},
error:function(){
errorFn();
$.ajax({
url: "https://tenapi.cn/resou/",
type: "get",
dataType: "json",
success: function(res) {
var data = res.list;
if (!data) {
errorFn();
return false
}
var html = '';
for (var i = 0; i < 4; i++) {
html +=
'<div class="news-item"><div class="news-item-count">' +
(i + 1) + '</div><div class="news-item-title">' + data[i]
.name +
'</div><div class="news-item-hot">' + data[i].hot +
'</div></div>';
}
$('.news-list').html(html);
},
error: function() {
errorFn();
}
});
}
});
}

function getDouyin() {
function errorFn(){
var msg="抖音api失效或日次数达上限";
console.log(msg);
$('.douyin-list').html(`<h1>${msg}</h1>`);
}
$.ajax({ //https://creator.douyin.com/aweme/v1/creator/data/billboard/?billboard_type=1
url: "https://tenapi.cn/douyinresou/",
type: "get",
dataType: "json",
success: function(res) {
var data = res.list;
if(!data){
errorFn();
return false

function getDouyin() {
function errorFn() {
var msg = "抖音api失效或日次数达上限";
console.log(msg);
$('.douyin-list').html(`<h1>${msg}</h1>`);
}
var html = '';
for (var i = 0; i < 4; i++) {
html +=
'<div class="douyin-item"><div class="douyin-item-count">' +
(i + 1) + '</div><div class="douyin-item-title">' + data[i]
.name +
'</div><div class="douyin-item-hot">' + data[i].hot +
'</div></div>';
}
$('.douyin-list').html(html);
},
error:function(){
errorFn();
$.ajax({ //https://creator.douyin.com/aweme/v1/creator/data/billboard/?billboard_type=1
url: "https://tenapi.cn/douyinresou/",
type: "get",
dataType: "json",
success: function(res) {
var data = res.list;
if (!data) {
errorFn();
return false
}
var html = '';
for (var i = 0; i < 4; i++) {
html +=
'<div class="douyin-item"><div class="douyin-item-count">' +
(i + 1) + '</div><div class="douyin-item-title">' + data[i]
.name +
'</div><div class="douyin-item-hot">' + data[i].hot +
'</div></div>';
}
$('.douyin-list').html(html);
},
error: function() {
errorFn();
}
});
}
});
}

function getZhihu() {
function errorFn(){
var msg="知乎api失效或日次数达上限";
console.log(msg);
$('.audio-list').find('.audio-swipe').html(`<div class="swiper-wrapper">${msg}</div>`);
}
$.ajax({
url: "https://tenapi.cn/zhihuresou/",
type: "get",
dataType: "json",
success: function(res) {
var data = res.list;
if(!data){
errorFn();
return false
}
var html = '';
for (var i = 0, l = data.length; i < l; i++) {
html +=
'<div class="audio-item swiper-slide"><div class="audio-item-icon"></div><div class="audio-item-title">' +
data[i].query + '</div></div>';

function getZhihu() {
function errorFn() {
var msg = "知乎api失效或日次数达上限";
console.log(msg);
$('.audio-list').find('.audio-swipe').html(`<div class="swiper-wrapper">${msg}</div>`);
}
$('.audio-list').find('.swiper-wrapper').html(html);
require(['Swiper'], function(Swiper) {
var swiper = new Swiper('.audio-swipe', {
allowTouchMove: false,
height: 54,
direction: 'vertical',
slidesPerView: 2,
slidesPerGroup: 2,
loop: true,
autoplay: {
delay: 5000,
disableOnInteraction: false,
},
});
$.ajax({
url: "https://tenapi.cn/zhihuresou/",
type: "get",
dataType: "json",
success: function(res) {
var data = res.list;
if (!data) {
errorFn();
return false
}
var html = '';
for (var i = 0, l = data.length; i < l; i++) {
html +=
'<div class="audio-item swiper-slide"><div class="audio-item-icon"></div><div class="audio-item-title">' +
data[i].query + '</div></div>';
}
$('.audio-list').find('.swiper-wrapper').html(html);
require(['Swiper'], function(Swiper) {
var swiper = new Swiper('.audio-swipe', {
allowTouchMove: false,
height: 54,
direction: 'vertical',
slidesPerView: 2,
slidesPerGroup: 2,
loop: true,
autoplay: {
delay: 5000,
disableOnInteraction: false,
},
});
})
},
error: function() {
errorFn();
}
});
}

function test(imgSrc) {
var img = new Image();
img.src = imgSrc;
$("#app").append(img)
$(img).ready(function() {
console.log(img)
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
var dataURL = canvas.toDataURL();
console.log(dataURL);
})
},
error:function(){
errorFn();
}
});
}

function test(imgSrc) {
var img = new Image();
img.src=imgSrc;
$("#app").append(img)
$(img).ready(function(){
console.log(img)
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
var dataURL = canvas.toDataURL();
console.log(dataURL);
})
}

this.getWeather=getWeather;
this.getWeibo=getWeibo;
this.getDouyin=getDouyin;
this.getZhihu=getZhihu;
}
})
25 changes: 11 additions & 14 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1336,9 +1336,7 @@ require(['jquery'], function($) {
setTimeout(() => {
dom.removeAttr("delay");
}, 500)
}).keydown(function(evt) {
evt.keyCode === 13 && $(".fullscreen-search-page-foot button").click();
});
})
$(".fullscreen-search-page-foot div").click(function(e) {
e = $(e.currentTarget);
console.log(e)
Expand Down Expand Up @@ -2060,16 +2058,16 @@ require(['jquery'], function($) {
$(".page-bg").remove();
});
});


// 天气
getWeather(settings.get("weatherApiIdKey"), settings.get("weatherApiCity"));
//微博热搜榜
getWeibo()
//抖音热搜榜
getDouyin()
//知乎热搜榜
getZhihu()
require(["ajaxJson"], function(ajaxJson) {
//天气
ajaxJson.getWeather(settings.get("weatherApiIdKey"), settings.get("weatherApiCity"));
//微博热搜榜
ajaxJson.getWeibo()
//抖音热搜榜
ajaxJson.getDouyin()
//知乎热搜榜
ajaxJson.getZhihu()
});
})
}

Expand Down Expand Up @@ -2888,7 +2886,6 @@ require(['jquery'], function($) {
$(".set-markdown-page").show();
history.pushState(null, document.title, changeParam("page", "aboutVersion"));
})

}

//扫一扫
Expand Down

0 comments on commit 54eb971

Please sign in to comment.