File uploaded to SharePoint library using JQuery and SharePointPlus js lib only from second click

I’m using createFile() method of SharepointPlus 5.2 js library to upload a file to a SharePoint 2013 library. It works perfect on most of the SP libraries. But on newly created SP libraries it throws an error (the file content is required) on first click, and then makes a proper upload on the second click. How to solve this issue?

The Header section includes:

<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script> <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script> <script type="text/javascript" src="/_layouts/15/sp.js"></script> <script type="text/javascript" src="/_layouts/15/init.js"></script> <script type="text/javascript" src="/_layouts/15/core.js"></script> <script type="text/javascript" src="/_layouts/15/1049/strings.js"></script> <script type="text/javascript" src="/_layouts/15/sp.ui.dialog.js"></script> <script type="text/javascript" src="/SiteAssets/_js/jquery-3.3.1.min.js"></script> <script type="text/javascript" src="/SiteAssets/_js/bootstrap.min.js"></script> <script type="text/javascript" src="/SiteAssets/_js/sharepointplus-5.2.min.js"></script> 

The HTML body:

<div data-role="form" class="container form">      <div data-field="Title">             <label class="form_label required">Title:</label><br>             <input class="form_field required" value=""></input>         </div>          <div id="fileUploadControl" >          <label class="form_label required">Document selection:</label><br/>          <input id="fileUploadInput" class="form_field" type="file"/>          </div>      <hr>      <div class="btn_panel">         <input type="button" class="btn" id="save_btn" name="Save" value="Save" onclick="_uploadFile();">          <input type="button" class="btn" id="cancel_btn" name="Cancel" value="Cancel">     </div>  </div> 

The JS function:

function _uploadFile() {    var Title = $  ('div[data-field="Title"] input').val();    var files = document.querySelector('#fileUploadInput').files;    files = Array.prototype.slice.call(files);   // read the files   Promise.all(files.map(function(file) {     return new Promise(function(prom_res, prom_rej) {       // use fileReader       var fileReader = new FileReader();       fileReader.onloadend = function(e) {         file.content = e.target.result;         prom_res(file);       }       fileReader.onerror = function(e) {         prom_rej(e.target.error);       }       fileReader.readAsArrayBuffer(file);     });   })).then(function(files) {     // upload files     return Promise.all(files.map(function(file) {       return $  SP().list("8D5132D2-A458-4961-BCD6-FFD9CE964C0F").createFile({ //Doc lib UID         content:file.content,         filename:file.name,         fields:{             "Title":Title           }       });     }))   }).then(function(file) {         alert(file[0].Name+" has been uploaded");         console.log("Document " + file[0].Name+" has been uploaded to the Outgoing documents library");     }, function(error) {         console.log("Error: ",error);     }); } 

The error in Firefox console is

uncaught exception: [SharepointPlus ‘createFile’]: the file content is required.

Debugging the file object contents shows that it exists (the size in bytes is shown). Error handler doesn’t return an error text message. On the second click on the same form (without page refresh) uploads the file and gives success message. I’m stuck, if it is a SharePoint, JQuery or SharepointPlus issue, or some conflict. Normally, the file upload from the first click is expected as the same code works on other existing libraries.

File uploaded to SharePoint library using JQuery and SharePointPlus js lib only from second click

I’m using createFile() method of SharepointPlus 5.2 js library to upload a file to a SharePoint 2013 library. It works perfect on most of the SP libraries. But on newly created SP libraries it throws an error (the file content is required) on first click, and then makes a proper upload on the second click. How to solve this issue?

The Header section includes:

<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script> <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script> <script type="text/javascript" src="/_layouts/15/sp.js"></script> <script type="text/javascript" src="/_layouts/15/init.js"></script> <script type="text/javascript" src="/_layouts/15/core.js"></script> <script type="text/javascript" src="/_layouts/15/1049/strings.js"></script> <script type="text/javascript" src="/_layouts/15/sp.ui.dialog.js"></script> <script type="text/javascript" src="/SiteAssets/_js/jquery-3.3.1.min.js"></script> <script type="text/javascript" src="/SiteAssets/_js/bootstrap.min.js"></script> <script type="text/javascript" src="/SiteAssets/_js/sharepointplus-5.2.min.js"></script> 

The HTML body:

<div data-role="form" class="container form">      <div data-field="Title">             <label class="form_label required">Title:</label><br>             <input class="form_field required" value=""></input>         </div>          <div id="fileUploadControl" >          <label class="form_label required">Document selection:</label><br/>          <input id="fileUploadInput" class="form_field" type="file"/>          </div>      <hr>      <div class="btn_panel">         <input type="button" class="btn" id="save_btn" name="Save" value="Save" onclick="_uploadFile();">          <input type="button" class="btn" id="cancel_btn" name="Cancel" value="Cancel">     </div>  </div> 

The JS function:

function _uploadFile() {    var Title = $  ('div[data-field="Title"] input').val();    var files = document.querySelector('#fileUploadInput').files;    files = Array.prototype.slice.call(files);   // read the files   Promise.all(files.map(function(file) {     return new Promise(function(prom_res, prom_rej) {       // use fileReader       var fileReader = new FileReader();       fileReader.onloadend = function(e) {         file.content = e.target.result;         prom_res(file);       }       fileReader.onerror = function(e) {         prom_rej(e.target.error);       }       fileReader.readAsArrayBuffer(file);     });   })).then(function(files) {     // upload files     return Promise.all(files.map(function(file) {       return $  SP().list("8D5132D2-A458-4961-BCD6-FFD9CE964C0F").createFile({ //Doc lib UID         content:file.content,         filename:file.name,         fields:{             "Title":Title           }       });     }))   }).then(function(file) {         alert(file[0].Name+" has been uploaded");         console.log("Document " + file[0].Name+" has been uploaded to the Outgoing documents library");     }, function(error) {         console.log("Error: ",error);     }); } 

The error in Firefox console is

uncaught exception: [SharepointPlus ‘createFile’]: the file content is required.

Debugging the file object contents shows that it exists (the size in bytes is shown). Error handler doesn’t return an error text message. On the second click on the same form (without page refresh) uploads the file and gives success message. I’m stuck, if it is a SharePoint, JQuery or SharepointPlus issue, or some conflict. Normally, the file upload from the first click is expected as the same code works on other existing libraries.

Removing / Editing Desktop Right Click Actions 16.04

I would like to remove the ‘Organize Desktop by Name’ action, or at least edit the desktop right click menu to put an indent between ‘paste’ and ‘Organize Desktop by Name’, so I don’t keep mucking up my desktop icon layout when I missclick and hit the latter when intending to hit the former.

Nautilus actions helps define and add new actions, but I’ve been unable to use it to remove already existing actions.

Any help is much appreciated.

Cycling windows by click on dock program’s icon

By now, when I click to an application in my dock it is minimized. But I would like to cycle through all open tabs of that application with this action.

I use to use the Super+number hot keys to toggle between programs, however, by this, it show me the system activities while there is multiple tabs of the target application.

How could I change this behavior?

Handle click count for documents in SharePoint 2010

I am having a page with documents loaded in SharePoint 2010. I have three buttons below each documents in the page and they are ‘Like’,’Unlike’ and ‘Comment’. So whenever people go there and see the documents they can click on any buttons of their wish.

My question is how to take the hit count of these buttons seperately and display it for each document. Is it possible to create a list with having these three columns and handle it using Client-Side scripting. Any suggestions or help is much appreciated.

What’s better action after click on the “Add To Cart” button?

Reading about the add to cart flow on e-commerce on the web and here on Stack Overflow, I observed that is a very common question but is difficult to take a decision considering that nowhere we are comparing all alternatives and not pointing why to decide for each strategy.

My question is:

In which situation should I choose each of the alternative bellows?

After click on “Add To Cart” Button:

1. Keep on the current page, make animation on the “Add to cart” button to show the item was added and show a bubble message on the mini-cart at on the header.

enter image description here

2. Keep on the current page, scroll the screen to frequently bought together and show a message that the product was added on the cart.

enter image description here

3. Open a modal with continue buying and go to checkout buttons and frequently bought together items.

enter image description here

4. Go to an intermediary page like Amazon are doing.

enter image description here

5. Redirect to the shopping cart and guarantee that has a continue buying button there.

Ps: I already read Do we need to show Cart page after user clicked “Add to Cart” from list page? and What is the best eCommerce add-to-cart flow?

I know that each one has your own good reason and interesting conversion and would be awesome if you can list pros and cons for each one to argument about your usage suggestion.

Why on all real estate websites you need to click to show the phone number?

I’ve noticed that on all real estate websites, any country, in the details page of a property, there’s always a button/field that says “show phone number“… and all it takes to see the phone number is just a click! I haven’t seen any website where it takes more than a click to show the phone number… no login/signup required, no restrictions such as “first match” (a bit like on Airbnb)…

Seems kind of pointless of hiding the phone number in the first place. Is it just an easy gimmick to track interest? Is it a “manufactured” CTA?

C++ OpenGL man appears where I click

I have a program to display a man scratching his head on an openGL window. I am wanting to make it so that where ever I click on the window, that is where the man will appear. If I right click on the man he will appear in that position with a different color.

Here is my code:

include

include // include GLUT library

include

//***********************************************************************************

std::string input; void drawPoints() {

//axis labels glColor3f(0, 0, 0); glRasterPos2i(155, -5); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, 'X'); glRasterPos2i(-5, 155); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, 'Y');  glPointSize(5); glBegin(GL_POINTS); // use points to form X-/Y-axes        // change drawing color to black for (int x = -150; x <= 150; x++) // draw X-axis     glVertex2i(x, 0); for (int y = -150; y <= 150; y++) // draw Y-axis     glVertex2i(0, y); glEnd();      static GLubyte smiley[] = /* 16x16 smiley face */ {   0x01, 0x80, 0, 0,  ///1   0x03, 0xE0, 0, 0,   0x01, 0xFF, 0x80, 0,   0x00, 0x3f, 0x80, 0,   0x70, 0x00, 0x80, 0,  ///2   0xFC, 0x00, 0x80, 0,   0x1f, 0x80, 0x80, 0,   0x03, 0xC0, 0xC0, 0,   0x00, 0xC1, 0x80, 0, //3   0x00, 0xC1, 0x80, 0,   0x00, 0xc1, 0x80, 0,   0x00, 0xc3, 0, 0,   0x00, 0xC3, 0, 0, //4   0x00, 0x86, 0, 0,   0x00, 0x86, 0, 0,   0x00, 0x8c, 0, 0 ,     0x00, 0x8c, 0, 0,//5     0x01, 0x8c, 0, 0,     0x01, 0x9c, 0, 0,     0x01, 0x9c, 0, 0,     0x01, 0x9c, 0, 0,//6     0x01, 0xDC, 0, 0,     0x01, 0xDC, 0, 0,     0x01, 0xFC, 0, 0,     0x01, 0xFC, 0x10, 0,//7     0x01, 0xFE, 0x70, 0,     0x01, 0xFE, 0xC0, 0,     0x03, 0xFF, 0x80, 0,     0x03, 0xFF, 0, 0,//8     0x03, 0xFF, 0, 0,     0x03, 0xFD, 0xFC, 0,     0x03, 0xF8, 0x3, 0,//////////     0x03, 0xF8, 0x3, 0,//9     0x03, 0xF8, 0x6, 0,     0x03, 0xF8, 0xC, 0,     0x03, 0xF8, 0x18, 0,     0x03, 0xFc, 0x70, 0,//10/////     0x03, 0xFC, 0xE0, 0,     0x01, 0xFD, 0xC0, 0,     0x01, 0xFF, 0xC0, 0,/////     0x01, 0xFF, 0x80, 0,//11     0x03, 0xFF, 0, 0,     0x07, 0xBE, 0, 0,     0x0F, 0x98, 0, 0,     0x0F, 0x30, 0, 0,//12     0x1E, 0x3c, 0, 0,     0x3c, 0x7f, 0, 0,     0x38, 0x7f, 0x80, 0,     0x70, 0x7f, 0xc0, 0,//13     0x63, 0xFF, 0xE0, 0,     0x60, 0x7f, 0xF0, 0,     0xE0, 0x3f, 0xF0, 0,/////     0xE0, 0x1f, 0xF0, 0,//14     0xE0, 0x1f, 0xF0, 0,     0xF0, 0x0F, 0xF0, 0,     0x3f, 0xF7, 0xF0, 0,     0x01, 0xF3, 0xF0, 0,//5///     0x00, 0x10, 0x1c, 0,     0x00, 0x18, 0x06, 0,     0x00, 0x0F, 0x06, 0,     0x00, 0x06, 0x01, 0,//5////     0x00, 0x00, 0x01, 0xc0,     0x00, 0x00, 0, 0x20,     0x00, 0x00, 0, 0x20,     0x00, 0x00, 0, 0xE0,//5     0x00, 0x00, 0, 0,     0x00, 0x00, 0, 0,     0x00, 0x00, 0, 0, };   glMatrixMode(GL_PROJECTION);  /*  * This bitmap is aligned to 4-byte boundaries…  */  glPixelTransferi(GL_UNPACK_ALIGNMENT, 4);  glColor3f(1.0, 0.0, 0.0); glRasterPos2i(0, 0); glBitmap(32, 72, 8.0, 8.0, 0.0, 0.0, smiley); 

}

//*********************************************************************************** void myInit() { glClearColor(1, 1, 1, 0); // specify a background clor: white gluOrtho2D(-200, 200, -200, 200); // specify a viewing area }

//*********************************************************************************** void myDisplayCallback() { glClear(GL_COLOR_BUFFER_BIT); // draw the background

drawPoints();  glFlush(); // flush out the buffer contents 

}

//*********************************************************************************** int main(int argc, char** argv) {
glutInit(& argc, argv);

glutInitWindowSize(400, 400);               // specify a window size glutInitWindowPosition(100, 0);         // specify a window position glutCreateWindow("Simple Point Drawing");   // create a titled window  myInit();                                   // setting up  glutDisplayFunc(myDisplayCallback);     // register a callback  glutMainLoop();                         // get into an infinite loop  return 0; 

}

Calcluate Mesh top, bottom, left and right position relative to mouse click position on the mesh

I have a mesh (suppose it can be circle, or rectangular,square or an arc). The geometry of the mesh can be anything. I can click on mesh at any position. From relative to the clicked position, I want to get its right, left top and bottom position of the mesh. Maybe the picture explain it better then my words enter image description here