我遇到长码的问题,这是代码:
navigator.geolocation.getCurrentPosition(function(position) {
var long = position.coords.longitude;
var lat = position.coords.latitude;
var theDateC = new Date();
var D = (367 * theDateC.getFullYear()) - (parseInt((7 / 4)(theDateC.getFullYear + parseInt((theDateC.getMonth() + 9) / 12)))) + parseInt(275(theDateC.getMonth() / 9)) + theDateC.getDate() - 730531.5);
var L = 280.461 + 0.9856474 * D;
var M = 357.528 + 0.9856003 * D;
var Lambda = L + 1.915 * Math.sin(M) + 0.02 * Math.sin(2 * M);
var Obliquity = 23.439 - 0.0000004 * D;
var Alpha = Math.atan(Math.cos(Obliquity) * Math.tan(Lambda)); Alpha = Alpha - (360 * parseInt(Alpha / 360); Alpha = Alpha + 90 * (Math.trunc(Alpha / 90) - Math.trunc(Alpha / 90));
var ST = 100.46 + 0.985647352 * D;
var Dec = Math.asin(Math.sin(Obliquity) * Math.sin(Lambda));
var Noon = Alpha - ST;
var UTNoon = Noon - long;
if (Date().substring(Date().length - 3, Date().length) === "GMT"
} {
var Zone = 0;
} else {
var Zone = Number(Date().substring(Date().length - 4, Date().length - 2)) + Number(Number(Date().substring(Date().length - 2, Date().length) * 60))) / 60;
};
var LocalNoon = UTNoon / 15 + Zone;
var AsrAlt = Math.atan(1 + Math.tan(lat - Dec));
var AsrArc = Math.acos((Math.sin(90 - AsrAlt) - Math.sin(Dec) * Math.sin(Lat)) / (Math.cos(Dec) * Math.cos(Lat))); AsrArc = AsrArc / 15;
var AsrTime = LocalNoon + AsrArc; alert("وقت العصر : " + AsrTime);
});
我知道代码非常非常长,它用于计算访客经度和时间中的Asr祈祷时间。纬度(伊斯兰祈祷),当我执行代码时,它显示:"失踪 ;在陈述之前" 。
答案 0 :(得分:0)
我已更新了该功能...立即检查?
navigator.geolocation.getCurrentPosition(function(position){
var long = position.coords.longitude;
var lat = position.coords.latitude;
var theDateC = new Date();
var D = (367*theDateC.getFullYear())-(parseInt((7/4)*(theDateC.getFullYear+parseInt((theDateC.getMonth()+9)/12))))+parseInt(275*(theDateC.getMonth()/9))+theDateC.getDate()-730531.5;
var L = 280.461+0.9856474*D;
var M = 357.528+0.9856003*D;
var Lambda = L +1.915*Math.sin(M)+0.02*Math.sin(2*M);
var Obliquity = 23.439-0.0000004*D;
var Alpha = Math.atan (Math.cos(Obliquity)*Math.tan(Lambda));
Alpha = Alpha - (360 * parseInt(Alpha/360));
Alpha = Alpha + 90 * ( Math.trunc ( Alpha / 90 ) - Math.trunc(Alpha / 90));
var ST = 100.46 + 0.985647352 *D;
var Dec = Math.asin(Math.sin (Obliquity )*Math.sin(Lambda));
var Noon = Alpha - ST;
var UTNoon = Noon - long;
if (Date().substring(Date().length - 3, Date().length) === "GMT") {
var Zone = 0;
} else {
var Zone = Number(Date().substring(Date().length - 4, Date().length - 2)) + Number(Number(Date().substring(Date().length - 2, Date().length) * 60)) / 60;
}
var LocalNoon = UTNoon / 15 + Zone; var AsrAlt = Math.atan (1+ Math.tan( lat - Dec));
var AsrArc = Math.acos ((Math.sin(90- AsrAlt )-Math.sin(Dec)*Math.sin(lat))/(Math.cos(Dec)*Math.cos(lat))); AsrArc = AsrArc / 15;
var AsrTime = LocalNoon + AsrArc; alert("وقت العصر : " + AsrTime);
});
答案 1 :(得分:0)
特别感谢js_noob帮助我,他的功能完美无缺!
但我仍然有功能问题,这是完整编辑的工作代码:
navigator.geolocation.getCurrentPosition(function(position){
var long = position.coords.longitude;
var lat = position.coords.latitude;
var theDateC = new Date();
var D = (367*theDateC.getFullYear())-(parseInt((7/4)*(theDateC.getFullYear+parseInt((theDateC.getMonth()+9)/12))))+parseInt(275*(theDateC.getMonth()/9))+theDateC.getDate()-730531.5;
var L = 280.461+0.9856474*D;
var M = 357.528+0.9856003*D;
var Lambda = L +1.915*Math.sin(M)+0.02*Math.sin(2*M);
var Obliquity = 23.439-0.0000004*D;
var Alpha = Math.atan (Math.cos(Obliquity)*Math.tan(Lambda));
Alpha = Alpha - (360 * parseInt(Alpha/360));
Alpha = Alpha + 90 * ( Math.trunc ( Alpha / 90 ) - Math.trunc(Alpha / 90));
var ST = 100.46 + 0.985647352 *D;
var Dec = Math.asin(Math.sin (Obliquity )*Math.sin(Lambda));
var Noon = Alpha - ST;
var UTNoon = Noon - long;
var Zone = theDateC.getTimezoneOffset();
var LocalNoon = UTNoon / 15 + Zone; var AsrAlt = Math.atan (1+ Math.tan( lat - Dec));
var AsrArc = Math.acos ((Math.sin(90- AsrAlt )-Math.sin(Dec)*Math.sin(lat))/(Math.cos(Dec)*Math.cos(lat))); AsrArc = AsrArc / 15;
var AsrTime = LocalNoon + AsrArc; alert("وقت العصر : " + AsrTime);
});
该功能现在正在运行,但问题最终还是存在。
当警报出现时,它说:
“وقتالعصر:NaN”
正如我在javascript中的知识,这意味着最终变量不是数字,但是当我检查函数时,我发现没有使用字符串!