Tag Archive for link

hpricot xpath string to grab favicon for a website

hpricot.at("/html/head/link[@rel='shorcut icon']").get_attribute('href')

source

*nix symbolic link

ln -s sourcefile destinationfile

source

PHP Create Google Map Directions Link

function googleMapLink($to, $from) {
$destinationAddy = '&daddr='.urlencode($to->getAddress().' '.$to->getCity().' '.$to->getState());

if($from) {
$startAddy = '&saddr='.urlencode($from->getAddress().' '.$from->getCity().' '.$from->getState());
} else {
$startAddy = '&saddr=';
}

return htmlentities("http://maps.google.com/maps?f=q&hl=en&{$startAddy}{$destinationAddy}");
}

source

Remove Attribution Link from the Footer

// Remove thesis attribution link
remove_action('thesis_hook_footer', 'thesis_attribution');

source

Twitter @reply and urls to links

$text = utf8_decode( $results[ $i ][ "text" ] );
$text = preg_replace('@(https?://([-w.]+)+(d+)?(/([w/_.]*(?S+)?)?)?)@', '<a href="$1">$1</a>',  $text );
$text = preg_replace("#(^|[
])@([^ "

<]*)#ise", "'1<a href="http://www.twitter.com/2" >@2</a>'", $text);
$text = preg_replace("#(^|[
])#([^ "

<]*)#ise", "'1<a href="http://hashtags.org/search?query=2" >#2</a>'", $text);

source

PHP 文字列から自動でリンク作成 mbex PbItem

// pbItemで使用 %5p%を <a href="[url]5[tail]">5</a> に置き換える
function autoLink($tag, $url, $tail = null, $max_page = 10){
for ($i=1; $i <= $max_page; $i++) {
$link = "<a href='".$url.$i.$tail."'>".$i."</a>";
$tag = preg_replace("/%".$i."p%/", $link, $tag);
}
// マッチしなかったページは消去される
$tag = preg_replace("/%[0-9]+p%/", "", $tag);
//preg_match("/%(.*?)%/",$tag,$matches);
return $tag;
}

source

Open a link in a cell by clicking anywhere on that cell’s row

$("tr.TrClassName").click(function(){
newURL = $(this).children("td.tdClassName").children("a").attr("href");
//window.open.location.href = newURL;  // Choose one: Open in the same page
window.open(newURL); // Choose one: Open in a new page
return false; // Stops the click that is over the link to open 2 different copies of the  same linked page.
});

source

AS3 button link

btnname.addEventListener(MouseEvent.CLICK, myBtnClicked);

function myBtnClicked(e:MouseEvent):void {
try {
navigateToURL(new URLRequest("/index.php"), "_self");
} catch (e:Error) {
trace("Error occurred!");
}
}

source

Create Links To Page

<h1>New link</h1>

<% form_for(@link) do |f| %>
<%= f.error_messages %>

<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= select("link", "content_id", Content.find(:all).collect {|c| [ c.title, c.id ] }, { :include_blank => true }) %>
</p>
<p>
<%= f.submit "Create" %>
</p>
<% end %>

<%= link_to 'Back', links_path %>

source

Rollover image buttons to WYSIWYG editors like TinyMCE, FCKEditor, Kupu

/**
* The following jQuery snippets allows use of roll over image effects in
* WYSIWYG HTML editors such as TinyMCe, FCKEditor and Kupu.
*
*
*
* Criteria which must be met:
*
* 1) This javascript is linked in
*
* 2) Image has two versions with URLs lik
*
*    - images/my_button.gif
*
*    - images/my_button_rollover.gif
*
*
*
* 3) You will have WYSIWYG editor style Rollover image link (a.image-button-link) created
*
* Creation of a button in WYSIWYG editor:
*
* - Upload my_button.gif and my_button_rollover.gif to your site
*
* - Place my_button.gif image to the document in your WYSIWYG editor
*
* - Click image, make a link of it
*
* - Apply style "Rollover image" to the link
*
* - Reload the page
*
* When the page is loaded, this snippet adds and loads hidden rollover
* button images.
*
*
*
*/function bootstrapImageButtonRollOvers() {
jq("a.image-button-link").each( function() {
var t= jq(this);

var img = t.find("img");

var imageSrc= img.attr("src");

// Construct URLs
var hoverSrc = imageSrc;

var	filename = imageSrc
var splitted = filename.split(".gif");
hoverSrc = splitted[0] + "_rollover.gif" + splitted[1];

// Create hidden hover image and roll over image holders
var hoverButton = jq('<img src="' + hoverSrc + '" style="display:none" class="hover-image">');

hoverButton.insertBefore(img);

// Hide src image
img.addClass("normal-image");

var normalImage = img;
var hoverImage = t.find(".hover-image");

t.bind("mouseenter", function(e) {
normalImage.css("display", "none");
hoverImage.css("display", "inline");
return true;
});

t.bind("mouseleave", function(e) {
normalImage.css("display", "inline");
hoverImage.css("display", "none");
return true;
});
});
}

source