wordpress rendering invisible - wordpress

I have a page on a wordpress site located here: http://www.3cdesignsolutions.com/?page_id=331
It's not rendering anything visible but I know the code is there because I'm pasting it into the editor and I can see it in the admin area. Ideas?
<div id="album-6"><br></div><script type="mce-text/javascript"><!--
/** SCRIPT TO ENSURE window.onload WORKS FOR ALL BROWSERS ****************/
function init() {
if (arguments.callee.done) return;
arguments.callee.done = true;
// do your thing
loadAjaxPage("touch-ups","../../ajax.get-photo-touch-ups.php");
}
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', init, false);
}
(function() {
/*#cc_on
if (document.body) {
try {
document.createElement('div').doScroll('left');
return init();
} catch(e) {}
}
/*#if (false) #*/
if (/loaded|complete/.test(document.readyState)) return init();
/*#end #*/
if (!init.done) setTimeout(arguments.callee, 50);
})();
_prevOnload = window.onload;
window.onload = function() {
if (typeof _prevOnload === 'function') _prevOnload();
init();
};
/** AJAX FOR RFQ FORM SUBMISSION *****************************************/
var ajax = new sack();
function whenLoading(element){
var e = document.getElementById(element);
e.innerHTML = "Sending Data...";
}
function whenLoaded(element){
var e = document.getElementById(element);
e.innerHTML = "Data Sent...";
}
function whenInteractive(element){
var e = document.getElementById(element);
e.innerHTML = "Getting data...";
}
function whenCompleted(){
/* do nothing...*/
}
function loadAjaxPage(el,file){
ajax.requestFile = file;
ajax.element = el;
var onLoading = whenLoading(ajax.element);
var onLoaded = whenLoaded(ajax.element);
var onInteractive = whenInteractive(ajax.element);
ajax.onCompletion = whenCompleted;
ajax.runAJAX();
}
// --></script><br> <!-- LOAD RSS FEED INTO DIV -->

Related

javascript injected in tinymce editor by wordpress when gutenberg is desactivated

with a fresh install and up to date of wordpress (5.8.2), when I desactivate gutenberg editor, Wordpress add this javascript code in all TinyMCE editor (content, acf fields etc..)
I have no plugin and theme by default. I desactivate Gutenberg with code or with a plugin, no changes. Anyone have a tip ? thx
<script type="text/javascript">
var spector;
var captureOnLoad = false;
var captureOffScreen = false;
window.__SPECTOR_Canvases = [];
(function() {
var __SPECTOR_Origin_EXTENSION_GetContext = HTMLCanvasElement.prototype.getContext;
HTMLCanvasElement.prototype.__SPECTOR_Origin_EXTENSION_GetContext = __SPECTOR_Origin_EXTENSION_GetContext;
if (typeof OffscreenCanvas !== 'undefined') {
var __SPECTOR_Origin_EXTENSION_OffscreenGetContext = OffscreenCanvas.prototype.getContext;
OffscreenCanvas.prototype.__SPECTOR_Origin_EXTENSION_OffscreenGetContext = __SPECTOR_Origin_EXTENSION_OffscreenGetContext;
OffscreenCanvas.prototype.getContext = function () {
var context = null;
if (!arguments.length) {
return context;
}
if (arguments.length === 1) {
context = this.__SPECTOR_Origin_EXTENSION_OffscreenGetContext(arguments[0]);
if (context === null) {
return context;
}
}
else if (arguments.length === 2) {
context = this.__SPECTOR_Origin_EXTENSION_OffscreenGetContext(arguments[0], arguments[1]);
if (context === null) {
return context;
}
}
var contextNames = ["webgl", "experimental-webgl", "webgl2", "experimental-webgl2"];
if (contextNames.indexOf(arguments[0]) !== -1) {
// context.canvas.setAttribute("__spector_context_type", arguments[0]);
// Notify the page a canvas is available.
var myEvent = new CustomEvent("SpectorWebGLCanvasAvailableEvent");
document.dispatchEvent(myEvent);
this.id = "Offscreen";
window.__SPECTOR_Canvases.push(this);
if (captureOnLoad) {
// Ensures canvas is in the dom to capture the one we are currently tracking.
if (false) {
spector.captureContext(context, 500, false, false);
captureOnLoad = false;
}
}
}
return context;
}
}
HTMLCanvasElement.prototype.getContext = function () {
var context = null;
if (!arguments.length) {
return context;
}
if (arguments.length === 1) {
context = this.__SPECTOR_Origin_EXTENSION_GetContext(arguments[0]);
if (context === null) {
return context;
}
}
else if (arguments.length === 2) {
context = this.__SPECTOR_Origin_EXTENSION_GetContext(arguments[0], arguments[1]);
if (context === null) {
return context;
}
}
var contextNames = ["webgl", "experimental-webgl", "webgl2", "experimental-webgl2"];
if (contextNames.indexOf(arguments[0]) !== -1) {
context.canvas.setAttribute("__spector_context_type", arguments[0]);
// Notify the page a canvas is available.
var myEvent = new CustomEvent("SpectorWebGLCanvasAvailableEvent");
document.dispatchEvent(myEvent);
if (captureOffScreen) {
var found = false;
for (var i = 0; i < window.__SPECTOR_Canvases.length; i++) {
if (window.__SPECTOR_Canvases[i] === this) {
found = true;
break;
}
}
if (!found) {
window.__SPECTOR_Canvases.push(this);
}
}
if (captureOnLoad) {
// Ensures canvas is in the dom to capture the one we are currently tracking.
if (this.parentElement || false) {
spector.captureContext(context, 500, false, false);
captureOnLoad = false;
}
}
}
return context;
}
})()</script>
It is very likely added by the Spector.js extension : same behaviour with the Spector extension enabled on Firefox (when switching editor, or after save) => disabling the extension solved the issue.

SignalR and .NET

I'm basically trying to dynamically create a list element and update it across multiple clients. I'm using SignalR library of .NET. Following is my code.
$(function () {
// Reference the auto-generated proxy for the hub.
var listSync = $.connection.myHub1;
console.log("List Sync ");
// Create a function that the hub can call back to display messages and toggle.
listSync.client.addNewItemToPage = function (name, url) {
console.log("List Sync 3");
var play_list = document.getElementById('playlist');
var empty = document.getElementById('empty');
if (empty != null) {
empty.remove();
}
var pli = document.createElement("li");
var ptag = document.createElement('a');
var icon = document.createElement('i');
icon.setAttribute('class', "fa fa-toggle-right");
ptag.setAttribute('href', "#");
ptag.setAttribute('class', "play_track");
ptag.appendChild(icon);
ptag.innerHTML += name;
ptag.type = url;
pli.appendChild(ptag);
play_list.appendChild(pli);
//handler to play songs by playlist
var favLinks = document.getElementsByClassName('play_track');
for (var j = 0; j < favLinks.length; j++) {
var favLink = favLinks[j];
favLink.onclick = function (e) {
e.preventDefault();
xurl = this.type;
myFunc();
}
}
};
// Start the connection.
$.connection.hub.start().done(function () {
window.listFunc = function listFunc(name, url) {
console.log("List Sync 1");
// Call the Send method on the hub.
listSync.server.update_playlist(name, url);
console.log("List Sync 2");
}
});
});
The problem is it doesn't go into the function listSync.client.addNewItemToPage. Can someone please tell me why?

Google Earth plugin time slider stays running

Google Earth plugin time slider stays running even though the kmz file ends. Time seems to run forever even not stopped manually. See the the page
http://www.sodanjaljet.fi/kuhmo/
Some other page has basically the same code code, but does not stay running, it ends as the kmz file is finished, see the page
http://www.sodanjaljet.fi/uncategorized/viipurinlahti-helmi-maaliskuussa-1940/
The problem code below
<script src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
var ge;
var firsttime = 0;
var timer;
google.load("earth", "1", {"other_params":"sensor=false"});
function init()
{
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance)
{
var defaultRate = 1; // 1 second in the plugin for each real second.
var speedyRate = 60*60*24*4; // 1 day for each real second.
ge = instance;
ge.getWindow().setVisibility(true);
addSampleButton('Alkuun', camera);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
var href = 'http://www.sodanjaljet.fi/wp-content/uploads/kmz/Kuhmo2.kmz';
google.earth.fetchKml(ge, href, function(kmlObject) {
if (kmlObject)
ge.getFeatures().appendChild(kmlObject);
if (kmlObject.getAbstractView() !== null)
ge.getView().setAbstractView(kmlObject.getAbstractView());
});
ge.getTime().getControl().setVisibility(ge.VISIBILITY_SHOW);
}
function failureCB(errorCode)
{
}
function camera()
{
var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
lookAt.setLatitude(63.95335);
lookAt.setLongitude(30.08484);
lookAt.setRange(20000.0); //default is 0.0
lookAt.setTilt(30);
lookAt.setHeading(0);
ge.getView().setAbstractView(lookAt);
start();
}
function setRate(rate)
{
var rate = 60*60*24*4;
var extents = ge.getTime().getControl().getExtents();
if (firsttime == 0)
start();
firsttime = 1;
ge.getTime().setRate(eval(rate));
}
function setRate2(rate)
{
var rate = 60*60*24*4;
var time = ge.getTime().getTimePrimitive();
ge.getTime().setRate(eval(0));
}
function addSampleButton(caption, clickHandler)
{
var btn = document.createElement('input');
btn.type = 'button';
btn.value = caption;
if (btn.attachEvent)
btn.attachEvent('onclick', clickHandler);
else
btn.addEventListener('click', clickHandler, false);
document.getElementById('sample-ui').appendChild(btn);
}
function start()
{
var groundOverlay = ge.createGroundOverlay('');
var timeSpan = ge.createTimeSpan('');
timeSpan.getBegin().set('1940-01-01');
timeSpan.getEnd().set('1940-01-03');
groundOverlay.setTimePrimitive(timeSpan)
ge.getFeatures().appendChild(groundOverlay);
ge.getTime().setTimePrimitive(timeSpan);
}
google.setOnLoadCallback(init);
</script>
The code works other way fine, there are play, stop, and "back to begin" buttons, and they work. Time not stopping is however quite an annoying problem.
Any ideas how to get it stop?
Thanks in advance.
br
jouko

Custom control that's not shown

I'm porting a v2 to v3 app map and there's one thing I can't get to work.
I have a custom control that is not shown, anything.
I'm not sure where is the problem so I'll post everything i think is relevant, ask for some more if needed
Here's the constructor:
Note that there's still the comments from v2
function Semaforo(){}
//Semaforo.prototype = new GControl();
Semaforo.prototype.semaforo = document.createElement("img");
Semaforo.prototype.initialize = function(map) {
var container = document.createElement("div");
var semaforoDiv = document.createElement("img");
semaforoDiv.setAttribute("class", "semaforo");
this.setButtonStyle_(semaforoDiv);
this.semaforo = semaforoDiv;
container.appendChild(semaforoDiv);
semaforoDiv.setAttribute("src", "img/semaforo_rojo.png");
map.getContainer().appendChild(container);
return container;
}
And some of the methods:
Semaforo.prototype.setColor = function(color, mapa) {
this.semaforo.setAttribute("src", "img/semaforo_" + color + ".png");
if(color == "rojo")
{
this.semaforo.setAttribute("alt", "Tr�fico dif�cil");
this.semaforo.setAttribute("title", "Tr�fico dif�cil");
}
else if(color == "ambar")
{
this.semaforo.setAttribute("alt", "Tr�fico irregular");
this.semaforo.setAttribute("title", "Tr�fico irregular");
}
else
{
this.semaforo.setAttribute("alt", "Tr�fico fluido");
this.semaforo.setAttribute("title", "Tr�fico fluido");
}
}
Semaforo.prototype.getDefaultPosition = function() {
return new google.maps.ControlPosition.TOP_RIGHT;
//return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, 0)); //TO DO
}
Semaforo.prototype.setButtonStyle_ = function(button) {
button.style.width = "19px";
button.style.height = "53px";
button.style.cursor = "default";
}
function getIconoSemaforo(color, mapa){
var semaforo = new Semaforo();
semaforo.setColor(color, mapa);
return semaforo;
}
Here is where I call the constructor and try to make/show the control
function incluirDatosXML()
{
for (var i=0; i<ciudadDato.length; i++)
{
if (i==0)
{
if (semaforoDato[i]!="no")
{
var semaforo = new Semaforo(this.semaforo, map[1]);
map[1].controls[google.maps.ControlPosition.TOP_RIGHT].push(this.semaforo);
//map[1].addControl(semaforo);
semaforo.setColor(semaforoDato[i], map[1]);
/*google.maps.event.addListener(map[1], 'idle', function() {
map[1].controls[google.maps.ControlPosition.TOP_RIGHT].push(this.semaforo);
});*/
}
}
if (i==1)
{
if (semaforoDato[i]!="no")
{
var semaforo = new Semaforo(this.semaforo, map[2]);
//map[2].addControl(semaforo);
semaforo.setColor(semaforoDato[i], map[2]);
//map[2].controls[google.maps.ControlPoistion.TOP_RIGHT].push(this.semaforo);
}
}
if (i==2)
{
if (semaforoDato[i]!="no")
{
var semaforo = new Semaforo(this.semaforo, map[3]);
//map[3].addControl(semaforo);
semaforo.setColor(semaforoDato[i], map[3]);
//map[3].controls[google.maps.ControlPoistion.TOP_RIGHT].push(this.semaforo);
}
}
$("#clima"+(i+1)).attr("class",climaDato[i]+"_mini");
$("#temp"+(i+1)).html(temperaturadDato[i]+"°");
}
}
So all you can see there is what i tested so far even there's still some comments from previous testings

Validation with ajax AutoCompleteExtender

I have a TextBox with AutoCompleteExtenderwhen the person starts typing in the TextBox List with City name Appear .This works fine but now I want to validate that if they just type in a textbox and don't select one from the list that it validates that City Is Not Exist In database.
I want to validate it Using Ajax And Without PostBack Before Final Submit of form.
Add new js file with content below and add add reference on it to ToolkitScriptManager's Scrips collection:
Type.registerNamespace('Sjax');
Sjax.XMLHttpSyncExecutor = function () {
Sjax.XMLHttpSyncExecutor.initializeBase(this);
this._started = false;
this._responseAvailable = false;
this._onReceiveHandler = null;
this._xmlHttpRequest = null;
this.get_aborted = function () {
//Parameter validation code removed here...
return false;
}
this.get_responseAvailable = function () {
//Parameter validation code removed here...
return this._responseAvailable;
}
this.get_responseData = function () {
//Parameter validation code removed here...
return this._xmlHttpRequest.responseText;
}
this.get_started = function () {
//Parameter validation code removed here...
return this._started;
}
this.get_statusCode = function () {
//Parameter validation code removed here...
return this._xmlHttpRequest.status;
}
this.get_statusText = function () {
//Parameter validation code removed here...
return this._xmlHttpRequest.statusText;
}
this.get_xml = function () {
//Code removed
}
this.executeRequest = function () {
//Parameter validation code removed here...
var webRequest = this.get_webRequest();
if (webRequest === null) {
throw Error.invalidOperation(Sys.Res.nullWebRequest);
}
var body = webRequest.get_body();
var headers = webRequest.get_headers();
var verb = webRequest.get_httpVerb();
var xmlHttpRequest = new XMLHttpRequest();
this._onReceiveHandler = Function.createCallback(this._onReadyStateChange, { sender: this });
this._started = true;
xmlHttpRequest.onreadystatechange = this._onReceiveHandler;
xmlHttpRequest.open(verb, webRequest.getResolvedUrl(), false); // False to call Synchronously
if (headers) {
for (var header in headers) {
var val = headers[header];
if (typeof (val) !== "function") {
xmlHttpRequest.setRequestHeader(header, val);
}
}
}
if (verb.toLowerCase() === "post") {
if ((headers === null) || !headers['Content-Type']) {
xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
}
if (!body) {
body = '';
}
}
this._started = true;
this._xmlHttpRequest = xmlHttpRequest;
xmlHttpRequest.send(body);
}
this.getAllResponseHeaders = function () {
//Parameter validation code removed here...
return this._xmlHttpRequest.getAllResponseHeaders();
}
this.getResponseHeader = function (header) {
//Parameter validation code removed here...
return this._xmlHttpRequest.getResponseHeader(header);
}
this._onReadyStateChange = function (e, args) {
var executor = args.sender;
if (executor._xmlHttpRequest && executor._xmlHttpRequest.readyState === 4) {
//Validation code removed here...
executor._responseAvailable = true;
executor._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
executor._onReceiveHandler = null;
executor._started = false;
var webRequest = executor.get_webRequest();
webRequest.completed(Sys.EventArgs.Empty);
//Once the completed callback handler has processed the data it needs from the XML HTTP request we can clean up
executor._xmlHttpRequest = null;
}
}
}
Sjax.XMLHttpSyncExecutor.registerClass('Sjax.XMLHttpSyncExecutor', Sys.Net.WebRequestExecutor);
On a page:
<ajaxToolkit:ToolkitScriptManager runat="server" ID="ScriptManager1">
<Scripts>
<asp:ScriptReference Path="~/XMLHttpSyncExecutor.js" />
</Scripts>
</ajaxToolkit:ToolkitScriptManager>
Then, add CustomValidator for target TextBox and use function below for client validation:
<asp:TextBox runat="server" ID="myTextBox" Width="300" autocomplete="off" />
<asp:CustomValidator runat="server" ID="myTbCustomValidator" ControlToValidate="myTextBox"
Text="*" Display="Dynamic" ValidateEmptyText="false" ClientValidationFunction="validateTextBox"
OnServerValidate="ValidateTextBox" />
function validateTextBox(sender, args) {
if (args.Value.length > 0) {
var extender = $find("AutoCompleteEx"); // AutoComplete extender's BehaviorID
if (extender._completionListElement) {
var children = extender._completionListElement.childNodes;
var length = extender._completionListElement.childNodes.length;
for (var i = 0; i < length; i++) {
if (children[i].innerHTML == args.Value) {
args.IsValid = true;
return;
}
}
}
var request = new Sys.Net.WebRequest();
request.set_url('<%= ResolveClientUrl("~/AutoComplete/AutoComplete.asmx/Validate") %>');
var body = Sys.Serialization.JavaScriptSerializer.serialize({ value: args.Value });
request.set_body(body);
request.set_httpVerb("POST");
request.get_headers()["Content-Type"] = "application/json; encoding=utf-8";
request.add_completed(function (eventArgs) {
var result = Sys.Serialization.JavaScriptSerializer.deserialize(eventArgs.get_responseData());
args.IsValid = result.d;
});
var executor = new Sjax.XMLHttpSyncExecutor();
request.set_executor(executor);
request.invoke();
}
}
The main idea of code above is to check suggested items at first for entered text and if there aren't any concidence then to do synchronous AJAX call to Validate method of web service or page method. That method should have such signature: public bool Validate(string value)
P.S. Code for XMLHttpSyncExecutor taken here: Using Synchronous ASP.Net AJAX Web Service Calls and Scriptaculous to Test your JavaScript

Resources