#StackBounty: #javascript #tinymce-4 Tinymce get image _description with file_picker_callback and image uploader

Bounty: 50

TL:DR I am trying to get the value of image_description field using javascript to past it my post xhr request

Original question below

I am using file_picker_callback type image

I enabled image_description input field in my

     image_description: true,

Everything is uploading fine but I want to pass the image_description field as well to store in the DB. But i can’t grab the data

Here are my two functions, taking directly from the tinymce website

  file_picker_callback: function(cb, value, meta) {

    var input = document.createElement('input');
    input.setAttribute('type', 'file');
    input.setAttribute('accept', 'image/*');

    input.onchange = function() {
      var file = this.files[0];

      console.log( meta ); //I thought it might be here in the meta bt it isn't

     console.log( $('#mceu_62').val() ); //I tried to get it from its id but it returns undefined i think that field is created after this function is created.

      var id = file.name;
      var blobCache = tinymce.activeEditor.editorUpload.blobCache;
      var blobInfo = blobCache.create(id, file);

      // call the callback and populate the Title field with the file name
      cb(blobInfo.blobUri(), { title: file.name });

  images_upload_handler: function (blobInfo, success, failure) {
      var xhr, formData;

      xhr = new XMLHttpRequest();
      xhr.withCredentials = false;
      xhr.open('POST', '/articles/postAcceptor');

      xhr.onload = function() {
        var json;

        if (xhr.status != 200) {
          failure('HTTP Error: ' + xhr.status);

        json = JSON.parse(xhr.responseText);

        if (!json || typeof json.location != 'string') {
          failure('Invalid JSON: ' + xhr.responseText);


      formData = new FormData();
      formData.append('file', blobInfo.blob(), blobInfo.filename());
      formData.append('description', /*but i can't get the value*/);


@Karl Morrisons

Get this bounty!!!

#StackBounty: #javascript #chrome Why is init.js using a synchronous XMLHttpRequest?

Bounty: 50

Newer version of the Chrome browser are shouting warnings when the XMLHttpRequest object is being used synchronously. We all know that we must not block the main UI thread with unnecessary synchronous calls.

I recently noticed that also one of the core SharePoint JavaScript libraries, init.js, is generating such a warning in Chrome!

Synchronous XMLHttpRequest on the main thread is deprecated because of
its detrimental effects to the end user’s experience. For more help,
check http://xhr.spec.whatwg.org/.

Part of the function UpdateFormDigest is the following faulty line:

b.open("POST", GetUrlFromWebUrlAndWebRelativeUrl(f, "_vti_bin/sites.asmx"), false);

Where the false parameter states a synchronous request.

Searching on the web was not providing me any evidence that Microsoft is currently working on this particular piece of legacy code.

Anyone in the StackExchange community picked something up?

I have checked this against the following SharePoint versions:

  • SharePoint Server
  • SharePoint Online

Get this bounty!!!

#StackBounty: #javascript Open current url without last path

Bounty: 350

If I click on a link the page should load without the last path of the current url.



<a href="javascript:jumpback()"></a>

function jumpback() {

How could this be done. I know there are similar questions, but the answers could not help me.

Get this bounty!!!

#StackBounty: #javascript #elasticsearch #browser #kibana Kibana stuck on loading screen

Bounty: 50

Kibana is not starting up properly. When I open up the console it appears to be a javascript resource issue. When I open the js files directly (clicking on their link in the console) it appears they are incomplete and have been abruptly been cut off. Not sure if this is a browser file limit or somehow my files have been cut off? Please see the images below to show you what Im seeing.

Kibana stuck on loading screen

File as seen in chrome. This is the very bottom of the file as per how chrome loads it.


I have restarted kibana to see if that would resolve it, no luck.

I think browsers have a max line limit in js files. I am not sure why kibana hasn’t minified the js files? has it started up in some dev mode?

question summary

I guess I have discovered the reason for kibana not loading is because of the js not fully loading, this would change my question to how can I get all of my javascript to load?


I have located the JS files in the kibana bundles folder and found that the file is fully intact. It is indeed a browser loading complete file issue. I’m confused why suddenly those files are too long to be loaded by the browser? Was working fine a fortnight ago. Still trying to work out how I can get chrome to load the files.

As suggested by @asettouf I have removed(backed up) bundles folder in the /opt/kibana/optimize directory and started kibana up again. This did re-generate the bundles folder but the files are identical, meaning I still have the same issue. How come Kibana is not minifying the js when it bundles the files for caching?

My kibana.yml. I think it is cleaner to paste a link to it:


went back turned on verbose logging and this is my output from deleting optimize folder and restarting. nothing stands out as an error message to me.


replaced hostname with localhost for privacy and security reasons


I think this is an error with the webpack module not compiling the JS correctly. however i dont know enough about the module to debug it.

the files in question in the optimize folder are:

commons.bundle.js which is 65723 lines

kibana.bundle.js at 108950 lines

These are far from optimized and the content inside the files are not minified.

Result of curl -v localhost:5601


Get this bounty!!!

#StackBounty: #javascript #eslint Detecting nested undefined attributes using command line tools (eslint/standard)

Bounty: 50

I’d like to be able to use static code analysis tool (standard/eslint) to detect following situation:

  const obj = {a: {b: 'just a value'}}
  // should be obj.a.b
  const b = obj.a.c
  // so b will be undefined

Both Standard and ESLint will not find any issue here.
Is it possible to detect it using good code quality tools?

Just to give example, IDEA/Webstorm is reporting the problem correctly
enter image description here

so, just wondering, is it possible to detect the same issue using command line tools.

Get this bounty!!!

#StackBounty: #javascript #angularjs #routing #angular-ui-router #state-management How to pass $state variable into 2 other sibling $st…

Bounty: 200

Plnkr: https://plnkr.co/edit/Brmcxd2LjGVJ6DXwuJtF?p=preview


$login -> $container (contains $dashboard and $feed), dashboard contains: $tickers, $tags, $viewHeader and $socialMedia components.


tags needs to communicate and send a tag object into the viewHeader and socialMedia states.


After Login, selecting a button in the Tags list should send that tag into the ViewHeader and SocialMedia states/components.


After Login, selecting a button in the Tags and going to $state dashboard the $states for the ViewHeader and SocialMedia refresh but the view model variable {{ term }} does not update with the appropriate tag in either component.

enter image description here

Design explanation:

The reason I’m trying to use a mix of states, components, sibling components and views is that I’m trying to solve a problem I have where I do not want every single component re-init when something in the state changes.

IE: When I select a Ticker or a Tag I do NOT want the Feed component to refresh every single time. However the user should be able to take an action in the Feed component and it will update all the others.

This is why I created a container state to hold both the dashboard and feed states. Originally I had everything in the dashboard state, and anything $state.go('dashboard' happened the feed component would also refresh. If there is a better way to solve this issue lmk! 🙂

enter image description here

In this screenshot below I can clearly see that the correct tag is being passed into the correct $states, but yet {{ term }} does not update.

enter image description here

enter image description here

The click function in the Tags list:

$scope.clickTag = function(tag) {
  console.log(' Tag clicked', $state);
  $state.go('dashboard', { tag: tag });

socialMedia controller:

social.component('socialModule', {
  templateUrl: 'social-module-template.html',
  controller: function($scope, $state) {
    console.log('Social component', $state.params);
    $scope.term = $state.params.tag.term;

viewHeader controller:

view.component('viewModule', {
  templateUrl: 'view-module-template.html',
  controller: function($scope, $state) {
    console.log('View component', $state.params);
    $scope.term = $state.params.tag.term;

Strange doubling up of components

Just noticed this, after clicking on a tag and breaking inside of the social.component. It looks like the dashboard component is being re-rendering in place of the tags component for a split second:

enter image description here

Get this bounty!!!

#StackBounty: #javascript #neural-network #genetic-algorithm Avoid local optima training XOR

Bounty: 50

I’m using Gynaptic to train a neural network that solves an XOR with a genetic algorithm. The fitness is defined as follows:

// max score = 0
score -= Math.abs(0 - network.activate([0, 0])) * 5000;
score -= Math.abs(1 - network.activate([1, 0])) * 5000;
score -= Math.abs(1 - network.activate([0, 1])) * 5000;
score -= Math.abs(0 - network.activate([1, 1])) * 5000;

Sometimes it runs just fine. But i’m assuming it just lucked out then. But quite often, it won’t even reach -6000. It will hang around -8000 a lot.

These are my settings:

  GNN = new Evolution({
    size: 100,
    elitism: 10,
    mutationRate: 0.3,
    networkSize : [2,3,1],
    mutationMethod: [
    crossOverMethod: [
    selectionMethod: [
    generationMethod: [
    fitnessFunction: function(network){
      var score = 0;

      score -= Math.abs(0 - network.activate([0, 0])) * 5000;
      score -= Math.abs(1 - network.activate([1, 0])) * 5000;
      score -= Math.abs(1 - network.activate([0, 1])) * 5000;
      score -= Math.abs(0 - network.activate([1, 1])) * 5000;

      return Math.round(score);

(view the JSFiddle here, open console and press train)

What settings do you advise me to change?

P.S. I understand that training an XOR is much easier through backpropagation, but this is just for experimental purposes.

Get this bounty!!!

#StackBounty: #javascript #google-maps #angular2 #typescript How to remove drawn circle or polygon from google map using drawing manage…

Bounty: 50

How can I remove the drawn circle or polygon using drawing manager from the google map.


import {Ng2MapComponent, DrawingManager, Polygon} from 'ng2-map';

export class CreateAlertComponent implements OnInit {
   @ViewChild(Ng2MapComponent) mapObj: Ng2MapComponent;
   @ViewChild(DrawingManager) drawingManager: DrawingManager;

   polygonCompleteFunction(e) {



<ng2-map [zoom]="mapOptions.zoom" [minZoom]="mapOptions.minZoom" [center]="mapOptions.center" clickable="false" (click)="mapClick($event)">
                    <drawing-manager *ngIf = "selectedJurisdictions.length > 0" 
                        position: 2,
                        drawingModes: ['circle', 'polygon']
                        fillColor: 'red',
                        fillOpacity: 0.3,
                        strokeColor: 'black',
                        strokeWeight: 2,
                        editable: true,
                        draggable: true,
                        zIndex: 1
                        fillColor: 'red',
                        fillOpacity: 0.3,
                        strokeColor: 'black',
                        strokeWeight: 2,
                        editable: true,
                        draggable: true,
                        zIndex: 1

But on polygon complete function or circle complete I am not getting the drawn polygons from the map object

Get this bounty!!!

#StackBounty: #javascript #angularjs #angular2 #webpack-2 AngularJS is not found in Hybrid app

Bounty: 50

I’m building a POC of Angular 1+2 Hybrid application. I have managed to run it and now I’m trying to introduce Webpack.

I get a Error: AngularJS v1.x is not loaded! error when bootstrapping the module. I’ve checked – the angular is loaded when initializing the module.

Any help would be appreciated.

Entry file:

import { downgradeInjectable, downgradeComponent } from '@angular/upgrade/static';
import { BrowserModule } from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {HelloAngular2} from './components/hello-angular2';
import {TimeZonesService} from './services/timezones';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { UpgradeModule } from '@angular/upgrade/static';
import * as angular from 'angular';

angular.module('scotchTodo', [/*'todoController', 'todoService'*/]);
angular.module('scotchTodo').directive('helloAngular2', downgradeComponent({ component: HelloAngular2}));
angular.module('scotchTodo').factory('timeZones', downgradeInjectable(TimeZonesService));   

 declarations: [HelloAngular2],
 entryComponents: [HelloAngular2],
 imports: [BrowserModule, UpgradeModule],
 providers: [TimeZonesService]
class MyNg2Module {
    ngDoBootstrap() {};

platformBrowserDynamic().bootstrapModule(MyNg2Module).then(platformRef => {
  const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
  upgrade.bootstrap(document.documentElement, ['scotchTodo']);

Webpack config:

var webpack = require('webpack'),
    path = require('path'),
    ExtractTextPlugin = require('extract-text-webpack-plugin');

var config = {
  entry: {
    app: __dirname + '/public/js/boot.js'
  output: {
    path: __dirname + '/public/dist',
    filename: 'app-loader.js'
      extensions: ['.js'],
      alias: {
          'controllers/main.js': 'controllers/main.js',

module.exports = config;


  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  "exclude": [

Bootstrap generated part that has angular defined:

angular.module('scotchTodo', []);
angular.module('scotchTodo').directive('helloAngular2', static_1.downgradeComponent({ component: hello_angular2_1.HelloAngular2 }));
angular.module('scotchTodo').factory('timeZones', static_1.downgradeInjectable(timezones_1.TimeZonesService));
var MyNg2Module = (function () {
    function MyNg2Module() {
    MyNg2Module.prototype.ngDoBootstrap = function () { };
    return MyNg2Module;
MyNg2Module = __decorate([
        declarations: [hello_angular2_1.HelloAngular2],
        entryComponents: [hello_angular2_1.HelloAngular2],
        imports: [platform_browser_1.BrowserModule, static_2.UpgradeModule],
        providers: [timezones_1.TimeZonesService]
], MyNg2Module);
platform_browser_dynamic_1.platformBrowserDynamic().bootstrapModule(MyNg2Module).then(function (platformRef) {
    var upgrade = platformRef.injector.get(static_2.UpgradeModule);
    upgrade.bootstrap(document.documentElement, ['scotchTodo']);


After adding ProvidePlugin with this config:

new webpack.ProvidePlugin({
‘angular’: ‘angular’

the Error: AngularJS v1.x is not loaded! error which I presume came from Upgrade module has disappeared.
Now the angular is undefined in angular.module because angular is imported by __webpack_require__


It seems like the problem is that AngularJS doesn’t support CommonJS style module.exports. I’m trying to use exports-loader but it doesn’t work now. The config is:

loaders: [
      { test: /[/]angular.js$/, loader: "exports-loader?angular" }


After adding module.exports = windows.angular; to the bootstrap generated file there is no error. But application still doesn’t work because there is no resumeBootstrap function for angular available.


Here is the main page HTML:

<body ng-controller="mainController">

I'm a Todo-aholic {{ todos.length }}

<!-- TODO LIST -->
<p class="text-center" ng-show="loading"> <span class="fa fa-spinner fa-spin fa-3x"></span> </p> </div> </div> <!-- FORM TO CREATE TODOS -->
<!-- createToDo() WILL CREATE NEW TODOS --> <button type="submit" class="btn btn-primary btn-lg" ng-click="createTodo()">Add</button> </form> </div> </div>
A demo by Scotch. Read the tutorial.

Get this bounty!!!

#StackBounty: #javascript #google-maps #google-maps-api-3 Google map api directions service gives OVER_QUERY_LIMIT while displaying rou…

Bounty: 50

I’m working with project module which is using google map api direction services to draw path between multiple markers.

Here is my code:

var iconsetngs = {
    path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW

//Initialize the Path Array
var path = new google.maps.MVCArray();

//Initialize the Direction Service
var service = new google.maps.DirectionsService();

var polylineoptns = {
    strokeOpacity: 0.8,
    strokeWeight: 3,
    strokeColor: '#4986E7',
    map: map,
    icons: [{
              icon: iconsetngs,
              offset: '100%'

  var poly = new google.maps.Polyline(polylineoptns);

  //Loop and Draw Path Route between the Points on MAP
  for (var i = 0; i < lat_lng.length; i++) {
      if ((i + 1) < lat_lng.length) {
           var src = lat_lng[i];
           var des = lat_lng[i + 1];
           origin: src,
           destination: des,
           travelMode: google.maps.DirectionsTravelMode.DRIVING                              

},function (result, status) {
            if (status == google.maps.DirectionsStatus.OK) {
               for (var i = 0, len = result.routes[0].overview_path.length; i < len; i++) { 

It’s displaying route, but after some points, it’s break.
Here is the result.

enter image description here

I’m not sure where I’m wrong or missing anything!


It gives a status of OVER_QUERY_LIMIT

Get this bounty!!!