How to use _dispatch method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

pymol.js

Source: pymol.js Github

copy
1// This file contains source code for the PyMOL computer program
2// Copyright (c) Schrodinger, LLC.
3
4var pymol_fn_counter = 0;
5
6function PyMOL(host, port, bufferMode, prefix) {
7
8    this.Path = "/apply?_json="; // URL path to pass json args to pymol
9
10    // now using _underscore_names for internal attributes & methods
11
12    this._cmd_buffer = [];
13
14    // do we throw up visible alerts when exceptions occur?
15
16    this._alerts = true;
17
18    this._host = host;
19    this._port = port;
20
21    this._parseBufferMode = function (bufferMode) {
22        if ((bufferMode != undefined) && (bufferMode == 'on')) {
23            return 'on';
24        } else {
25            return 'off';
26        }
27    }
28    this._bufferMode = this._parseBufferMode(bufferMode);
29
30    if(prefix == undefined) {
31        this._prefix = 'pymol'; // default remote object name
32    } else {
33        this._prefix = prefix;
34    }
35
36    try {
37        xmlhttp = new XMLHttpRequest();
38    } catch(e) {
39        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
40    }
41
42    this.setBufferMode = function(bufferMode) {
43        this._bufferMode = this._parseBufferMode(bufferMode);
44        if (this._bufferMode == 'off') {
45            this.flush();
46        }
47    }
48
49    this.flush = function(callback) {
50        if (this._cmd_buffer.length > 0) {
51            var result = this._json('[' + this._cmd_buffer.join(',') + ']', callback);
52            this._cmd_buffer.length = 0;
53            return result;
54        }
55    }
56    this.getBufferJSON = function() {
57        return ('[' + this._cmd_buffer.join(',') + ']');
58    }
59    this.getBufferURL = function() {
60        return (this.Path + '[' + this._cmd_buffer.join(',') + ']');
61    }
62
63    this._send_ajax = function(pypath, callback) {
64        if (host == null) {
65            myurl = pypath;
66        } else {
67            myurl = "http://" + host + ":" + port + pypath;
68        }
69        if(myurl.length>2000) { /* some broswers can't handle long URLs */
70            var part = myurl.split("?",2);
71            short_url = part[0];
72            long_param = part[1];
73            if (callback) {
74                xmlhttp.open("POST", short_url, true);
75                xmlhttp.onreadystatechange = callback;
76            } else {
77                xmlhttp.open("POST", short_url, false);
78            }
79            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
80            xmlhttp.setRequestHeader("Content-length", long_param.length);
81            xmlhttp.setRequestHeader('Accept', 'text/json');
82            xmlhttp.send(long_param);
83        } else {
84            if (callback) {
85                xmlhttp.open("GET", myurl, true);
86                xmlhttp.onreadystatechange = callback;
87            } else {
88                xmlhttp.open("GET", myurl, false);
89            }
90            xmlhttp.setRequestHeader('Accept', 'text/json');
91            xmlhttp.send(null);
92        }
93        if (callback) {
94        } else {
95            if (xmlhttp.status == 500) {
96                alert("PyMOL Exception:\n" + eval('(' + xmlhttp.responseText + ')').join("\n"));
97                return null;
98            } 
99            return eval('(' + xmlhttp.responseText + ')');
100        }
101        return false;
102    }
103    
104    this._send_cross_script = function(pypath, callback) {
105        if (host == null) {
106            myurl = pypath;
107        } else {
108            myurl = "http://" + host + ":" + port + pypath;
109        }
110        if (callback == undefined) {
111            //myurl +=  "&_callback=alert"
112            myurl +=  "&_callback=void"
113        } else {
114            // IE does not have callback.name, so we invent a unique one
115            // and store it in the "global" namespace, window.  In this way,
116            // the javascript callback from our cross-domain script hack
117            // contains a javascript function name known to this page/window.
118            if (callback.name == undefined) {
119               callback.name = '_fn' + pymol_fn_counter++;
120               window[ callback.name ] = callback;
121            } 
122            myurl +=  "&_callback=" + callback.name;
123        }
124        var head = document.getElementsByTagName("head")[0];
125        var script = document.createElement("script");
126        script.src = myurl;
127        head.appendChild(script);
128        return true;
129    }
130
131    this._send = function(pypath, callback) {
132        if ( (host == null) || 
133             ((host == document.domain) && (port == document.location.port)) ) {
134            return this._send_ajax(pypath, callback);
135        } else {
136            return this._send_cross_script(pypath, callback);
137        }
138    }
139    
140    this._handle_response = function(status, text) {
141        response = JSON.parse(text);
142        if(status == 200) { // normal result
143            return response;
144        } else { // some kind of error condition
145            if(this._alerts) {
146                alert(response.join("\n"));
147            }
148            return;
149        }
150    }
151
152    this._result = function(e) {
153        if ((host == document.domain) || (host == null)) {
154            if (typeof e == "object") {
155                // asynchronous ajax was used
156                if (xmlhttp.readyState == 4) {
157                    return this._handle_response(xmlhttp.status, xmlhttp.responseText);
158                    return;
159                }
160            }
161            // "synchronous" (no-callback) ajax was used
162            if(xmlhttp.responseText) {
163                return this._handle_response(xmlhttp.status, xmlhttp.responseText);
164            } else {
165                return;
166            }
167        } 
168        // e was provided by cross-script callback, so just return it
169        return e;
170    }
171
172    // for private use
173    this._json = function(jcmd,callback) {
174        return this._send(this.Path+jcmd,callback);
175    }
176    // for public use;  args switched to match style of pymol.cmd calls
177    this.sendJSON = function(anyargs) {
178        if (typeof arguments[0] == 'function') {
179            //this.sendJSON = function(callback, jcmd) {
180            callback = arguments[0];
181            jcmd     = arguments[1];
182        } else {
183            //this.sendJSON = function(jcmd) {
184            callback = null;
185            jcmd     = arguments[0];
186        }
187        return this._send(this.Path+jcmd,callback);
188    }
189
190    this._apply = function(name, args, kwds, callback) {
191        // note: javascript's 'this' can refer to either pymol or cmd
192        if (name.substring(0,1) == '.') { // .cmd.method -> pymol.cmd.method
193            name = this._prefix + name;
194        }
195        var mypath = this.Path;
196        var myargs = '["' + name + '"';
197        if (args != null)  {
198            myargs = myargs + "," + JSON.stringify(args);
199            if(kwds != null) {
200                myargs = myargs + "," + JSON.stringify(kwds);
201            }
202        } else if(kwds != null) {
203            myargs = myargs + ",[]," + JSON.stringify(kwds)
204        }
205        myargs = myargs + "]";
206
207        //        document.getElementById('debug').innerHTML = mypath;
208
209        if (this._bufferMode == 'on') {
210            this._cmd_buffer.push(myargs);
211            if ( callback ) {
212                this.flush(callback);
213            } else {
214                return;
215            }
216        } else {
217            return this._send(mypath+myargs,callback);
218        }
219    }
220
221    this.apply_cmd = function(name, args, kwds, callback) {
222        this._apply(".cmd." + name, args, kwds, callback);
223    }
224
225    this.cmd = { // cmd is a public attribute of PyMOL instances
226        
227        _dispatch: function(anyargs) {
228           //  name is always first argument
229           var name = ".cmd." + arguments[0];
230           // callback function is optional second argument
231           var callback = undefined;
232           var argstart = 1;
233           if (typeof arguments[1] == 'function') {
234             callback = arguments[1];
235             argstart = 2;
236           }
237           return this._outer._apply(name,Array.prototype.slice.apply(arguments).slice(argstart),null,callback);
238        },
239
240        // BEGIN MACHINE-GENERATED CODE
241        // python webapi.py
242
243        load: function() {
244            return this._dispatch.apply(this,
245                ["load"].concat(Array.prototype.slice.apply(arguments)));
246        },
247        load_traj: function() {
248            return this._dispatch.apply(this,
249                ["load_traj"].concat(Array.prototype.slice.apply(arguments)));
250        },
251        load_png: function() {
252            return this._dispatch.apply(this,
253                ["load_png"].concat(Array.prototype.slice.apply(arguments)));
254        },
255        fragment: function() {
256            return this._dispatch.apply(this,
257                ["fragment"].concat(Array.prototype.slice.apply(arguments)));
258        },
259        fetch: function() {
260            return this._dispatch.apply(this,
261                ["fetch"].concat(Array.prototype.slice.apply(arguments)));
262        },
263        read_mmodstr: function() {
264            return this._dispatch.apply(this,
265                ["read_mmodstr"].concat(Array.prototype.slice.apply(arguments)));
266        },
267        read_molstr: function() {
268            return this._dispatch.apply(this,
269                ["read_molstr"].concat(Array.prototype.slice.apply(arguments)));
270        },
271        read_sdfstr: function() {
272            return this._dispatch.apply(this,
273                ["read_sdfstr"].concat(Array.prototype.slice.apply(arguments)));
274        },
275        read_pdbstr: function() {
276            return this._dispatch.apply(this,
277                ["read_pdbstr"].concat(Array.prototype.slice.apply(arguments)));
278        },
279        read_xplorstr: function() {
280            return this._dispatch.apply(this,
281                ["read_xplorstr"].concat(Array.prototype.slice.apply(arguments)));
282        },
283        get_pdbstr: function() {
284            return this._dispatch.apply(this,
285                ["get_pdbstr"].concat(Array.prototype.slice.apply(arguments)));
286        },
287        get_fastastr: function() {
288            return this._dispatch.apply(this,
289                ["get_fastastr"].concat(Array.prototype.slice.apply(arguments)));
290        },
291        copy: function() {
292            return this._dispatch.apply(this,
293                ["copy"].concat(Array.prototype.slice.apply(arguments)));
294        },
295        create: function() {
296            return this._dispatch.apply(this,
297                ["create"].concat(Array.prototype.slice.apply(arguments)));
298        },
299        extract: function() {
300            return this._dispatch.apply(this,
301                ["extract"].concat(Array.prototype.slice.apply(arguments)));
302        },
303        split_states: function() {
304            return this._dispatch.apply(this,
305                ["split_states"].concat(Array.prototype.slice.apply(arguments)));
306        },
307        symexp: function() {
308            return this._dispatch.apply(this,
309                ["symexp"].concat(Array.prototype.slice.apply(arguments)));
310        },
311        ramp_new: function() {
312            return this._dispatch.apply(this,
313                ["ramp_new"].concat(Array.prototype.slice.apply(arguments)));
314        },
315        set_name: function() {
316            return this._dispatch.apply(this,
317                ["set_name"].concat(Array.prototype.slice.apply(arguments)));
318        },
319        map_new: function() {
320            return this._dispatch.apply(this,
321                ["map_new"].concat(Array.prototype.slice.apply(arguments)));
322        },
323        map_set: function() {
324            return this._dispatch.apply(this,
325                ["map_set"].concat(Array.prototype.slice.apply(arguments)));
326        },
327        map_set_border: function() {
328            return this._dispatch.apply(this,
329                ["map_set_border"].concat(Array.prototype.slice.apply(arguments)));
330        },
331        map_double: function() {
332            return this._dispatch.apply(this,
333                ["map_double"].concat(Array.prototype.slice.apply(arguments)));
334        },
335        map_halve: function() {
336            return this._dispatch.apply(this,
337                ["map_halve"].concat(Array.prototype.slice.apply(arguments)));
338        },
339        map_trim: function() {
340            return this._dispatch.apply(this,
341                ["map_trim"].concat(Array.prototype.slice.apply(arguments)));
342        },
343        isodot: function() {
344            return this._dispatch.apply(this,
345                ["isodot"].concat(Array.prototype.slice.apply(arguments)));
346        },
347        isolevel: function() {
348            return this._dispatch.apply(this,
349                ["isolevel"].concat(Array.prototype.slice.apply(arguments)));
350        },
351        isomesh: function() {
352            return this._dispatch.apply(this,
353                ["isomesh"].concat(Array.prototype.slice.apply(arguments)));
354        },
355        isosurface: function() {
356            return this._dispatch.apply(this,
357                ["isosurface"].concat(Array.prototype.slice.apply(arguments)));
358        },
359        slice_new: function() {
360            return this._dispatch.apply(this,
361                ["slice_new"].concat(Array.prototype.slice.apply(arguments)));
362        },
363        gradient: function() {
364            return this._dispatch.apply(this,
365                ["gradient"].concat(Array.prototype.slice.apply(arguments)));
366        },
367        ungroup: function() {
368            return this._dispatch.apply(this,
369                ["ungroup"].concat(Array.prototype.slice.apply(arguments)));
370        },
371        group: function() {
372            return this._dispatch.apply(this,
373                ["group"].concat(Array.prototype.slice.apply(arguments)));
374        },
375        pseudoatom: function() {
376            return this._dispatch.apply(this,
377                ["pseudoatom"].concat(Array.prototype.slice.apply(arguments)));
378        },
379        fab: function() {
380            return this._dispatch.apply(this,
381                ["fab"].concat(Array.prototype.slice.apply(arguments)));
382        },
383        enable: function() {
384            return this._dispatch.apply(this,
385                ["enable"].concat(Array.prototype.slice.apply(arguments)));
386        },
387        disable: function() {
388            return this._dispatch.apply(this,
389                ["disable"].concat(Array.prototype.slice.apply(arguments)));
390        },
391        delete_: function() {
392            return this._dispatch.apply(this,
393                ["delete_"].concat(Array.prototype.slice.apply(arguments)));
394        },
395        reinitialize: function() {
396            return this._dispatch.apply(this,
397                ["reinitialize"].concat(Array.prototype.slice.apply(arguments)));
398        },
399        deselect: function() {
400            return this._dispatch.apply(this,
401                ["deselect"].concat(Array.prototype.slice.apply(arguments)));
402        },
403        select: function() {
404            return this._dispatch.apply(this,
405                ["select"].concat(Array.prototype.slice.apply(arguments)));
406        },
407        indicate: function() {
408            return this._dispatch.apply(this,
409                ["indicate"].concat(Array.prototype.slice.apply(arguments)));
410        },
411        select_list: function() {
412            return this._dispatch.apply(this,
413                ["select_list"].concat(Array.prototype.slice.apply(arguments)));
414        },
415        pop: function() {
416            return this._dispatch.apply(this,
417                ["pop"].concat(Array.prototype.slice.apply(arguments)));
418        },
419        angle: function() {
420            return this._dispatch.apply(this,
421                ["angle"].concat(Array.prototype.slice.apply(arguments)));
422        },
423        dihedral: function() {
424            return this._dispatch.apply(this,
425                ["dihedral"].concat(Array.prototype.slice.apply(arguments)));
426        },
427        dist: function() {
428            return this._dispatch.apply(this,
429                ["dist"].concat(Array.prototype.slice.apply(arguments)));
430        },
431        distance: function() {
432            return this._dispatch.apply(this,
433                ["distance"].concat(Array.prototype.slice.apply(arguments)));
434        },
435        get_angle: function() {
436            return this._dispatch.apply(this,
437                ["get_angle"].concat(Array.prototype.slice.apply(arguments)));
438        },
439        get_dihedral: function() {
440            return this._dispatch.apply(this,
441                ["get_dihedral"].concat(Array.prototype.slice.apply(arguments)));
442        },
443        get_distance: function() {
444            return this._dispatch.apply(this,
445                ["get_distance"].concat(Array.prototype.slice.apply(arguments)));
446        },
447        get_area: function() {
448            return this._dispatch.apply(this,
449                ["get_area"].concat(Array.prototype.slice.apply(arguments)));
450        },
451        color: function() {
452            return this._dispatch.apply(this,
453                ["color"].concat(Array.prototype.slice.apply(arguments)));
454        },
455        bg_color: function() {
456            return this._dispatch.apply(this,
457                ["bg_color"].concat(Array.prototype.slice.apply(arguments)));
458        },
459        rebuild: function() {
460            return this._dispatch.apply(this,
461                ["rebuild"].concat(Array.prototype.slice.apply(arguments)));
462        },
463        refresh: function() {
464            return this._dispatch.apply(this,
465                ["refresh"].concat(Array.prototype.slice.apply(arguments)));
466        },
467        recolor: function() {
468            return this._dispatch.apply(this,
469                ["recolor"].concat(Array.prototype.slice.apply(arguments)));
470        },
471        set_color: function() {
472            return this._dispatch.apply(this,
473                ["set_color"].concat(Array.prototype.slice.apply(arguments)));
474        },
475        set_object_color: function() {
476            return this._dispatch.apply(this,
477                ["set_object_color"].concat(Array.prototype.slice.apply(arguments)));
478        },
479        show: function() {
480            return this._dispatch.apply(this,
481                ["show"].concat(Array.prototype.slice.apply(arguments)));
482        },
483        show_as: function() {
484            return this._dispatch.apply(this,
485                ["show_as"].concat(Array.prototype.slice.apply(arguments)));
486        },
487        hide: function() {
488            return this._dispatch.apply(this,
489                ["hide"].concat(Array.prototype.slice.apply(arguments)));
490        },
491        cartoon: function() {
492            return this._dispatch.apply(this,
493                ["cartoon"].concat(Array.prototype.slice.apply(arguments)));
494        },
495        spectrum: function() {
496            return this._dispatch.apply(this,
497                ["spectrum"].concat(Array.prototype.slice.apply(arguments)));
498        },
499        center: function() {
500            return this._dispatch.apply(this,
501                ["center"].concat(Array.prototype.slice.apply(arguments)));
502        },
503        zoom: function() {
504            return this._dispatch.apply(this,
505                ["zoom"].concat(Array.prototype.slice.apply(arguments)));
506        },
507        reset: function() {
508            return this._dispatch.apply(this,
509                ["reset"].concat(Array.prototype.slice.apply(arguments)));
510        },
511        clip: function() {
512            return this._dispatch.apply(this,
513                ["clip"].concat(Array.prototype.slice.apply(arguments)));
514        },
515        orient: function() {
516            return this._dispatch.apply(this,
517                ["orient"].concat(Array.prototype.slice.apply(arguments)));
518        },
519        origin: function() {
520            return this._dispatch.apply(this,
521                ["origin"].concat(Array.prototype.slice.apply(arguments)));
522        },
523        set_view: function() {
524            return this._dispatch.apply(this,
525                ["set_view"].concat(Array.prototype.slice.apply(arguments)));
526        },
527        get_view: function() {
528            return this._dispatch.apply(this,
529                ["get_view"].concat(Array.prototype.slice.apply(arguments)));
530        },
531        move: function() {
532            return this._dispatch.apply(this,
533                ["move"].concat(Array.prototype.slice.apply(arguments)));
534        },
535        turn: function() {
536            return this._dispatch.apply(this,
537                ["turn"].concat(Array.prototype.slice.apply(arguments)));
538        },
539        rock: function() {
540            return this._dispatch.apply(this,
541                ["rock"].concat(Array.prototype.slice.apply(arguments)));
542        },
543        stereo: function() {
544            return this._dispatch.apply(this,
545                ["stereo"].concat(Array.prototype.slice.apply(arguments)));
546        },
547        get: function() {
548            return this._dispatch.apply(this,
549                ["get"].concat(Array.prototype.slice.apply(arguments)));
550        },
551        set: function() {
552            return this._dispatch.apply(this,
553                ["set"].concat(Array.prototype.slice.apply(arguments)));
554        },
555        set_bond: function() {
556            return this._dispatch.apply(this,
557                ["set_bond"].concat(Array.prototype.slice.apply(arguments)));
558        },
559        unset: function() {
560            return this._dispatch.apply(this,
561                ["unset"].concat(Array.prototype.slice.apply(arguments)));
562        },
563        unset_bond: function() {
564            return this._dispatch.apply(this,
565                ["unset_bond"].concat(Array.prototype.slice.apply(arguments)));
566        },
567        get_setting_boolean: function() {
568            return this._dispatch.apply(this,
569                ["get_setting_boolean"].concat(Array.prototype.slice.apply(arguments)));
570        },
571        get_setting_int: function() {
572            return this._dispatch.apply(this,
573                ["get_setting_int"].concat(Array.prototype.slice.apply(arguments)));
574        },
575        get_setting_float: function() {
576            return this._dispatch.apply(this,
577                ["get_setting_float"].concat(Array.prototype.slice.apply(arguments)));
578        },
579        get_setting_tuple: function() {
580            return this._dispatch.apply(this,
581                ["get_setting_tuple"].concat(Array.prototype.slice.apply(arguments)));
582        },
583        get_setting_text: function() {
584            return this._dispatch.apply(this,
585                ["get_setting_text"].concat(Array.prototype.slice.apply(arguments)));
586        },
587        window: function() {
588            return this._dispatch.apply(this,
589                ["window"].concat(Array.prototype.slice.apply(arguments)));
590        },
591        viewport: function() {
592            return this._dispatch.apply(this,
593                ["viewport"].concat(Array.prototype.slice.apply(arguments)));
594        },
595        full_screen: function() {
596            return this._dispatch.apply(this,
597                ["full_screen"].concat(Array.prototype.slice.apply(arguments)));
598        },
599        quit: function() {
600            return this._dispatch.apply(this,
601                ["quit"].concat(Array.prototype.slice.apply(arguments)));
602        },
603        draw: function() {
604            return this._dispatch.apply(this,
605                ["draw"].concat(Array.prototype.slice.apply(arguments)));
606        },
607        ray: function() {
608            return this._dispatch.apply(this,
609                ["ray"].concat(Array.prototype.slice.apply(arguments)));
610        },
611        align: function() {
612            return this._dispatch.apply(this,
613                ["align"].concat(Array.prototype.slice.apply(arguments)));
614        },
615        super_: function() {
616            return this._dispatch.apply(this,
617                ["super_"].concat(Array.prototype.slice.apply(arguments)));
618        },
619        fit: function() {
620            return this._dispatch.apply(this,
621                ["fit"].concat(Array.prototype.slice.apply(arguments)));
622        },
623        rms: function() {
624            return this._dispatch.apply(this,
625                ["rms"].concat(Array.prototype.slice.apply(arguments)));
626        },
627        rms_cur: function() {
628            return this._dispatch.apply(this,
629                ["rms_cur"].concat(Array.prototype.slice.apply(arguments)));
630        },
631        intra_fit: function() {
632            return this._dispatch.apply(this,
633                ["intra_fit"].concat(Array.prototype.slice.apply(arguments)));
634        },
635        intra_rms: function() {
636            return this._dispatch.apply(this,
637                ["intra_rms"].concat(Array.prototype.slice.apply(arguments)));
638        },
639        intra_rms_cur: function() {
640            return this._dispatch.apply(this,
641                ["intra_rms_cur"].concat(Array.prototype.slice.apply(arguments)));
642        },
643        pair_fit: function() {
644            return this._dispatch.apply(this,
645                ["pair_fit"].concat(Array.prototype.slice.apply(arguments)));
646        },
647        space: function() {
648            return this._dispatch.apply(this,
649                ["space"].concat(Array.prototype.slice.apply(arguments)));
650        },
651        order: function() {
652            return this._dispatch.apply(this,
653                ["order"].concat(Array.prototype.slice.apply(arguments)));
654        },
655        edit_mode: function() {
656            return this._dispatch.apply(this,
657                ["edit_mode"].concat(Array.prototype.slice.apply(arguments)));
658        },
659        button: function() {
660            return this._dispatch.apply(this,
661                ["button"].concat(Array.prototype.slice.apply(arguments)));
662        },
663        config_mouse: function() {
664            return this._dispatch.apply(this,
665                ["config_mouse"].concat(Array.prototype.slice.apply(arguments)));
666        },
667        mouse: function() {
668            return this._dispatch.apply(this,
669                ["mouse"].concat(Array.prototype.slice.apply(arguments)));
670        },
671        mask: function() {
672            return this._dispatch.apply(this,
673                ["mask"].concat(Array.prototype.slice.apply(arguments)));
674        },
675        unmask: function() {
676            return this._dispatch.apply(this,
677                ["unmask"].concat(Array.prototype.slice.apply(arguments)));
678        },
679        count_atoms: function() {
680            return this._dispatch.apply(this,
681                ["count_atoms"].concat(Array.prototype.slice.apply(arguments)));
682        },
683        get_chains: function() {
684            return this._dispatch.apply(this,
685                ["get_chains"].concat(Array.prototype.slice.apply(arguments)));
686        },
687        get_color_index: function() {
688            return this._dispatch.apply(this,
689                ["get_color_index"].concat(Array.prototype.slice.apply(arguments)));
690        },
691        get_color_indices: function() {
692            return this._dispatch.apply(this,
693                ["get_color_indices"].concat(Array.prototype.slice.apply(arguments)));
694        },
695        get_object_color_index: function() {
696            return this._dispatch.apply(this,
697                ["get_object_color_index"].concat(Array.prototype.slice.apply(arguments)));
698        },
699        get_object_list: function() {
700            return this._dispatch.apply(this,
701                ["get_object_list"].concat(Array.prototype.slice.apply(arguments)));
702        },
703        get_color_tuple: function() {
704            return this._dispatch.apply(this,
705                ["get_color_tuple"].concat(Array.prototype.slice.apply(arguments)));
706        },
707        get_atom_coords: function() {
708            return this._dispatch.apply(this,
709                ["get_atom_coords"].concat(Array.prototype.slice.apply(arguments)));
710        },
711        get_extent: function() {
712            return this._dispatch.apply(this,
713                ["get_extent"].concat(Array.prototype.slice.apply(arguments)));
714        },
715        get_names: function() {
716            return this._dispatch.apply(this,
717                ["get_names"].concat(Array.prototype.slice.apply(arguments)));
718        },
719        get_names_of_type: function() {
720            return this._dispatch.apply(this,
721                ["get_names_of_type"].concat(Array.prototype.slice.apply(arguments)));
722        },
723        get_legal_name: function() {
724            return this._dispatch.apply(this,
725                ["get_legal_name"].concat(Array.prototype.slice.apply(arguments)));
726        },
727        get_unused_name: function() {
728            return this._dispatch.apply(this,
729                ["get_unused_name"].concat(Array.prototype.slice.apply(arguments)));
730        },
731        get_object_matrix: function() {
732            return this._dispatch.apply(this,
733                ["get_object_matrix"].concat(Array.prototype.slice.apply(arguments)));
734        },
735        get_phipsi: function() {
736            return this._dispatch.apply(this,
737                ["get_phipsi"].concat(Array.prototype.slice.apply(arguments)));
738        },
739        get_position: function() {
740            return this._dispatch.apply(this,
741                ["get_position"].concat(Array.prototype.slice.apply(arguments)));
742        },
743        get_raw_alignment: function() {
744            return this._dispatch.apply(this,
745                ["get_raw_alignment"].concat(Array.prototype.slice.apply(arguments)));
746        },
747        get_renderer: function() {
748            return this._dispatch.apply(this,
749                ["get_renderer"].concat(Array.prototype.slice.apply(arguments)));
750        },
751        get_symmetry: function() {
752            return this._dispatch.apply(this,
753                ["get_symmetry"].concat(Array.prototype.slice.apply(arguments)));
754        },
755        get_title: function() {
756            return this._dispatch.apply(this,
757                ["get_title"].concat(Array.prototype.slice.apply(arguments)));
758        },
759        get_type: function() {
760            return this._dispatch.apply(this,
761                ["get_type"].concat(Array.prototype.slice.apply(arguments)));
762        },
763        get_version: function() {
764            return this._dispatch.apply(this,
765                ["get_version"].concat(Array.prototype.slice.apply(arguments)));
766        },
767        id_atom: function() {
768            return this._dispatch.apply(this,
769                ["id_atom"].concat(Array.prototype.slice.apply(arguments)));
770        },
771        identify: function() {
772            return this._dispatch.apply(this,
773                ["identify"].concat(Array.prototype.slice.apply(arguments)));
774        },
775        index: function() {
776            return this._dispatch.apply(this,
777                ["index"].concat(Array.prototype.slice.apply(arguments)));
778        },
779        phi_psi: function() {
780            return this._dispatch.apply(this,
781                ["phi_psi"].concat(Array.prototype.slice.apply(arguments)));
782        },
783        matrix_copy: function() {
784            return this._dispatch.apply(this,
785                ["matrix_copy"].concat(Array.prototype.slice.apply(arguments)));
786        },
787        matrix_reset: function() {
788            return this._dispatch.apply(this,
789                ["matrix_reset"].concat(Array.prototype.slice.apply(arguments)));
790        },
791        rotate: function() {
792            return this._dispatch.apply(this,
793                ["rotate"].concat(Array.prototype.slice.apply(arguments)));
794        },
795        translate: function() {
796            return this._dispatch.apply(this,
797                ["translate"].concat(Array.prototype.slice.apply(arguments)));
798        },
799        set_object_ttt: function() {
800            return this._dispatch.apply(this,
801                ["set_object_ttt"].concat(Array.prototype.slice.apply(arguments)));
802        },
803        set_dihedral: function() {
804            return this._dispatch.apply(this,
805                ["set_dihedral"].concat(Array.prototype.slice.apply(arguments)));
806        },
807        transform_object: function() {
808            return this._dispatch.apply(this,
809                ["transform_object"].concat(Array.prototype.slice.apply(arguments)));
810        },
811        transform_selection: function() {
812            return this._dispatch.apply(this,
813                ["transform_selection"].concat(Array.prototype.slice.apply(arguments)));
814        },
815        translate_atom: function() {
816            return this._dispatch.apply(this,
817                ["translate_atom"].concat(Array.prototype.slice.apply(arguments)));
818        },
819        update: function() {
820            return this._dispatch.apply(this,
821                ["update"].concat(Array.prototype.slice.apply(arguments)));
822        },
823        attach: function() {
824            return this._dispatch.apply(this,
825                ["attach"].concat(Array.prototype.slice.apply(arguments)));
826        },
827        bond: function() {
828            return this._dispatch.apply(this,
829                ["bond"].concat(Array.prototype.slice.apply(arguments)));
830        },
831        unbond: function() {
832            return this._dispatch.apply(this,
833                ["unbond"].concat(Array.prototype.slice.apply(arguments)));
834        },
835        cycle_valence: function() {
836            return this._dispatch.apply(this,
837                ["cycle_valence"].concat(Array.prototype.slice.apply(arguments)));
838        },
839        drag: function() {
840            return this._dispatch.apply(this,
841                ["drag"].concat(Array.prototype.slice.apply(arguments)));
842        },
843        dss: function() {
844            return this._dispatch.apply(this,
845                ["dss"].concat(Array.prototype.slice.apply(arguments)));
846        },
847        edit: function() {
848            return this._dispatch.apply(this,
849                ["edit"].concat(Array.prototype.slice.apply(arguments)));
850        },
851        unpick: function() {
852            return this._dispatch.apply(this,
853                ["unpick"].concat(Array.prototype.slice.apply(arguments)));
854        },
855        fix_chemistry: function() {
856            return this._dispatch.apply(this,
857                ["fix_chemistry"].concat(Array.prototype.slice.apply(arguments)));
858        },
859        flag: function() {
860            return this._dispatch.apply(this,
861                ["flag"].concat(Array.prototype.slice.apply(arguments)));
862        },
863        fuse: function() {
864            return this._dispatch.apply(this,
865                ["fuse"].concat(Array.prototype.slice.apply(arguments)));
866        },
867        get_editor_scheme: function() {
868            return this._dispatch.apply(this,
869                ["get_editor_scheme"].concat(Array.prototype.slice.apply(arguments)));
870        },
871        h_add: function() {
872            return this._dispatch.apply(this,
873                ["h_add"].concat(Array.prototype.slice.apply(arguments)));
874        },
875        h_fill: function() {
876            return this._dispatch.apply(this,
877                ["h_fill"].concat(Array.prototype.slice.apply(arguments)));
878        },
879        h_fix: function() {
880            return this._dispatch.apply(this,
881                ["h_fix"].concat(Array.prototype.slice.apply(arguments)));
882        },
883        invert: function() {
884            return this._dispatch.apply(this,
885                ["invert"].concat(Array.prototype.slice.apply(arguments)));
886        },
887        torsion: function() {
888            return this._dispatch.apply(this,
889                ["torsion"].concat(Array.prototype.slice.apply(arguments)));
890        },
891        valence: function() {
892            return this._dispatch.apply(this,
893                ["valence"].concat(Array.prototype.slice.apply(arguments)));
894        },
895        clean: function() {
896            return this._dispatch.apply(this,
897                ["clean"].concat(Array.prototype.slice.apply(arguments)));
898        },
899        deprotect: function() {
900            return this._dispatch.apply(this,
901                ["deprotect"].concat(Array.prototype.slice.apply(arguments)));
902        },
903        protect: function() {
904            return this._dispatch.apply(this,
905                ["protect"].concat(Array.prototype.slice.apply(arguments)));
906        },
907        reference: function() {
908            return this._dispatch.apply(this,
909                ["reference"].concat(Array.prototype.slice.apply(arguments)));
910        },
911        remove: function() {
912            return this._dispatch.apply(this,
913                ["remove"].concat(Array.prototype.slice.apply(arguments)));
914        },
915        remove_picked: function() {
916            return this._dispatch.apply(this,
917                ["remove_picked"].concat(Array.prototype.slice.apply(arguments)));
918        },
919        rename: function() {
920            return this._dispatch.apply(this,
921                ["rename"].concat(Array.prototype.slice.apply(arguments)));
922        },
923        replace: function() {
924            return this._dispatch.apply(this,
925                ["replace"].concat(Array.prototype.slice.apply(arguments)));
926        },
927        sculpt_purge: function() {
928            return this._dispatch.apply(this,
929                ["sculpt_purge"].concat(Array.prototype.slice.apply(arguments)));
930        },
931        sculpt_deactivate: function() {
932            return this._dispatch.apply(this,
933                ["sculpt_deactivate"].concat(Array.prototype.slice.apply(arguments)));
934        },
935        sculpt_activate: function() {
936            return this._dispatch.apply(this,
937                ["sculpt_activate"].concat(Array.prototype.slice.apply(arguments)));
938        },
939        sculpt_iterate: function() {
940            return this._dispatch.apply(this,
941                ["sculpt_iterate"].concat(Array.prototype.slice.apply(arguments)));
942        },
943        set_geometry: function() {
944            return this._dispatch.apply(this,
945                ["set_geometry"].concat(Array.prototype.slice.apply(arguments)));
946        },
947        set_symmetry: function() {
948            return this._dispatch.apply(this,
949                ["set_symmetry"].concat(Array.prototype.slice.apply(arguments)));
950        },
951        set_title: function() {
952            return this._dispatch.apply(this,
953                ["set_title"].concat(Array.prototype.slice.apply(arguments)));
954        },
955        smooth: function() {
956            return this._dispatch.apply(this,
957                ["smooth"].concat(Array.prototype.slice.apply(arguments)));
958        },
959        sort: function() {
960            return this._dispatch.apply(this,
961                ["sort"].concat(Array.prototype.slice.apply(arguments)));
962        },
963        undo: function() {
964            return this._dispatch.apply(this,
965                ["undo"].concat(Array.prototype.slice.apply(arguments)));
966        },
967        push_undo: function() {
968            return this._dispatch.apply(this,
969                ["push_undo"].concat(Array.prototype.slice.apply(arguments)));
970        },
971        redo: function() {
972            return this._dispatch.apply(this,
973                ["redo"].concat(Array.prototype.slice.apply(arguments)));
974        },
975        wizard: function() {
976            return this._dispatch.apply(this,
977                ["wizard"].concat(Array.prototype.slice.apply(arguments)));
978        },
979        replace_wizard: function() {
980            return this._dispatch.apply(this,
981                ["replace_wizard"].concat(Array.prototype.slice.apply(arguments)));
982        },
983        count_frames: function() {
984            return this._dispatch.apply(this,
985                ["count_frames"].concat(Array.prototype.slice.apply(arguments)));
986        },
987        count_states: function() {
988            return this._dispatch.apply(this,
989                ["count_states"].concat(Array.prototype.slice.apply(arguments)));
990        },
991        mset: function() {
992            return this._dispatch.apply(this,
993                ["mset"].concat(Array.prototype.slice.apply(arguments)));
994        },
995        madd: function() {
996            return this._dispatch.apply(this,
997                ["madd"].concat(Array.prototype.slice.apply(arguments)));
998        },
999        mclear: function() {
1000            return this._dispatch.apply(this,
1001                ["mclear"].concat(Array.prototype.slice.apply(arguments)));
1002        },
1003        mmatrix: function() {
1004            return this._dispatch.apply(this,
1005                ["mmatrix"].concat(Array.prototype.slice.apply(arguments)));
1006        },
1007        mdump: function() {
1008            return this._dispatch.apply(this,
1009                ["mdump"].concat(Array.prototype.slice.apply(arguments)));
1010        },
1011        mview: function() {
1012            return this._dispatch.apply(this,
1013                ["mview"].concat(Array.prototype.slice.apply(arguments)));
1014        },
1015        forward: function() {
1016            return this._dispatch.apply(this,
1017                ["forward"].concat(Array.prototype.slice.apply(arguments)));
1018        },
1019        backward: function() {
1020            return this._dispatch.apply(this,
1021                ["backward"].concat(Array.prototype.slice.apply(arguments)));
1022        },
1023        rewind: function() {
1024            return this._dispatch.apply(this,
1025                ["rewind"].concat(Array.prototype.slice.apply(arguments)));
1026        },
1027        middle: function() {
1028            return this._dispatch.apply(this,
1029                ["middle"].concat(Array.prototype.slice.apply(arguments)));
1030        },
1031        ending: function() {
1032            return this._dispatch.apply(this,
1033                ["ending"].concat(Array.prototype.slice.apply(arguments)));
1034        },
1035        mplay: function() {
1036            return this._dispatch.apply(this,
1037                ["mplay"].concat(Array.prototype.slice.apply(arguments)));
1038        },
1039        mtoggle: function() {
1040            return this._dispatch.apply(this,
1041                ["mtoggle"].concat(Array.prototype.slice.apply(arguments)));
1042        },
1043        mstop: function() {
1044            return this._dispatch.apply(this,
1045                ["mstop"].concat(Array.prototype.slice.apply(arguments)));
1046        },
1047        frame: function() {
1048            return this._dispatch.apply(this,
1049                ["frame"].concat(Array.prototype.slice.apply(arguments)));
1050        },
1051        get_movie_playing: function() {
1052            return this._dispatch.apply(this,
1053                ["get_movie_playing"].concat(Array.prototype.slice.apply(arguments)));
1054        },
1055        get_state: function() {
1056            return this._dispatch.apply(this,
1057                ["get_state"].concat(Array.prototype.slice.apply(arguments)));
1058        },
1059        get_frame: function() {
1060            return this._dispatch.apply(this,
1061                ["get_frame"].concat(Array.prototype.slice.apply(arguments)));
1062        },
1063        view: function() {
1064            return this._dispatch.apply(this,
1065                ["view"].concat(Array.prototype.slice.apply(arguments)));
1066        },
1067        get_scene_list: function() {
1068            return this._dispatch.apply(this,
1069                ["get_scene_list"].concat(Array.prototype.slice.apply(arguments)));
1070        },
1071        scene: function() {
1072            return this._dispatch.apply(this,
1073                ["scene"].concat(Array.prototype.slice.apply(arguments)));
1074        },
1075        scene_order: function() {
1076            return this._dispatch.apply(this,
1077                ["scene_order"].concat(Array.prototype.slice.apply(arguments)));
1078        }
1079
1080        // END MACHINE-GENERATED CODE
1081
1082    }
1083    
1084    this.getattr = {
1085      dispatch: function(attrname) {
1086        if (attrname) {
1087          mypath = "/getattr/pymol." + attrname;
1088          this._outer._send(mypath);
1089        }
1090      }
1091      //      viewing: function() {
1092      //        this._dispatch("viewing");
1093      //      }
1094    }
1095
1096    // enable inner pseudo-inner-instance to find the outer instance
1097
1098    this.cmd._outer                = this
1099    this.getattr._outer            = this
1100}
1101
1102// utility functions not used above, but of use to some users, one hopes
1103function parse_file(f) {
1104  var re = /[\\\/]/;
1105  fields = f.split(re);
1106  filename = fields[fields.length-1];
1107  dot = filename.lastIndexOf('.');
1108  if (dot > -1) {
1109    name = filename.slice(0,dot);
1110    ext    = filename.slice(dot);
1111  } else {
1112    name = filename;
1113    ext = "";
1114  }
1115  // Javascript 1.7+ only in Mozilla?
1116  // return [name, ext];
1117  return new Array(name, ext);
1118}
1119function validate_file(n,f) {
1120  if (f.value) {
1121    // Javascript 1.7+ only in Mozilla?
1122    // [name, ext] = parse_file(f.value);
1123    parsed = parse_file(f.value);
1124    name = parsed[0];
1125    ext = parsed[1];
1126    if (name) {
1127      n.value = name;
1128      //add_checkbox(name, "objects");
1129      return true;
1130    } else {
1131      alert('cannot extract name from file');
1132      return false;
1133    }
1134  } else {
1135    alert('no file selected');
1136    return false;
1137  }
1138}
1139
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Playwright Internal on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)