Bug reporting initial setup

bugReportStatus added, off to begin with
bugFileMDTs also added to contain a list of modified datetimes for bug
files being checked upon
On init, startBugChecking()
When using new settings, pull through 3 x bug related settings so we can
restart service (to do!)
xhrObj setup to return cross browser XHR object to make our calls
openBugReport will look to bugStatusReport and display an appropriate
message, for now
startBugChecking is the main function. If we have a timer, clear any
existing interval and start a new one
That then builds up a URL to call, with null values if items don't exist
(for error handling later on - to do!). The MDTs will need something
other than push, as this will all be called after changing settings. Use
the i int instead to hard set each array key & value (after clearing the
array)
The XHR call is made using our object and on a successful state, we
parse the result to read and handle the bug icon changing before setting
the bugReportStatus value. Need to also handle other states & statuses.
The status is set to 'ok' on restarting the bug checking function
This commit is contained in:
Matt Pass
2014-02-28 12:31:56 +00:00
parent f5be67675b
commit 70ca67b3d5
2 changed files with 133 additions and 46 deletions

View File

@@ -45,6 +45,8 @@ var ICEcoder = {
overPopup: false, // Indicates if we're over a popup or not
cmdKey: false, // Tracking apple Command key up/down state
fmReady: false, // Indicates if the file manager is ready for action
bugReportStatus: "off", // Values of: off, error, ok, bugs
bugFileMDTs: [], // Array of bug file modification datetimes user last saw
ready: false, // Indicates if ICEcoder is ready for action
// Set our aliases
@@ -76,6 +78,9 @@ var ICEcoder = {
// Update the nesting indicator every 30ms
setInterval(ICEcoder.updateNestingIndicator,30);
// Start bug checking
top.ICEcoder.startBugChecking();
// ICEcoder is ready to start using
top.ICEcoder.ready = true;
},
@@ -1831,7 +1836,7 @@ var ICEcoder = {
},
// Update the settings used when we make a change to them
useNewSettings: function(themeURL,codeAssist,lockedNav,tagWrapperCommand,autoComplete,visibleTabs,fontSize,lineWrapping,indentWithTabs,indentSize,pluginPanelAligned,refreshFM) {
useNewSettings: function(themeURL,codeAssist,lockedNav,tagWrapperCommand,autoComplete,visibleTabs,fontSize,lineWrapping,indentWithTabs,indentSize,pluginPanelAligned,bugFilePaths,bugFileCheckTimer,bugFileMaxLines,refreshFM) {
var styleNode, strCSS, cMCSS, activeLineBG;
// Add new stylesheet for selected theme
@@ -1886,6 +1891,8 @@ var ICEcoder = {
top.get('plugins').style.left = pluginPanelAligned == "left" ? "0" : "auto";
top.get('plugins').style.right = pluginPanelAligned == "right" ? "0" : "auto";
console.log(bugFilePaths + "," + bugFileCheckTimer + "," + bugFileMaxLines);
// Finally, refresh the file manager if we need to
if (refreshFM) {top.ICEcoder.refreshFileManager()};
},
@@ -1993,6 +2000,83 @@ var ICEcoder = {
}
},
// XHR object
xhrObj: function(){
try {return new XMLHttpRequest();}catch(e){}
try {return new ActiveXObject("Msxml3.XMLHTTP");}catch(e){}
try {return new ActiveXObject("Msxml2.XMLHTTP.6.0");}catch(e){}
try {return new ActiveXObject("Msxml2.XMLHTTP.3.0");}catch(e){}
try {return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){}
try {return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
return null;
},
// Open bug report
openBugReport: function() {
if(top.ICEcoder.bugReportStatus=="off") {
top.ICEcoder.message('You can start bug reporting in Help > Settings');
}
if(top.ICEcoder.bugReportStatus=="error") {
top.ICEcoder.message('Error: can\'t find/access the error file paths');
}
if(top.ICEcoder.bugReportStatus=="ok") {
top.ICEcoder.message('No new errors found');
}
if(top.ICEcoder.bugReportStatus=="bugs") {
top.ICEcoder.message('Need to open bugs log file at this point...');
}
},
// Start bug checking by looking in bug file paths on a timer
startBugChecking: function() {
var bugCheckURL;
if (top.ICEcoder.bugFileCheckTimer !== 0) {
// Clear any existing interval
if ("undefined" != typeof top.ICEcoder.bugFileCheckTimerInt) {
clearInterval(top.ICEcoder.bugFileCheckTimerInt);
}
// Start a new timer
top.ICEcoder.bugFileCheckInt = setInterval(function() {
bugCheckURL = "lib/bug-files-check.php?";
bugCheckURL += "files="+(top.ICEcoder.bugFilePaths[0] !== "" ? top.ICEcoder.bugFilePaths.join() : "null");
bugCheckURL += "&filesMDTs="
if (top.ICEcoder.bugFileMDTs.length != top.ICEcoder.bugFilePaths.length) {
// Fill the array with nulls
for (var i=0; i<top.ICEcoder.bugFilePaths.length; i++) {
top.ICEcoder.bugFileMDTs.push("null");
}
}
bugCheckURL += top.ICEcoder.bugFileMDTs.join();
bugCheckURL += "&maxLines="+top.ICEcoder.bugFileMaxLines;
// top.ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href = bugCheckURL;
var xhr = top.ICEcoder.xhrObj();
xhr.onreadystatechange=function() {
if (xhr.readyState==4 && xhr.status==200) {
console.log(xhr.responseText);
var statusArray = JSON.parse(xhr.responseText);
console.log(statusArray);
top.get('bugIcon').style.backgroundPosition =
statusArray['result'] == "off" ? "0 0" :
statusArray['result'] == "ok" ? "-32 0" :
statusArray['result'] == "bugs" ? "-48 0" :
"-16 0"; // if the result is 'error' or another value
top.ICEcoder.bugReportStatus = statusArray['result'];
}
};
console.log('Calling '+bugCheckURL+' via XHR');
xhr.open("GET",bugCheckURL,true);
xhr.send();
},parseInt(top.ICEcoder.bugFileCheckTimer*1000,10));
// State that we're checking for bugs
top.ICEcoder.bugReportStatus = "ok";
}
},
// ==============
// TABS
// ==============