这次项目就快要结束了,项目希望这几天能够做完,做好,保质保量, 最后会进行bug测试,尽量使得项目能够像一个正常的网站能够正常使用,在这一周的的过程中,发现项目还是有点不够人性化,希望让用户用着舒服,不追求功能多么厉害,但是要好用,评论还差点,希望我能够顺利完成,之后会进行拓展功能的实现,后台希望能够尽快与网页主体实现正常功能。
其他也没什么说的
把我项目的工具库函数发出来吧
function getStyle(obj, name) {
if (window.getComputedStyle) {
return getComputedStyle(obj, null)[name];
} else {
return obj.currentStyle[name];
}
}
function imgup(obj) {
let file = obj.files[0];
let reader = new FileReader();
let name1 = obj.parentNode.children[0];
reader.readAsDataURL(file);
reader.onload = function (ev) {
/* $(name).attr("src", ev.target.result); */
name1.setAttribute("src", ev.target.result)
}
}
function outdifficulty(obj) {
let text = obj.innerText;
$(".pr-inner-xz:eq(0)").attr("value", text);
}
function outdifficulty2(obj) {
let text = obj.innerText;
$(".pr-inner-xz:eq(1)").attr("value", text);
}
//删除功能
function del(obj) {
let a = obj.parentNode;
a.parentNode.removeChild(a);
}
function del1(obj) {
let a = obj.parentNode.parentNode;
a.parentNode.removeChild(a);
}
function userkouweitext(obj) {
let text = obj.innerText;
console.log(text);
$(".kouweiinput").val(text);
$(".kouweilist").fadeOut(200);
}
function pushcode(obj) {
$.ajax({
async:true,
dataType:"json",
type:"get",
url:"http://localhost:8080/user/getSession",
success:function(date){
if (date.data == null) {
console.log("未登录");
}
else {
obj.src = "http://localhost:8080/recipe/getCode?id=" +date.data.id+ "&" + Math.random();
}
}
});
}
function pushcode2(obj) {
$.ajax({
async:true,
dataType:"json",
type:"get",
url:"http://localhost:8080/user/getSession",
success:function(date){
if (date.data == null) {
console.log("未登录");
}
else {
obj.src = "http://localhost:8080/menu/getCode?id=" +date.data.id+ "&" + Math.random();
}
}
});
}
function outlogin() {
let userimgtab = document.getElementsByClassName('userimgmodel')[0];
let longin = document.getElementsByClassName('longin')[0];
userimgtab.style.display = "none";
longin.style.display = "block";
$.get("http://localhost:8080/user/exist",
{},
function(){
}
)
window.location.assign('./home-page.html');
}
function logintest() {
let userimgtab = document.getElementsByClassName('userimgmodel')[0];
let admin=document.getElementsByClassName("userimgtab")[0];
let longin = document.getElementsByClassName('longin')[0];
$.ajax({
async:true,
dataType:"json",
type:"get",
url:"http://localhost:8080/user/getSession",
success:function(date){
if (date.data == null) {
console.log("未登录");
userimgtab.style.display = "none";
longin.style.display = "block";
}
else {
userimgtab.style.display = "block";
longin.style.display = "none";
}
if(date.data.sign==1){
$(admin.children[0]).append(`<li><a href="./back-html/background.html">进入后台</a></li>`);
}
else{
console.log("普通用户");
}
}
});
}
function upmsg(param) {
$.ajax({
async:true,
dataType:"json",
type:"get",
url:"http://localhost:8080/user/getSession",
success:function(date){
if (date.data == null) {
}
else {
$.get("http://localhost:8080/user/getUser",
{
"id": date.data.id
},
function (date) {
let userimgmodel = document.getElementsByClassName("userimgmodel")[0];
$(userimgmodel.children[0].children[0]).attr("src", date.data.userInfo.photo);
}
)
}
}
});
}
//获取URL传递的参数
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) { return pair[1]; }
}
return (false);
}
function getQueryVariable2(variable, url) {
var query = url.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) { return pair[1]; }
}
return (false);
}
function hasclass(obj, join) {
var reg = new RegExp("\\b" + join + "\\b");
return reg.test(obj.className);
}
function addClass(obj, join) {
if (!hasclass(obj, join)) {
obj.className += " " + join;
}
}
function deleteclass(obj, join) {
var reg = new RegExp("\\b" + join + "\\b");
obj.className = obj.className.replace(reg, "");
}
function statuswitch(i) {
let type1 = document.getElementsByClassName("type-head")[0];
for (let i = 0; i < 3; i++) {
deleteclass(type1.children[i], "active");
$(".state:eq(" + (i + 2) + ")").css("color", "#020202");
}
$(".state:eq(" + (i + 2) + ")").css("color", "rgb(255,197,82)");
addClass(type1.children[i], "active");
$(".content2").empty();
//清空后用根据选择的项目进行ajax请求获取对应数据
//-------------------------------------------------------
//收藏内部的加载
if (i == 2) {
$(".recipe-head").css("display", "block");
$(".content2").empty();
//ajax请求收藏菜谱的数据!!
}
else {
$(".recipe-head").css("display", "none");
}
}
function search(param) {
let tabsearchcontent = document.getElementsByClassName("tabsearchcontent")[0];
console.log(tabsearchcontent.value);
window.location.assign(`searchpage.html?name=${tabsearchcontent.value}`);
}
function zuiresousuo(obj) {
let url=encodeURI(`searchpage.html?name=${obj.children[0].innerText}`);
window.location.assign(url);
}
function search1(param) {
let tabsearchcontent = document.getElementsByClassName("tabsearchcontent")[0];
console.log(tabsearchcontent.value);
window.location.assign(`../searchpage.html?name=${tabsearchcontent.value}`);
}
function fenlei(obj) {
let url=encodeURI(`../searchpage.html?name=${obj.innerText}`);
window.location.assign(url);
}
function fenlei1(obj) {
let url=encodeURI(`./searchpage.html?name=${obj.innerText}`);
window.location.assign(url);
}
function textnums(obj) {
console.log(obj.value);
if(200-obj.value.lenght<=0){
obj.value.lenght=200;
}
$(".talknums").text(`还可以输入${200-obj.value.length}`);
}
function zitinums(obj){
let obj1=obj.parentNode;
let kuang=obj1.children[1].children[0];
if(200-obj.value.lenght<=0){
obj.value.lenght=200;
}
$(kuang).text(`还可以输入${200-obj.value.length}`);
}
没有注释,因为也就我一个人看😎