How to define and assign variables in html - javascript

I am making a website, but i am learning it by editing a template. So far i start to learn it quite quickly, but i cant figure everything out and i cant find everything on the internet. What i'm trying to achieve is that i can add a variable, which i place on every page of my site, so i do not have to modify it per HTML file.
This is the code (HTML):
<div id="sidebar">
<h2>Interesting Topics</h2>
<p class="news">####Read More » </p>
<p class="news">####Read More » </p>
<p class="news">####Read More » </p>
</div>
all #### basically need to be articles that i only have to define once, so it will show the same on every page. even better would be random/personalized articles, but that will come later i guess. if anyone can help me or has any tips, please let me know. :)

HTML is a markup language, meaning it is used to give semantics to text. Thus, you cannot declare variables, as it is not a programming language. However, what you can do instead, is use a server-side language to "feed" in the data to each page, and store the data in a separate file or something.

Related

How to get the <body> item's class by python crawler?

I'm now designing my own index page, but I've met a problem.
Due to the custom in our country, I want to make my site grey at a large event, and I'm going to check the class of other sites' item to achieve this goal.
However, I'm not good at python crawler and can someone help me?
<body class="open-homepage-tts s-manhattan-index big-event-gray" style="">
<div>
<a
id="aging-total-page"
role="pagedescription"
aria-label="欢迎进入 百度一下,你就知道,盲人用户进入读屏幕模式请按快捷键Ctrl加Alt加R;阅读详细操作说明请按快捷键Ctrl加Alt加问号键。"
tabindex="0"
href="javascript:void(0)"
></a>
</div>
</body>
The code of the site is like this.
Moreover, I suppose the crawler will save the result in a *.txt, but I don't know how to let my *.js change the color when the result changes.
(If the problem can be solved using Javascript, it's also acceptable and better.)
Sincerely thanks
I searched for these questions in Google, but I found nothing I can really use.
(Frankly speaking, crawlers are not easy things to me.)

edit homepage text in source file

I am trying to fix some text on the homepage prototype created by a company for my dad. I viewed their prototype homepage in a browser, right-clicked, viewed and downloaded the page source, and created my own copy of it. Now, I intended to manually edit the text fields in the source files so that, in the end, we just have to send them copies of the edited source files with the fixed text fields.
If I move the to parts in the source that has the text I want to change, and I change this text, then, upon saving and opening the file in a browser, the changes are sometimes visible but other times not.
EG. here, if I change the specified text, the changes are not visible upon reopening.
<div class="elementor-element elementor-element-3efde4d elementor-widget elementor-widget-text-editor" data-id="3efde4d" data-element_type="widget" data-widget_type="text-editor.default">
<div class="elementor-widget-container">
<p>TEXT I WANT TO CHANGE</p> </div>
</div>
<div class="elementor-element elementor-element-509c8d79 elementor-align-left elementor-widget elementor-widget-button" data-id="509c8d79" data-element_type="widget" data-widget_type="button.default">
<div class="elementor-widget-container">
Now, while I do program in C++ and Python, I have no clue at all of HTML and web development. Let me know whether my approach is not going to work... There are certain links in the source as well, leading to the servers of the company. Looks like some text fields are somehow protected by these links?
Seeing the string elementor in the page source your browser gets from the server should tip you off strongly that the Elementor WYSIWYG tool is in use here, which would also necessitate a WordPress-based backend.
As such, it's a very safe assumption that the HTML you're seeing here is generated by a highly complex web of back-end technology which you wouldn't be privy to simply by visiting the publicly-facing part of this site.
To answer your questions directly:
Let me know whether my approach is not going to work
It's unlikely, as there are intricate interdependencies at play here that would probably break or cease to function as intended when manually updated outside the WYSIWYG editor that seems to be in place here.
There are certain links in the source as well, leading to the servers of the company. Looks like some text fields are somehow protected by these links?
"Protected" might be a bit of a misnomer, but it appears that the company that generated the initial website has dependencies on their own servers for resources in use on the site in question.
homepage prototype created by a company
This generally also indicates that you likely have some sort of contract or other agreement with this company to perform these changes, which you should work through them to have completed. Manually updating raw HTML source you've retrieved from your browser will not provide much value (if any at all) if this back-end complexity is indeed in place here.

Creating a JS form that outputs usable HTML

I'm working on creating a way for editors at my school's newspaper to be able to go to a page that would have places to type in info (ie. img url, titles, captions) and it would output HTML code that is already stylized.
So they type into the form in the title area: "Title"
And in the paragraph area: "This is a test"
and it would output something like this:
<div class="div1">
<span>Title</span>
<p>This is a test</p>
</div>
(div1 since since it's the first one you put and could add more later)
I've been looking into finding something like this, which I know it's possible, I just don't know where to start with this or what I would even google search. Any help would be greatly appreciated.
Thank you.
EDIT: We can't set up a Wordpress due to contracts with outside companies.
It depends on whether you want to implement a solution yourself or use what is already out there.
This type of functionality is already built into platforms like Wordpress and SquareSpace out of the box via a WYSIWYG (what you see is what you get) editor - similar to Stackoverflow's question box.
If you are looking to implement a custom solution then I would recommend looking into into markdown languages.
For example, here is one markdown javascript library called Remarkable:
https://github.com/jonschlinkert/remarkable.
This code snippet is taken directly from their github README
var Remarkable = require('remarkable');
var md = new Remarkable();
console.log(md.render('# Remarkable rulezz!'));
// => <h1>Remarkable rulezz!</h1>
As you can see the markdown text is passed to a render function and it translates into html.
Alex

PrestaShop MultiShops class name changing

I have 6 same shops but in different languages. Last developer(which not answering for me) created this theme and made "Free Shipping" image(Red one with a car) in the header on https://www.badetonnesite.de/, how should I display it in other shops/languages?
I know that in .de shop picture div gets <div class="free_shipping_de"></div> class name, but in others it is : <div class="free_shipping"></div>
I was looking in modules, in code files, but I cant find file to modify it. Maybe anyone can help for me with this problem? Where should I look and what should I do?
Thank you in advice !
Judging by the way the previous developer has done it, you should look in your translations, because the way he has done it is via
<div class="{l s='free_shipping'}"></div>
In your themes/default-bootstrap/header.tpl, line 98. Same goes for payment_logo and a few others. Which means that this div's class attribute will be obtained from theme's translations for the currently selected language.
So in your theme's translations (in your Back Office) you should look for free_shipping line and translate it for other languages.
I might add you're lucky he doesn't respond, because this is very poorly executed :) You should consider hiring someone to do it properly.
Also, you might want to instruct your server to forbid directory index, because right now it allows anyone to download the template files. Ideally I should be getting an error when trying to do this.

Script to search for a value and create a variable dynamically?

Sorry if the question in the title is a bit vague, here's what I'm trying to accomplish:
Is there a script out there that can search a page (or page source) for a particular determined value (for example, a product ID "1234") and insert it dynamically or on-the-fly into a variable which can be used anywhere on the page if called?
For example:
I'm working on a site that uses a shopping cart/feed platform that is closed source, so I can't grab variables I need (such as the product ID, product price, and order ID), as they are "locked down" (so to speak). And I need to be able to grab them and dynamically insert them into click trackers/pixel URL strings.
I'm not sure if this is possible or if this is a much larger task at hand.
A webpage might have many ways of showing a value, and it takes some human interpretation to determine what values are important. Example:
<div id="couponDisplay" class="inset hidden">Enter your coupon code: <input name="coupon"/></div>
<div id="cartRegion">
<div class="cart">
<div class="lolbx_quantityControl" data-initialValue="1" onKey="lolbx_notify()">
</div>
</div>
</div>
It may be that you're looking at a shopping cart page, and though the whole HTML is hundreds of lines long, the most important part of that page for you is the data-initialValue="1" part. That's less obvious to a computer. The first step for you might be the path the computer uses to reach the value you want, then see if you can replicate that.
I'm not sure if I understand what sort of system you're connecting to, though; I will say that using outside web services through "hacks" like this without their permission may be violating their terms of use (ie, grabbing Google Maps data to make your own map control with no Google branding)

Categories

Resources