View Single Post
  #137  
Old 10.12.2020, 13:41
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 69,621
Default

@mgpai

Quote:
var history=getHistory();
alert(history);
addToHistory("test2222");
alert(history);

function getHistory() {
var file = getPath(JD_HOME + "/cfg/history.txt");
var name = file.name;
var lock = getModifyLock(name);
lock.writeLock();
history = getProperty(name, true);
if (history == null) {
if (file.exists()) {
history = readFile(file);
} else {
history = "";
}
setProperty(name, history, true);
}
lock.writeUnlock();
return history;
}

function addToHistory(value) {
var file = getPath(JD_HOME + "/cfg/history.txt");
var name = file.name;
var lock = getModifyLock(name);
lock.writeLock();
history = getProperty(name, true);
if (history == null) {
history = getHistory();
}
if (history.indexOf(value) == -1) {
var add = value+"\r\n";
history += add;
setProperty(name, history, true);
writeFile(file, add, true);
}
lock.writeUnlock();
return history;
}
__________________
JD-Dev & Server-Admin
Reply With Quote