I thought I had solved an issue with my Swiffy file when I uploaded it to my server along with the file it dynamically pulls text from, but even on my server no text is pulled from the external file. It only sits there with everything blank.
And the only thing that shows up in the console is:
[trace] TypeError: Error #1009: Cannot access a property or method of a null object reference. runtime.js:187
Here's a link to the file generated by swiffy (only valid for 15 minutes I think):
Link 1
Here's a link to the runtime.js file: Link 2.
EDIT:
This is the line where the error is being given in runtime.js:
var rk=function(a,b)
{
a.__swiffy_baseclass=b[I];
Xa(a,q[vd](b[I]));
a[I].constructor=a;
if(b.__swiffy_if)
{
var c=new kh;
c.Be(b.__swiffy_if);
q[E](a,"__swiffy_if",{value:c})
}
},
sk=function(a)
{
q[E](a[I],"__swiffy_nvr",{value:l})
},
tk=function(a)
{
ba.console&&ba.console.log("[trace] "+a)
},
uk=function(){},
vk=function(a)
{
tk(a)
},
wk=function(a)
{
f(a)
};"__proto__"in q||q[E](mi[I],"__proto__",{get:function(){return q[hd](this)}});
var xk=function(a,b,c,d,e,g,k)
{
this.D=a;
this.variables=b;
this.url=c; fb(this,d||"_self"); La(this,e);
this.Xk=!!g;
this.Di=!!k;
this.Wh=m;
if(this.Xk||this.Di)
this.Wh=this.fo()
},
yk={0:h,1:"GET",2:"POST"};
M=xk[I];
Related
I'm trying to get the current pre-market price for this stock. This is the formula I'm trying:
=IMPORTXML("https://www.marketwatch.com/investing/stock/mtsl", "//bg-quote[#session='pre']")
I'm not getting the value:
Any ideas?
I understand that you want to read a stock price on MarketWatch in Sheets. Unfortunately you can't use =IMPORTXML("https://www.marketwatch.com/investing/stock/oln", "/") because you will get a JavaScript response like this one:
(function(window) {
try {
if (typeof sessionStorage !== 'undefined') {
sessionStorage.setItem('distil_referrer', document.referrer);
}
} catch (e) {}
})(window);
#d__fFH {
position: absolute;top: -5000 px;left: -5000 px
}
#d__fF {
font - family: serif;
font - size: 200 px;
visibility: hidden
}
#fwqssyztxufxfzwwduebdqwxedwrzazqaaavux {
display: none!important
}
This behaviour occurs because IMPORTXML is expecting a XML page in the URL, and since this URL doesn't address a XML-compatible file it will return the page load as best effort. In this case, the server elegantly raises an error because it requires a defined session storage to determine the browser cookie protocol. To prevent this incompatibility, you can use an Apps Script code to fetch the stock price like this one below:
function listingPrice() {
return UrlFetchApp.fetch("https://www.marketwatch.com/investing/stock/mtsl")
.getContentText().match(/(<meta name="price" content=")(.*)(?=")/)[2];
}
In that example I have used UrlFetchApp.fetch() to get the page, HTTPResponse.getContentText() to read it's contents and String.match() to capture the price with a regexp. To prevent intraday values you could develop a condition like this example:
function listingPrice() {
var stock = UrlFetchApp.fetch(
"https://www.marketwatch.com/investing/stock/mtsl").getContentText();
if (stock.match(/(<div class="status">)(.*)(?=<\/div>)/)[2] == "Premarket") {
return stock.match(/(<meta name="price" content=")(.*)(?=">)/)[2];
} else {
return "NASDAQ:MTSL is trading at this time.";
}
}
Then you can save the price on the Sheet with:
function refreshSheet() {
SpreadsheetApp.getActiveSheet().getRange(1, 1).setValue(listingPrice());
}
SpreadsheetApp.getActiveSheet() will open the active sheet to select the A1 range with Sheet.getRange() and write the price using Range.setValue(). Please, don't hesitate to ask me further questions.
We have an application running that currently works with both 3D and 2D files, and do not experience any issues when loading 3D files and DWG.
But when trying to load a PDF neither my "onItemLoadSuccess" or "onItemLoadFail" gets run
Autodesk.Viewing.Initializer(options, function onInitialized() {
// Select the container for the viewer
viewerApp = new Autodesk.Viewing.ViewingApplication(container);
// Load settings, i.e extension manager
viewerApp.registerViewer(viewerApp.k3D,
Autodesk.Viewing.Private.GuiViewer3D, { extensions: [ 'ExtensionManager'] });
// Select model to load defined by URN
viewerApp.loadDocument(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});
}
function onDocumentLoadSuccess(doc) {
var viewables = viewerApp.bubble.search({ 'type': 'geometry' });
if (viewables.length === 0) {
console.error('Document contains no viewables.');
return;
}
// Choose any of the avialble viewables
viewerApp.selectItem(viewables[0], onItemLoadSuccess, onItemLoadFail);
}
function onItemLoadSuccess(viewer, item) {
console.log('onItemLoadSuccess()!');
}
function onItemLoadFail(errorCode) {
console.error('onItemLoadFail() - errorCode:' + errorCode);
}
The PDF file will still open and load, so I am wondering if there might be a different way to run an onItemLoadSuccess function, or we have to do something a bit differently to ensure that our PDF's also gets loaded correctly.
Any help is highly appreciated!
Starting from Viewer v6.3 you can load PDF directly with Autodesk.PDF and pass in callbacks to loadModel like you do other models:
Autodesk.Viewing.Initializer(options, function() {
viewer.start()
viewer.loadExtension('Autodesk.PDF').then(function() {
viewer.loadModel('/path/to/pdf', { page: 1 }, onLoadSuccess, onLoadFail);
});
});
See release notes here: https://forge.autodesk.com/blog/viewer-release-notes-v-63
(Adding to Bryan's answer...)
I wrote a blog post about this. Take a look at the DEMO and sample code to help answer your question about 'onItemLoadSuccess / onItemLoadFail' events.
BLOG: https://forge.autodesk.com/blog/fast-pdf-viewingmarkup-inside-forge-viewer
DEMO: https://wallabyway.github.io/offline-pdf-markup/
Hope that helps!
I am using SCEditor and I am trying to set my own custom emoticons according to the emoticons option specified on this page.
So I called it like so:
$(document).ready(function() {
$(".sceditor").sceditor({
// Other options
emoticons: $.getJSON('../../images/emoticons/default/emoticons.json'),
emoticonsRoot: '../../images/emoticons/default/'
});
})
Then in my emoticons.json file I have this:
{
dropdown: {
':)': 'emoticons/smile.png',
':angel:': 'emoticons/angel.png',
':angry:': 'emoticons/angry.png'
}
}
However it is not working. I have checked the NET panel in my browser and I have confirmed it is fetching the .json file fine, however when I click to open the smiley window in the editor it is blank (all I see is the "more" link).
Am I doing something wrong here?
Json lint show above text in json file is invalid.
Try putting this in your json file
{
"dropdown": {
":)": "emoticons/smile.png",
":angel:": "emoticons/angel.png",
":angry:": "emoticons/angry.png"
}
}
I tried this in php
$a = '{
"dropdown": {
":)": "emoticons/smile.png",
":angel:": "emoticons/angel.png",
":angry:": "emoticons/angry.png"
}
}' ;
print_r(json_decode($a));
Output
Array
(
[dropdown] => Array
(
[:)] => emoticons/smile.png
[:angel:] => emoticons/angel.png
[:angry:] => emoticons/angry.png
)
)
I have tried by your link.
The follows is my code:
$(function() {
// Replace all textarea's
// with SCEditor
$("textarea").sceditor({
plugins: "bbcode",
style: "plugins/SCEditor/development/jquery.sceditor.default.css",
emoticons: {
// Emoticons to be included in the dropdown
dropdown: {
":)": "emoticons/smile.png",
":angel:": "emoticons/angel.png"
},
// Emoticons to be included in the more section
more: {
":alien:": "emoticons/alien.png",
":blink:": "emoticons/blink.png"
},
// Emoticons that are not shown in the dropdown but will still
// be converted. Can be used for things like aliases
hidden: {
":aliasforalien:": "emoticons/alien.png",
":aliasforblink:": "emoticons/blink.png"
}
},
emoticonsRoot: "plugins/SCEditor/"
});
});
Above this, you may kown why your code is wrong.
Accross from jQuery.getJSON, $.getJSON returns JQXHR,not a Json object. So, It is not possible to show your emoticons.
As per WhiteWater's answer the reason it wasn't working was because it was returning a JQXHR object and not a JSON object, so I had to work out how to get it to return a JSON object whilst the editor loading not being dependent on the emoticons existence.
So we have the solution below with credit to jeremysawesome for his answer to this question:
// create a variable to store the results
var emoticons = false;
$.getJSON('../../images/emoticons/default/emoticons.json')
.done(function(result){
emoticons = result;
})
.always(function(){
// always initialize the sceditor
$('.my-selector').sceditor({emoticons: emoticons});
});
This will load the emoticons but will always load the sceditor instance, even if the emoticons fail for some reason.
I'm trying to work with this library (RPG.js) because it looks very powerfull, I looked at the official tutorial but i don't understand a lot of things, State 4 : "Initialize the canvas in your JS file :", whitch one ?
Is any one already used this library or know an other powerfull ?
Thanks for all.
Well, actually it was not so simple; I struggled I bit until I got a minimal functional game. What I did was not the "optimal" approach, but at least worked for me (I was using Mozilla Firefox in a Windows 7 OS). If someone knows how to improve what I did, I would be happy to know (since I'm a newbie in this library too), but since I was not able to find a good a simple starter tutorial in the net, I want to share what I did, in the hope I can help someone.
Before anything, create a HTML file, and call the libs inside the <head> tag:
<script src="canvasengine-X.Y.Z.all.min.js"></script>
<script src="rpgjs-X.Y.Z.min.js"></script>
And the canvas inside the <body> tag:
<canvas id="canvas_id" width="640" height="480"></canvas>
There's a 'sample' folder inside the github project (see https://github.com/RSamaium/RPG-JS), and inside this folder there is a functional game, and you can open it in the browser by the file quick.html. The idea is that if the sample game can work, then you can make your game work too, so I started trying to use the same graphics, data etc. of the sample.
First, you need to create in the root of your project the following folders and subfolders:
core
core\scene
Data
Data\Maps
Graphics
To have a minimal functional game, you need 1) a map to walk with your character, and 2) a character to control. So, you need to have graphics for some tiles to build your map and the walking model for your character. Create the subfolders below:
Graphics\Characters
Graphics\Tilesets
Graphics\Windowskins
And then copy the following files from the corresponding sample subfolder to these folders you created:
Graphics\Characters\event1.png
Graphics\Tilesets\tileset.png
Graphics\Windowskins\window.png #this file will be necessary for some of the js files below, even if not used; to remove this necessity, you'll need to edit these files - not what we want to do in the start.
In the 'core/scene' folder, you'll have some js files to load scenes (like the scene of your walking in the map, the gameover scene). I needed to copy all the js files inside the corresponding folder in the 'sample' project to the 'core/scene' folder of your game. This folder is not inside the 'sample' folder, but in the root of the github project. I only got my game working when I added all the 7 js files (without some work inside the codes you can remove the scenes you don't want, but since what we want is just to be able to run a simple game, let's copy them for now):
Scene_Gameover.js
Scene_Generated.js
Scene_Load.js
Scene_Map.js
Scene_Menu.js
Scene_Title.js
Scene_Window.js
Now, I added the following code inside a <script> tag on the html. This is more or less the same that was in the documentation. These codes will create an "actor" (a character), a "map", and the tiles you'll use in the map
For more details on maps or tiles, you should read the documentation (the same you linked in your question).
RPGJS.Materials = {
"characters": {
"1": "event1.png"
},
"tilesets": {
"1": "tileset.png"
}
};
RPGJS.Database = {
"actors": {
"1": {
"graphic": "1"
}
},
"tilesets": {
"1": {
"graphic": "1"
}
},
"map_infos": {
"1": {
"tileset_id": "1"
}
}
};
RPGJS.defines({
canvas: "canvas_id",
autoload: false
}).ready(function() {
RPGJS.Player.init({
actor: 1,
start: {x: 10, y: 10, id: 1} // Here, map id doesn't exist
});
RPGJS.Scene.map();
Lastly, create the json file setting every tile of your map. I just copied the MAP-1.json file from the 'sample' folder to inside the Data\Maps folder.
Then you'll be able to walk with your character in an empty map! Open the html file in your browser and try it!
Printscreen from the game running in a browser
Of course to have a real game you'll need to change a lot of this (as creating a database.json file and a materials.json file where you'll put most of the code you put in the <script> tag), but with the basics I hope you can work from that!
The tutorial is very clear
3. Add this code in your page :
<!DOCTYPE html>
<script src="canvasengine-X.Y.Z.all.min.js"></script>
<script src="rpgjs-X.Y.Z.min.js"></script>
<canvas id="canvas_id" width="640" height="480"></canvas>
That's "the canvas" ^
Brian Hellekin post a great tutorial. If you want see all the power of this library you must modify your html file in this way:
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script src="http://canvasengine.net/cdn/dev/canvasengine-latest.all.min.js"></script>
<script src="http://rpgjs.com/cdn/rpgjs-2.0.0.min.js"></script>
<script src="plugins/gamepad.js"></script>
<script src="plugins/virtualjoystick.js"></script>
<script src="plugins/soundmanager2-jsmin.js"></script>
<script>
var Data = null;
if (Data) {
Data.database._scenes = Data.menus;
Data.database.system = Data.settings;
}
RPGJS.defines({
canvas: "canvas",
plugins: ["/rpgjs/plugins/Hub", "/rpgjs/plugins/Arpg", "/rpgjs/plugins/MenuGenerated"],
scene_path: "/rpgjs/",
soundmanager: {
url: "/rpgjs/swf/",
},
autoload: Data == null,
ignoreLoadError: true
}).ready(function(rpg) {
var material_json = {};
var m, type;
if (Data) {
for (var i in Data.materials) {
m = Data.materials[i];
type = m['type'] + "s";
if (!material_json[type]) {
material_json[type] = {};
}
material_json[type][m['material_id']] = RPGJS_Canvas.Materials.getFilename(m['path'], true);
}
var m, e;
var map_info = Data.maps, info;
for (var id in Data.data_maps) {
m = Data.data_maps[id];
this.setMap(id, m.map.map);
info = map_info[id];
info.tileset_id = info.tileset;
info.autotiles_id = info.autotiles;
info.events = [];
info.dynamic_event = [];
for (var i=0 ; i < m.events.length ; i++) {
e = m.events[i];
if (e.data_event.type == "event" ) {
var format =
[
{
"id" : e.event_id,
"x" : e.position_x,
"y" : e.position_y,
"name" : 'EV-' + e.event_id
},
e.data_event.data.pages
];
this.setEvent(id, 'EV-' + e.event_id, format);
info.events.push('EV-' + e.event_id);
}
else {
var name, _id;
for(var key in e.data_event.data) {
_id = e.data_event.data[key];
name = key;
break;
}
info.dynamic_event.push({
"x" : e.position_x,
"y" : e.position_y,
"name" : name,
"id" : _id
});
}
}
}
Data.database.map_infos = map_info;
global.materials = material_json;
global.data = Data.database;
global.game_player.init();
}
var scene = this.scene.call("Scene_Title", {
overlay: true
});
scene.zIndex(0);
});
</script>
<style>
body {
padding: 0;
margin: 0;
overflow: hidden;
background: black;
}
canvas {
-webkit-user-select : none;
-moz-user-select : none;
overflow : hidden;
}
#font-face{
font-family : "RPG";
src : url("Graphics/Fonts/Philosopher-Regular.ttf");
}
#font-face{
font-family : "Megadeth";
src : url("Graphics/Fonts/Elementary_Gothic_Bookhand.ttf");
}
</style>
<div id="game">
<canvas id="canvas" width="640" height="480"></canvas>
</div>
Note:
/rpgjs/ is the folder where i put my project in my local server. For play the game i go to http://localhost/rpgjs/
For work you need to modify the JS file in /plugins/ directory.
/Hub/Sprite_Hub.js
use this path:
array.push(RPGJS.Path.getFile("pictures", "../Pictures/hub.png", "hub"));
array.push(RPGJS.Path.getFile("pictures", "../Pictures/hp_meter.png", "hp_meter"));
array.push(RPGJS.Path.getFile("pictures", "../Pictures/hp_number.png", "hp_number"));
array.push(RPGJS.Path.getFile("pictures", "../Pictures/Hero_Face.png", "hero_face"));
array.push(RPGJS.Path.getFile("pictures", "../Pictures/button_A.png", "button_a"));
array.push(RPGJS.Path.getFile("pictures", "../Pictures/button_B.png", "button_b"));
is very useful debug in the first time with developer tool of google chrome. When you see 404 error on a img resourse just go to your project and search the file name. Find what js script load it and fix path.
And not...the tutorial inside library project is not clear and isn't complete...they just want sell his rpgeditor and js library is put only for promotion purpose i think.
you can see here: http://rpgworld.altervista.org/rpgjs/ my final working project. Is just a try... but you can see the power of this library.
this demo load:
1- a welcome page with new and load came
2- a custom map with one event
3- a working event: a chest that if you open you will find 30 gold
4- a player manu: just click ESC button on keyboard
i don't know how use arpg plugin for a realtime combat event but i working on for understand of to use it.
I've tried to use the Highcharts export feature as exampled on their site: http://jsfiddle.net/highcharts/cqjvD/ but I would like to be able to download the csv file instead of alerting/displaying it.
Here is my chart: http://jsfiddle.net/uF4H7/10/
The code for displaying the csv is simple, you just add:
$('#getcsv').click(function () {
alert(chart.getCSV());
});
Can this be done in html/js/highcharts?
Check the following http://jsfiddle.net/uF4H7/11/
$('#getcsv').click(function () {
var chart = $('#container').highcharts();
alert(chart.getCSV());
window.open();
//this line was added to your code to download the CSV
window.open("data:text/csv;charset=utf-8," + escape(chart.getCSV()));
});
The following line tells browser to open the data in the new window - browsers do not recognize text/csv mime it so they ask you to download the CSV file
window.open("data:text/csv;charset=utf-8," + escape(chart.getCSV()));
Or you could use the new feature of HTML - the link which forces to download with download attribute. In your case add this code to javascript:
$('#getcsvAnchor').click(function() {
var chart = $('#container').highcharts();
$(this).attr('href', 'data:text/csv;charset=utf-8,'+escape(chart.getCSV()));
$(this).attr('download', "data-visualisation.csv");
});
And this to your HTML - link to download:
<a id="getcsvAnchor" href="#">download</a>
The javascript gets the CSV content and puts it as anchor href, then adds the download attribute to anchor where the value is filename.
You could check preview here http://jsfiddle.net/uF4H7/12/ (click "download" next to "Alert CSV")
exporting: {
buttons: {
contextButton: {
menuItems: [{
textKey: 'downloadXLS',
onclick: function () {
this.downloadXLS();
}
}, {
textKey: 'downloadCSV',
onclick: function () {
this.downloadCSV();
}
}]
}
}
},
You can add this options directly when you are creating highchart.
Asiya Shaikh's suggestion only worked for me once I added the following Highcharts plugin:
<script src="http://highcharts.github.io/export-csv/export-csv.js"></script>
Which is a little weird considering how the plugin home page mentions nothing of the downloadXLS(); function.
If that doesn't work, you should also try using:
<script src="http://code.highcharts.com/modules/exporting.js"></script>
You can use the EXPORT-CSV plugin homepage as a reference, but as I said it doesn't mention downloadXLS().