This blog is subject the DISCLAIMER below.
Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Thursday, March 03, 2011

"Note in (Google) Reader" issue Fix

Probably you're familiar with the sharing button (at least on Firefox and Chrome) offered by Google reader to help you share stuff that don't have feeds. Today, for some reason I realized that mine wasn't working!

GReader

 

After tweeting about it, thanks to Flavio Gomes and @mtobis, I realized what went wrong. Seems like the JavaScript file used by the button was updated, without updating the button script accordingly.

 

To solve this, all you have to do is set _IS_MULTILOGIN_ENABLED a variable that's not defined (but used) in the script file in the button script. So add something like:

_IS_MULTILOGIN_ENABLED=true;


// or


_IS_MULTILOGIN_ENABLED=false;


// or better


_IS_MULTILOGIN_ENABLED=((typeof(_IS_MULTILOGIN_ENABLED)=="undefined")?false:_IS_MULTILOGIN_ENABLED);




 



at the beginning of the button script, just to set _IS_MULTILOGIN_ENABLED before it's accessed as "undefined" in the script.

.. more.

Saturday, July 10, 2010

Creating a simple Open Search Provider/Plug-in

Yesterday, I needed to check/search my delicious bookmarks more than once. I then realized that delicious have its a search plug-in as a part of a tool bar (along with other bookmarking tools, few search tools, though), which -I guess- loads all your bookmarks to browser & make them available for search.

As I’m not so much into too much plug-ins, specially if they load lots of data (in contradiction to Pointy-haired Boss) , not to mention that I won’t need bookmarks when I’m offline, anyway, I decided I should create my search provider.

Creating the provider:

Here’s an example:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
   <ShortName>My Delicious</ShortName>
   <Description>Search Shady’s Delicious Bookmarks</Description>
   <Tags>Delicious Bookmarks Search Favorites</Tags>
   <Image width="16" height="16" type="image/x-icon">http://delicious.com/favicon.ico</Image>
   <Url type="text/html"
        template="http://delicious.com/search?p={searchTerms}&amp;context=userposts|m.shady|&amp;lc=1"/>
</OpenSearchDescription>

Away from the fact that I badly need a WYSIWYG code hi-lighter, let’s check that XML. First the ShortName which appears in your search box, something like this:

Click to Enlarge Description and Tags are obvious, & I think optional too.

Image is the small icon that appear beside when you select your provider (check the pic above again). You can either supply it as a URL to an image file (usually .ico or .png) or you can replace it with the base 64 string of the image (though I wasted quite sometime to make that work), like:

<Image width="16" height="16">data:image/x-icon;base64,AAA…AAA==</Image>

Finally, URL note that I’m using {SearchTerms} to pass the string typed in the search box. You can send other parameters to your search page. You might want add another URL for suggestions, here I’m only providing the search URL.

Using the provider:

To add the provider to your browser (as far as I’m concerned it works fine for Firefox & IE) you have one of two options:

Adding it as a suggested search provider: This can be done by adding a single line in your page <Head> tag, note that the attribute title in the below tag refers to the name appearing in the list as [Add “title”], check the image below the tag.

<link rel="search"
           type="application/opensearchdescription+xml"
           href="http://localhost/SearchProviders/delicious.xml"
           title="Delicious" />

Click to Enlarge

Using JavaScript to add the provider: The other available option is to add the provider using scripting, here’s an eg of how you can do that:

<a href="#" onclick="window.external.AddSearchProvider('http://localhost/SearchProviders/delicious.xml')">Add delicious Search to your browser</a>

Clicking a link like the one above will pop up a windows asking if you want to add the search provider.

References: http://www.opensearch.org

.. more.

Wednesday, August 19, 2009

Disabling the mouse right click : JavaScript

As mention in the title here is code to disable the right click for the mouse in the browser (tested in IE ).
The code is JavaScript ,the code is readable and can be used to handle other mouse events.
just call DisableRightclick() once in your page.



[script language="javascript" ]
var IE;
var NN;
function right(click)
{
if(IE && (event.button==2 || event.button==3))
{
alert("The right click has been disabled here.");
return false;
}

if(NN && (click.which==2 || click.which==3))
{
alert("The right click has been disabled here.");
return false;
}

return false;
}

function
DisableRightclick()
{


if(navigator.appName=="Microsoft Internet Explorer")
{
IE=true;
}

if(navigator.appName=="Netscape")
{
NN=true;
}


if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
document.onmousedown=right;
document.onmouseup=right;
window.document.layers=right;
}
[/script]

.. more.

Check Acrobat Reader (PDF) installed : JavaScript with IE

Here you can find helper function I got by Google and do some changes to it to be suitable for me .It checks if the Acrobat Reader is installed in the browser or not (it tested on IE6 and IE7 with Acrobat 6 and 7).
Function returns : true for OK else false .

function CheckPDF()
{
var isInstalled = false;
var version = null;
if (window.ActiveXObject)
{
var control = null;
try {
// version 7
control = new ActiveXObject('AcroPDF.PDF');
}
catch (e)
{
// Do nothing
}
if (!control)
{
try {
//version 6
control = new ActiveXObject('PDF.PdfCtrl');
}
catch (e)
{
return false ;
}
}
if (control)
{

return true ;
}
else
{
return false ;
}
}
}

.. more.