logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
SST  
#1 Posted : Wednesday, May 17, 2017 4:16:35 AM(UTC)
SST


Rank: Newbie

Joined: 6/29/2015(UTC)
Posts: 4
United States

I created some code back in the SC 4.x days that would cycle through background images. This doesn't work in 5.x or 6.x with the changes made which load a byte array of these payloads.

So..... How would you suggest I go about replicating this in 6.x? My goal is to have a different background JPG image loaded each time the guest page is refreshed in the browser.

Thanks for any suggestions!
Scott  
#2 Posted : Thursday, May 18, 2017 10:17:55 AM(UTC)
Scott


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 3/28/2014(UTC)
Posts: 2,399
United States

Thanks: 3 times
Was thanked: 297 time(s) in 255 post(s)
So, I actually wrote an extension that does this basically as a prank to mess with people's sandboxes in the office, the extension itself is very simple, just a Manifest.xml and an Initializer.js with an array defining different image URLs.

Manifest.xml:
Code:

<?xml version="1.0" encoding="utf-8"?>
<ExtensionManifest>
	<Version>1.0</Version>
	<Name>Rotating Guest Background</Name>
	<Author>ConnectWise Labs</Author>
	<ShortDescription></ShortDescription>
	<Components>
		<ClientScriptInitializer SourceFile="Initializer.js" />
	</Components>
</ExtensionManifest>



Initializer.js:
Code:

SC.event.addGlobalHandler(SC.event.PreRender, function (eventArgs) {
	if (SC.context.pageType == 'GuestPage'){

		var backgrounds = [
			//"https://i.redd.it/7ru2j9ndmfdy.jpg" //landscape
			//"https://i.imgur.com/5ttHWpO.jpg", //dooom
			//"http://i.imgur.com/QQ3O6PO.jpg", //jurassic toy story
			"http://1.bp.blogspot.com/-7pwdKWm7xHQ/UX1WERYbT4I/AAAAAAAALew/fZPWI_m6Hb4/s1600/vince-mcmahon-walk.gif"//, vince mcmahan walk
			//"http://i.imgur.com/EGqqQR9.gif", 
			//"https://lh5.googleusercontent.com/-uITxt6RcH1M/VN9ulYkzOCI/AAAAAAAAA28/aU4X4fQ4_nE/w803-h324-no/greenland-sail.gif",
			//"http://i.imgur.com/ypAvYH2.gif", //putin mcmahon
			//"http://i.imgur.com/eFdWtHA.gif", //mcmahon on floor 
			//"https://media.giphy.com/media/3oEduKOlpkEizFm9bO/giphy.gif" //mcmahon lewendovski
			//"http://i.imgur.com/ThDLxEW.jpg", //space 
			"http://i.imgur.com/TGa9TfT.jpg", //tsunami
			"http://i.imgur.com/gGClkiy.jpg"//, business guy
			//"http://i.imgur.com/wvunc.jpg", //lightning cat
			//"http://i.imgur.com/d5wydMZ.gif", //louis ck
			//"http://i.imgur.com/ROCmbwF.jpg", //space sloth
			//"http://i.imgur.com/DqYDvbV.jpg", //t-rex
			//"http://i.imgur.com/NoN1Deb.jpg", //sloth
			//"http://i.imgur.com/tA1NBkt.jpg", //it's always sunny
			//"http://i.imgur.com/GEjml4N.jpg", //it's always sunny
			//"http://i.imgur.com/SDTZI.jpg", //pandas
			//"http://i.imgur.com/4HF3G.jpg", //gooby
			//"http://i.imgur.com/mHRQt.jpg", //oscar
			//"http://i.imgur.com/M9Xpb.jpg", //astronaut on fire
			//"http://i.imgur.com/aD6Obgj.gif"//, //star trek
			//"http://i.imgur.com/ZxoB1WR.gif" //numberwang
			//"http://i.imgur.com/GPueP2k.gif" //snow
		];
		var rnd = Math.floor((Math.random() * backgrounds.length) + 0);
		
		($('.ContentPanel')).style.backgroundImage = "url('" + backgrounds[rnd] + "')";
	}
});


Most of the images are commented out so they don't actually rotate unless you uncomment/change/add more image URIs.

Also, if you decide to use this, please keep in mind that it will increase the load time for the Guest page.

I suppose if you wanted to be a stickler and say this doesn't necessarily load a different one each time, just a random pre-selected one, you'd be right.

You could make a call to something like reddit.com/r/wallpapers and pull a random result, although you might get some unsavory stuff.

Edited by user Thursday, May 18, 2017 10:28:21 AM(UTC)  | Reason: some images were less than professional

ScreenConnect Team
SST  
#3 Posted : Thursday, May 18, 2017 2:36:01 PM(UTC)
SST


Rank: Newbie

Joined: 6/29/2015(UTC)
Posts: 4
United States

Originally Posted by: Scott Go to Quoted Post
So, I actually wrote an extension that does this basically as a prank to mess with people's sandboxes in the office, the extension itself is very simple


This is great Scott. Thank you. I haven't made an extension before but this will be a great way to get my feet wet. I'll give it a try and let you know how it goes. Smile

SST  
#4 Posted : Friday, May 26, 2017 4:02:21 PM(UTC)
SST


Rank: Newbie

Joined: 6/29/2015(UTC)
Posts: 4
United States

Works great. Thanks again.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.