Very new to code. Searching for 2 days has yielded no results and I've gone nearly mad.
I have this CSS designed bar that I use in my live streaming overlays. I'm trying to populate text from a local .txt, xml, or json file onto the bar. I just cant figure out how to call this text and then style it.
Why? I'd like to eventually write a python script/GUI that can read / write to the .txt file (if its json or xml, ill try to figure it out). Baby steps.
So far, everything is div boxes and a video that is clipped to create the black bar (its looped to look animated).
Using
embed src="txtfile.txt"
loads up the file, but I cant style it T_T. I would really appreciate the help!
Main question. With this file that I am opening locally - how can I (on the backend) select a text file to be read, and then style that text?
I really appreciate the help or even a nudge in the right direction. I am so lost.
You will probably need to use a server language. I recommend using PHP as you are new to code. First you will need to set up a PHP supported development server for developing. You can search how to do this yourself as its out of the scope of your question (WAMP/MAMP/XAMPP).
If you are using PHP as your server language. presuming txtfile.txt is located in the same directory as your CSS designed bar, you can do the following:
<?php
// specify txt file path
include 'txtfile.txt';
// store txt file contents as string
$my_string = file_get_contents('txtfile.txt');
?>
Then wherever you want the string to appear, just echo the variable. Here's an example:
<span class="myCustomClass"><?php echo $my_string; ?></span>
You can then style whatever class you gave it in CSS.
Oh, and remember to change the file extension to .php
You can also use other server languages to achieve this.
Alternatively, you could embed the txt file in an iframe, and place the iframe inside the element you want:
<iframe src='txtfile.txt' scrolling='no' frameborder='0'></iframe>
...and there are other ways, too! Look into using jQuery and AJAX as it may be easier to do without the hassle of using PHP. You can just load the text file via an AJAX call, insert it inside the document and then you can style the content with CSS.
Related
I was looking for a way to write a script that will download a file from a specific website but without opening the website itself. I want everything to happen in the background.
The website is morningstar and a specific link for the example is this one:
https://financials.morningstar.com/ratios/r.html?t=MSFT
in this page, there is a "Button" (it is not really declared as a button but as a Hyperlink, the <a> tag in HTML)
I added a photo in the bottom so you can see for yourself exactly the way they wrote the code.
Anyway, I saw that when I clicked the button the href attribute actually calls a javascript function which then creates the links from which the file will be downloaded.
I am looking for a way that I can write a script and give it the link I want, for example, the link above, and the script will download this specific CSV file from that page into a folder of my choice.
I was looking at some selenium tutorials but I couldn't find much help for my specific problem.
Here's an example I use:
import requests
url = 'http://via.placeholder.com/350x150'
dashboardFile = requests.get(url, allow_redirects=True)
open('d:/dev/projects/new-wave/dashboard.pdf', 'wb').write(dashboardFile .content)
Oh, and depending on the size of the file you would want to download in chunks. A quick search of: "python download large file in chunks" will help.
The system I am working on has a questionnaire in it and then shows the responses to the admin in a nice report on screen. I need to create functionality that turns the on screen report into a pdf, similar to how the browser generates a pdf of the page when you select print. Although I need to only turn a section of the page into pdf. And it would be ideal to be able to alter the HTML so that the pdf page breaks don't interfere with the presentation of the report.
You can download a pdf of how the report looks, generated by the browser functionality. This is just an example, I need the pdf to be generated by a link or button and not include the whole page (the top part in this case).
I have tried some php HTML to pdf generators, but it's difficult because the HTML is dynamically generated so I'm not sure how to send all the HTML, once rendered, to the page that creates the pdf.
To overcome the page breaks, I've considered using javascript or jquery to read the height of the div of each question within the report and then write a simple script to calculate if the next div will fit on the page and if not add a margin on top of that div so that it starts on a new page.
What software can I use to generate the pdf, given these requirements? Either php or javascript. Appreciate the help.
Have you considered Snappy for PHP? It makes use of wkhtmltopdf behind the curtains to convert any HTML document into PDF.
We are using it and it works great.
https://github.com/KnpLabs/snappy
You could try mpdf and use the page-break-inside: avoid property which is actually a CSS property. I have not used this, but it might be what you're looking for.
Looks like you can add this property to the <div> and <table> tags (mPDF Supported CSS).
Here is a link to my site, http://johnathonpowers.bigcartel.com
Trying to play around with images on my product pages...well actually created a test page.
Unable to figure out a few things:
Where does one host a jquery file?
Do I need to have the jquery src for both jquery.min.js (many use the one hosted by google, if I am understanding any of this correctly) and jquery.elevatezoom.js?
If I end up not liking the zoom is this still an appropriate way to have a large image with small thumbnails beneath (perhaps I will explore how to click on the big image to open a full-screen version).
Should all my pictures be the same size? Right now I have square format photos and rectangle...it might end up looking horrible.
Do I put any code into CSS or just the layout and the specific page I want the images to take place?
Will these images replace the ones I upload through bigcartel's system?
There is already a jquery entry in the layout...do I just add to the end of this same section the additional src?
This is what I added to layout:
<script src="http://s000.tinyupload.com/index.php?file_id=24823496361920795072" type="text/javascript"></script>
This is my test page:
<img id="zoom_01" src="http://i.imgur.com/1L86Fcms.jpg" data-zoom-image="http://i.imgur.com/1L86Fcm.jpg"/>
$("#img_01").elevateZoom();
<head><script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"></script></head>
<img id="product_zoom" src="http://i.imgur.com/1L86Fcms.jpg" data-zoom-image="http://i.imgur.com/1L86Fcm.jpg" class="fade_in">
Thanks again for all the help and honestly probably biting off more than I can chew. I just wanted to play around with it and see if it would work/was something I liked, but seems like I have gone down a rabbit hole into a whole other world, way above my rudimentary html skillset.
Here is where I first saw the jquery stuff:
Can I integrate an Internal zoom on my products in my big cartel store?
The best place to host your javascript files is on a server that you have control over -but if you don't have any webspace, you can easily host files with a service like Dropbox or Google Drive.
The Luna theme you're using already loads jQuery in the <head> portion of your Layout, so you don't need to include that script again (and you'll get errors in your browser's javascript console if you try).
Since you're using a separate image zooming library that has a bunch of custom CSS, you'll probably want to have your CSS file hosted on a separate server as well. It's a good idea to put any files you're including in the Layout section, following the same format as the existing theme files.
It looks like the javascript file you're hosting on tinyupload.com is just bringing up a download page instead of actually loading the javascript content into the page, so you'll definitely need to change how that's loaded. Otherwise the HTML code you're using looks like it should work.
How can I read XML file on html page.
i want my XML link value to go in anchor
tags href attribute and Name of the website
between the anchor tags
I just know very basic Javascript.
I am trying to change value in footer of my website using XML because i have more than 100 pages and every time I change something in footer I have to change all 100 pages manually that's why i want to change the footer links through XML.
Please explain by showing code page should look like this
<div>
<a href "this value should be read by xml">and this value should also be read by xml</a>
</div>
Thanks guys for your answers but after a lot of search i found exactly what i wanted. I wanted to change multiple pages footer section using single file without changing my pages name (from .html pages to other like .aspx,.php,.asp) I thought using xml would be a good way but i am really novice in this field and xml didnt work for me (or say i am unable to use it in proper way) therefore i found out an alternative to change to content of multiple html pages using single file. All i needed to do was use SSI aka server side includes. The only thing you need to do is check if your server supports SSI or not and then make an individual html footer page that you want to include on every page. In order to include that external footer page just type.
<!--#include file="footer.html" -->
in the area,div,table wherever you want your footer to load and its done .
For detailed article pls go to following link http://httpd.apache.org/docs/2.2/howto/ssi.html
I need your help to grab the source code of the page & can save it in a text file.
What actually i want!!
Instead of doing the lot of work like, right click on the page then click on view source code then to copy & paste it in a text file...
I want to make a short, i want to put a link on the page, in which i need to grab a source code, so when i just click on that link let say "Download Code" it grabs the current page source code & save it in a .txt format.
Kindly help me how can i do this?? it would be great if i can achieve this by using a java script, i don't want to use server side programming language.
I tried data URI but dont get the exact what i need
I find some thing on the below link:
http://css-tricks.com/examples/ViewSourceButton/#