Change icon based on posts from another page - html

Apologies if this has been asked before. I searched and couldn't find anything.
I have a basic landing page website that has an icon that links to "Hot Alerts", ie notifications of system outages. What I'm wondering is if there's a way to either change the icon or add a notification bubble (similar to Facebook notifications) if content on a Sharepoint blog has been updated in the past "X" hours.
Here's the icon I'm referring to:
Hot Alerts Icon
I've found examples of how to style the icon with CSS, but those all require manually entering the number of new notifications.
What I need is a way for the icon to "check" the sharepoint page for its most recent post when the landing page is loaded.
Most of my colleagues use Internet Explorer, but Chrome is creeping into the workflow.

What you need to use it the Javascript Object Model (JSOM). You will be able to read lists (for new posts) upon page loading and then showing or hiding the icon. A lot of example code to read lists can be found on SO.
If you want to use a 'bubble', take a look at sp.ui.notify (https://msdn.microsoft.com/en-us/library/office/ee550701%28v=office.14%29.aspx) methods to show an overlay notification popup on the page.

It's very unlikely this can be done with pure CSS. Any of the following languages will provide suitable solutions: JQuery, JS, PHP.
In PHP, you could use $_GET to place the variable in the URL. So one page would use $_GET to post the variable to the URL and the PHP file loading the page would use it to retrieve the variable from the URL.

Related

How to pass html options to another html file?

I am new in web development so please don't judge .
So let's say I have 2 html files ( x.html and y.html) (just 2 examples).
And on x.html the user can change the background from white to black using a button ( clicking the button will make the transition ) . What is want is that when the user has changed the value on x.html to appear the same on y.html ( black background aswell ).
So my question is?
What i need to do this and how can I make this?
Thanks for reading
Since you're new in HTML this might seem really difficult (it did to me when I was new). To actually build such applications I highly recommend that you learn CSS followed by JavaScript.
Once you know that you'll automatically know how you can pass "HTML Options" (aka variables) between files.
The actual answer is through cookies. You set the background color as a cookie in the browser from one HTML page, the other HTML page will read the cookie and set the background accordingly.
Cookies are shared between HTML pages.
You might find this tutorial about web storage API useful too if you want web storage instead of cookies.
The thing about web storage api is that the web storage API doesn't share information with your server. (It's explained in my tutorail that I've linked).
Tutorials for reference:
W3Schools' page on JavaScript cookies
My article on web storage API and tutorial series.
Use Javascript to set a cookie storing the change the user makes on your website.
When loading either x.html or y.html do a check with javascript to check if a cookie is set, and then display a background corresponding to the cookies value.
There are several ways of doing this, but I would suggest you to use google and learn how to create cookies with javascript and binding events to clicks on elements.
HTML is a static code which cannot hold parameters and send them along to other files.
The web is stateless, which means that every page request is separate and doesn't know about other requests. To maintain state between requests you need some kind of client storage which doesn't dissipate between requests, e.g a cookie, which is a small file saved on the client side as a key-value pair.
So, with regards to your question, you can use a plugin like jquery cookie to create a cookie which will store the background color, and pull that cookie (if exists) on any other page in your domain. Then you can use simple jquery DOM manipulation functions, such as .css to apply the desired background color to the element in question
you can use a plugin like jquery cookie to create a cookie which will store the background color, and pull that cookie (if exists) on any other page in your domain. Then you can use simple jquery DOM manipulation functions, such as .css to apply the desired background color to the element in question

HTML Form appearing on button press

I am a newbie to web development so sorry for my stupidity. I am actually creating a local website and I wanted to make a user profile page on that website. What I want to accomplish is that the profile page should be not be editable in the normal use case but when the user presses the Edit button (like in facebook), the fields become editable and a save button appears (basically a form but without reloading the page or any server side work). The user then updates the fields and saves. The save request will be sent to the server to update the database (can that somehow be done without reloading the page too ? i see facebook page does not reload when you edit and save).
So that is it. Waiting for a reply.
P.S. I think some javascript code will come to my rescue.
This is a very general question, so I can't do anything but give a general answer. I would highly recommend you learn jQuery.
jQuery makes it easy to manipulate the HTML and CSS from Javascript - which you'll need to do in order to show/hide the content and the forms for editing the content (or otherwise manipulate the code on the page in order to achieve what you want - there are various ways to do this, adriano's comment on your question lays out a good solution).
The specific part about sending such requests in the background is called AJAX, and jQuery has support for that too.

live content from html to html

I'm using UIWebView to display data from my organization data (publicize and legal), however, for instance, I would only want to pull specific data from the html file rather than pulling the whole URL. e.g. I want to pull the "News" section of the html and I want the user to only stay in that page, not enabling them to go into other parts of the website (e.g. home page, contact us) and allowing them to view the PDF article on the HTML file.
I've asked around and read up on DOM and screen scraping, but it seem that the data pulled are stored in a database instead.
Is there any way that I can pull just the HTML "News" section with the PDF URL into my customized HTML file and that it will be updated live (maybe every 30second it will refresh and pull information from the website so that the content and list of PDF are up to date)(e.g. added in 3new article into the main website, my customize HTML file will also refresh and pull information from website and update my article list)
If anyone can point to me a specific method that allow HTML to HTML data passing (live), that will be great and I can go do more research on it. Currently very lost and confuse as it is my first time doing this. Any help/feedback will be very much appreciated :)
EDIT: For example, google map or google search. I don't want to use the whole google webpage, just taking the important thing that i want like the search result or map display.
This will involve quite a lot of learning on your part - you'll have to learn HTML / the DOM / JavaScript and iOS/UIWebVIew.
Lets leave the live refresh part for now, I'll post another answer or edit to that later on.
That's not going to easy either (check out my earlier posting today on background execution issues that will affect you, unless the update is only to take place in the foreground
iOS Run Code Once a Day)
You will have to do something like this. And note that I've never tried this, nor seen posting of people who have on here, but in theory it should work, but there will be a lot of learning as I've said, and lots of trial and error. Its a big task when you're not familiar with these things.
1) Download the html page and load it in a UIWebView, but that UIWebView is hidden so the user's can't see it.
2) When the page has loaded its dom will be accessable.
3) You can use Javascript to access the DOM and look for the parts you want.
How you inject and run the Javascript in UIWebView can be answered in a separate question (this answer will get too long if all the exact details are included).
4) Remove the parts of the dom you are not interested in. Or use use events to make only those parts you are interested in appear, jQuery can probably help here.
5) Display the UIWebView
Alternatively the HTML could be saved to a file and string parsing could be used to search for the bits you are looking for and create a new text html file from it. I think this would get very messy, better to take advantage of the fact that UIWebView will parse the HTML page and create the dom for you.

How can I get a chrome extension to affect the webpage itself? (not the popup)

I have been reading the dev guide but haven't been able to work out how to put my own codes into webpages
I know it is possible because AVG uses it (in it's link scanner), and FastestChrome extension uses it too (highlight something and a link to a search pops up).
I have a backgrounded page but I can't get it to effect the webpages I go on (permissions are correct as I can get css to effect)
I am probably missing something really simple :/
It's not intuitively presented in the documentation but your background page can not access the current webpage b/c they are in different contexts. In other words the background page is it's own separate page so it has no access to any other page's DOM.
If you want to affect the page the user is viewing in the browser you will need to use what is referred to as a "content script".
If you want to communicate between content scripts and the background page you will need to refer to the message passing API. Check out my extension's source code for reference. I do exactly that.
Just remember...
Background Page: used for general logic in your extension, not anything page specific.
Content Scripts: are loaded into every page the user sees, and can manipulate that specific page.
Those probably use Content Scripts to inject Javascript into webpages. These scripts run in the context of the web pages and can access the DOM.
You can either define a script to always run in a web page by declaring the script file in the extension manifest, or you can use your background page to inject a script when needed.

One page website and linking

Ok guys, what I can't seem to grasp is how, on a one page website, you link to certain pages/divs while using the scrollto function.
if you look at Ultranoir.com
You can see the site is built with the one page format but if you watch the url field, it navigates to subfolders etc, but is still loading all content dynamically. How do they achieve this effect while still keeping it so clean and ordered? on my current site it all stays at www.url.com/index.html even when I navigate pages. any help? thanks!
They are using hash tags to load different parts of their pages dynamically. if u add i.e. index.html#!/blog or index.html#!/about
you can parse the url client-side using javascript and load the correct content through ajax based on the url.
Check out this page to see an example implementation of this functionality using php and JQuery: http://www.queness.com/post/328/a-simple-ajax-driven-website-with-jqueryphp
They do it by abusing the fragment identifier. A modern approach would make use of pushState