@@ -19,6 +19,31 @@ declare var diff_match_patch: any;
1919declare var codeopticonUsername : string ; // FIX later when porting Codeopticon
2020declare var codeopticonSession : string ; // FIX later when porting Codeopticon
2121
22+ // augment existing interface definitions from typings/
23+ interface JQuery {
24+ // attr can also take a boolean as a second argument
25+ attr ( attributeName : string , b : boolean ) : JQuery ;
26+ }
27+
28+ interface JQueryStatic {
29+ doTimeout : any ;
30+ }
31+
32+ declare namespace AceAjax {
33+ interface IEditSession {
34+ setFoldStyle : any ;
35+ setOption : any ;
36+ gutterRenderer : any ;
37+ }
38+
39+ interface Editor {
40+ setHighlightGutterLine : any ;
41+ setDisplayIndentGuides : any ;
42+ on : any ;
43+ }
44+ }
45+
46+
2247var originFrontendJsFile : string = undefined ;
2348
2449// backend scripts to execute (Python 2 and 3 variants, if available)
@@ -167,14 +192,14 @@ function initDeltaObj() {
167192 startTime : new Date ( ) . getTime ( ) } ;
168193}
169194
170- function initAceEditor ( height ) {
195+ var initAceEditor = function ( height ) {
171196 pyInputAceEditor = ace . edit ( 'codeInputPane' ) ;
172197 var s = pyInputAceEditor . getSession ( ) ;
173198 // tab -> 4 spaces
174199 s . setTabSize ( 4 ) ;
175200 s . setUseSoftTabs ( true ) ;
176201 // disable extraneous indicators:
177- ( s as any /* TS too strict */ ) . setFoldStyle ( 'manual' ) ; // no code folding indicators
202+ s . setFoldStyle ( 'manual' ) ; // no code folding indicators
178203 s . getDocument ( ) . setNewLineMode ( 'unix' ) ; // canonicalize all newlines to unix format
179204 pyInputAceEditor . setHighlightActiveLine ( false ) ;
180205 pyInputAceEditor . setShowPrintMargin ( false ) ;
@@ -189,7 +214,7 @@ function initAceEditor(height) {
189214
190215 initDeltaObj ( ) ;
191216 pyInputAceEditor . on ( 'change' , function ( e ) {
192- ( $ as any /* TS too strict */ ) . doTimeout ( 'pyInputAceEditorChange' , CODE_SNAPSHOT_DEBOUNCE_MS , snapshotCodeDiff ) ; // debounce
217+ $ . doTimeout ( 'pyInputAceEditorChange' , CODE_SNAPSHOT_DEBOUNCE_MS , snapshotCodeDiff ) ; // debounce
193218 clearFrontendError ( ) ;
194219 s . clearAnnotations ( ) ;
195220 } ) ;
@@ -485,7 +510,7 @@ function initTogetherJS() {
485510 if ( appMode == 'edit' && msg . codeInputScrollTop !== undefined &&
486511 pyInputGetScrollTop ( ) != msg . codeInputScrollTop ) {
487512 // hack: give it a bit of time to settle first ...
488- ( $ as any /* TS too strict */ ) . doTimeout ( 'pyInputCodeMirrorInit' , 200 , function ( ) {
513+ $ . doTimeout ( 'pyInputCodeMirrorInit' , 200 , function ( ) {
489514 pyInputSetScrollTop ( msg . codeInputScrollTop ) ;
490515 } ) ;
491516 }
@@ -498,7 +523,7 @@ function initTogetherJS() {
498523 $ ( "#codeInputWarnings" ) . hide ( ) ;
499524 $ ( "#someoneIsTypingDiv" ) . show ( ) ;
500525
501- ( $ as any /* TS too strict */ ) . doTimeout ( 'codeMirrorWarningTimeout' , 1000 , function ( ) { // debounce
526+ $ . doTimeout ( 'codeMirrorWarningTimeout' , 1000 , function ( ) { // debounce
502527 $ ( "#codeInputWarnings" ) . show ( ) ;
503528 $ ( "#someoneIsTypingDiv" ) . hide ( ) ;
504529 } ) ;
@@ -570,7 +595,7 @@ function initTogetherJS() {
570595 // give pyInputAceEditor a bit of time to settle with
571596 // its new value. this is hacky; ideally we have a callback function for
572597 // when setValue() completes.
573- ( $ as any /* TS too strict */ ) . doTimeout ( 'pyInputCodeMirrorInit' , 200 , function ( ) {
598+ $ . doTimeout ( 'pyInputCodeMirrorInit' , 200 , function ( ) {
574599 pyInputSetScrollTop ( msg . codeInputScrollTop ) ;
575600 } ) ;
576601 }
@@ -646,11 +671,11 @@ function initTogetherJS() {
646671 } ) ;
647672}
648673
649- function TogetherjsReadyHandler ( ) {
674+ var TogetherjsReadyHandler = function ( ) {
650675 alert ( "ERROR: need to override TogetherjsReadyHandler()" ) ;
651676}
652677
653- function TogetherjsCloseHandler ( ) {
678+ var TogetherjsCloseHandler = function ( ) {
654679 alert ( "ERROR: need to override TogetherjsCloseHandler()" ) ;
655680}
656681
@@ -706,7 +731,7 @@ function populateTogetherJsShareUrl() {
706731
707732 $("#sharedSessionWhatLearned").val('');
708733 $("#sharedSessionWhatLearnedThanks").show();
709- ($ as any) .doTimeout('sharedSessionWhatLearnedThanksFadeOut', 1000, function() {
734+ $ .doTimeout('sharedSessionWhatLearnedThanksFadeOut', 1000, function() {
710735 $("#sharedSessionWhatLearnedThanks").fadeOut(2000);
711736 });
712737 }
@@ -851,7 +876,7 @@ function genericOptFrontendReady(params) {
851876 /*
852877 pyInputAceEditor.getSession().on('changeScrollTop', function() {
853878 if (typeof TogetherJS !== 'undefined' && TogetherJS.running) {
854- ($ as any) .doTimeout('codeInputScroll', 100, function() { // debounce
879+ $ .doTimeout('codeInputScroll', 100, function() { // debounce
855880 // note that this will send a signal back and forth both ways
856881 // (there's no easy way to prevent this), but it shouldn't keep
857882 // bouncing back and forth indefinitely since no the second signal
@@ -977,7 +1002,7 @@ function genericOptFrontendReady(params) {
9771002 clearFrontendError ( ) ;
9781003
9791004 $ ( "#embedLinkDiv" ) . hide ( ) ;
980- $ ( "#executeBtn" ) . attr ( 'disabled' , ( false as any /* TS too strict */ ) ) ;
1005+ $ ( "#executeBtn" ) . attr ( 'disabled' , false ) ;
9811006 $ ( "#executeBtn" ) . click ( executeCodeFromScratch ) ;
9821007
9831008 // for Versions 1 and 2, initialize here. But for version 3+, dynamically
@@ -1242,13 +1267,13 @@ function updateAppDisplay(newAppMode) {
12421267 pendingCodeOutputScrollTop = null ;
12431268 }
12441269
1245- ( $ as any /* TS too strict */ ) . doTimeout ( 'pyCodeOutputDivScroll' ) ; // cancel any prior scheduled calls
1270+ $ . doTimeout ( 'pyCodeOutputDivScroll' ) ; // cancel any prior scheduled calls
12461271
12471272 // TODO: this might interfere with experimentalPopUpSyntaxErrorSurvey (2015-04-19)
12481273 myVisualizer . domRoot . find ( '#pyCodeOutputDiv' ) . scroll ( function ( e ) {
12491274 var elt = $ ( this ) ;
12501275 // debounce
1251- ( $ as any /* TS too strict */ ) . doTimeout ( 'pyCodeOutputDivScroll' , 100 , function ( ) {
1276+ $ . doTimeout ( 'pyCodeOutputDivScroll' , 100 , function ( ) {
12521277 // note that this will send a signal back and forth both ways
12531278 if ( typeof TogetherJS !== 'undefined' && TogetherJS . running ) {
12541279 // (there's no easy way to prevent this), but it shouldn't keep
@@ -1319,13 +1344,13 @@ function handleUncaughtExceptionFunc(trace) {
13191344
13201345function startExecutingCode ( ) {
13211346 $ ( '#executeBtn' ) . html ( "Please wait ... executing (takes up to 10 seconds)" ) ;
1322- $ ( '#executeBtn' ) . attr ( 'disabled' , ( true as any /* TS too strict */ ) ) ;
1347+ $ ( '#executeBtn' ) . attr ( 'disabled' , true ) ;
13231348 isExecutingCode = true ; // nasty global
13241349}
13251350
13261351function doneExecutingCode ( ) {
13271352 $ ( '#executeBtn' ) . html ( "Visualize Execution" ) ;
1328- $ ( '#executeBtn' ) . attr ( 'disabled' , ( false as any /* TS too strict */ ) ) ;
1353+ $ ( '#executeBtn' ) . attr ( 'disabled' , false ) ;
13291354 isExecutingCode = false ; // nasty global
13301355}
13311356
@@ -1421,7 +1446,7 @@ function executeCodeAndCreateViz(codeToExec,
14211446 }
14221447
14231448 // debounce to compress a bit ... 250ms feels "right"
1424- ( $ as any /* TS too strict */ ) . doTimeout ( 'updateOutputLogEvent' , 250 , function ( ) {
1449+ $ . doTimeout ( 'updateOutputLogEvent' , 250 , function ( ) {
14251450 var obj : any = { type : 'updateOutput' , step : args . myViz . curInstr ,
14261451 curline : args . myViz . curLineNumber ,
14271452 prevline : args . myViz . prevLineNumber } ;
@@ -2010,7 +2035,7 @@ display a brief "Thanks!" note]
20102035
20112036 $("#iJustLearnedInput").val('');
20122037 $("#iJustLearnedThanks").show();
2013- ($ as any) .doTimeout('iJustLearnedThanksFadeOut', 1200, function() {
2038+ $ .doTimeout('iJustLearnedThanksFadeOut', 1200, function() {
20142039 $("#iJustLearnedThanks").fadeOut(1000);
20152040 });
20162041 });
@@ -2161,7 +2186,7 @@ display a brief "Thanks!" note]
21612186
21622187 $("#iJustLearnedInput").val('');
21632188 $("#iJustLearnedThanks").show();
2164- ($ as any) .doTimeout('iJustLearnedThanksFadeOut', 1200, function() {
2189+ $ .doTimeout('iJustLearnedThanksFadeOut', 1200, function() {
21652190 $("#iJustLearnedThanks").fadeOut(1000);
21662191 });
21672192
@@ -2185,6 +2210,7 @@ function logEventCodeopticon(obj) {}
21852210// only export methods and NOT objects, since they're copied by value
21862211// (unless they're constants, in which case they can be exported at the
21872212// end after they've been initialized)
2213+ declare var module : any ;
21882214module . exports = {
21892215 setSurveyHTML : setSurveyHTML ,
21902216 genericOptFrontendReady : genericOptFrontendReady ,
0 commit comments