I am trying to learn how to use Google Local Search API. I am unable to set the local search center point to Pakistan. Please guide me. Thanks.
The line in code with the problem is:
localSearch.setCenterPoint("Pakistan, PAK");
The fiddle showing that results from NewYork are being displayed is here.
The whole code is,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Hello World - Google Web Search API Sample</title>
<script src="https://www.google.com/jsapi"
type="text/javascript"></script>
<script language="Javascript" type="text/javascript">
//<!
//google.load('search', '1');
google.load("search", "1", {"nocss" : true});
function OnLoad() {
// Create a search control
var searchControl = new google.search.SearchControl();
// Add in a full set of searchers
var localSearch = new google.search.LocalSearch();
searchControl.addSearcher(new google.search.NewsSearch());
// Set the Local Search center point
localSearch.setCenterPoint("Pakistan, PAK");
// tell the searcher to draw itself and tell it where to attach
searchControl.draw(document.getElementById("searchcontrol"));
// execute an inital search
searchControl.execute("Facebook");
}
google.setOnLoadCallback(OnLoad);
//]]>
</script>
</head>
<body>
<div id="searchcontrol">Loading</div>
</body>
</html>
I believe you need to know what the latitude and longitude of PAK is for it to find it.
setCenter(latlng:LatLng);
Related
I am learning svg and would like to compare displaying svg items on different browsers. My code works fine on firefox, chrome, edge, safari etc, but cannot work on ie11. Unfortunately application I develop needs to support ie11 so I need to force my code to work correctly.
Here is fiddle: https://jsbin.com/hemawaboqa/1/edit?html,js,output
HTML
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/#svgdotjs/svg.js"></script>
</head>
<body>
<div style="position:absolute;left:0px;top:0px;right:0px;bottom:0px;overflow:hidden;" id="svg-main-container">
<div style="position:absolute;left:0px;top:0px;bottom:0px;right:300px;border:1px solid #dadada;overflow:auto;" id="svg-canvas"></div>
</div>
</body>
</html>
JS
var draw = SVG().addTo('#svg-canvas').size(400, 400)
var rect = draw.rect(100, 100)
Why that code is not working on ie11?
I have created a sample using the SVG.js 3.0 version with your code, it will show the "Object doesn't support property or method 'from'" in IE11 browser, perhaps the issue is related to the svg.js version, and it is a plugin issue, you could feedback this issue to SVG.js forum.
Besides, I suggest you could refer to the following code, to use the old version of SVG.js:
<!DOCTYPE html>
<html lang=en-us>
<head>
<meta charset=utf-8>
<title>TEST</title>
</head>
<body>
<div style="position:absolute;left:0px;top:0px;right:0px;bottom:0px;overflow:hidden;" id="svg-main-container">
<div style="position:absolute;left:0px;top:0px;bottom:0px;right:300px;border:1px solid #dadada;overflow:auto;" id="drawing">
</div>
</div>
<script src=https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js></script>
<script>
(function () {
'use strict';
// Add title as first child of SVG element:
var createTitle = function (svgObject, text) {
var fragment = document.createDocumentFragment();
var titleElement = document.createElement('TITLE');
fragment.appendChild(titleElement);
titleElement.innerHTML = text;
svgObject.node.insertAdjacentElement('afterbegin', titleElement);
};
SVG.extend(SVG.Doc, {
namespace: function () {
return this
.attr({xmlns: 'http://www.w3.org/2000/svg', version: '1.1'})
.attr('xmlns:xlink', SVG.xlink, SVG.xmlns);
}
});
var draw = new SVG('drawing').size(300, 300);
var rect = draw.rect(100, 100).attr({fill: '#f06'});
// Add title to SVG element
createTitle(draw, 'Rectangle');
}());
</script>
</body>
</html>
The result as below:
The library you are using has ECMA 6 elements that are not understood in IE.
If you need your project to work in IE, you will have to use another library or find out how to change it so it allows for older browsers (as suggested here: https://svgjs.dev/docs/3.0/compatibility/)
I have a button link which I'm using the 'onClick' event to play a sound (the correct answer to a quiz question). I then want to add a delay so the sound has enough time to play out before the link function loads the next page in.
I've tried using the set time out function, but I can't get it to work. Is this the best way to do this?
HEAD
<script>
$("#correct").click(function()
{
var url = "question2.html";
//5000 is the number of milliseconds (or 5 seconds) that you want to wait before redirection.
var delay = 5000;
setTimeout(function() {
window.location.href = url;
}, delay);
});
</script>
BODY
<button onclick="document.getElementById('answer1').play()" id="correct">A) Reduce – make less waste in the first place</button>
This is using HTML5 tags. Therefore, it will only work with browser that support HTML5. However, I think is a bad idea to validate the answer via javascript, since people can cheat and look the code and know which answer is corrected.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- javascript/jQuery -->
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<div id='audio'>This will be replaced with an audio tag</div>
<button id="correct">A) Reduce – make less waste in the first place</button>
<script type='text/javascript'>
$("#correct").on('click',function (){
$("#audio").stop("true").delay('5000').queue(function() {
$(this).html('<audio controls="controls" autoplay="autoplay"><source src="song.mp3" type="audio/mp3" /></audio>');
});
});
</script>
</body>
</html>
I trying to create main page (part of node.js and mongoDB application) that includes login form.
To add view part I included js files with function that returns HTML, but as I can see much better is using template engine.
Everything is OK until I including one compiled swig part inside another one.
The output of main page is OK, but login part outputs like text on the page.
How is possible to output the login HTML as HTML instead of plain text?
Does more information needed to understand the issue?
Thank you in advance.
var swig = require('swig');
var mainPage_tpl = swig.compileFile(__dirname+'/../views/mainpage_tpl.html');
var formLogin_tpl = swig.compileFile(__dirname+'/../views/login_tpl.html');
var loginOutput = formLogin_tpl();
var mainPageOutput = mainPage_tpl({
title: 'Sometitle',
pagetitle: 'Somepagetitle',
content: loginOutput
});
exports.get = function(req, res){
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(mainPageOutput);
res.end();
}
mainpage_tpl.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{title}}</title>
<link rel="stylesheet" href="/assets/reset.css" />
<link rel="stylesheet" href="/assets/style.css" />
<script type="text/javascript" src="/assets/jquery-2.0.0.js"></script>
<script type="text/javascript" src="/assets/script.js"></script>
</head>
<body id="login_page">
<h1>{{pagetitle}}</h1>
<div id="content">{{content}}</div>
</body>
</html>
If you want to include literal HTML, you need to tell Swig to not escape it using the safe filter:
...
<div id="content">{{ content|safe }}</div>
...
I would like to modify the language text on the extenstion library's name picker buttons.
I found this tip http://xpageswiki.com/web/youatnotes/wiki-xpages.nsf/dx/Work_with_Extension_Library but it did not work for me with 8.53 and IE8.
Does anyone have a work around ?
Thanks
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="fr">
<head>
<title>Groupe</title>
<link rel="stylesheet" type="text/css" href="/xsp/.ibmxspres/.mini/css/2Ojcore.css&2Ojdojo.css&2OldefaultTheme.css&2OldojoTheme.css&#Da&#Ib&#Th&#Ti&#Tj.css">
<script type="text/javascript" src="/xsp/.ibmxspres/dojoroot-1.6.1/dojo/dojo.js" djConfig="locale: 'fr-ca', parseOnLoad: true"></script>
<script type="text/javascript">dojo.registerModulePath('extlib', '/xsp/.ibmxspres/.extlib');</script>
<script type="text/javascript" src="/xsp/.ibmxspres/.mini/dojo/.fr-ca/#EOb&#EOf&#Ek&#Eya.js"></script>
<link rel="stylesheet" type="text/css" href="/EIJ%20852.nsf/Required.css">
</head>
<body class="xsp lotusui tundra">
<form id="view:_id1" method="post" action="/EIJ%20852.nsf/xAdminGestionAccesGroupeDetails.xsp" class="lotusForm" enctype="multipart/form-data">
<script>[| dojo.provide("yn.dijit.PickerName");
dojo.declare(
"yn.dijit.PickerName", [extlib.dijit.OneUIPickerName], {
postMixInProperties: function() {
this.inherited(arguments);
var t = this.templateString;
// change text in HTML
t = t.replace(/Search for/, 'Rechercher pour');
// change button labels, add ">" in regex to make sure to select a button and nothing else
// the "g" option in the regex leads to javascript errors at runtime
t = t.replace(/>Search/, '>Rechercher');
t = t.replace(/>Add/, '>Ajouter');
t = t.replace(/>Remove/, '>Retirer');
t = t.replace(/>Remove All/, '>Retirer tout');
t = t.replace(/>Cancel/, '>Annuler');
this.templateString = t;
}
}); ]</script><script>[| var ynXSPSelectValue = XSP.selectValue;
XSP.selectValue = function(t, vars) {
if (t == "extlib.dijit.OneUIPickerName") {
ynXSPSelectValue("yn.dijit.PickerName", vars);
} else {
ynXSPSelectValue(t, vars);
}
} ]</script><br>
The labels on the dialog are automatically changed according to the language that is used in the browser. Julian's solution still works for me.
If you want to have it in a more elegant way, you have to do a little Java to not only use the browser language but let the user change the language
This can be done using a variable resolver. The trick is to set the "locale" on the view root at every change or reload of the page. This one http://hasselba.ch/blog/?p=649 should give you an idea, how this will look like.
I have some problems with the extLib from OpenNTF. Some of the localization packages seems not to be implemented correct. So I still see english labels even if I choose a different language. But this is a known issue and has been fixed in the upgrade pack.
I would like to listen for all io request in all my web pages, however, when I used the syntax below, I can ONLY listen for the io with the yui instance.
Y.on('io:success', myCallBack);
How can I write a custom method/event or something else to achieve this?
My question is actually the same as below URL:
http://yuilibrary.com/forum/viewtopic.php?p=26009
I googled for a while but did not find a practical answer for this, any help will be appreciated, thanks.
Try
(Y.io._map['io:0'] || new Y.IO()).publish({
'io:success': { broadcast: 2 },
'io:complete': { broadcast: 2 },
etc.
});
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>io.jsp</title>
<script src="/spring-test/scripts/yui_3.5.1/build/yui/yui-min.js"></script>
</head>
<body>
test
<script>
YUI().use("io-base", function(Y){
function onSuccess(transactionid,response,arguments){
alert('start!');
}
Y.Global.on('io:start',onSuccess);
});
Y1 = YUI().use("io-base", "node", function(Y1){
Y1.publish('io:start',{broadcast : 2});
Y1.io("http://www.yahoo.com.hk");
});
</script>
</body>
Finally I got one example , however it works only on FF, Chrome but fail in IE:
Please suggest if there is any improvement, thanks.