Is it possible to show the full path to files in the stack trace when XDebug catches an error?
At the moment I just get this:
../stack.php:47
But I would rather see something like:
C:\inetpub\wwwroot\mysite\stack.php:47
Is this possible?
No, but there is a mouseOver. If you hover over the filename, the whole path should pop up in a tooltip. If you want to full path there by default, you'll have to send in a feature request at http://bugs.xdebug.org.
Too late but I think it will be wery useful for a lot of people :)
var xtable = document.getElementsByClassName('xdebug-error');
if(xtable.length){
for(var k=0;k<xtable.length;k++){
var xbody = xtable[k].getElementsByTagName('tbody');
var xtr = xbody[0].getElementsByTagName('tr');
for(var i=0;i<xtr.length;i++){
var xtd = xtr[i].getElementsByTagName('td');
for(var j=0;j<xtd.length;j++){
if(xtd[j].title){
xtd[j].data = xtd[j].innerHTML;
xtd[j].innerHTML = xtd[j].title;
xtd[j].title = "";
}else if(xtd[j].data){
var data = xtd[j].data;
xtd[j].data = xtd[j].innerHTML;
xtd[j].innerHTML = data;
}
}
}
}
}
And bookmarklet for this script:
javascript:(function(){var%20xtable%20=%20document.getElementsByClassName(%27xdebug-error%27);if(xtable.length){for(var%20k=0;k<xtable.length;k++){var%20xbody%20=%20xtable[k].getElementsByTagName(%27tbody%27);var%20xtr%20=%20xbody[0].getElementsByTagName(%27tr%27);for(var%20i=0;i<xtr.length;i++){var%20xtd%20=%20xtr[i].getElementsByTagName(%27td%27);for(var%20j=0;j<xtd.length;j++){if(xtd[j].title){xtd[j].data%20=%20xtd[j].innerHTML;xtd[j].innerHTML%20=%20xtd[j].title;xtd[j].title%20=%20%22%22;}else%20if(xtd[j].data){var%20data%20=%20xtd[j].data;xtd[j].data%20=%20xtd[j].innerHTML;xtd[j].innerHTML%20=%20data;}}}}}})();
Just create bookmark in browser and when you want to get full file path click on it ;)
Related
I have created a Google Form that logs Timestamps, a numerical value, and an image file from its respondents to a Google Sheet. The image files are saved to an "imageFolder", but when I get too many responses, my imageFolder and Google Sheet get too large. Ideally, I want my imageFolder and its Google Sheet to stay below 50 entries.
I want to move the 10 oldest images in imageFolder to waitFolder. I want to save an array of those oldest values from column "How many?" before the entry is deleted. Then I want any new entries to replace the oldest ones who's information I have already save to waitFolder and the howMany() array (myArray10).
I know I have to move 10 images from "imageFolder" to "waitFolder" using functions along the lines of:
var text1 = "Response Form";
var text2 = "imageFolder";
var text3 = "Copy of imageFolder";
var text4 = "Wait Folder"
function moveFiles(sourceFileId, targetFolderId) {
var myFolder = DriveApp;
var files = myFolder.getFileById(sourceFileId).getFiles()
while (files.hasNext()) {
var file = files.next());
var dest = myFolder.getFolderById(targetFolderId);
dest.addFile(file);
var pull = DriveApp.getFolderById(sourceFolderId);
pull.removeFile(file);
}
}
function getMyId(text) {
var Ids = [];
var myFolder = DriveApp;
var folderIter = myFolder.getFoldersByName(text);
var folder = folderIter.next();
var folderIter = folder.getFiles();
while(folderIter.hasNext()) {
var file = folderIter.next();
var fileId = file.getId();
Ids.push(fileId);
}
return Ids
}
function getMyId10(text) {
var Ids = [];
var myFolder = DriveApp;
var folderIter = myFolder.getFoldersByName(text);
var folder = folderIter.next();
var folderIter = folder.getFiles();
for (var i = 0; i < 10; i++) { //Take the first 10
while(folderIter.hasNext()) {
var file = folderIter.next();
var fileId = file.getId();
Ids.push(fileId);
}
}
return Ids
}
function main() {
var imageFolderId = getMyId(text2);
var imageFolderId10 = getMyId10(text2);
var waitFolderId = getMyId(text4);
var Copy_imageFolderId = getMyId(text3);
moveFiles(imageFolderId, Copy_imageFolderId); //make a copy of imageFolder
moveFiles(imageFolderId10, waitFolderId); //Move first 10, remove from original
}
How can I move images from imageFolder to Copy_imageFolder?
How can I move the 10 oldest images from imageFolder to waitFolder?
How can I remove the 10 oldest images from imageFolder?
How can I limit the number of rows in my spreadsheet using Google script?
How can I overwrite my oldest rows with new entries/rows?
edit1: I am getting unexpected tokens in every function, and I am unsure why? It seems to pop up in the while loop of my function getMyId().
edit2: I see now why I was getting unexpected tokens. It seems that I was being irresponsible with my loops. I have replaced my 'while's with 'for's to amend this mistake.
edit3: I removed some unnecessary snippets of code to make it easier to follow.
edit4: Here is what my Form Response looks like in my Spreadsheet. The images are saved to subfolder imageFolder. But I can't grab the 10 array elements I want from the spreadsheet using howMany(). I also can't seem to move any of the files anywhere. When I call on moveFiles(), I get an unexpected error as soon as it asks for my DriveApp. How do I make my moveFiles() move my images from source to target folders?
Perhaps this is what you were looking for:
function moveFiles(sourceFolderId, targetFolderId) {
var srcFolder=DriveApp.getFolderById(sourceFolderId);
var desFolder=DriveApp.getFolderById(targetFolderId);
var files=srcFolder.getFiles();
while(files.hasNext()) {
var file=files.next();
desFolder.addFile(file);
srcFolder.removeFile(file)
}
}
I have created SSRS report and want to change the name of file with adding Date to it. I really appreciate your help.
Already tried https://reportsyouneed.com/ssrs-adding-date-to-exported-filenames/ solution and it doesn't work.
An easy alternative might be
An alternative approach to creating unique files for every delivery is to include a timestamp in the file name. To do this, add the #timestamp variable to the file name (for example, CompanySales#timestamp). With this approach, the file name is unique by definition, so it will never be overwritten.
See https://learn.microsoft.com/en-us/sql/reporting-services/subscriptions/file-share-delivery-in-reporting-services?view=sql-server-ver15
I got a perfect solution for this Issue.
This link works (very well) only if there is no parameter required before export.
Code in this link try to get the file name when you click on the file, means when download not ready and report looking for initial inputs.
But my file has date parameters in the beginning to input.
So I modify the code to wait till download is available and added to the end of "C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportManager\js\ReportingServices.js" file
function ModifyExportFileName(){
var rv=null;
var r= null;
var today =new Date();
var day= ("0" + today.getDate()).slice(-2);
var month = ("0"+ (today.getMonth() + 1)).slice(-2);
var year = ("0"+ today.getFullYear()).slice(-2);
var text= "DD";
try{
rv=this.$find("ctl31");
r=rv._getInternalViewer();
var url=r.ExportUrlBase;
var i = url.indexOf("FileName=");
}
catch(err)
{
//console.log(err);
setTimeout(ModifyExportFileName,2000);
return;
}
if(r==null)
{
setTimeout(ModifyExportFileName,2000);
return;
}
else
{
var url=r.ExportUrlBase;
var i = url.indexOf("FileName=");
var j = url.indexOf("&",i+1);
var oldFileName= url.substring(i+9,j);
var filename=text.concat(year,month,day)
r.ExportUrlBase= url.substring(0,i) + 'FileName=' + filename+ url.substring(j);
}
//console.log(filename);
setTimeout(ModifyExportFileName,2000);
}
ModifyExportFileName();
I need date as a filename so date is added as "filename". you can change it as required
I have a strange error occurring in an Apps Script function attached to a Google Form.
I call the responses, then list them in an array. The log shows that there are 6 items in the array, which matches the six form questions:
[18-05-08 00:13:31:900 AEST] [ItemResponse, ItemResponse, ItemResponse, ItemResponse, ItemResponse, ItemResponse]
When I call the first two, it works just fine. Any more and it bugs out and says undefined.
// Open a form by ID and log the responses to each question.
var form = FormApp.getActiveForm();
var formResponses = form.getResponses();
for (var i = 0; i < formResponses.length; i++) {
var formResponse = formResponses[i];
var editUrl = String(formResponse.getEditResponseUrl());
var theResponseId = formResponses.indexOf(form);
var itemResponses = formResponse.getItemResponses();
var timestamp = formResponse.getTimestamp();
var firstName = itemResponses[0].getResponse();
var lastName = itemResponses[1].getResponse();
Logger.log(itemResponses); // Log shows there are 6 objects in the array. Matching the amount of Form Questions.
// If I try to use these variables below, it doesn't work and the script 'breaks' at this point.
//var number = itemResponses[2].getResponse();
//var email = itemResponses[3].getResponse();
//var firstName2 = itemResponses[4].getResponse();
//var comments = itemResponses[5].getResponse();
}
Note: I have tried FormApp.openById('id'); to see if maybe getting the active form was a problem. This didn't help.
This is because some answers were submitted to a 2 question form. If you submitted some responses prior to updating the form, the answers to these new questions will be "undefined".
I found a snowing image script on the web (http://www.jqueryrain.com/?GKBtfF4Q) and I am trying to modify the script to have multiple images.
So far, I figured out that it's necessary to change:
$(document).snow({ SnowImage: "snow.gif" });
to
$(document).snow({ SnowImage:[ "snow.gif", "2.gif", "3.gif", "4.gif"] });
but I am not sure how to make the script accept an array. Any suggestions would be much appreciated! (full disclosure: I am a coding noob)
Edit: pulled the script into JSFiddle: http://jsfiddle.net/px6w1xdm/
function __ShowSnow(settings)
{
var snowsrc = settings.SnowImage;
var no = settings.Quantity;
var dx, xp, yp; // coordinate and position variables
var am, stx, sty; // amplitude and step variables
var i;
etc.
Add this in the loop (above var flake):
var randno = Math.floor(snowsrc.length*Math.random());
var randsnowsrc = snowsrc[randno];
Then change snowsrc to randsnowsrc in this line:
flake.append("<img src='" + randsnowsrc + "'>");
I have created an array which is being used to store a series of .gif images and I'm just trying to test everything out by using document.getElementById to change the .src value but when I change it and load the page the image stays the same as it was before.
function setImage()
{
var images = new Array();
images[0] = anemone.gif;
images[1] = ball.gif;
images[2] = crab.gif;
images[3] = fish2.gif;
images[4] = gull.gif;
images[5] = jellyfish.gif;
images[6] = moon.gif;
images[7] = sail.gif;
images[8] = shell.gif;
images[9] = snail.gif;
images[10] = sun.gif;
images[11] = sunnies.gif;
images[12] = whale.gif;
var slots = new Array();
slots[0] = document.getElementById("slot" + 0);
slots[1] = document.getElementById("slot" + 1);
slots[2] = document.getElementById("slot" + 2);
slots[0].src = "snail.gif";
document.getElementById('slot0').src = images[0];
alert(images.length);
}
I can't understand why the image wont change, but I know it has to be something very simple. I've been wasting hours trying to get this one thing to change but nothing works. can anyone please point out the error of my ways?
There are a couple of issues with your code:
Your filenames need to be Strings, so they'll have to be quoted (also you can simplify the Array creation):
var images = ['anemone.gif', 'ball.gif', 'crab.gif', 'fish2.gif', 'gull.gif', 'jellyfish.gif', 'moon.gif', 'sail.gif', 'shell.gif', 'snail.gif', 'sun.gif', 'sunnies.gif', 'whale.gif'];
Also make sure you are getting your slot-elements right, quote all the attributes like:
<img id="slot0" class="slot" src="crab.gif" width="120" height="80">
When you create the slots-Array you can do it like this (no need to concat the ID string):
var slots = [document.getElementById('slot0'), document.getElementById('slot1'), document.getElementById('slot2')];
Finally make sure you call your function when the document has loaded / the DOM is ready. If you don't want to use a framework like jQuery your easiest bet is probably still using window.onload:
window.onload = setImage; //note that the parens are missing as you want to refer to the function instead of executing it
Further reading on Arrays, window.onload and DOMReady:
https://developer.mozilla.org/de/docs/DOM/window.onload
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array
javascript domready?