Page 7 of 8 FirstFirst ... 5678 LastLast
Results 61 to 70 of 80

Thread: Turn simple javascript code to a button

  1. #61
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Ok John I presumed you meant add this after the last code and I presumed right, no dot and the images load perfectly, tested it in FF too, works great and if you look at it on the forum can you use Chrome if you have it? Only thing is now if I can figure out how to get ride of the two dots in the personal profile? Doesn't bother me but rest assured someone will find it and want it gone? I've tried several CSS removal codes like we did with the shoutbox button but to no avail.
    Last edited by JRR; 04-25-2015 at 07:52 PM.

  2. #62
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    No, and it's not working here in Chrome, it might work in IE (shouldn't though really). I meant add only the highlighted section to the head of the page where the non-highlighted portions already exist. So, get rid of what you just added, go back to the beginning of the page and find:

    Code:
    <!DOCTYPE HTML>
    	<!--[if IE 7]><html class="ie7"><![endif]--><!--[if IE 8]><html class="ie8"><![endif]--><!--[if IE 9]><html class="ie9"><![endif]--><!--[if gt IE 9]><!--> <html> <!--<![endif]-->
    	<head>
    		<script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    		<script type="text/javascript">
    if(/postimage_id/.test(location.href)){location.href = 'about:blank';}
    </script>
    Make that look like so (addition highlighted):

    Code:
    <!DOCTYPE HTML>
    	<!--[if IE 7]><html class="ie7"><![endif]--><!--[if IE 8]><html class="ie8"><![endif]--><!--[if IE 9]><html class="ie9"><![endif]--><!--[if gt IE 9]><!--> <html> <!--<![endif]-->
    	<head>
    		<script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    <script type="text/javascript">
    if(window.addEventListener){window.removeEventListener('DOMContentLoaded',postimage_insert,false);}else if(window.attachEvent){window.detachEvent('onload',postimage_insert);}
    </script>
    		<script type="text/javascript">
    if(/postimage_id/.test(location.href)){location.href = 'about:blank';}
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #63
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    OK John got a little lost! That code went in the Forum Wrapper that controls all template pages and I ran it in IE11 and FF with success! No Dots anywhere! Only chrome to test now!~

    OK John I've discovered a little hitch and on this one I think we'll have to live with it as it is? One can go to their profile and you have a setting that you can choose that is just for the NR page and it's the Posting Default and you can choose Preview or BBCode . I have put this on two of my forums and have my posting default in my profile in the Preview mode and I can use the image insert on the NR with no problem at all.

    But on one of my forums with it in the Preview mode the image link will not insert at all, isn't that weird? I can go change it to BBCode and it works like a charm. Also I can leave it in the Preview mode and before I hit the Insert Image I can hit BBCode on the bottom left corner of the NR posting page and it works fine too.

    The forum in question is this one:

    http://thescooterprofessor.proboards.com/

    Not worried about it just don't understand why 3 forums work fine in Preview and this one doesn't?

    Edit: This is a PB issue, the support board is lit up with problems of this nature, and they are working on it, all is well, Thanks John!
    Last edited by JRR; 04-25-2015 at 11:24 PM.

  4. #64
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, that's right now. It will prevent the dot and the default "Add image to post" link from ever getting written to any page. So you can remove (not use) all the css styles that you were using to hide those items. Also, in the script we had for the normal reply only page, that can now be simplified further to be just:

    Code:
    <script type="text/javascript">
    jQuery(function($){
    	$('a[onclick="postimage_upload(1);"]').on('click', function(){
    		if(!$('#menu-item-bbcode').hasClass('ui-active')){
    			$('#menu-item-bbcode a').get(0).onclick();
    		}
    	});
    });
    </script>
    Now, about it working with the bbcode editor versus the preview editor, I don't know why. In chrome here on the test forum it only works in the bbcode editor. So I wrote it so that if it's in the preview editor and you click the 'Insert Image' button, it will switch it to the bbcode editor. It should do that in all browsers - does it? If not I think I can fix that. Then later, if they ever fix the discrepancy between the two modes of the normal reply editor, then we can remove the above code completely.



    Ah - it's not working properly on the scooter professor because where you have:

    Code:
    <script type="text/javascript">
    jQuery(function($){
    	$('a[onclick="postimage_upload(1);"]').on('click', function(){
    		if(!$('#menu-item-bbcode').hasClass('ui-active')){
    			$('#menu-item-bbcode a').get(0).onclick();
    		}
    	});
    	$(window).on('load', function(){$('a[href^="javascript:postimage_upload("]').parent('div').remove();});
    });
    </script>
    There is an errant opening script tag (red) ahead of that which makes the script not parse:

    Code:
    <script>
    
    
    
    
    
    
    
    
    
    				</tbody>
    			</table>
    		</div>
    	</div>
    
    
    <script type="text/javascript">
    jQuery(function($){
    	$('a[onclick="postimage_upload(1);"]').on('click', function(){
    		if(!$('#menu-item-bbcode').hasClass('ui-active')){
    			$('#menu-item-bbcode a').get(0).onclick();
    		}
    	});
    	$(window).on('load', function(){$('a[href^="javascript:postimage_upload("]').parent('div').remove();});
    });
    </script>
    Last edited by jscheuer1; 04-26-2015 at 04:21 AM. Reason: detail
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #65
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    First things first. It works fine in both the QR and NR areas without having to switch to the BBCode mode except for scooter professor. That forum is the only one where one has to manually switch to the BBCode mode.

    Now John either I'm blind or am in the wrong place but I can't for the life of me see that errant <script> tag? Here is the entire code for that page:

    Code:
    <div class="container new-area wysiwyg-area">
    	<div class="title-bar">
    		<h2>$[title_bar]</h2>
    	</div>
    	<div class="content cap-bottom">
    		$[form.header]
    			{if $[form.created_by_guest_name.input]}
    				<div class="guest_name">
    					<label>Guest Name:</label>
    					$[form.created_by_guest_name.input]
    				</div>
    			{/if}
    			<div class="subject_line">
    				<table>
    					<tr>
    						<td class="subject">
    							<label>Subject:</label>
    						</td>
    						<td>
    							<div class="controls">
    								$[poll_button]
    								$[event_button]								
    								$[options]
    							</div>
    							<div class="subject_input">
    								$[form.subject.input]
    							</div>
    						</td>
    					</tr>
    				</table>
    			</div>
    			{if $[form.recipients.input]}
    				<div class="recipients">
    					<label>Recipients:</label>
    					$[form.recipients.input]
    				</div>
    			{/if}
    			{if $[participant]}
    				<div class="participants">
    					Participants:
    					<span class="$[participant_list_class]">
    						{foreach $[participant]}$[participant]$[participant.comma] {/foreach}
    					</span>
    					{if $[change_participants_button]}($[change_participants_button]){/if}
    				</div>
    			{/if}
    			<div class="editor ui-helper-clearfix">
    				$[form.message.input]
    			</div>
    			{if $[form.updated_reason.input]}
    				<div class="edit_reason content-box pad-all-double">
    					<label>Edit Reason (optional):</label>
    					<div>$[form.updated_reason.input]</div>
    				</div>
    			{/if}
    			{if $[posting_errors]}
    				<div class="posting-errors">$[posting_errors]</div>
    			{/if}
    			$[captcha]
    			<div class="submit content-box pad-all-double">
    				<span class="float-right">$[form.post.button]<a href="javascript:void(0);" onclick="postimage_upload(1);" class="button">Insert Image</a></span>
    				<span class="note small left-item" id="$[transcription.id]"></span>
    			</div>
    		$[form.footer]
            <style type="text/css">
    .Radio-site label { font-weight: normal; }
    </style>
                    <script type="text/javascript">
    function whichsite(form){
                    var sites = form.elements.site, i = sites.length;
                    while (--i > -1){
                                    if(sites[i].checked){
                                                    return sites[i].value;
                                    }
                    }
    }
    </script>
    <form action="#" onsubmit="window.open(whichsite(this), '_blank'); return false;">
        <div style="color: black" class="Radio-site"><center><b><font color ="3f9249">Where do you need to go?</b></font></center>
    <p align="center"><label><input type="radio" name="site" value="http://yahoo.com/">Yahoo</label>
    <label><input type="radio" name="site" value="http://google.com/">Google</label>
    <label><input type="radio" name="site" value="http://amazon.com/">Amazon</label>
    <label><input type="radio" name="site" value="http://cnn.com/">CNN</label>
    <label><input type="radio" name="site" value="http://espn.go.com/espnradio/play?s=espn">ESPN Live</label> 
    <label><input type="radio" name="site" value="http://www.youtube.com/">You Tube</label>
    <label><input type="radio" name="site" value="https://www.facebook.com/">Facebook</label> 
    <label><input type="radio" name="site" value="https://twitter.com/">Twitter</label> 
    <label><input type="radio" name="site" value="http://www.myspace.com/">MySpace</label> 
    <label><input type="radio" name="site" value="http://s499.photobucket.com/">Photobucket</label><br/>
    <label><input type="radio" name="site" value="https://signin.ebay.com/">Ebay</label>
    <label><input type="radio" name="site" value="http://on.aol.com/">AOL</label>
    <label><input type="radio" name="site" value="http://windows.microsoft.com/en-US/hotmail/home">Hotmail</label>
    <label><input type="radio" name="site" value="https://accounts.google.com/ServiceLogin">Gmail</label>
    <label><input type="radio" name="site" value="http://tunein.com/radio/977-70s-Rock-s48937/">Classic Rock</label> 
    <label><input type="radio" name="site" value="http://www.iheart.com/live/2513/?autoplay=true">Country</label>    
    <label><input type="radio" name="site" value="http://www.kdfc.com/pages/15744854.php">Classical</label>
    <label><input type="radio" name="site" value="http://www.weather.com/maps/maptype/currentweatherusnational/uscurrentweather_large.html">Weather Channel</label>   
    <label><input type="radio" name="site" value="http://affiliates.foxnewsradio.com/radio/player.html">Fox News</label><br/>
    <label><input type="radio" name="site" value="http://www.timeanddate.com/worldclock/custom.html?sort=1">World Clock&nbsp;<img src="http://www.jr-richscooterdoc.com/Vbanlogo/world.gif"border="0" alt="world.gif"/></label>
    <label><input type="radio" name="site" value="http://www.tacomaworld.com/forum/tirecalc.php?tires=130-60r13-130-70r13">Tire Size Calc.</label> 
    <label><input type="radio" name="site" value="http://www.harborfreight.com/#">Harbor Freight</label>
    <label><input type="radio" name="site" value="http://www.bikebandit.com/">Bike Bandit</label>
    <label><input type="radio" name="site" value="http://www.motorcycle-superstore.com/">Motorcycle Superstore</label>        
    <center><input type="submit" value="Select"></center></p></div><br/>
        </form> 
     </div>       
    	</div>
    {if $[summary]}
    	<div class="container $[summary.class]">
    		<div class="title-bar">
    			<h2>$[summary.title]</h2>
    		</div>
    		<div class="content cap-bottom">
    			<table class="list">
    				<tbody class="$[list_class]">
    					$[summary]
    				</tbody>
    			</table>
    		</div>
    	</div>
    {/if}
    
    <script type="text/javascript">
    jQuery(function($){
    	$('a[onclick="postimage_upload(1);"]').on('click', function(){
    		if(!$('#menu-item-bbcode').hasClass('ui-active')){
    			$('#menu-item-bbcode a').get(0).onclick();
    		}
    	});
    });
    </script>
    For your question of does it switch to the BBCode editor the answer is yes except scooter professor and I wouldn't know about Chrome? I refuse to put chrome on my computer.

    I also have had a user that uses Safari say this doesn't work for him but I haven't had a answer yet as to if it works if he switches it to the BBCode editor himself? I also have a Opera user that I'm wondering about, oh those oddballs! LOL

    The Safari user is on this forum which works just fine for me using IE and FF?

    http://scooterdoc.proboards.com/
    Last edited by JRR; 04-26-2015 at 01:07 PM.

  6. #66
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm a little confused now. Let's try to clear this up. On http://thescooterprofessor.proboards.com/ (SCOOTER PROFESSOR) if I go to a post and use normal reply in preview mode and then use the postimage Insert Image link that looks like a button, in both IE 11 and current Chrome and Firefox, it lets me upload to the popup, but nothing appears in the editor. If I'm in bbcode mode, it works fine. Are you experiencing different?

    Also, again in all those browsers on SCOOTER PROFESSOR on its normal reply page, if I do a view source (CTRL - U) for the page and look for postimage_upload(1) (using CTRL - F) and go to the second occurrence, I see this (red added to the errant opening script tag, bold added to the search text):

    Code:
    <script>
    
    
    
    
    
    
    
    
    
    				</tbody>
    			</table>
    		</div>
    	</div>
    
    
    <script type="text/javascript">
    jQuery(function($){
    	$('a[onclick="postimage_upload(1);"]').on('click', function(){
    		if(!$('#menu-item-bbcode').hasClass('ui-active')){
    			$('#menu-item-bbcode a').get(0).onclick();
    		}
    	});
    });
    </script>
    Not sure if you have seen that or even looked for it.

    Now, this is not the template of course, that might look differently. However, it is how the page is being served to the browser, or at least how the browser is parsing the page as served to it. And of course, with the red opening script tag there where it is, the script below that is not used because it isn't parsed correctly - the browser sees all this stuff before it that looks like garbage once inside the red script tag.

    If that script were to work, if the normal reply editor is in preview mode when the Insert Image button is clicked, it will switch to bbcode mode in time to work just as well as if it were in bbcode mode when the Insert Image button was clicked. That script does work and does this on the test forum. (checked in IE 11 and current Chrome only, but I assume Firefox would do that there too)

    Now we might be seeing the same things and misunderstanding each other's explanations, or of course it's possible that we could be doing the exact same thing in the exact same browser(s) and be seeing different results, but it's not real likely. If it is happening, it's probably due to settings in those browsers and/or different network conditions.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #67
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I'm a little confused now. Let's try to clear this up. On http://thescooterprofessor.proboards.com/ (SCOOTER PROFESSOR) if I go to a post and use normal reply in preview mode and then use the postimage Insert Image link that looks like a button, in both IE 11 and current Chrome and Firefox, it lets me upload to the popup, but nothing appears in the editor. If I'm in bbcode mode, it works fine. Are you experiencing different?

    Yes to this and it is only at scooter professor. But it works like a champ in the QR. If I switch to BBCode which one can do at the bottom of the left in the NR posting area it also works like a champ. It's exactly like your quote above.

    But I have the exact same code in my test forum and at these two forums:

    http://scooterdoc.proboards.com/

    http://itistheride.boards.net/

    At the test forum and on these two forums it works like a dream in the Preview editor even in the NR posting page, ONLY on Scooter Professor it does not? Weird?

    On the <script> tag I'm lost so I'll ask this, is it something I can remove and if so where? I don't have a clue as to how or where it happens? But the question is why does this not happen at the other forums with the exact same coding? Why do they work in the Preview mode and Scooter Professor doesn't? Is it possible that I've got some little something elsewhere that makes only this forum do this?


    Edit: I just for kicks tried one of the other forums using FF. Now when you click on the Insert Image button on the NR you can watch a little black dotted circle appear just for seconds, it's the same thing one sees on any PB forum when switching from Preview to BBCode mode. I knew the image link would post which it did.

    I went to Scooter Professor again using FF and no dotted circle which we both know is a indication of the editor switching from Preview to BBCode. It didn't happen at Scooter Professor, weird?
    Last edited by JRR; 04-26-2015 at 09:36 PM.

  8. #68
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, sounds like we are closer together than I thought. I can't know where that errant opening script tag is coming from specifically. Most likely it is in the SCOOTER PROFESSOR normal reply template. If you can copy that template and paste it into a text only editor and search for:

    <script>

    It looks like there are only 6 (possibly less, one or more might be in the full template) of them. Look for one which has no corresponding:

    </script>

    tag before a new opening script tag occurs. Get rid of it. Like if you have:

    Code:
    <script>
    anything and any amount of stuff can be here but if there is not a closing </script> tag and then you have another opening one like -
    <script type="text/javascript">
    Well then, the red one has to go.


    All closing script tags on the page exactly match:

    </script>

    There are 60 of those in the served source code.

    Opening tags can look different, but the ones on the page all start out with:

    <script

    There are 61 of those on the page - one too many. You or somebody has to find the extra one in the template, the one without a closing </script> tag and remove it or else setup some way I can see the template to find it for you.

    If it's any help, a tag like that is usually left over from a script you removed, you took everything else away, but just missed the opening tag. Basically a sort of typo. But it's possible it's there because of some other reason. Regardless, it is preventing the other script from working, it has to be removed or at least worked around.

    You can just put a closing tag before the opening tag. So, where you have:

    Code:
    <script type="text/javascript">
    jQuery(function($){
    	$('a[onclick="postimage_upload(1);"]').on('click', function(){
    		if(!$('#menu-item-bbcode').hasClass('ui-active')){
    			$('#menu-item-bbcode a').get(0).onclick();
    		}
    	});
    });
    </script>
    Make that:

    Code:
    </script>
    <script type="text/javascript">
    jQuery(function($){
    	$('a[onclick="postimage_upload(1);"]').on('click', function(){
    		if(!$('#menu-item-bbcode').hasClass('ui-active')){
    			$('#menu-item-bbcode a').get(0).onclick();
    		}
    	});
    });
    </script>
    That will probably fix it. Do that only on SCOOTER PROFESSOR.

    But it would be better to find the extra tag and remove it.
    Last edited by jscheuer1; 04-27-2015 at 12:24 AM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #69
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I finally found it John! When you go to the NR template section it is actually divided into three sections, The Posting Page where the button and the bottom javascript code goes, the Thread Summary and the Conversation Summary.

    I combed the Posting Page until I was nearly blind for that <script> tag and couldn't find it. I even went as far as removing the entire template and copying and pasting one from one of my other forums and still the same oh same oh.

    So I thought maybe this is in one of the other parts of the Posting page template and sure enough the unwanted tag was at the very bottom of the Thread Summary! Removed it and all is fine! Works like a charm!

    BTW do you know anything about Safari?

  10. #70
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Not a lot. I have Safari Win. It often can be used to troubleshoot Safari in general, though almost no one who uses Safari uses it in Win and the Mac versions are a little different. Also, many Safari users are using outdated versions. But given all that, if you can describe the problem that the Safari user is having, I can try to duplicate it and/or figure out a likely cause/solution.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Please write a simple javascript code for me
    By laperashvili in forum JavaScript
    Replies: 2
    Last Post: 06-18-2012, 03:10 PM
  2. adding rollover button to javascript code
    By Repatilian in forum JavaScript
    Replies: 6
    Last Post: 12-04-2011, 10:28 AM
  3. Help with javascript code to make next and previous button dissapear
    By ajmancilla in forum Looking for such a script or service
    Replies: 1
    Last Post: 02-07-2011, 03:00 PM
  4. Looking for a simple Javascript code for a web board
    By donelian in forum Looking for such a script or service
    Replies: 1
    Last Post: 08-15-2007, 10:24 PM
  5. How to turn a menu into a javascript file?
    By Eternal_Howl in forum JavaScript
    Replies: 4
    Last Post: 07-23-2007, 07:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •