Print an HTML header on every page - javascript

I have found many older suggestions and solutions, none of which work as expected and many that just cause more issues.
Assume my web app allows users to create invoices and print them. These invoices may have any number of line items (even 100 or more). If the number of line items exceeds the page size, they are placed on the second page. This is fine.
What isn't fine is that if the second page should ever become separated from the first, it can get hard to tell which invoice it belongs to.
Is it at all possible (css, js, html, hacks, etc) to have a block of content repeat at the beginning of each and every paper page printed from a web page?
The linked possible duplicate question is from a few years ago and has no accepted answer, while the top answer doesn't actually work (as shown in the comments)

If at all possible create a PHP module and put it on every page inside of your web app. I've had to do this a few times.
If you want it to have an invoice number you can script it to start at 1001 and go up every time a function is completed. (A print button is selected)

May I suggest using page-break-after:. With page break you can control wherethe page breaks then re-insert headers.

Related

Randomize google forms sections with Gsuit?

I need to randomize the SECTIONS (not questions) in my google form. The reason I need to do sections is because every section corresponds to a video so each needs to be a section.
This is the closest thing I've gotten to a solution:
https://developers.google.com/apps-script/reference/forms/page-break-item
// Create a form and add three page-break items.
var form = FormApp.create('Form Name');
var pageTwo = form.addPageBreakItem().setTitle('Page Two');
var pageThree = form.addPageBreakItem().setTitle('Page Three');
// Make the first two pages navigate elsewhere upon completion.
pageTwo.setGoToPage(pageThree); // At end of page one (start of page two), jump to page three
pageThree.setGoToPage(FormApp.PageNavigationType.RESTART); // At end of page two, restart form
I've already made the form and don't want to remake it (so many questions, so many videos). If I could use the .setGoToPage function shown above I think I could find a solution to randomize the sections aka pages. I just don't know what the names of my already existing pages are or how to find them. Please help!!!!
As you noticed yourself the methods applicable to a page are very limited
So, while you can add a page break, you cannot retrieve it in a subsequent code execution, and thus there is no way to shuffle it.
There is also no way to retrieve or set the questions belonging to each page in order to create new pages with questions on each script execution.
You have the possibility to file relevant feature requests on Google's Public Issue Tracker, chances are they will be implemented in the future if enough users show interest
In the mean time, as a workaround the only 2 things I can come up with is
a) Duplicate your form, shuffle the pages manually from the UI for each duplicate, create a WebApp that will arbitrary redirect the user to one of the URLs of the different form versions
b) Summarize all questions belonging to one page / section into one question item - it is easy to shuffle opposed to pages
In case it's helpful - further information:
How to shuffle questions each time a form is submitted
How to shuffle questions on time-driven trigger

How to add a dictionary to a website content

I'm trying to create a website for learning, and learning web programming meanwhile. Inside of the website, there are some words that are hard to understand, so I wish to put a tooltip/modal to explain the meaning. Here is the prototype of my website: http://findmyself.herokuapp.com/ . Click on chinese word in blue, to see the modal.
While searching on stackoverflow: Tooltips for mobile browsers , I currently have something working.
This is what I'm doing right now.
a json file as dictionary.
a json file with the content of the text to display.
When the front end asks, nodejs send both files. When frontend javascript display on the browser, each word I print on the screen I have to look up into the dictionary and create a html span for the word. So when the user click on the word, its popup the meaning.
The problem is, since i did that, I feel somehow the page is slow to load. I think there is something wrong with my way of doing. And i will have a lot of text later.
I wish to know if there is another way of doing it.
And this is the website that inspire me: https://thuvienhoasen.org/p27a16641/48-dai-nguyen-cua-duc-phat-a-di-da
I hope I'm clear enough. Thanks.
You're right, the page is pretty slow to load. It's partly how large the JSON object is at http://findmyself.herokuapp.com/dtq/theory. It's nearly 600KB and takes a half second on its own just to download. But probably the slowest part of the page is how much time it takes to render that entire JSON object.
If you're not already familiar, I'd suggest checking the dev tools that are included in every browser, chrome's network and performance tabs are a good place to start if you're interesting in exactly where the time goes when the page is loading.
And if you're looking for more of a rule of thumb, a good place to start would be to only render some of the JSON object at once, or split that object into smaller parts.

WebExtension: collect infos on all iframes of current page

I’m writing a WebExtension that identify fields using a given criterion in a web page.
The content script which is loaded with every page and iframe does its job well identifying and highlighting those fields.
Now I want to count the total number of said fields in a page as the user sees it, that is, including its iframes, and display this number over the browserAction icon (as adblock displays a count over its action icon).
My plan was to use setBadgeText in the action script to clear the current counter, then issue a tabs.sendMessage({req:"countFields"}), and then let every content script respond to that message by getting the current value of the badgeText and increase it with the number of fields it found on its part of the page.
Well, that does not work well. I’m getting erratic values when a page contains iFrames. I guess this is a synchronization problem, when content scripts from different parts of the page try to get the badge value and update it.
I’ve also tried navigating through window.frames from a top level content script ("all_frames":false), but that won’t work either, since cross script errors can prevent me from descending all iFrames (using the online version of tinyMce for example)
Well, at this point, I’m asking for help and advice on how to solve my problem.
Any clue or pointer would be very much welcome !
I found the answer to that problem !
Since I believe knowing where to find for answers to a specific kind of problems (here, WebExtension development) is part of the answer, I give the link to that answer on the right place instead of just repeating here what was given me there.
https://discourse.mozilla.org/t/collect-infos-on-all-iframes-of-current-page-solved/30453

Chrome / HTML memory

I am testing some html that our developers wrote. Actually, I am evaluating selenium tests from another SQA and these tests test the HTML code.
In the web page you basically fill out a bunch of information, click next, review (sometimes there will be errors like a required field is missing, bad date, etc, and other times there will not be, such as when you correct the error and click next again).
after clicking next you click a link they have to go back to the previous page to make any changes, etc.
So the tests are basically
while [some expression]
fill out / change form
click *next*
examine results
click *return to previous page* to make changes
done
note return to previous page is NOT Chrome's <- (back) button but is a link on the page. The loop is executed many times. Not sure how many but > 5 and maybe > 10.
Anyway, at one of the later iterations, clicking next no longer brings up a results page and is just blank. My question, or what I wonder, is whether Chrome (or IE or whatever) stores all the visited pages in memory (while the back button may clear the page before going back or so) and is therefore running out of memory causing a blank screen. I should also note that the web pages use a lot of java script, and are being debugged with eclipse / selenium / testng.
So could this be what is happening? [please think of anything surrounded by asterisks as being in italics. Looks like it is not converting the font in my preview]

Help : printing multiple "reports" from browser (IE 6 essential, others would be nice)

No thoughts on this one? Anyone?
Here is my scenario:
I have a form where the user selects a report type, and then selects a list of users they want to generate reports for. When they submit the form, a new window is opened that uses pagination to allow the user to review each user report individual by using next and previous links.
The user wants the option to:
print both the currently displayed report by itself (that's an easy one), and
a "print all" option to print all the selected reports.
However, each report for each user must have its own "Page x of n" footer.
For the footer, I have been using the browser footer options, but in order to have the page numbering start new on each report printout, I have to make a separate window.print() call for each one. I have implemented this this way, and it works, but it's awful because each print() call causes a new print dialog to display, meaning the user has to click print in each dialog to finalise the print request. Many reports = a stupid number of popped up print dialogs.
Ideally, I would like the printing of a report group to look like a single print job, but I need that page count to be restarted for each report.
I thought of trying to count pages myself to make my own footer, but that seemed like a daunting task considering all the variables that could affect how many pages a report would occupy. I also read some about using ActiveX and WebBrowser objects to force prints and hide the print dialog, but I have had no success with that because I am running on XP SP2. Also, I understand it's frowned upon from a security perspective, and it's not a good cross-browser solution.
Has anyone dealt with printing of this type before and would have some suggestions for a way to make this work or a better way to handle it?
Thanks in advance.
I've seen this done two ways the simplist using the MeadCo scriptx component which alows you to print without a dialog. But as you rightly say this is not good from a security perspective. This was done in a corporate environment where they had control over the end users browser.
The second would be to go down the ajax route and load each report page individually, without prining, then concat each report html together into one doucment adding any needed page breaks. Finally rendering to an IFRAME and calling print on that frame to print all reports in one action.
This isn't tremendously helpful, but you may want to look into using a pdf generator, such as PDFlib or fpdf. Doing this with static pages will incur all the problems you stated, as well as some which you didn't (such as the user setting his own font or font size and ruining your pagination).

Categories

Resources