var clientContext = null;
var globalCount = 0;
var itemCountList = 0;
var curentDate = new Date();
function uploadDest(){
clientContext = new SP.ClientContext("");
oList = clientContext.get_web().get_lists().getByTitle("");
camlQuery1 = new SP.CamlQuery();
query1 ='<View></View>';
camlQuery1.set_viewXml(query1);
this.collListItems1 = oList.getItems(camlQuery1);
clientContext.load(collListItems1);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onMultiSelectListDataLoadQuerySucceeded1), Function.createDelegate(this, this.onMultiSelectListDataLoadQueryFailed));
}
function onMultiSelectListDataLoadQuerySucceeded1(sender, args){
listItemEnumerator1 = collListItems1.getEnumerator();
itemCountList = collListItems1.get_count();
while (listItemEnumerator1.moveNext()) {
oListItem1 = listItemEnumerator1.get_current();
oListItem1.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
function onMultiSelectListDataLoadQueryFailed(){
alert("error occured");
}
function onQuerySucceeded() {
globalCount = globalCount + 1;
console.log("success / "+ globalCount + "/" + itemCountList);
if(globalCount==itemCountList){
localStorage.setItem("code","1");
window.location = document.location.href;
location.reload();
}
}
function onQueryFailed(sender, args) {
console.log("error");
}
if(localStorage.getItem("code") === null){
ExecuteOrDelayUntilScriptLoaded(function(){
var div = document.getElementById("WebPartWPQ2");
div.style.opacity = 0;
uploadDest();
},"sp.js");
}else{
localStorage.removeItem("code");
}
}
</script>