Skip to content

Instantly share code, notes, and snippets.

@tomohiro
Created November 20, 2009 12:13
Show Gist options
  • Save tomohiro/239465 to your computer and use it in GitHub Desktop.
Save tomohiro/239465 to your computer and use it in GitHub Desktop.
OpenPNE 用の cmd プラグイン
function url2cmd(url) {
var static_flickr_com = url.match(/^http:\/\/farm([0-9]+)\.static\.flickr\.com\/([0-9]+)\/([a-z0-9_]+)\.(jpg|jpeg|png|gif)/);
if (static_flickr_com) {
var pid1 = RegExp.$1;
var pid2 = RegExp.$2;
var pid3 = RegExp.$3;
var pid4 = RegExp.$4;
main(pid1, pid2, pid3, pid4);
} else {
pne_url2a(url);
}
}
function main(pid1, pid2, pid3, pid4) {
var html = '<img src="http://farm' + pid1 + '.static.flickr.com/' + pid2 + '/' + pid3 + '.' + pid4 + '">';
document.write(html);
}
function url2cmd(url) {
var static_flickr_com = url.match(/^http:\/\/farm([0-9]+)\.static\.flickr\.com\/([0-9]+)\/([a-z0-9_]+)\.(jpg|jpeg|png|gif)/);
if (static_flickr_com) {
var pid1 = RegExp.$1;
var pid2 = RegExp.$2;
var pid3 = RegExp.$3;
var pid4 = RegExp.$4;
main(pid1, pid2, pid3, pid4);
} else {
pne_url2a(url);
}
}
function main(pid1, pid2, pid3, pid4) {
var html = '<img src="http://farm' + pid1 + '.static.flickr.com/' + pid2 + '/' + pid3 + '.' + pid4 + '">';
document.write(html);
}
function url2cmd(url) {
var static_flickr_com = url.match(/^http:\/\/farm([0-9]+)\.static\.flickr\.com\/([0-9]+)\/([a-z0-9_]+)\.(jpg|jpeg|png|gif)/);
if (static_flickr_com) {
var pid1 = RegExp.$1;
var pid2 = RegExp.$2;
var pid3 = RegExp.$3;
var pid4 = RegExp.$4;
main(pid1, pid2, pid3, pid4);
} else {
pne_url2a(url);
}
}
function main(pid1, pid2, pid3, pid4) {
var html = '<img src="http://farm' + pid1 + '.static.flickr.com/' + pid2 + '/' + pid3 + '.' + pid4 + '">';
document.write(html);
}
function url2cmd(url) {
var static_flickr_com = url.match(/^http:\/\/farm([0-9]+)\.static\.flickr\.com\/([0-9]+)\/([a-z0-9_]+)\.(jpg|jpeg|png|gif)/);
if (static_flickr_com) {
var pid1 = RegExp.$1;
var pid2 = RegExp.$2;
var pid3 = RegExp.$3;
var pid4 = RegExp.$4;
main(pid1, pid2, pid3, pid4);
} else {
pne_url2a(url);
}
}
function main(pid1, pid2, pid3, pid4) {
var html = '<img src="http://farm' + pid1 + '.static.flickr.com/' + pid2 + '/' + pid3 + '.' + pid4 + '">';
document.write(html);
}
function url2cmd(url) {
if (!url.match(/^http:\/\/gist\.github\.com\/([0-9]+)#file_(.+$)/) &&
!url.match(/^http:\/\/gist\.github\.com\/([0-9]+)/)) {
pne_url2a(url);
return;
}
var gistId = RegExp.$1;
var fileName = RegExp.$2;
var width = 425;
var height = 350;
main(gistId, fileName, width, height);
}
function main(gistId, fileName, width, height) {
if (!gistId.match(/^[0-9]+$/)) {
return;
}
if (!width) width = 0; else width = parseInt(width);
if (!height) height = 0; else height = parseInt(height);
if (width <= 0 || width > 425) {
width = 425;
}
if (height <= 0 || height > 350) {
height = 350;
}
var gist = '';
if (fileName != null) {
gist = gistId + '.js?file=' + fileName;
} else {
gist = gistId + '.js';
}
var html = '<script src="http://gist.github.com/' + gist + '"></script>';
document.write(html);
}
<html>
<head>
<script src="./gist.github.com.js" type="text/javascript"></script>
</head>
<body>
<script>
url2cmd('http://gist.github.com/226929#file_loto6.scm');
url2cmd('http://gist.github.com/226929');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment