<script src="hoge1"></script>
<script src="hoge2"></script>
If you call a function of hoge1 on hoge2, console.log in the function of hoge1 does not work.Is it possible to make it work when I call from hoge2?
<script src="js/api.js"defer></script>
<script src="js/test.js"defer></script>
test.js
class Editor {
constructor(){
if(!(this instance of Editor)) return new Editor()
this.currentToList={item:null, todolist:null, time:null}
This.wholeToList={};
this.timer;
constrained=newEditData()
This.pushStartBtn()
This.changeInput()
This.inputFocused()
This.switchTimer()
This.tabDelete()
}
pushStartBtn(){
$(document).on("click", ".start", ()=>{
letitem_group = validationAndDataOrganize($(".item-group"))
if(!item_group){
console.error("validationAndDataOrganize return value is missing")
return;
}
console.log(item_group)
ed.setWholeData(item_group).setCurrentData()
insert_dom({"dataset":item_group, "edit_process": "new_and_edit"},)
let first_val = Array.from(item_group.values())[0]
let first_key = Array.from(item_group.keys())[0]
console.log(first_key, first_val)
console.log(item_group)
This.wholeToList=item_group
This.setToList({item:first_key,
todolist: first_val[0]["todorist"],
time: first_val[0]["time"]})
console.log (this.wholeToList)
})
}
api.js
function validationAndDataOrganize(jqueryDom){
let item_group = new Map();
letitem_group__obj = Array.from (jqueryDom)
conditions = Array.from(jqueryDom.find(".item")
let choufuku=items.filter((x, i, self)=>{return self.indexOf(x)!==self.lastIndexOf(x);});
if(choufuku.length) alert(" items cannot be duplicated."); return false;
console.trace((items))
if(items.some(x=>!x)) alert("item required"); return false;
for(let w of item_group__obj){
let values = [ ];
let input = Array.from($(w).find('.input'))
let koumoku=input.shift().value
let lists = [ ];
console.log(input)
let todoListArr = [ ];
for (let i in input) {
if(i%2!==0&i>0){
let todolist=input[i-1].value
let time = input [i].value
console.log (todolist, time)
//todolist & time validation
if([todolist, time].length>0&&[todolist, time].length<2){
alert("Please complete all forms.");
return false;
} else if ([todolist, time].every(x=>!x)) { // undefined
continue;
} else if(time.length>3) {
alert('Study time' must be within 3 digits')
return false;
}
todoListArr.push(todolist)
lists.push({"todolist":todolist, "time":time})
console.log(todoListArr)
}
}
if(todoListArr.length!==[...newSet(todoListArr)].length) {//set deduplication
alert("Small items cannot be duplicated.");
console.log(todoListArr)
return
}
if(lists.length){
item_group.set(koumoku,lists);
}
console.log(item_group)
}
return item_group
}
if() alert("item required"); return false;
I didn't realize that the above would look like the following,
if() alert("item required");
return false;
© 2024 OneMinuteCode. All rights reserved.